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

SelectField Storybook leftovers #746

Merged
merged 2 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Not released

- SelectField Storybook leftovers [#746](https://github.com/CartoDB/carto-react/pull/746)

## 2.2

### 2.2.0 (2023-07-19)
Expand Down
83 changes: 10 additions & 73 deletions packages/react-ui/storybook/stories/atoms/SelectField.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,6 @@ const menuItems = [
}
];

const menuItemsLong = [
{
label: 'table_openstreetmap_pointsofinterest',
value: '10Long'
},
{
label: 'Twenty',
value: '20'
},
{
label: 'Thirty',
value: '30'
}
];

const SelectFieldItem = ({
label,
required,
Expand Down Expand Up @@ -121,7 +106,6 @@ const SelectFieldItem = ({
label={label}
variant={variant}
placeholder={placeholder}
items={menuItems}
helperText={helperText}
onChange={handleChange}
value={content}
Expand Down Expand Up @@ -160,7 +144,6 @@ const VariantsTemplate = ({ label, required, placeholder, ...rest }) => {
label={label}
variant='filled'
placeholder={placeholder}
items={menuItems}
/>
</Container>
</Grid>
Expand All @@ -172,7 +155,6 @@ const VariantsTemplate = ({ label, required, placeholder, ...rest }) => {
label={label}
variant='outlined'
placeholder={placeholder}
items={menuItems}
/>
</Container>
</Grid>
Expand All @@ -184,7 +166,6 @@ const VariantsTemplate = ({ label, required, placeholder, ...rest }) => {
label={label}
variant='standard'
placeholder={placeholder}
items={menuItems}
/>
</Container>
</Grid>
Expand All @@ -203,36 +184,25 @@ const LabelAndHelperTextTemplate = ({ label, placeholder, helperText, ...rest })
label={label}
placeholder={placeholder}
helperText={helperText}
items={menuItems}
/>
</Container>
</Grid>
<Grid item>
<Container>
<Label variant='body2'>{'Without label + helper text'}</Label>
<SelectFieldItem {...rest} placeholder={placeholder} items={menuItems} />
<SelectFieldItem {...rest} placeholder={placeholder} />
</Container>
</Grid>
<Grid item>
<Container>
<Label variant='body2'>{'Only label'}</Label>
<SelectFieldItem
{...rest}
label={label}
placeholder={placeholder}
items={menuItems}
/>
<SelectFieldItem {...rest} label={label} placeholder={placeholder} />
</Container>
</Grid>
<Grid item>
<Container>
<Label variant='body2'>{'Only helper text'}</Label>
<SelectFieldItem
{...rest}
placeholder={placeholder}
helperText={helperText}
items={menuItems}
/>
<SelectFieldItem {...rest} placeholder={placeholder} helperText={helperText} />
</Container>
</Grid>
</Grid>
Expand Down Expand Up @@ -273,7 +243,6 @@ const SizeTemplate = ({
variant='filled'
label={label}
placeholder={placeholder}
items={menuItems}
size={size}
/>
</Grid>
Expand All @@ -283,7 +252,6 @@ const SizeTemplate = ({
variant='outlined'
label={label}
placeholder={placeholder}
items={menuItems}
size={size}
/>
</Grid>
Expand All @@ -293,7 +261,6 @@ const SizeTemplate = ({
variant='standard'
label={label}
placeholder={placeholder}
items={menuItems}
size={size}
/>
</Grid>
Expand All @@ -306,19 +273,19 @@ const SizeTemplate = ({
<Grid item xs={3}>
<FormControl>
<InputLabel>{label}</InputLabel>
<SelectFieldItem {...rest} variant='filled' size={size} items={menuItems} />
<SelectFieldItem {...rest} variant='filled' size={size} />
</FormControl>
</Grid>
<Grid item xs={3}>
<FormControl>
<InputLabel>{label}</InputLabel>
<SelectFieldItem {...rest} variant='outlined' size={size} items={menuItems} />
<SelectFieldItem {...rest} variant='outlined' size={size} />
</FormControl>
</Grid>
<Grid item xs={3}>
<FormControl>
<InputLabel>{label}</InputLabel>
<SelectFieldItem {...rest} variant='standard' size={size} items={menuItems} />
<SelectFieldItem {...rest} variant='standard' size={size} />
</FormControl>
</Grid>
</Grid>
Expand Down Expand Up @@ -398,7 +365,6 @@ const SizeTemplate = ({
placeholder={placeholder}
focused
size={size}
items={menuItems}
/>
</Grid>
<Grid item xs={3}>
Expand All @@ -409,7 +375,6 @@ const SizeTemplate = ({
placeholder={placeholder}
focused
size={size}
items={menuItems}
/>
</Grid>
<Grid item xs={3}>
Expand All @@ -420,7 +385,6 @@ const SizeTemplate = ({
placeholder={placeholder}
focused
size={size}
items={menuItems}
/>
</Grid>
</Grid>
Expand All @@ -437,7 +401,6 @@ const SizeTemplate = ({
placeholder={placeholder}
disabled
size={size}
items={menuItems}
/>
</Grid>
<Grid item xs={3}>
Expand All @@ -448,7 +411,6 @@ const SizeTemplate = ({
placeholder={placeholder}
disabled
size={size}
items={menuItems}
/>
</Grid>
<Grid item xs={3}>
Expand All @@ -459,7 +421,6 @@ const SizeTemplate = ({
placeholder={placeholder}
disabled
size={size}
items={menuItems}
/>
</Grid>
</Grid>
Expand All @@ -477,7 +438,6 @@ const SizeTemplate = ({
helperText={helperText}
error
size={size}
items={menuItems}
/>
</Grid>
<Grid item xs={3}>
Expand All @@ -489,7 +449,6 @@ const SizeTemplate = ({
helperText={helperText}
error
size={size}
items={menuItems}
/>
</Grid>
<Grid item xs={3}>
Expand All @@ -501,7 +460,6 @@ const SizeTemplate = ({
helperText={helperText}
error
size={size}
items={menuItems}
/>
</Grid>
</Grid>
Expand Down Expand Up @@ -535,12 +493,7 @@ const BehaviorTemplate = ({ label, placeholder, defaultValue, helperText, ...res
<Label variant='subtitle1'>{'Overflow'}</Label>
<Container style={{ maxWidth: '440px' }}>
<Label variant='body2'>{'Default'}</Label>
<SelectFieldItem
{...rest}
label={label}
placeholder={placeholder}
items={menuItemsLong}
/>
<SelectFieldItem {...rest} label={label} placeholder={placeholder} />
</Container>
</Grid>

Expand All @@ -551,20 +504,10 @@ const BehaviorTemplate = ({ label, placeholder, defaultValue, helperText, ...res

<Grid container spacing={2}>
<Grid item>
<SelectFieldItem
{...rest}
label={label}
placeholder={placeholder}
items={menuItems}
/>
<SelectFieldItem {...rest} label={label} placeholder={placeholder} />
</Grid>
<Grid item>
<SelectFieldItem
{...rest}
label={label}
placeholder={placeholder}
items={menuItems}
/>
<SelectFieldItem {...rest} label={label} placeholder={placeholder} />
</Grid>
</Grid>
</Container>
Expand All @@ -574,12 +517,7 @@ const BehaviorTemplate = ({ label, placeholder, defaultValue, helperText, ...res
<Label variant='subtitle1'>{'Width'}</Label>
<Container>
<Label variant='body2'>{'Default (fullWidth)'}</Label>
<SelectFieldItem
{...rest}
label={label}
placeholder={placeholder}
items={menuItems}
/>
<SelectFieldItem {...rest} label={label} placeholder={placeholder} />
</Container>
<Container>
<Label variant='body2'>{'No fullWidth'}</Label>
Expand All @@ -588,7 +526,6 @@ const BehaviorTemplate = ({ label, placeholder, defaultValue, helperText, ...res
label={label}
placeholder={placeholder}
fullWidth={false}
items={menuItems}
/>
</Container>
</Grid>
Expand Down
41 changes: 28 additions & 13 deletions packages/react-ui/storybook/stories/molecules/Table.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
TableContainer,
TableBody,
Table,
IconButton
IconButton,
MenuItem
} from '@mui/material';
import SelectField from '../../../src/components/atoms/SelectField';
import { MoreVertOutlined } from '@mui/icons-material';
Expand Down Expand Up @@ -103,12 +104,19 @@ const PlaygroundTemplate = (args) => {
<SelectField
size='small'
placeholder='Placeholder'
items={[
{ value: '1', label: 'One' },
{ value: '2', label: 'Two' },
{ value: '3', label: 'Three' }
]}
/>
onChange={() => void 0}
value={[]}
>
{[...Array(3)].map((item, index) => {
const itemText = `${index + 1}`;

return (
<MenuItem key={index} value={itemText}>
{itemText}
</MenuItem>
);
})}
</SelectField>
</TableCell>
<TableCell sx={{ maxWidth: 160 }}>
{index === 3 ? (
Expand Down Expand Up @@ -172,12 +180,19 @@ const ScrollTemplate = (args) => (
<SelectField
size='small'
placeholder='Placeholder'
items={[
{ value: '1', label: 'One' },
{ value: '2', label: 'Two' },
{ value: '3', label: 'Three' }
]}
/>
onChange={() => void 0}
value={[]}
>
{[...Array(3)].map((item, index) => {
const itemText = `${index + 1}`;

return (
<MenuItem key={index} value={itemText}>
{itemText}
</MenuItem>
);
})}
</SelectField>
</TableCell>
<TableCell sx={{ maxWidth: 160 }}>
{index % rows.length === 3 ? (
Expand Down