Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ch122277/list component meta value #31

Merged
merged 5 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Unreleased
- Make OAuthLogin component responsive [#28](https://github.com/CartoDB/carto-react-lib/pull/28)

## 1.0.0-beta5 (2020-11-26)
- Added meta value version to List component [#31](https://github.com/CartoDB/carto-react-lib/pull/31)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this item to ##Unreleased section, please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


## 1.0.0-beta5 (2020-11-25)
- Fix addSource keeping optional credentials property in the payload [#24](https://github.com/CartoDB/carto-react-lib/pull/24)

Expand Down
65 changes: 65 additions & 0 deletions src/ui/stories/common/List.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import {
Avatar,
Box,
Checkbox,
Collapse,
Divider,
Expand All @@ -12,6 +13,7 @@ import {
ListItemIcon,
ListItemSecondaryAction,
ListItemText,
Typography,
makeStyles,
Switch,
Paper,
Expand Down Expand Up @@ -154,6 +156,66 @@ const Template = ({ secondary, ...args }) => {
);
};

const TemplateMetaValue = ({ secondary, ...args }) => {
const classes = useStyles();

const MetaValueLabel = ({ value }) => {
return (
<Box alignSelf='flex-start' marginY={0.75}>
<Typography variant='body2' align='right'>{value}</Typography>
</Box>
);
};

return (
<Grid container spacing={6} className={classes.root}>
<Grid container item spacing={2}>
<Grid item xs={3}>
<Paper>
<List component='nav' aria-label='main mailbox folders'>
<ListItem button>
<ListItemText primary='Home' />
<MetaValueLabel value={ args.metaValue }></MetaValueLabel>
</ListItem>
<Divider />
<ListItem button>
<ListItemText primary='Inbox' />
<MetaValueLabel value={ args.metaValue }></MetaValueLabel>
</ListItem>
<Divider />
<ListItem button>
<ListItemText primary='Drafts' />
<MetaValueLabel value={ args.metaValue }></MetaValueLabel>
</ListItem>
</List>
</Paper>
</Grid>

<Grid item xs={3}>
<Paper>
<List component='nav' aria-label='main mailbox folders'>
<ListItem button>
<ListItemText primary='Home' secondary={secondary} />
<MetaValueLabel value={ args.metaValue }></MetaValueLabel>
</ListItem>
<Divider />
<ListItem button>
<ListItemText primary='Inbox' secondary={secondary} />
<MetaValueLabel value={ args.metaValue }></MetaValueLabel>
</ListItem>
<Divider />
<ListItem button>
<ListItemText primary='Drafts' secondary={secondary} />
<MetaValueLabel value={ args.metaValue }></MetaValueLabel>
</ListItem>
</List>
</Paper>
</Grid>
</Grid>
</Grid>
);
};

const TemplateSecondaryActions = ({ ...args }) => {
const classes = useStyles();

Expand Down Expand Up @@ -334,4 +396,7 @@ TwoLines.args = { secondary: 'Secondary text' };

export const SecondaryActions = TemplateSecondaryActions.bind({});

export const MetaValue = TemplateMetaValue.bind({});
MetaValue.args = { secondary: 'Secondary text too long here', metaValue: '$1,234.87' };

export const NestedOptions = TemplateNested.bind({});