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

[Modal] Migrate to emotion + unstyled #24857

Merged
merged 29 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
43cdb74
[Modal] Migrate to emotion
povilass Feb 10, 2021
737459f
[Modal] Migrate to emotion
povilass Feb 10, 2021
eddbb1c
[Modal] Migration to unstyled
povilass Feb 20, 2021
5eb9089
[Modal] docs
povilass Feb 20, 2021
ba2389c
[Modal] types
povilass Feb 20, 2021
1aa96d0
migrate some of the demos to emotion
oliviertassinari Feb 21, 2021
d9266af
no blank line between imports
oliviertassinari Feb 21, 2021
257e9b6
no need for default argument
oliviertassinari Feb 21, 2021
0c002ab
naming convention
oliviertassinari Feb 21, 2021
0ed9af5
avoid cloning objects
oliviertassinari Feb 21, 2021
a0b70b1
sort asc
oliviertassinari Feb 21, 2021
7ee6770
avoid blank lines
oliviertassinari Feb 21, 2021
99f592e
children can be implicit
oliviertassinari Feb 21, 2021
984d67e
avoid creating new objects or even default values
oliviertassinari Feb 21, 2021
f532066
needed since a rebase on HEAD would break without
oliviertassinari Feb 21, 2021
0937b08
shorter
oliviertassinari Feb 21, 2021
b03dc83
shorter
oliviertassinari Feb 21, 2021
b1ac8a8
export directly
oliviertassinari Feb 21, 2021
aa83be2
fix ci
oliviertassinari Feb 21, 2021
dff9423
my bad, the other are spread on a different component
oliviertassinari Feb 21, 2021
06d89b1
fix script error
oliviertassinari Feb 21, 2021
6536601
demo docs update
povilass Feb 22, 2021
5c17712
prettier
povilass Feb 22, 2021
db05a07
Showcase unstyled sooner as more relevant for a Modal
oliviertassinari Feb 23, 2021
0b786d0
bring a bit more light to the unstyled sections
oliviertassinari Feb 23, 2021
802106c
fix duplicated id
oliviertassinari Feb 23, 2021
7d6e490
create more contrast between styled and unstyled
oliviertassinari Feb 23, 2021
8cf6477
denser demos
oliviertassinari Feb 23, 2021
13ffe70
polish
oliviertassinari Feb 23, 2021
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
1 change: 1 addition & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ module.exports = {
'no-missing-end-of-source-newline': null,
'declaration-colon-newline-after': null,
'value-keyword-case': null,
'value-list-comma-newline-after': null, // not compatible with prettier
},
};
2 changes: 1 addition & 1 deletion docs/pages/api-docs/backdrop-unstyled.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"props": {
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" }, "default": "{}" },
"classes": { "type": { "name": "object" } },
"component": { "type": { "name": "elementType" } },
"components": {
"type": { "name": "shape", "description": "{ Root?: elementType }" },
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/backdrop.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"props": {
"open": { "type": { "name": "bool" }, "required": true },
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" }, "default": "{}" },
"classes": { "type": { "name": "object" } },
"component": { "type": { "name": "elementType" } },
"components": {
"type": { "name": "shape", "description": "{ Root?: elementType }" },
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/badge-unstyled.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"badgeContent": { "type": { "name": "node" } },
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" }, "default": "{}" },
"classes": { "type": { "name": "object" } },
"component": { "type": { "name": "elementType" } },
"components": {
"type": { "name": "shape", "description": "{ Badge?: elementType, Root?: elementType }" },
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/badge.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"badgeContent": { "type": { "name": "node" } },
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" }, "default": "{}" },
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "union",
Expand Down
23 changes: 23 additions & 0 deletions docs/pages/api-docs/modal-unstyled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import ApiPage from 'docs/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './modal-unstyled.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <ApiPage descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
const req = require.context(
'docs/translations/api-docs/modal-unstyled',
false,
/modal-unstyled.*.json$/,
);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
40 changes: 40 additions & 0 deletions docs/pages/api-docs/modal-unstyled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"props": {
"children": { "type": { "name": "custom", "description": "element" }, "required": true },
"open": { "type": { "name": "bool" }, "required": true },
"BackdropComponent": { "type": { "name": "elementType" } },
"BackdropProps": { "type": { "name": "object" } },
"classes": { "type": { "name": "object" } },
"closeAfterTransition": { "type": { "name": "bool" } },
"component": { "type": { "name": "elementType" } },
"components": {
"type": { "name": "shape", "description": "{ Root?: elementType }" },
"default": "{}"
},
"componentsProps": { "type": { "name": "object" }, "default": "{}" },
"container": { "type": { "name": "union", "description": "HTML element<br>&#124;&nbsp;func" } },
"disableAutoFocus": { "type": { "name": "bool" } },
"disableEnforceFocus": { "type": { "name": "bool" } },
"disableEscapeKeyDown": { "type": { "name": "bool" } },
"disablePortal": { "type": { "name": "bool" } },
"disableRestoreFocus": { "type": { "name": "bool" } },
"disableScrollLock": { "type": { "name": "bool" } },
"hideBackdrop": { "type": { "name": "bool" } },
"keepMounted": { "type": { "name": "bool" } },
"onBackdropClick": { "type": { "name": "func" } },
"onClose": { "type": { "name": "func" } }
},
"name": "ModalUnstyled",
"styles": {
"classes": ["root", "hidden"],
"globalClasses": { "root": "MuiModal-root", "hidden": "MuiModal-hidden" },
"name": null
},
"spread": true,
"forwardsRefTo": "HTMLDivElement",
"filename": "/packages/material-ui-unstyled/src/ModalUnstyled/ModalUnstyled.js",
"inheritance": null,
"demos": "<ul><li><a href=\"/components/modal/\">Modal</a></li></ul>",
"styledComponent": true,
"cssComponent": false
}
14 changes: 11 additions & 3 deletions docs/pages/api-docs/modal.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
"props": {
"children": { "type": { "name": "custom", "description": "element" }, "required": true },
"open": { "type": { "name": "bool" }, "required": true },
"BackdropComponent": { "type": { "name": "elementType" }, "default": "SimpleBackdrop" },
"BackdropComponent": { "type": { "name": "elementType" }, "default": "Backdrop" },
"BackdropProps": { "type": { "name": "object" } },
"classes": { "type": { "name": "object" } },
"closeAfterTransition": { "type": { "name": "bool" } },
"component": { "type": { "name": "elementType" } },
"components": {
"type": { "name": "shape", "description": "{ Root?: elementType }" },
"default": "{}"
},
"componentsProps": { "type": { "name": "object" }, "default": "{}" },
"container": { "type": { "name": "union", "description": "HTML element<br>&#124;&nbsp;func" } },
"disableAutoFocus": { "type": { "name": "bool" } },
"disableEnforceFocus": { "type": { "name": "bool" } },
Expand All @@ -15,10 +22,11 @@
"hideBackdrop": { "type": { "name": "bool" } },
"keepMounted": { "type": { "name": "bool" } },
"onBackdropClick": { "type": { "name": "func" } },
"onClose": { "type": { "name": "func" } }
"onClose": { "type": { "name": "func" } },
"sx": { "type": { "name": "object" } }
},
"name": "Modal",
"styles": { "classes": [], "globalClasses": {}, "name": null },
"styles": { "classes": ["root", "hidden"], "globalClasses": {}, "name": "MuiModal" },
"spread": true,
"forwardsRefTo": "HTMLDivElement",
"filename": "/packages/material-ui/src/Modal/Modal.js",
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/slider-unstyled.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"aria-label": { "type": { "name": "custom", "description": "string" } },
"aria-labelledby": { "type": { "name": "string" } },
"aria-valuetext": { "type": { "name": "custom", "description": "string" } },
"classes": { "type": { "name": "object" }, "default": "{}" },
"classes": { "type": { "name": "object" } },
"component": { "type": { "name": "elementType" } },
"components": {
"type": {
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/slider.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"aria-label": { "type": { "name": "custom", "description": "string" } },
"aria-labelledby": { "type": { "name": "string" } },
"aria-valuetext": { "type": { "name": "custom", "description": "string" } },
"classes": { "type": { "name": "object" }, "default": "{}" },
"classes": { "type": { "name": "object" } },
"color": {
"type": { "name": "enum", "description": "'primary'<br>&#124;&nbsp;'secondary'" },
"default": "'primary'"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/company/careers/careers.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The company is bootstrapped (so far). It was incorporated in mid 2019 and yet gr

- **Customer obsessed**. We put our customers front & center. We focus on delivering web experiences that feel amazing. We ask questions. We experiment with new ideas.
- **Transparency**. Most of our work is public. We share what we work on regularly in the open. We collect feedback as soon and as frequently as possible. We learn from each other and
grow from it.
grow from it.
- **Freedom**. We work from anywhere in the world. We keep meetings to a minimum, preferring asynchronous and written communication.
- **Autonomy**. We want to create a safe, high-trust team. We want you to be able to feel invested in your work and proud of it.
- **Excellence**. We're aiming high, and we know it. Even the smallest details are important to us. We only want the best for each other and our customers.
Expand Down
3 changes: 3 additions & 0 deletions docs/src/pages/components/badges/UnstyledBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const StyledBadge = styled(BadgeUnstyled)`
font-variant: tabular-nums;
list-style: none;
font-feature-settings: 'tnum';
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol';
position: relative;
display: inline-block;
line-height: 1;
Expand Down
3 changes: 3 additions & 0 deletions docs/src/pages/components/badges/UnstyledBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const StyledBadge = styled(BadgeUnstyled)`
font-variant: tabular-nums;
list-style: none;
font-feature-settings: 'tnum';
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol';
position: relative;
display: inline-block;
line-height: 1;
Expand Down
7 changes: 7 additions & 0 deletions docs/src/pages/components/badges/badges.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ You can use the `anchorOrigin` prop to move the badge to any corner of the wrapp

## Unstyled badge

The badge also comes with an unstyled version.
It's ideal for doing heavy customizations and minimizing bundle size.

```js
import BadgeUnstyled from '@material-ui/unstyled/BadgeUnstyled';
```

{{"demo": "pages/components/badges/UnstyledBadge.js"}}
28 changes: 11 additions & 17 deletions docs/src/pages/components/modal/BasicModal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from 'react';
import Box from '@material-ui/core/Box';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import Modal from '@material-ui/core/Modal';

const style = {
Expand All @@ -11,38 +13,30 @@ const style = {
bgcolor: 'background.paper',
border: '2px solid #000',
boxShadow: 24,
pt: 2,
px: 4,
pb: 3,
p: 4,
};

export default function BasicModal() {
const [open, setOpen] = React.useState(false);

const handleOpen = () => {
setOpen(true);
};

const handleClose = () => {
setOpen(false);
};
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

return (
<div>
<button type="button" onClick={handleOpen}>
Open Modal
</button>
<Button onClick={handleOpen}>Open modal</Button>
<Modal
open={open}
onClose={handleClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box sx={style}>
<h2 id="modal-modal-title">Text in a modal</h2>
<p id="modal-modal-description">
<Typography id="modal-modal-title" variant="h6" component="h2">
Text in a modal
</Typography>
<Typography id="modal-modal-description" sx={{ mt: 2 }}>
Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
</p>
</Typography>
</Box>
</Modal>
</div>
Expand Down
28 changes: 11 additions & 17 deletions docs/src/pages/components/modal/BasicModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from 'react';
import Box from '@material-ui/core/Box';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import Modal from '@material-ui/core/Modal';

const style = {
Expand All @@ -11,38 +13,30 @@ const style = {
bgcolor: 'background.paper',
border: '2px solid #000',
boxShadow: 24,
pt: 2,
px: 4,
pb: 3,
p: 4,
};

export default function BasicModal() {
const [open, setOpen] = React.useState(false);

const handleOpen = () => {
setOpen(true);
};

const handleClose = () => {
setOpen(false);
};
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

return (
<div>
<button type="button" onClick={handleOpen}>
Open Modal
</button>
<Button onClick={handleOpen}>Open modal</Button>
<Modal
open={open}
onClose={handleClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box sx={style}>
<h2 id="modal-modal-title">Text in a modal</h2>
<p id="modal-modal-description">
<Typography id="modal-modal-title" variant="h6" component="h2">
Text in a modal
</Typography>
<Typography id="modal-modal-description" sx={{ mt: 2 }}>
Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
</p>
</Typography>
</Box>
</Modal>
</div>
Expand Down
Loading