Skip to content

Commit 847feaa

Browse files
[docs] Increase the contrast of the demos (#18396)
1 parent aed1f38 commit 847feaa

File tree

119 files changed

+983
-1159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+983
-1159
lines changed

docs/src/modules/components/Demo.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
44
import clsx from 'clsx';
55
import copy from 'clipboard-copy';
66
import { useSelector, useDispatch } from 'react-redux';
7-
import { withStyles } from '@material-ui/core/styles';
7+
import { withStyles, fade } from '@material-ui/core/styles';
88
import IconButton from '@material-ui/core/IconButton';
99
import useMediaQuery from '@material-ui/core/useMediaQuery';
1010
import Collapse from '@material-ui/core/Collapse';
@@ -54,15 +54,22 @@ const styles = theme => ({
5454
position: 'relative',
5555
outline: 0,
5656
margin: 'auto',
57-
borderRadius: theme.shape.borderRadius,
58-
backgroundColor: theme.palette.background.level2,
5957
display: 'flex',
6058
justifyContent: 'center',
61-
padding: 20,
59+
borderLeftWidth: 0,
60+
borderRightWidth: 0,
61+
border: `1px solid ${fade(theme.palette.action.active, 0.12)}`,
62+
padding: theme.spacing(3),
6263
[theme.breakpoints.up('sm')]: {
63-
padding: theme.spacing(3),
64+
borderRadius: theme.shape.borderRadius,
65+
borderLeftWidth: 1,
66+
borderRightWidth: 1,
6467
},
6568
},
69+
demoBg: {
70+
border: 'none',
71+
backgroundColor: theme.palette.background.level2,
72+
},
6673
demoHiddenHeader: {
6774
paddingTop: theme.spacing(2),
6875
[theme.breakpoints.up('sm')]: {
@@ -136,7 +143,6 @@ function Demo(props) {
136143
const dispatch = useDispatch();
137144
const t = useSelector(state => state.options.t);
138145
const codeVariant = useSelector(state => state.options.codeVariant);
139-
140146
const demoData = getDemoData(codeVariant, demo, githubLocation);
141147

142148
const [sourceHintSeen, setSourceHintSeen] = React.useState(false);
@@ -244,6 +250,10 @@ function Demo(props) {
244250
[demoOptions.height, demoOptions.maxWidth],
245251
);
246252

253+
if (demoOptions.iframe) {
254+
demoOptions.bg = true;
255+
}
256+
247257
const createHandleCodeSourceLink = anchor => async () => {
248258
try {
249259
await copy(`${window.location.href.split('#')[0]}#${anchor}`);
@@ -269,9 +279,12 @@ function Demo(props) {
269279

270280
const match = useMediaQuery(theme => theme.breakpoints.up('sm'));
271281

272-
const jsx = getJsxPreview(demoData.raw || '', demoOptions.defaultCodeOpen);
282+
const jsx = getJsxPreview(demoData.raw || '');
273283
const showPreview =
274-
!demoOptions.hideHeader && jsx !== demoData.raw && jsx.split(/\n/).length <= 20;
284+
!demoOptions.hideHeader &&
285+
demoOptions.defaultCodeOpen !== false &&
286+
jsx !== demoData.raw &&
287+
jsx.split(/\n/).length <= 15;
275288

276289
let showCodeLabel;
277290
if (codeOpen) {
@@ -285,6 +298,7 @@ function Demo(props) {
285298
<div
286299
className={clsx(classes.demo, {
287300
[classes.demoHiddenHeader]: demoOptions.hideHeader,
301+
[classes.demoBg]: demoOptions.bg,
288302
})}
289303
tabIndex={-1}
290304
onMouseEnter={handleDemoHover}

docs/src/modules/components/DemoSandboxed.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Frame from 'react-frame-component';
88
import DemoErrorBoundary from 'docs/src/modules/components/DemoErrorBoundary';
99

1010
const styles = theme => ({
11-
root: {
11+
frame: {
1212
backgroundColor: theme.palette.background.default,
1313
flexGrow: 1,
1414
height: 400,
@@ -54,7 +54,7 @@ function DemoFrame(props) {
5454
<NoSsr>
5555
<Frame
5656
ref={handleRef}
57-
className={classes.root}
57+
className={classes.frame}
5858
contentDidMount={onContentDidMount}
5959
contentDidUpdate={onContentDidUpdate}
6060
{...other}

docs/src/modules/utils/getJsxPreview.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function getJsxPreview(code, defaultCodeOpen) {
1+
export default function getJsxPreview(code) {
22
/* The regex matches the content of the return statement in the default export,
33
* stripping any wrapper divs:
44
*
@@ -14,7 +14,7 @@ export default function getJsxPreview(code, defaultCodeOpen) {
1414
);
1515
// Just the match, otherwise the full source if either no match or preview disabled,
1616
// so as not to break the Collapse transition.
17-
jsx = jsx && defaultCodeOpen !== false ? jsx[1] : code;
17+
jsx = jsx ? jsx[1] : code;
1818

1919
// Remove leading spaces from each line
2020
return jsx.split(/\n/).reduce(

docs/src/modules/utils/getJsxPreview.test.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,6 @@ export function UseWidth() {
7272
return ( <MyComponent />;
7373
}
7474
75-
`);
76-
});
77-
it('should return all if defaultCodeOpen is false', () => {
78-
expect(
79-
getJsxPreview(
80-
`
81-
export default function UseWidth() {
82-
return <MyComponent />;
83-
}
84-
`,
85-
false,
86-
),
87-
).to.equal(`
88-
export default function UseWidth() {
89-
return <MyComponent />;
90-
}
91-
9275
`);
9376
});
9477
});

docs/src/pages/components/app-bar/app-bar.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,33 @@ It can transform into a contextual action bar or be used as a navbar.
1313

1414
## Simple App Bar
1515

16-
{{"demo": "pages/components/app-bar/ButtonAppBar.js"}}
16+
{{"demo": "pages/components/app-bar/ButtonAppBar.js", "bg": true}}
1717

1818
## App Bar with a primary search field
1919

2020
A primary searchbar.
2121

22-
{{"demo": "pages/components/app-bar/PrimarySearchAppBar.js"}}
22+
{{"demo": "pages/components/app-bar/PrimarySearchAppBar.js", "bg": true}}
2323

2424
## App Bar with menu
2525

26-
{{"demo": "pages/components/app-bar/MenuAppBar.js"}}
26+
{{"demo": "pages/components/app-bar/MenuAppBar.js", "bg": true}}
2727

2828
## App Bar with search field
2929

3030
A side searchbar.
3131

32-
{{"demo": "pages/components/app-bar/SearchAppBar.js"}}
32+
{{"demo": "pages/components/app-bar/SearchAppBar.js", "bg": true}}
3333

3434
## Dense (desktop only)
3535

36-
{{"demo": "pages/components/app-bar/DenseAppBar.js"}}
36+
{{"demo": "pages/components/app-bar/DenseAppBar.js", "bg": true}}
3737

3838
## Prominent
3939

4040
A prominent app bar.
4141

42-
{{"demo": "pages/components/app-bar/ProminentAppBar.js"}}
42+
{{"demo": "pages/components/app-bar/ProminentAppBar.js", "bg": true}}
4343

4444
## Bottom App Bar
4545

docs/src/pages/components/avatars/IconAvatars.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,38 @@ import Avatar from '@material-ui/core/Avatar';
55
import FolderIcon from '@material-ui/icons/Folder';
66
import PageviewIcon from '@material-ui/icons/Pageview';
77
import AssignmentIcon from '@material-ui/icons/Assignment';
8-
import Grid from '@material-ui/core/Grid';
98

10-
const useStyles = makeStyles({
11-
avatar: {
12-
margin: 10,
9+
const useStyles = makeStyles(theme => ({
10+
root: {
11+
display: 'flex',
12+
'& > *': {
13+
margin: theme.spacing(1),
14+
},
1315
},
14-
pinkAvatar: {
15-
margin: 10,
16+
pink: {
1617
color: '#fff',
1718
backgroundColor: pink[500],
1819
},
19-
greenAvatar: {
20-
margin: 10,
20+
green: {
2121
color: '#fff',
2222
backgroundColor: green[500],
2323
},
24-
});
24+
}));
2525

2626
export default function IconAvatars() {
2727
const classes = useStyles();
2828

2929
return (
30-
<Grid container justify="center" alignItems="center">
31-
<Avatar className={classes.avatar}>
30+
<div className={classes.root}>
31+
<Avatar>
3232
<FolderIcon />
3333
</Avatar>
34-
<Avatar className={classes.pinkAvatar}>
34+
<Avatar className={classes.pink}>
3535
<PageviewIcon />
3636
</Avatar>
37-
<Avatar className={classes.greenAvatar}>
37+
<Avatar className={classes.green}>
3838
<AssignmentIcon />
3939
</Avatar>
40-
</Grid>
40+
</div>
4141
);
4242
}
Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
import React from 'react';
2-
import { makeStyles } from '@material-ui/core/styles';
2+
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
33
import { green, pink } from '@material-ui/core/colors';
44
import Avatar from '@material-ui/core/Avatar';
55
import FolderIcon from '@material-ui/icons/Folder';
66
import PageviewIcon from '@material-ui/icons/Pageview';
77
import AssignmentIcon from '@material-ui/icons/Assignment';
8-
import Grid from '@material-ui/core/Grid';
98

10-
const useStyles = makeStyles({
11-
avatar: {
12-
margin: 10,
13-
},
14-
pinkAvatar: {
15-
margin: 10,
16-
color: '#fff',
17-
backgroundColor: pink[500],
18-
},
19-
greenAvatar: {
20-
margin: 10,
21-
color: '#fff',
22-
backgroundColor: green[500],
23-
},
24-
});
9+
const useStyles = makeStyles((theme: Theme) =>
10+
createStyles({
11+
root: {
12+
display: 'flex',
13+
'& > *': {
14+
margin: theme.spacing(1),
15+
},
16+
},
17+
pink: {
18+
color: '#fff',
19+
backgroundColor: pink[500],
20+
},
21+
green: {
22+
color: '#fff',
23+
backgroundColor: green[500],
24+
},
25+
}),
26+
);
2527

2628
export default function IconAvatars() {
2729
const classes = useStyles();
2830

2931
return (
30-
<Grid container justify="center" alignItems="center">
31-
<Avatar className={classes.avatar}>
32+
<div className={classes.root}>
33+
<Avatar>
3234
<FolderIcon />
3335
</Avatar>
34-
<Avatar className={classes.pinkAvatar}>
36+
<Avatar className={classes.pink}>
3537
<PageviewIcon />
3638
</Avatar>
37-
<Avatar className={classes.greenAvatar}>
39+
<Avatar className={classes.green}>
3840
<AssignmentIcon />
3941
</Avatar>
40-
</Grid>
42+
</div>
4143
);
4244
}
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import React from 'react';
22
import { makeStyles } from '@material-ui/core/styles';
33
import Avatar from '@material-ui/core/Avatar';
4-
import Grid from '@material-ui/core/Grid';
54

6-
const useStyles = makeStyles({
7-
avatar: {
8-
margin: 10,
5+
const useStyles = makeStyles(theme => ({
6+
root: {
7+
display: 'flex',
8+
'& > *': {
9+
margin: theme.spacing(1),
10+
},
911
},
1012
bigAvatar: {
11-
margin: 10,
1213
width: 60,
1314
height: 60,
1415
},
15-
});
16+
}));
1617

1718
export default function ImageAvatars() {
1819
const classes = useStyles();
1920

2021
return (
21-
<Grid container justify="center" alignItems="center">
22-
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" className={classes.avatar} />
22+
<div className={classes.root}>
23+
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />
2324
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" className={classes.bigAvatar} />
24-
</Grid>
25+
</div>
2526
);
2627
}
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
import React from 'react';
2-
import { makeStyles } from '@material-ui/core/styles';
2+
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
33
import Avatar from '@material-ui/core/Avatar';
4-
import Grid from '@material-ui/core/Grid';
54

6-
const useStyles = makeStyles({
7-
avatar: {
8-
margin: 10,
9-
},
10-
bigAvatar: {
11-
margin: 10,
12-
width: 60,
13-
height: 60,
14-
},
15-
});
5+
const useStyles = makeStyles((theme: Theme) =>
6+
createStyles({
7+
root: {
8+
display: 'flex',
9+
'& > *': {
10+
margin: theme.spacing(1),
11+
},
12+
},
13+
bigAvatar: {
14+
width: 60,
15+
height: 60,
16+
},
17+
}),
18+
);
1619

1720
export default function ImageAvatars() {
1821
const classes = useStyles();
1922

2023
return (
21-
<Grid container justify="center" alignItems="center">
22-
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" className={classes.avatar} />
24+
<div className={classes.root}>
25+
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />
2326
<Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" className={classes.bigAvatar} />
24-
</Grid>
27+
</div>
2528
);
2629
}

0 commit comments

Comments
 (0)