-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(mixed): improve perf & bundle size, fix issue with /layouts
- Loading branch information
1 parent
bcc1d06
commit 36d5513
Showing
14 changed files
with
158 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,12 @@ | ||
import { CodeSnippet as StardustCodeSnippet } from '@stardust-ui/docs-components' | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
import CodeEditor, { EDITOR_BACKGROUND_COLOR } from 'docs/src/components/CodeEditor' | ||
import formatCode from 'docs/src/utils/formatCode' | ||
import NoSSR from '../NoSSR' | ||
|
||
const containerStyle = { | ||
padding: '1rem', | ||
position: 'relative', | ||
background: EDITOR_BACKGROUND_COLOR, | ||
} | ||
|
||
const labelStyle = { | ||
border: '1px solid #566', | ||
color: '#899', | ||
fontFamily: 'monospace', | ||
fontSize: '0.8rem', | ||
lineHeight: 1, | ||
padding: '0.2rem 0.35rem', | ||
position: 'absolute', | ||
right: '1rem', | ||
top: '1rem', | ||
zIndex: 100, | ||
} | ||
|
||
const formatters = { | ||
html: (val) => formatCode(val, 'html'), | ||
json: (val) => val, | ||
jsx: (val) => formatCode(val, 'babel').replace(/^;</m, '<'), // will replace ";" from the beginning of line | ||
sh: (val) => val.replace(/^/g, '$ '), | ||
} | ||
|
||
const CodeSnippet = ({ fitted, label, mode, value, ...rest }) => ( | ||
<div style={{ ...containerStyle, margin: fitted ? 0 : '1rem 0' }}> | ||
{label === false ? null : <div style={labelStyle}>{label || mode}</div>} | ||
|
||
<CodeEditor | ||
highlightActiveLine={false} | ||
highlightGutterLine={false} | ||
mode={mode} | ||
readOnly | ||
showGutter={false} | ||
showCursor={false} | ||
value={formatters[mode](value).trim()} | ||
{...rest} | ||
/> | ||
</div> | ||
const CodeSnippet = (props) => ( | ||
<NoSSR> | ||
<StardustCodeSnippet {...props} /> | ||
</NoSSR> | ||
) | ||
|
||
CodeSnippet.propTypes = { | ||
fitted: PropTypes.bool, | ||
label: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]), | ||
mode: PropTypes.oneOf(['html', 'json', 'jsx', 'sh']), | ||
value: PropTypes.string.isRequired, | ||
} | ||
|
||
CodeSnippet.defaultProps = { | ||
mode: 'jsx', | ||
} | ||
|
||
export default CodeSnippet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,12 @@ const Document = ({ Body, children, Head, Html, siteData: { dev, versions } }) = | |
rel='stylesheet' | ||
href={`https://cdn.jsdelivr.net/npm/semantic-ui@${versions.sui}/dist/semantic.min.css`} | ||
/> | ||
<link | ||
rel='stylesheet' | ||
href={`https://cdn.jsdelivr.net/npm/prismjs@${ | ||
versions.prismjs | ||
}/themes/prism-tomorrow.min.css`} | ||
/> | ||
|
||
<script src='https://cdn.jsdelivr.net/npm/@babel/[email protected]/dist/polyfill.min.js' /> | ||
<script | ||
|
@@ -34,15 +40,13 @@ const Document = ({ Body, children, Head, Html, siteData: { dev, versions } }) = | |
|
||
<script | ||
crossOrigin='true' | ||
src={`https://unpkg.com/prettier@${versions.prettier}/standalone.js`} | ||
/> | ||
<script | ||
crossOrigin='true' | ||
src={`https://unpkg.com/prettier@${versions.prettier}/parser-babylon.js`} | ||
src={`https://cdn.jsdelivr.net/npm/prettier@${versions.prettier}/standalone.min.js`} | ||
/> | ||
<script | ||
crossOrigin='true' | ||
src={`https://unpkg.com/prettier@${versions.prettier}/parser-html.js`} | ||
src={`https://cdn.jsdelivr.net/combine/npm/prettier@${ | ||
versions.prettier | ||
}/parser-babylon.min.js,npm/prettier@${versions.prettier}/parser-html.min.js`} | ||
/> | ||
<script | ||
src={`https://cdnjs.cloudflare.com/ajax/libs/prop-types/${versions.propTypes}/prop-types${ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.