From 65eb64cd07dcaf1b57405189fcd054684d3f5e2f Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 18 Mar 2022 17:52:46 -0300 Subject: [PATCH] mui text field, standard variation --- .../taler-wallet-webextension/package.json | 6 +- .../src/mui/Button.stories.tsx | 133 +++++++ .../src/mui/Button.tsx | 87 ++++- .../src/mui/TextField.stories.tsx | 108 ++++++ .../src/mui/TextField.tsx | 69 ++++ .../src/mui/input/FormControl.tsx | 156 ++++++++ .../src/mui/input/FormHelperText.tsx | 54 +++ .../src/mui/input/FormLabel.tsx | 67 ++++ .../src/mui/input/InputBase.tsx | 258 ++++++++++++++ .../src/mui/input/InputFilled.tsx | 5 + .../src/mui/input/InputLabel.tsx | 98 +++++ .../src/mui/input/InputOutlined.tsx | 5 + .../src/mui/input/InputStandard.tsx | 124 +++++++ .../src/mui/input/SelectFilled.tsx | 5 + .../src/mui/input/SelectOutlined.tsx | 5 + .../src/mui/input/SelectStandard.tsx | 5 + .../src/mui/style.tsx | 16 + .../src/popupEntryPoint.tsx | 2 +- .../src/walletEntryPoint.tsx | 337 +++++++++--------- .../static/img/delete_24px.svg | 1 + .../static/img/send_24px.svg | 1 + 21 files changed, 1356 insertions(+), 186 deletions(-) create mode 100644 packages/taler-wallet-webextension/src/mui/Button.stories.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/TextField.stories.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/TextField.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/FormControl.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/FormHelperText.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/FormLabel.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/InputBase.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/InputFilled.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/InputLabel.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/InputOutlined.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/InputStandard.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/SelectFilled.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/SelectOutlined.tsx create mode 100644 packages/taler-wallet-webextension/src/mui/input/SelectStandard.tsx create mode 100644 packages/taler-wallet-webextension/static/img/delete_24px.svg create mode 100644 packages/taler-wallet-webextension/static/img/send_24px.svg diff --git a/packages/taler-wallet-webextension/package.json b/packages/taler-wallet-webextension/package.json index 03232dee7..18563312c 100644 --- a/packages/taler-wallet-webextension/package.json +++ b/packages/taler-wallet-webextension/package.json @@ -37,9 +37,6 @@ "@babel/plugin-transform-react-jsx-source": "^7.12.13", "@babel/preset-typescript": "^7.13.0", "@gnu-taler/pogen": "workspace:*", - "@types/chai": "^4.3.0", - "chai": "^4.3.6", - "polished": "^4.1.4", "@linaria/babel-preset": "3.0.0-beta.4", "@linaria/core": "3.0.0-beta.4", "@linaria/react": "3.0.0-beta.4", @@ -57,14 +54,17 @@ "@storybook/preact": "6.4.18", "@testing-library/preact": "^2.0.1", "@testing-library/preact-hooks": "^1.1.0", + "@types/chai": "^4.3.0", "@types/chrome": "0.0.176", "@types/history": "^4.7.8", "@types/mocha": "^9.0.0", "@types/node": "^17.0.8", "babel-loader": "^8.2.3", "babel-plugin-transform-react-jsx": "^6.24.1", + "chai": "^4.3.6", "mocha": "^9.2.0", "nyc": "^15.1.0", + "polished": "^4.1.4", "preact-cli": "^3.3.5", "preact-render-to-string": "^5.1.19", "rimraf": "^3.0.2", diff --git a/packages/taler-wallet-webextension/src/mui/Button.stories.tsx b/packages/taler-wallet-webextension/src/mui/Button.stories.tsx new file mode 100644 index 000000000..a6863add3 --- /dev/null +++ b/packages/taler-wallet-webextension/src/mui/Button.stories.tsx @@ -0,0 +1,133 @@ +/* + 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 { Button } from "./Button"; +import { Fragment, h } from "preact"; +import DeleteIcon from "../../static/img/delete_24px.svg"; +import SendIcon from "../../static/img/send_24px.svg"; +import { styled } from "@linaria/react"; + +export default { + title: "mui/button", + component: Button, +}; + +const Stack = styled.div` + display: flex; + flex-direction: column; +`; + +export const BasicExample = () => ( + + + + + + + + + + + + + + + + + +); + +export const Others = () => ( + +

colors

+ + + + + +

disabled

+ + + + + +
+); + +export const WithIcons = () => ( + + + + + + + + + + + + + + + + + +); diff --git a/packages/taler-wallet-webextension/src/mui/Button.tsx b/packages/taler-wallet-webextension/src/mui/Button.tsx index ccca360fa..8da5b86be 100644 --- a/packages/taler-wallet-webextension/src/mui/Button.tsx +++ b/packages/taler-wallet-webextension/src/mui/Button.tsx @@ -1,6 +1,6 @@ import { ComponentChildren, h, VNode } from "preact"; import { css } from "@linaria/core"; -import { theme, ripple } from "./style"; +import { theme, ripple, Colors } from "./style"; import { alpha } from "./colors/manipulation"; interface Props { @@ -12,9 +12,9 @@ interface Props { fullWidth?: boolean; href?: string; size?: "small" | "medium" | "large"; - startIcon?: VNode; + startIcon?: VNode | string; variant?: "contained" | "outlined" | "text"; - color?: "primary" | "secondary" | "success" | "error" | "info" | "warning"; + color?: Colors; onClick?: () => void; } @@ -28,7 +28,7 @@ const baseStyle = css` outline: 0; border: 0; margin: 0; - border-radius: 0; + /* border-radius: 0; */ padding: 0; cursor: pointer; user-select: none; @@ -50,6 +50,17 @@ const button = css` color: ${theme.palette.action.disabled}; } `; +const colorIconVariant = { + outlined: css` + background-color: var(--color-main); + `, + contained: css` + background-color: var(--color-contrastText); + `, + text: css` + background-color: var(--color-main); + `, +}; const colorVariant = { outlined: css` @@ -90,6 +101,47 @@ const colorVariant = { `, }; +const sizeIconVariant = { + outlined: { + small: css` + padding: 3px; + font-size: ${theme.pxToRem(7)}; + `, + medium: css` + padding: 5px; + `, + large: css` + padding: 7px; + font-size: ${theme.pxToRem(10)}; + `, + }, + contained: { + small: css` + padding: 4px; + font-size: ${theme.pxToRem(13)}; + `, + medium: css` + padding: 6px; + `, + large: css` + padding: 8px; + font-size: ${theme.pxToRem(10)}; + `, + }, + text: { + small: css` + padding: 4px; + font-size: ${theme.pxToRem(13)}; + `, + medium: css` + padding: 6px; + `, + large: css` + padding: 8px; + font-size: ${theme.pxToRem(15)}; + `, + }, +}; const sizeVariant = { outlined: { small: css` @@ -162,12 +214,18 @@ export function Button({ css` margin-right: 8px; margin-left: -4px; + mask: var(--image) no-repeat center; `, + colorIconVariant[variant], + sizeIconVariant[variant][size], style, ].join(" ")} - > - {sip} - + style={{ + "--image": `url("${sip}")`, + "--color-main": theme.palette[color].main, + "--color-contrastText": theme.palette[color].contrastText, + }} + /> ); const endIcon = eip && ( - {eip} - + style={{ + "--image": `url("${eip}")`, + "--color-main": theme.palette[color].main, + "--color-contrastText": theme.palette[color].contrastText, + "--color-dark": theme.palette[color].dark, + }} + /> ); return (