From 31292a8bc69e8b61b10bd23f2850c66ecd2d5343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ver=C3=B3nica=20Mil=C3=A1n?= Date: Wed, 26 Jul 2023 16:08:50 +0200 Subject: [PATCH] update status and stories --- UPGRADE.md | 38 ++++ .../storybook/stories/atoms/Button.stories.js | 14 +- .../stories/atoms/Text-field.stories.js | 18 +- .../stories/foundations/Borders.stories.js | 6 +- .../stories/foundations/Elevations.stories.js | 7 +- .../stories/foundations/Spacing.stories.js | 12 +- .../stories/foundations/Typography.stories.js | 16 +- .../stories/molecules/Accordion.stories.js | 26 ++- .../stories/molecules/Avatar.stories.js | 42 +++- .../stories/molecules/Tooltip.stories.js | 14 +- .../stories/organisms/AppBar.stories.js | 14 +- .../stories/organisms/List.stories.js | 180 ++++++++++-------- .../organisms/ListItemGuide.stories.mdx | 35 ++++ .../stories/organisms/Menu.stories.js | 28 +++ .../react-ui/storybook/utils/storyStyles.js | 21 +- 15 files changed, 322 insertions(+), 149 deletions(-) create mode 100644 packages/react-ui/storybook/stories/organisms/ListItemGuide.stories.mdx diff --git a/UPGRADE.md b/UPGRADE.md index 01bc985af..fe7612a5c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -139,6 +139,44 @@ We have a new component for building data structures within Tooltips, `TooltipDa # Components +## Good practices + +### ListItem + +In order to be interactive, you need to use `MenuItem` component, or use `ListItemButton`instead. + +``` + + + + + + + + +``` + +``` + + + + + + + + +``` + +To render a link: + +``` + + + +``` + +Note that `` is deprecated. + ## Mui components replacement These components should be imported from carto-react library instead of Mui, as they replace the Mui components extending their functionality to meet with design criteria. diff --git a/packages/react-ui/storybook/stories/atoms/Button.stories.js b/packages/react-ui/storybook/stories/atoms/Button.stories.js index e88e600c5..d80a622c8 100644 --- a/packages/react-ui/storybook/stories/atoms/Button.stories.js +++ b/packages/react-ui/storybook/stories/atoms/Button.stories.js @@ -4,7 +4,7 @@ import { Add, Close } from '@mui/icons-material'; import LoadingButton from '@mui/lab/LoadingButton'; import Typography from '../../../src/components/atoms/Typography'; import Button from '../../../src/components/atoms/Button'; -import { DocContainer, DocTextHighlight, DocLink } from '../../utils/storyStyles'; +import { DocContainer, DocHighlight, DocLink } from '../../utils/storyStyles'; const options = { title: 'Atoms/Button', @@ -213,17 +213,15 @@ const DocTemplate = () => { {' '} component that uses Mui Button and wraps its children in a Typography{' '} component to meet with the designed behavior (text overflow case). - + So, instead of Mui Button, you should use this one:{' '} - - react-ui/src/components/atoms/Button - + react-ui/src/components/atoms/Button - + For external use:{' '} - + {'import { Button } from "@carto/react-ui";'} - + . diff --git a/packages/react-ui/storybook/stories/atoms/Text-field.stories.js b/packages/react-ui/storybook/stories/atoms/Text-field.stories.js index 86f608b79..dc1748712 100644 --- a/packages/react-ui/storybook/stories/atoms/Text-field.stories.js +++ b/packages/react-ui/storybook/stories/atoms/Text-field.stories.js @@ -3,12 +3,7 @@ import { Grid, InputAdornment, TextField } from '@mui/material'; import React from 'react'; import PasswordField from '../../../src/components/atoms/PasswordField'; import Typography from '../../../src/components/atoms/Typography'; -import { - Container, - DocContainer, - DocTextHighlight, - Label -} from '../../utils/storyStyles'; +import { Container, DocContainer, DocHighlight, Label } from '../../utils/storyStyles'; const options = { title: 'Atoms/Text Field', @@ -543,14 +538,9 @@ const PasswordFieldTemplate = ({ - Use{' '} - - {''} - {' '} - instead of{' '} - - {''} - {' '} + Use {''} instead + of{' '} + {''}{' '} This component build the show / hide content logic on top of TextField{' '} Mui component. diff --git a/packages/react-ui/storybook/stories/foundations/Borders.stories.js b/packages/react-ui/storybook/stories/foundations/Borders.stories.js index 813bc9cf9..68b8fb919 100644 --- a/packages/react-ui/storybook/stories/foundations/Borders.stories.js +++ b/packages/react-ui/storybook/stories/foundations/Borders.stories.js @@ -2,7 +2,7 @@ import React from 'react'; import { Box, Grid } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import Typography from '../../../src/components/atoms/Typography'; -import { DocContainer, FilledContainer } from '../../utils/storyStyles'; +import { DocContainer, DocHighlight, FilledContainer } from '../../utils/storyStyles'; const options = { title: 'Foundations/Borders', @@ -64,9 +64,7 @@ const DocTemplate = () => { return ( Use is restringed to a few specific values, defined in the design system, which are:{' '} - - 0.5, 1, 1.5, 2 - + 0.5, 1, 1.5, 2 ); }; diff --git a/packages/react-ui/storybook/stories/foundations/Elevations.stories.js b/packages/react-ui/storybook/stories/foundations/Elevations.stories.js index a67452fef..6944cf7dd 100644 --- a/packages/react-ui/storybook/stories/foundations/Elevations.stories.js +++ b/packages/react-ui/storybook/stories/foundations/Elevations.stories.js @@ -2,7 +2,7 @@ import React from 'react'; import { Box, Grid } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import Typography from '../../../src/components/atoms/Typography'; -import { DocContainer, FilledContainer } from '../../utils/storyStyles'; +import { DocContainer, DocHighlight, FilledContainer } from '../../utils/storyStyles'; const options = { title: 'Foundations/Elevations', @@ -71,10 +71,7 @@ const DocTemplate = () => { return ( Use is restringed to a few specific values, defined in the design system, which are:{' '} - - 0, 1, 2, 4, 6, 8, 16, 24 - - . + 0, 1, 2, 4, 6, 8, 16, 24. ); }; diff --git a/packages/react-ui/storybook/stories/foundations/Spacing.stories.js b/packages/react-ui/storybook/stories/foundations/Spacing.stories.js index 189f4008c..1cf77d1c1 100644 --- a/packages/react-ui/storybook/stories/foundations/Spacing.stories.js +++ b/packages/react-ui/storybook/stories/foundations/Spacing.stories.js @@ -3,7 +3,7 @@ import { Box, Grid } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import Typography from '../../../src/components/atoms/Typography'; import Button from '../../../src/components/atoms/Button'; -import { DocContainer, DocTextHighlight, FilledContainer } from '../../utils/storyStyles'; +import { DocContainer, DocHighlight, FilledContainer } from '../../utils/storyStyles'; const options = { title: 'Foundations/Spacing', @@ -88,14 +88,8 @@ const DocTemplate = () => { } > Check the usage guide before using{' '} - - spacing - {' '} - values, specially{' '} - - theme.spacing - {' '} - function. + spacing values, specially{' '} + theme.spacing function. ); }; diff --git a/packages/react-ui/storybook/stories/foundations/Typography.stories.js b/packages/react-ui/storybook/stories/foundations/Typography.stories.js index 82854d9ae..04624a6f0 100644 --- a/packages/react-ui/storybook/stories/foundations/Typography.stories.js +++ b/packages/react-ui/storybook/stories/foundations/Typography.stories.js @@ -1,7 +1,7 @@ import React from 'react'; import Typography from '../../../src/components/atoms/Typography'; import ButtonComp from '../../../src/components/atoms/Button'; -import { DocContainer, DocLink, DocTextHighlight } from '../../utils/storyStyles'; +import { DocContainer, DocLink, DocHighlight } from '../../utils/storyStyles'; const options = { title: 'Foundations/Typography', @@ -94,20 +94,20 @@ const DocTemplate = () => { Typography {' '} component that extends Mui Typography with some styling props. - + So, instead of Mui Typography, you should use this one:{' '} - + react-ui/src/components/atoms/Typography - + - + For external use:{' '} - + {'import { Typography } from "@carto/react-ui";'} - + . - + For more details, check the usage guide before using CARTO Typography diff --git a/packages/react-ui/storybook/stories/molecules/Accordion.stories.js b/packages/react-ui/storybook/stories/molecules/Accordion.stories.js index 86b267ffd..d2cd158b4 100644 --- a/packages/react-ui/storybook/stories/molecules/Accordion.stories.js +++ b/packages/react-ui/storybook/stories/molecules/Accordion.stories.js @@ -8,7 +8,12 @@ import { Grid } from '@mui/material'; import { Typography } from '@carto/react-ui'; -import { BoxContent, TitleContent } from '../../utils/storyStyles'; +import { + BoxContent, + DocContainer, + DocHighlight, + TitleContent +} from '../../utils/storyStyles'; import AccordionGroup from '../../../src/components/molecules/AccordionGroup'; const options = { @@ -103,6 +108,25 @@ const GroupTemplate = ({ defaultExpanded, ...args }) => { return ( + + Component used as a container of a group of `Mui Accordions`, that also adds a{' '} + variant prop to have different + styles in the group: Standard (default) and Outlined. + + Use AccordionGroup from:{' '} + + react-ui/src/components/molecules/AccordionGroup + + + + For external use:{' '} + + {'import { AccordionGroup } from "@carto/react-ui";'} + + . + + + {'AccordionGroup custom component'} diff --git a/packages/react-ui/storybook/stories/molecules/Avatar.stories.js b/packages/react-ui/storybook/stories/molecules/Avatar.stories.js index 92690f991..5396c89f0 100644 --- a/packages/react-ui/storybook/stories/molecules/Avatar.stories.js +++ b/packages/react-ui/storybook/stories/molecules/Avatar.stories.js @@ -2,7 +2,14 @@ import React from 'react'; import { Grid, useTheme } from '@mui/material'; import { Star } from '@mui/icons-material'; import { getCartoColorStylePropsForItem, Avatar } from '@carto/react-ui'; -import { BoxContent, TitleContent } from '../../utils/storyStyles'; +import { + BoxContent, + DocContainer, + DocLink, + DocHighlight, + TitleContent +} from '../../utils/storyStyles'; +import Typography from '../../../src/components/atoms/Typography'; const options = { title: 'Molecules/Avatar', @@ -326,6 +333,37 @@ const ColorBackgroundTemplate = ({ ...args }) => { ); }; +const DocTemplate = () => { + return ( + + We have our own{' '} + + Avatar + {' '} + component that uses Mui Avatar and extends it with a new styling prop,{' '} + size. + + This component normalize size and allow us to use only the 4 sizes defined + by the design system:{' '} + large, medium, small and xsmall + + + Import it from{' '} + + react-ui/src/components/molecules/Avatar + + + + For external use:{' '} + + {'import { Avatar } from "@carto/react-ui";'} + + . + + + ); +}; + const disabledVariantArgType = { variant: { table: { disable: true } } }; @@ -335,6 +373,8 @@ const disabledSizeArgType = { export const Playground = Template.bind({}); +export const Guide = DocTemplate.bind({}); + export const Shape = ShapeTemplate.bind({}); Shape.argTypes = disabledVariantArgType; diff --git a/packages/react-ui/storybook/stories/molecules/Tooltip.stories.js b/packages/react-ui/storybook/stories/molecules/Tooltip.stories.js index 98ce8082f..eaf03abbf 100644 --- a/packages/react-ui/storybook/stories/molecules/Tooltip.stories.js +++ b/packages/react-ui/storybook/stories/molecules/Tooltip.stories.js @@ -7,7 +7,7 @@ import { commonPalette } from '../../../src/theme/sections/palette'; import { Container, DocContainer, - DocTextHighlight, + DocHighlight, Label, Standalone } from '../../utils/storyStyles'; @@ -239,15 +239,9 @@ const TooltipBehaviorTemplate = (args) => { const DocTemplate = () => { return ( - By default a Tooltip is placed{' '} - - top - {' '} - and has an{' '} - - arrow - {' '} - indicator, so you don't need to specify these properties anymore. + By default a Tooltip is placed top and + has an arrow indicator, so you don't + need to specify these properties anymore. ); }; diff --git a/packages/react-ui/storybook/stories/organisms/AppBar.stories.js b/packages/react-ui/storybook/stories/organisms/AppBar.stories.js index 20eb61f08..c82a7240e 100644 --- a/packages/react-ui/storybook/stories/organisms/AppBar.stories.js +++ b/packages/react-ui/storybook/stories/organisms/AppBar.stories.js @@ -3,7 +3,7 @@ import { Avatar, Chip, Grid, IconButton, Menu, MenuItem } from '@mui/material'; import { CheckCircleOutline } from '@mui/icons-material'; import AppBar from '../../../src/components/organisms/AppBar/AppBar'; import Typography from '../../../src/components/atoms/Typography'; -import { DocContainer, DocLink, DocTextHighlight } from '../../utils/storyStyles'; +import { DocContainer, DocLink, DocHighlight } from '../../utils/storyStyles'; const options = { title: 'Organisms/AppBar', @@ -100,17 +100,17 @@ const DocTemplate = () => { to build the basic structure and styles on top of Mui AppBar. It normalizes the size and position of common elements like:{' '} logo, texts, avatar and burger menu icon. - + So, instead of Mui AppBar, you should use this one:{' '} - + react-ui/src/components/organisms/AppBar - + - + For external use:{' '} - + {'import { AppBar } from "@carto/react-ui";'} - + . diff --git a/packages/react-ui/storybook/stories/organisms/List.stories.js b/packages/react-ui/storybook/stories/organisms/List.stories.js index af4dad282..745f0d985 100644 --- a/packages/react-ui/storybook/stories/organisms/List.stories.js +++ b/packages/react-ui/storybook/stories/organisms/List.stories.js @@ -8,7 +8,6 @@ import { Grid, IconButton, List, - ListItem, ListItemAvatar, ListItemIcon, ListItemSecondaryAction, @@ -16,7 +15,8 @@ import { Typography, Switch, Paper, - styled + styled, + ListItemButton } from '@mui/material'; import { Drafts, @@ -27,6 +27,8 @@ import { Inbox, Star } from '@mui/icons-material'; +import { DocContainer, DocHighlight } from '../../utils/storyStyles'; +import Button from '../../../src/components/atoms/Button'; const options = { title: 'Organisms/List', @@ -56,17 +58,17 @@ const Template = ({ secondary, ...args }) => { - + - + - + - + - + - + @@ -74,26 +76,26 @@ const Template = ({ secondary, ...args }) => { - + - + - + - + - + - + @@ -101,26 +103,26 @@ const Template = ({ secondary, ...args }) => { - + - + - + - + - + - + @@ -128,32 +130,32 @@ const Template = ({ secondary, ...args }) => { - + - + - + - + - + - + @@ -179,20 +181,20 @@ const TemplateMetaValue = ({ secondary, ...args }) => { - + - + - + - + - + - + @@ -200,20 +202,20 @@ const TemplateMetaValue = ({ secondary, ...args }) => { - + - + - + - + - + - + @@ -229,20 +231,20 @@ const TemplateSecondaryActions = ({ ...args }) => { - + - + - + - + - + - + @@ -250,26 +252,26 @@ const TemplateSecondaryActions = ({ ...args }) => { - + - + - + - + - + - + @@ -277,32 +279,32 @@ const TemplateSecondaryActions = ({ ...args }) => { - + - + - + - + - + - + @@ -310,26 +312,26 @@ const TemplateSecondaryActions = ({ ...args }) => { - + - + - + - + - + - + @@ -345,42 +347,42 @@ const TemplateNested = ({ ...args }) => { - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -389,8 +391,34 @@ const TemplateNested = ({ ...args }) => { ); }; +const DocTemplate = () => { + return ( + + Guide + + } + > + In order ListItem to be interactive, + you need to use MenuItem component, or + use ListItemButton instead. + Note that {''} is deprecated. + + ); +}; + export const Playground = Template.bind({}); +export const Guide = DocTemplate.bind({}); + export const OneLine = Template.bind({}); export const TwoLines = Template.bind({}); diff --git a/packages/react-ui/storybook/stories/organisms/ListItemGuide.stories.mdx b/packages/react-ui/storybook/stories/organisms/ListItemGuide.stories.mdx new file mode 100644 index 000000000..14d8394fc --- /dev/null +++ b/packages/react-ui/storybook/stories/organisms/ListItemGuide.stories.mdx @@ -0,0 +1,35 @@ +import { Meta } from '@storybook/addon-docs'; + + + +# ListItem + +In order to be interactive, you need to use `MenuItem` component, or use `ListItemButton`instead. + +``` + + + + + + + + + + +``` + +``` + + + + + + + + + + +``` + +Note that `` is deprecated. diff --git a/packages/react-ui/storybook/stories/organisms/Menu.stories.js b/packages/react-ui/storybook/stories/organisms/Menu.stories.js index 54913f5b8..53f82dda6 100644 --- a/packages/react-ui/storybook/stories/organisms/Menu.stories.js +++ b/packages/react-ui/storybook/stories/organisms/Menu.stories.js @@ -7,6 +7,8 @@ import { ContentPasteOutlined } from '@mui/icons-material'; import Typography from '../../../src/components/atoms/Typography'; +import { DocContainer, DocHighlight } from '../../utils/storyStyles'; +import Button from '../../../src/components/atoms/Button'; const options = { title: 'Organisms/Menu', @@ -77,7 +79,33 @@ const Template = ({ label, ...args }) => { ); }; +const DocTemplate = () => { + return ( + + Guide + + } + > + In order ListItem to be interactive, + you need to use MenuItem component, or + use ListItemButton instead. + Note that {''} is deprecated. + + ); +}; + const commonArgs = { label: 'Label', dense: false }; export const Playground = Template.bind({}); Playground.args = { ...commonArgs }; + +export const Guide = DocTemplate.bind({}); diff --git a/packages/react-ui/storybook/utils/storyStyles.js b/packages/react-ui/storybook/utils/storyStyles.js index 67c6d8eec..f65996750 100644 --- a/packages/react-ui/storybook/utils/storyStyles.js +++ b/packages/react-ui/storybook/utils/storyStyles.js @@ -48,18 +48,27 @@ export const FilledContainer = styled(Box)(({ theme }) => ({ })); export const DocContainer = styled(Alert)(({ theme }) => ({ - marginBottom: theme.spacing(3) + marginBottom: theme.spacing(3), + + '& .MuiTypography-root': { + ...theme.typography.caption, + color: 'inherit' + } })); -export const DocTextHighlight = styled(Typography)(({ theme }) => ({ - display: 'inline', - fontWeight: theme.typography.fontWeightBold, - color: 'inherit' +export const DocHighlight = styled(Typography)(({ theme }) => ({ + '&.MuiTypography-root': { + display: 'inline', + color: 'inherit', + ...theme.typography.caption, + fontWeight: theme.typography.fontWeightBold + } })); export const DocLink = styled(Link)(({ theme }) => ({ textDecoration: 'underline', - color: 'inherit' + color: 'inherit', + ...theme.typography.caption })); export const Label = styled(Typography)(({ theme }) => ({