tldraw/components/code-panel/code-docs.tsx

122 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-06-21 21:35:28 +00:00
import styled from 'styles'
2021-06-27 13:53:06 +00:00
import ReactMarkdown from 'react-markdown'
import docs from './docs-content'
2021-05-14 22:56:41 +00:00
2021-06-21 21:35:28 +00:00
export default function CodeDocs({
isHidden,
}: {
isHidden: boolean
}): JSX.Element {
2021-05-14 22:56:41 +00:00
return (
<StyledDocs isHidden={isHidden}>
2021-06-27 13:53:06 +00:00
<ReactMarkdown>{docs.content}</ReactMarkdown>
2021-05-14 22:56:41 +00:00
</StyledDocs>
)
}
2021-06-21 21:35:28 +00:00
const StyledDocs = styled('div', {
position: 'absolute',
backgroundColor: '$panel',
2021-05-14 22:56:41 +00:00
top: 0,
left: 0,
2021-06-21 21:35:28 +00:00
width: '100%',
height: '100%',
2021-05-14 22:56:41 +00:00
padding: 16,
2021-06-21 21:35:28 +00:00
overflowY: 'scroll',
userSelect: 'none',
2021-05-14 22:56:41 +00:00
paddingBottom: 64,
2021-06-27 13:53:06 +00:00
fontFamily: '$body',
fontWeight: 500,
2021-05-14 22:56:41 +00:00
variants: {
isHidden: {
true: {
2021-06-21 21:35:28 +00:00
visibility: 'hidden',
2021-05-14 22:56:41 +00:00
},
false: {
2021-06-21 21:35:28 +00:00
visibility: 'visible',
2021-05-14 22:56:41 +00:00
},
},
},
2021-06-27 13:53:06 +00:00
'& p': {
fontSize: '$3',
lineHeight: '1.3',
},
'& ol, ul': {
fontSize: '$3',
lineHeight: '1.3',
marginTop: 16,
marginBottom: 16,
},
2021-05-14 22:56:41 +00:00
2021-06-21 21:35:28 +00:00
'& li': {
2021-06-27 13:53:06 +00:00
fontSize: '$3',
lineHeight: '1.5',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& code': {
font: '$mono',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& hr': {
margin: '32px 0',
borderColor: '$muted',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& h2': {
2021-06-27 13:53:06 +00:00
margin: '40px 0px 24px 0',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& h3': {
2021-05-14 22:56:41 +00:00
fontSize: 20,
2021-06-21 21:35:28 +00:00
margin: '48px 0px 32px 0px',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& h3 > code': {
2021-05-14 22:56:41 +00:00
fontWeight: 600,
2021-06-27 13:53:06 +00:00
font: '$mono',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& h4': {
margin: '32px 0px 0px 0px',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& h4 > code': {
2021-06-27 13:53:06 +00:00
font: '$mono',
2021-05-14 22:56:41 +00:00
fontSize: 16,
2021-06-21 21:35:28 +00:00
userSelect: 'all',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& h4 > code > i': {
2021-05-14 22:56:41 +00:00
fontSize: 14,
2021-06-21 21:35:28 +00:00
color: '$muted',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& pre': {
2021-06-27 13:53:06 +00:00
border: '1px solid $brushStroke',
2021-06-27 21:30:37 +00:00
font: '$mono',
2021-06-27 13:53:06 +00:00
fontWeight: 420,
lineHeight: 1.5,
2021-05-14 22:56:41 +00:00
padding: 16,
borderRadius: 4,
2021-06-21 21:35:28 +00:00
userSelect: 'all',
margin: '24px 0',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& p > code, blockquote > code': {
padding: '2px 4px',
2021-05-14 22:56:41 +00:00
borderRadius: 2,
2021-06-27 13:53:06 +00:00
color: '$text',
backgroundColor: '$codeHl',
2021-05-14 22:56:41 +00:00
},
2021-06-21 21:35:28 +00:00
'& blockquote': {
2021-07-10 20:52:52 +00:00
backgroundColor: '$overlay',
2021-05-14 22:56:41 +00:00
padding: 12,
2021-06-21 21:35:28 +00:00
margin: '20px 0',
2021-05-14 22:56:41 +00:00
borderRadius: 8,
},
})