feat: add copy code feature
This commit is contained in:
parent
8ad114c5e5
commit
ce013489ec
@ -44,6 +44,7 @@ export interface ContainerProps {
|
|||||||
right?: string;
|
right?: string;
|
||||||
bottom?: string;
|
bottom?: string;
|
||||||
zIndex?: number;
|
zIndex?: number;
|
||||||
|
float?: 'right' | 'left';
|
||||||
Tag?: ContainerTag;
|
Tag?: ContainerTag;
|
||||||
cursor?: string;
|
cursor?: string;
|
||||||
id?: string;
|
id?: string;
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import * as CopyToClipboard from 'react-copy-to-clipboard';
|
||||||
import SyntaxHighlighter from 'react-syntax-highlighter';
|
import SyntaxHighlighter from 'react-syntax-highlighter';
|
||||||
|
|
||||||
|
import { Button } from 'ts/components/ui/button';
|
||||||
|
import { Container } from 'ts/components/ui/container';
|
||||||
|
import { Text } from 'ts/components/ui/text';
|
||||||
import { colors } from 'ts/style/colors';
|
import { colors } from 'ts/style/colors';
|
||||||
import { styled } from 'ts/style/theme';
|
import { styled } from 'ts/style/theme';
|
||||||
|
|
||||||
@ -142,7 +147,16 @@ export interface CodeDemoProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const CodeDemo: React.StatelessComponent<CodeDemoProps> = props => (
|
export const CodeDemo: React.StatelessComponent<CodeDemoProps> = props => (
|
||||||
<SyntaxHighlighter language="html" style={customStyle} showLineNumbers={true} PreTag={CustomPre}>
|
<Container position="relative" height="100%">
|
||||||
{props.children}
|
<Container position="absolute" top="10px" right="10px">
|
||||||
</SyntaxHighlighter>
|
<CopyToClipboard text={props.children}>
|
||||||
|
<Button fontSize="14px">
|
||||||
|
<b>Copy</b>
|
||||||
|
</Button>
|
||||||
|
</CopyToClipboard>
|
||||||
|
</Container>
|
||||||
|
<SyntaxHighlighter language="html" style={customStyle} showLineNumbers={true} PreTag={CustomPre}>
|
||||||
|
{props.children}
|
||||||
|
</SyntaxHighlighter>
|
||||||
|
</Container>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user