Skip to content

Commit a8242dc

Browse files
authored
Merge pull request #1217 from kp0zhiqian/improve-doc-site-styles
Improve the styles of the doc site
2 parents 7b4f556 + 0ebf47c commit a8242dc

File tree

5 files changed

+72
-32
lines changed

5 files changed

+72
-32
lines changed

packages/react-renderer-demo/src/components/code-editor/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ const StyledPre = styled('pre')({
1212
maxWidth: '100vw',
1313
textAlign: 'left',
1414
margin: '1em 0',
15-
padding: '0.5em',
15+
padding: '1em',
1616
overflow: 'auto',
17+
borderRadius: 4,
18+
fontFamily: 'ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace',
1719
'& .token-line': {
18-
lineHeight: '1.3em',
19-
height: '1.3em',
20+
lineHeight: '1.5em',
21+
height: '1.5em',
2022
},
2123
},
2224
});

packages/react-renderer-demo/src/components/code-example.js

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import Typography from '@mui/material/Typography';
66
import Link from '@mui/material/Link';
77
import Box from '@mui/material/Box';
88
import CodeIcon from '@mui/icons-material/Code';
9+
import CodeOffIcon from '@mui/icons-material/CodeOff';
910
import Accordion from '@mui/material/Accordion';
10-
import AccordionSummary from '@mui/material/AccordionSummary';
11+
import MuiAccordionSummary from '@mui/material/AccordionSummary';
1112
import PropTypes from 'prop-types';
1213
import AccordionDetails from '@mui/material/AccordionDetails';
1314
import Paper from '@mui/material/Paper';
@@ -159,7 +160,32 @@ const getPayload = (code, sourceFiles = {}) =>
159160
},
160161
},
161162
});
162-
163+
const AccordionSummary = styled((props) => {
164+
const [codeExpand, setCodeExpand] = useState(false);
165+
return (
166+
<MuiAccordionSummary
167+
sx={{
168+
pointerEvents: 'none',
169+
}}
170+
expandIcon={
171+
<Tooltip title="Expand code example">
172+
<IconButton size="small" display="flex" sx={{ pointerEvents: 'auto' }} onClick={() => setCodeExpand(!codeExpand)}>
173+
{codeExpand ? <CodeOffIcon /> : <CodeIcon />}
174+
</IconButton>
175+
</Tooltip>
176+
}
177+
{...props}
178+
/>
179+
);
180+
})(({ theme }) => ({
181+
flexDirection: 'row',
182+
'& .MuiAccordionSummary-expandIconWrapper.Mui-expanded': {
183+
transform: 'none',
184+
},
185+
'& .MuiAccordionSummary-content': {
186+
flexDirection: 'row-reverse',
187+
},
188+
}));
163189
const CodeExample = ({ source, mode }) => {
164190
const [name, setName] = useState('');
165191
const [codeSource, setCodeSource] = useState('');
@@ -182,28 +208,32 @@ const CodeExample = ({ source, mode }) => {
182208
if (mode === 'preview') {
183209
return (
184210
<ExampleRoot container spacing={0} className={clsx('DocRawComponent', 'container')}>
211+
{Component && (
212+
<Heading component="h3" level="5">
213+
{name}
214+
</Heading>
215+
)}
216+
{Component && (
217+
<Grid className={'formContainer'} item xs={12}>
218+
<Paper className={'componentPanel'}>
219+
<Component />
220+
</Paper>
221+
</Grid>
222+
)}
185223
<Grid item xs={12}>
186224
<Accordion className={'accordion'}>
187-
<AccordionSummary
188-
className={'accordionSummary'}
189-
expandIcon={
190-
<Tooltip title="Expand code example">
191-
<IconButton size="large">
192-
<CodeIcon />
193-
</IconButton>
194-
</Tooltip>
195-
}
196-
>
197-
{Component && (
198-
<Heading component="h3" level="5">
199-
{name}
200-
</Heading>
201-
)}
225+
<AccordionSummary className={'accordionSummary'}>
202226
<Box display="flex">
203227
<form action="https://codesandbox.io/api/v1/sandboxes/define" method="POST" target="_blank">
204228
<input type="hidden" name="parameters" value={getPayload(codeSource, sourceFiles)} />
205229
<Tooltip title="Edit in codesandbox">
206-
<IconButton disableFocusRipple type="submit" onClick={(event) => event.stopPropagation()} size="large">
230+
<IconButton
231+
disableFocusRipple
232+
type="submit"
233+
sx={{ pointerEvents: 'auto' }}
234+
onClick={(event) => event.stopPropagation()}
235+
size="small"
236+
>
207237
<CodesandboxIcon />
208238
</IconButton>
209239
</Tooltip>
@@ -215,7 +245,7 @@ const CodeExample = ({ source, mode }) => {
215245
onClick={(event) => event.stopPropagation()}
216246
>
217247
<Tooltip title="View source on github">
218-
<IconButton size="large">
248+
<IconButton sx={{ pointerEvents: 'auto' }} size="small">
219249
<GhIcon style={{ color: grey[700] }} />
220250
</IconButton>
221251
</Tooltip>
@@ -227,13 +257,6 @@ const CodeExample = ({ source, mode }) => {
227257
</AccordionDetails>
228258
</Accordion>
229259
</Grid>
230-
{Component && (
231-
<Grid className={'formContainer'} item xs={12}>
232-
<Paper className={'componentPanel'}>
233-
<Component />
234-
</Paper>
235-
</Grid>
236-
)}
237260
</ExampleRoot>
238261
);
239262
}

packages/react-renderer-demo/src/components/landing-page/landing-page-cards.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,15 @@ const Root = styled(Grid)(({ theme }) => ({
178178
color: '#F28D63',
179179
},
180180
'& .editorWrapper': {
181-
background: '#1d1f21',
181+
background: '#1D1F21',
182182
padding: 16,
183+
borderRadius: 4,
183184
},
184185
'& .formState': {
185-
marginTop: 16,
186+
marginTop: 7,
186187
padding: 16,
187188
marginBottom: 16,
189+
borderRadius: 4,
188190
},
189191
'& .textBottom': {
190192
marginBottom: 16,

packages/react-renderer-demo/src/components/mdx/mdx-components.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import TableBody from '@mui/material/TableBody';
1111
import TableCell from '@mui/material/TableCell';
1212
import TableHead from '@mui/material/TableHead';
1313
import TableRow from '@mui/material/TableRow';
14+
import Divider from '@mui/material/Divider';
1415
import Paper from '@mui/material/Paper';
1516
import { headerToId } from '../../helpers/list-of-contents';
1617
import ShareButton from './share-button';
@@ -135,6 +136,15 @@ const MdLink = ({ href, children }) =>
135136
</StyledLink>
136137
);
137138

139+
const StyledDivider = styled(Divider)(() => ({
140+
'&.divider': {
141+
marginTop: 20,
142+
marginBottom: 15,
143+
},
144+
}));
145+
146+
const MdDivider = (props) => <StyledDivider {...props} variant="middle" className={'divider'} />;
147+
138148
const MdxComponents = {
139149
p: ({ children }) => (
140150
<Typography variant="body1" gutterBottom>
@@ -169,6 +179,7 @@ const MdxComponents = {
169179
inlineCode: ({ children }) => (
170180
<Root style={{ background: 'white', borderRadius: 3, fontFamily: 'courier, monospace', padding: '3px' }}>{children}</Root>
171181
),
182+
hr: MdDivider,
172183
};
173184

174185
export default MdxComponents;

packages/react-renderer-demo/src/pages/releases.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { Heading } from '../components/mdx/mdx-components';
66
import mdxComponents from '@docs/components/mdx/mdx-components';
77

88
const options = {
9-
overrides: { a: mdxComponents.link },
9+
overrides: {
10+
a: mdxComponents.link,
11+
},
1012
};
1113

1214
const parseData = (data) =>

0 commit comments

Comments
 (0)