added fake header to stories
This commit is contained in:
parent
2b9686ccc6
commit
56902288c6
@ -15,7 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { setupI18n } from "@gnu-taler/taler-util"
|
import { setupI18n } from "@gnu-taler/taler-util"
|
||||||
|
import { Fragment } from "preact"
|
||||||
import { strings } from '../src/i18n/strings.ts'
|
import { strings } from '../src/i18n/strings.ts'
|
||||||
|
import { NavBar } from '../src/popup/popup'
|
||||||
|
|
||||||
const mockConfig = {
|
const mockConfig = {
|
||||||
backendURL: 'http://demo.taler.net',
|
backendURL: 'http://demo.taler.net',
|
||||||
@ -45,12 +47,28 @@ export const globalTypes = {
|
|||||||
|
|
||||||
|
|
||||||
export const decorators = [
|
export const decorators = [
|
||||||
(Story, { globals }) => {
|
|
||||||
setupI18n(globals.locale, strings);
|
|
||||||
return <Story />
|
|
||||||
},
|
|
||||||
(Story, { kind }) => {
|
(Story, { kind }) => {
|
||||||
if (kind.startsWith('popup')) {
|
if (kind.startsWith('popup')) {
|
||||||
|
|
||||||
|
function Body() {
|
||||||
|
const isTestingHeader = (/.*\/header\/?.*/.test(kind));
|
||||||
|
if (isTestingHeader) {
|
||||||
|
// simple box with correct width and height
|
||||||
|
return <div style={{ width: 400, height: 320 }}>
|
||||||
|
<Story />
|
||||||
|
</div>
|
||||||
|
} else {
|
||||||
|
const path = !isTestingHeader ? /popup(\/.*)\/.*/.exec(kind)[1] : ''
|
||||||
|
// add a fake header so it looks similar
|
||||||
|
return <Fragment>
|
||||||
|
<NavBar path={path} devMode={path === '/dev'} />
|
||||||
|
<div style={{ padding: 8, width: 'calc(400px - 16px)', height: 'calc(320px - 34px - 16px)' }}>
|
||||||
|
<Story />
|
||||||
|
</div>
|
||||||
|
</Fragment>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return <div class="popup-container">
|
return <div class="popup-container">
|
||||||
<style>{`
|
<style>{`
|
||||||
html {
|
html {
|
||||||
@ -78,8 +96,8 @@ export const decorators = [
|
|||||||
font-family: Arial, Helvetica, sans-serif;
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
}`}
|
}`}
|
||||||
</style>
|
</style>
|
||||||
<div style={{ padding: 8, width: 'calc(400px - 16px - 2px)', height: 'calc(320px - 34px - 16px - 2px)', border: 'black solid 1px' }}>
|
<div style={{ width: 400, border: 'black solid 1px' }}>
|
||||||
<Story />
|
<Body />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@ -94,6 +112,10 @@ export const decorators = [
|
|||||||
<h1>this story is not under wallet or popup, check title property</h1>
|
<h1>this story is not under wallet or popup, check title property</h1>
|
||||||
<Story />
|
<Story />
|
||||||
</div>
|
</div>
|
||||||
}
|
},
|
||||||
|
(Story, { globals }) => {
|
||||||
|
setupI18n(globals.locale, strings);
|
||||||
|
return <Story />
|
||||||
|
},
|
||||||
// (Story) => <ConfigContextProvider value={mockConfig}> <Story /> </ConfigContextProvider>
|
// (Story) => <ConfigContextProvider value={mockConfig}> <Story /> </ConfigContextProvider>
|
||||||
];
|
];
|
||||||
|
@ -240,4 +240,23 @@ export const ErrorBox = styled.div`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
export const PopupNavigation = styled.div`
|
||||||
|
background-color: #033;
|
||||||
|
|
||||||
|
& > a {
|
||||||
|
color: #f8faf7;
|
||||||
|
padding-top: 0.7em;
|
||||||
|
display: inline-block;
|
||||||
|
width: calc(400px / 5);
|
||||||
|
padding-bottom: 0.7em;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > a.active {
|
||||||
|
background-color: #f8faf7;
|
||||||
|
color: #000;
|
||||||
|
font-weight: bold;
|
||||||
|
|
||||||
|
}
|
||||||
|
`
|
||||||
|
@ -19,9 +19,7 @@
|
|||||||
* @author Sebastian Javier Marchano (sebasjm)
|
* @author Sebastian Javier Marchano (sebasjm)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ProviderPaymentType } from '@gnu-taler/taler-wallet-core';
|
import { ComponentChildren, FunctionalComponent, h } from 'preact';
|
||||||
import { addDays } from 'date-fns';
|
|
||||||
import { ComponentChild, ComponentChildren, FunctionalComponent, h } from 'preact';
|
|
||||||
import { BalanceView as TestedComponent } from './BalancePage';
|
import { BalanceView as TestedComponent } from './BalancePage';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
amountFractionalBase, Amounts,
|
amountFractionalBase, Amounts,
|
||||||
|
|
||||||
Balance, BalancesResponse,
|
Balance, BalancesResponse,
|
||||||
i18n
|
i18n
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
@ -41,7 +40,7 @@ export function BalanceView({ balance, Linker }: BalanceViewProps) {
|
|||||||
|
|
||||||
if (balance.error) {
|
if (balance.error) {
|
||||||
return (
|
return (
|
||||||
<div class="balance">
|
<div>
|
||||||
<p>{i18n.str`Error: could not retrieve balance information.`}</p>
|
<p>{i18n.str`Error: could not retrieve balance information.`}</p>
|
||||||
<p>
|
<p>
|
||||||
Click <Linker pageName="welcome.html">here</Linker> for help and
|
Click <Linker pageName="welcome.html">here</Linker> for help and
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
This file is part of GNU Taler
|
||||||
|
(C) 2021 Taler Systems S.A.
|
||||||
|
|
||||||
|
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 3, or (at your option) any later version.
|
||||||
|
|
||||||
|
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Javier Marchano (sebasjm)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Fragment, FunctionalComponent } from 'preact';
|
||||||
|
import { NavBar as TestedComponent } from './popup';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'popup/header',
|
||||||
|
// component: TestedComponent,
|
||||||
|
argTypes: {
|
||||||
|
onRetry: { action: 'onRetry' },
|
||||||
|
onDelete: { action: 'onDelete' },
|
||||||
|
onBack: { action: 'onBack' },
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function createExample<Props>(Component: FunctionalComponent<Props>, props: Partial<Props>) {
|
||||||
|
const r = (args: any) => <Component {...args} />
|
||||||
|
r.args = props
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
export const OnBalance = createExample(TestedComponent, {
|
||||||
|
devMode:false,
|
||||||
|
path:'/balance'
|
||||||
|
});
|
||||||
|
|
||||||
|
export const OnHistoryWithDevMode = createExample(TestedComponent, {
|
||||||
|
devMode:true,
|
||||||
|
path:'/history'
|
||||||
|
});
|
@ -28,6 +28,7 @@ import { i18n } from "@gnu-taler/taler-util";
|
|||||||
import { ComponentChildren, JSX } from "preact";
|
import { ComponentChildren, JSX } from "preact";
|
||||||
import Match from "preact-router/match";
|
import Match from "preact-router/match";
|
||||||
import { useDevContext } from "../context/useDevContext";
|
import { useDevContext } from "../context/useDevContext";
|
||||||
|
import { PopupNavigation } from '../components/styled'
|
||||||
|
|
||||||
export enum Pages {
|
export enum Pages {
|
||||||
balance = '/balance',
|
balance = '/balance',
|
||||||
@ -58,18 +59,18 @@ function Tab(props: TabProps): JSX.Element {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function WalletNavBar() {
|
export function NavBar({devMode, path}:{path:string, devMode:boolean}) {
|
||||||
const { devMode } = useDevContext()
|
return <PopupNavigation>
|
||||||
return <Match>{({ path }: any) => {
|
<Tab target="/balance" current={path}>{i18n.str`Balance`}</Tab>
|
||||||
return (
|
<Tab target="/history" current={path}>{i18n.str`History`}</Tab>
|
||||||
<div class="nav" id="header">
|
<Tab target="/backup" current={path}>{i18n.str`Backup`}</Tab>
|
||||||
<Tab target="/balance" current={path}>{i18n.str`Balance`}</Tab>
|
<Tab target="/settings" current={path}>{i18n.str`Settings`}</Tab>
|
||||||
<Tab target="/history" current={path}>{i18n.str`History`}</Tab>
|
{devMode && <Tab target="/dev" current={path}>{i18n.str`Dev`}</Tab>}
|
||||||
<Tab target="/backup" current={path}>{i18n.str`Backup`}</Tab>
|
</PopupNavigation>
|
||||||
<Tab target="/settings" current={path}>{i18n.str`Settings`}</Tab>
|
}
|
||||||
{devMode && <Tab target="/dev" current={path}>{i18n.str`Dev`}</Tab>}
|
|
||||||
</div>
|
export function WalletNavBar() {
|
||||||
)
|
const { devMode } = useDevContext()
|
||||||
}}</Match>
|
return <Match>{({ path }: any) => <NavBar devMode={devMode} path={path} />}</Match>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user