From be489b6b3ea4214f546dfc33d6bb0f39ce82b5ab Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 29 Mar 2022 00:45:17 -0300 Subject: remove storybook --- .../taler-wallet-webextension/.storybook/.babelrc | 26 --- .../taler-wallet-webextension/.storybook/main.js | 85 ---------- .../.storybook/preview.js | 179 --------------------- packages/taler-wallet-webextension/package.json | 5 - .../src/NavigationBar.tsx | 2 - .../src/components/Banner.stories.tsx | 10 +- .../src/components/Banner.tsx | 2 +- .../src/components/index.stories.tsx | 25 +++ packages/taler-wallet-webextension/src/stories.tsx | 9 +- 9 files changed, 38 insertions(+), 305 deletions(-) delete mode 100644 packages/taler-wallet-webextension/.storybook/.babelrc delete mode 100644 packages/taler-wallet-webextension/.storybook/main.js delete mode 100644 packages/taler-wallet-webextension/.storybook/preview.js create mode 100644 packages/taler-wallet-webextension/src/components/index.stories.tsx (limited to 'packages') diff --git a/packages/taler-wallet-webextension/.storybook/.babelrc b/packages/taler-wallet-webextension/.storybook/.babelrc deleted file mode 100644 index 4476798e2..000000000 --- a/packages/taler-wallet-webextension/.storybook/.babelrc +++ /dev/null @@ -1,26 +0,0 @@ -/* - 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 - */ - - /** - * - * @author Sebastian Javier Marchano (sebasjm) - */ -{ - //FIXME: check if we can remove this preset and just use default storybook presets - "presets": [ - "preact-cli/babel", - ] -} \ No newline at end of file diff --git a/packages/taler-wallet-webextension/.storybook/main.js b/packages/taler-wallet-webextension/.storybook/main.js deleted file mode 100644 index d3f216922..000000000 --- a/packages/taler-wallet-webextension/.storybook/main.js +++ /dev/null @@ -1,85 +0,0 @@ -/* - 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 - */ - -/** -* -* @author Sebastian Javier Marchano (sebasjm) -*/ - - -module.exports = { - "stories": [ - "../src/**/*.stories.tsx", - ], - "addons": [ - "storybook-dark-mode", - "@storybook/addon-a11y", - "@storybook/addon-essentials" //docs, control, actions, viewport, toolbar, background - ], - // sb does not yet support new jsx transform by default - // https://github.com/storybookjs/storybook/issues/12881 - // https://github.com/storybookjs/storybook/issues/12952 - babel: async (options) => ({ - ...options, - presets: [ - ...options.presets, - [ - '@babel/preset-react', { - runtime: 'automatic', - }, - 'preset-react-jsx-transform' - ], - "@linaria", - ], - }), - webpackFinal: (config) => { - // should be removed after storybook 6.3 - // https://github.com/storybookjs/storybook/issues/12853#issuecomment-821576113 - // removing workaround since this creates another problem - // https://github.com/storybookjs/storybook/issues/16623 - // https://github.com/nodejs/node/issues/33460 - // FIXME: remove this comments in 2022 if no problem arise - // config.resolve.alias = { - // react: "preact/compat", - // "react-dom": "preact/compat", - // }; - - // we need to add @linaria loader AFTER the babel-loader - // https://github.com/callstack/linaria/blob/master/docs/BUNDLERS_INTEGRATION.md#webpack - config.module.rules[0] = { - ...(config.module.rules[0]), - loader: undefined, // Disable the predefined babel-loader on the rule - use: [ - { - ...(config.module.rules[0].use[0]), - loader: 'babel-loader', - }, - { - loader: '@linaria/webpack-loader', - options: { - sourceMap: true, //always true since this is dev - babelOptions: { - presets: config.module.rules[0].use[0].options.presets, - } - // Pass the current babel options to linaria's babel instance - } - } - ] - }; - - return config; - }, -} diff --git a/packages/taler-wallet-webextension/.storybook/preview.js b/packages/taler-wallet-webextension/.storybook/preview.js deleted file mode 100644 index 02d8a0e06..000000000 --- a/packages/taler-wallet-webextension/.storybook/preview.js +++ /dev/null @@ -1,179 +0,0 @@ -/* - 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 - */ - -import { h, Fragment } from "preact" -import { PopupNavBar, WalletNavBar } from '../src/NavigationBar' -import { LogoHeader } from '../src/components/LogoHeader' -import { TranslationProvider } from '../src/context/translation' -import { PopupBox, WalletBox } from '../src/components/styled' -export const parameters = { - controls: { expanded: true }, -} - -export const globalTypes = { - locale: { - name: 'Locale', - description: 'Internationalization locale', - defaultValue: 'en', - toolbar: { - icon: 'globe', - items: [ - { value: 'en', right: 'πŸ‡ΊπŸ‡Έ', title: 'English' }, - { value: 'ja', right: 'πŸ‡―πŸ‡΅', title: 'Japanese' }, - { value: 'es', right: 'πŸ‡ͺπŸ‡Έ', title: 'Spanish' }, - { value: 'de', right: 'πŸ‡©πŸ‡ͺ', title: 'German' }, - ], - }, - }, -}; - - - -export const decorators = [ - (Story, { kind }) => { - if (kind.startsWith('popup')) { - - function Body() { - const isTestingHeader = (/.*\/header\/?.*/.test(kind)); - if (isTestingHeader) { - // simple box with correct width and height - return
- -
- } - - const path = /popup(\/.*).*/.exec(kind)[1]; - // add a fake header so it looks similar - return - - - - - - } - - return - } - if (kind.startsWith('cta')) { - return
- - - - - -
- } - if (kind.startsWith('mui') || kind.startsWith('component')) { - return
- -
- } - if (kind.startsWith('wallet')) { - const path = /wallet(\/.*).*/.exec(kind)[1]; - return
- - - - - - - -
- } - return
-

this story is not under wallet or popup, check title property

- -
- }, - (Story, { globals }) => - - , -]; diff --git a/packages/taler-wallet-webextension/package.json b/packages/taler-wallet-webextension/package.json index f61a03903..909b27d03 100644 --- a/packages/taler-wallet-webextension/package.json +++ b/packages/taler-wallet-webextension/package.json @@ -14,8 +14,6 @@ "compile": "rollup -c -m", "compile:test": "rollup -c rollup.config.test.js -m", "prepare": "rollup -c -m", - "build-storybook": "build-storybook", - "storybook": "start-storybook -s . -p 6006 --no-open", "pretty": "prettier --write src", "watch": "tsc --watch & rollup -w -c", "i18n:extract": "pogen extract", @@ -51,9 +49,6 @@ "@rollup/plugin-node-resolve": "^13.1.3", "@rollup/plugin-replace": "^3.0.1", "@rollup/plugin-typescript": "^8.3.0", - "@storybook/addon-a11y": "^6.4.18", - "@storybook/addon-essentials": "^6.4.18", - "@storybook/preact": "6.4.18", "@testing-library/preact": "^2.0.1", "@testing-library/preact-hooks": "^1.1.0", "@types/chai": "^4.3.0", diff --git a/packages/taler-wallet-webextension/src/NavigationBar.tsx b/packages/taler-wallet-webextension/src/NavigationBar.tsx index 8b545b981..df779cae3 100644 --- a/packages/taler-wallet-webextension/src/NavigationBar.tsx +++ b/packages/taler-wallet-webextension/src/NavigationBar.tsx @@ -75,7 +75,6 @@ export function PopupNavBar({ path = "" }: { path?: string }): VNode { Backup - - ; + return ; } export const BasicExample = () => ( diff --git a/packages/taler-wallet-webextension/src/components/Banner.tsx b/packages/taler-wallet-webextension/src/components/Banner.tsx index 7bbacee8d..88b36430b 100644 --- a/packages/taler-wallet-webextension/src/components/Banner.tsx +++ b/packages/taler-wallet-webextension/src/components/Banner.tsx @@ -19,7 +19,7 @@ interface Props extends JSX.HTMLAttributes { }; } -export function Banner({ title, elements, confirm, ...rest }: Props) { +export function Banner({ title, elements, confirm, ...rest }: Props): VNode { return ( diff --git a/packages/taler-wallet-webextension/src/components/index.stories.tsx b/packages/taler-wallet-webextension/src/components/index.stories.tsx new file mode 100644 index 000000000..7cf9d4c58 --- /dev/null +++ b/packages/taler-wallet-webextension/src/components/index.stories.tsx @@ -0,0 +1,25 @@ +/* + 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 + */ + +/** + * + * @author Sebastian Javier Marchano (sebasjm) + */ + +import * as a1 from "./Banner.stories.js"; +import * as a2 from "./PendingTransactions.stories.js"; + +export default [a1, a2]; diff --git a/packages/taler-wallet-webextension/src/stories.tsx b/packages/taler-wallet-webextension/src/stories.tsx index 531425bc9..10c903ae6 100644 --- a/packages/taler-wallet-webextension/src/stories.tsx +++ b/packages/taler-wallet-webextension/src/stories.tsx @@ -35,8 +35,13 @@ import * as mui from "./mui/index.stories.js"; import { PopupNavBar, WalletNavBar } from "./NavigationBar.js"; import * as popup from "./popup/index.stories.js"; import * as wallet from "./wallet/index.stories.js"; +import * as components from "./components/index.stories.js"; +import { strings } from "./i18n/strings.js"; -setupI18n("en", { en: {} }); +const url = new URL(window.location.href); +const lang = url.searchParams.get("lang") || "en"; + +setupI18n(lang, strings); const Page = styled.div` * { @@ -107,7 +112,7 @@ function parseExampleImport(group: string, im: any): ComponentItem { }; } -const allExamples = Object.entries({ popup, wallet, mui }).map( +const allExamples = Object.entries({ popup, wallet, mui, components }).map( ([title, value]) => ({ title, list: value.default.map((s) => parseExampleImport(title, s)), -- cgit v1.2.3