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

Improve styles for MaterialUI - Dialog component #272

Merged
merged 4 commits into from
Jan 21, 2022
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

- Improve styles for MaterialUI Dialog component [#272](https://github.com/CartoDB/carto-react/pull/272)

## 1.2

### 1.2.1-alpha.5 (2022-01-20)
Expand Down
3 changes: 3 additions & 0 deletions packages/react-ui/src/theme/carto-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,9 @@ export const cartoThemeOptions = {
MuiSlider: {
color: 'primary',
marks: false
},
MuiDialog: {
maxWidth: 'md'
}
}
};
Expand Down
63 changes: 56 additions & 7 deletions packages/react-ui/storybook/stories/common/Dialog.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,50 @@ import {
DialogActions,
FormGroup,
Grid,
Slide,
TextField
} from '@material-ui/core';

const options = {
title: 'Common/Dialog',
component: Dialog
component: Dialog,
argTypes: {
disableEscapeKeyDown: {
description: 'If `true`, hitting escape will not fire the `onClose` callback.',
defaultValue: false,
control: {
type: 'boolean'
}
},
fullScreen: {
description: 'If `true`, the dialog will be full-screen',
defaultValue: false,
control: {
type: 'boolean'
}
},
fullWidth: {
description:
'If `true`, the dialog stretches to `maxWidth`. Notice that the dialog width grow is limited by the default margin.',
defaultValue: false,
control: {
type: 'boolean'
}
},
maxWidth: {
description:
'Determine the max-width of the dialog. The dialog width grows with the size of the screen. Set to `false` to disable `maxWidth`.',
defaultValue: 'md',
control: {
type: 'select',
options: ['lg', 'md', 'sm', 'xl', 'xs', false]
}
}
}
};
export default options;

const Template = ({ content, ...args }) => {
const Template = ({ content = <TextContent />, ...args }) => {
const [open, setOpen] = React.useState(false);

const handleClickOpen = () => {
Expand All @@ -31,16 +65,16 @@ const Template = ({ content, ...args }) => {
return (
<div>
<Button variant='outlined' color='primary' onClick={handleClickOpen}>
Open alert dialog
Open dialog
</Button>
<Dialog
open={open}
onClose={handleClose}
aria-labelledby='alert-dialog-title'
aria-describedby='alert-dialog-description'
aria-labelledby='dialog-title'
aria-describedby='dialog-description'
{...args}
>
<DialogTitle id='alert-dialog-title'>Dialog title</DialogTitle>
<DialogTitle id='dialog-title'>Dialog title</DialogTitle>
<DialogContent>{content}</DialogContent>
<DialogActions>
<Button onClick={handleClose} color='primary'>
Expand Down Expand Up @@ -82,7 +116,22 @@ const FormContent = () => (
);

export const Default = Template.bind({});
Default.args = { content: <TextContent /> };

export const Form = Template.bind({});
Form.args = { content: <FormContent /> };

export const DisableEscapeKeyDown = Template.bind({});
DisableEscapeKeyDown.args = { disableEscapeKeyDown: true };

export const SlideTransition = Template.bind({});
SlideTransition.args = {
TransitionComponent: Slide,
TransitionProps: { direction: 'up', timeout: 300 }
};

export const FullScren = Template.bind({});
FullScren.args = {
fullScreen: true,
TransitionComponent: Slide,
TransitionProps: { direction: 'up', timeout: 300 }
};