optional copy button in code component
This commit is contained in:
@@ -17,6 +17,7 @@ interface CodeProps {
|
|||||||
diff?: boolean;
|
diff?: boolean;
|
||||||
gutter?: Array<number>;
|
gutter?: Array<number>;
|
||||||
gutterLength?: number;
|
gutterLength?: number;
|
||||||
|
copy?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CodeState {
|
interface CodeState {
|
||||||
@@ -163,7 +164,7 @@ class Code extends React.Component<CodeProps, CodeState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { language, light, diff, children, gutterLength } = this.props;
|
const { language, light, diff, children, gutterLength, copy } = this.props;
|
||||||
const { hlCode } = this.state;
|
const { hlCode } = this.state;
|
||||||
|
|
||||||
let Code = 'code';
|
let Code = 'code';
|
||||||
@@ -185,7 +186,9 @@ class Code extends React.Component<CodeProps, CodeState> {
|
|||||||
<CopyInput readOnly aria-hidden="true" ref={this.code} value={children} />
|
<CopyInput readOnly aria-hidden="true" ref={this.code} value={children} />
|
||||||
) : null}
|
) : null}
|
||||||
</Base>
|
</Base>
|
||||||
{navigator.userAgent !== 'ReactSnap' ? <Button onClick={this.handleCopy}>{this.state.copied ? 'Copied' : 'Copy'}</Button> : null}
|
{navigator.userAgent !== 'ReactSnap' && copy ? (
|
||||||
|
<Button onClick={this.handleCopy}>{this.state.copied ? 'Copied' : 'Copy'}</Button>
|
||||||
|
) : null}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function Compiler() {
|
|||||||
<ContentBlock main title="Get started" />
|
<ContentBlock main title="Get started" />
|
||||||
<ContentBlock title="Install">
|
<ContentBlock title="Install">
|
||||||
<Breakout>
|
<Breakout>
|
||||||
<Code>npm install @0x/sol-compiler --g</Code>
|
<Code copy>npm install @0x/sol-compiler --g</Code>
|
||||||
</Breakout>
|
</Breakout>
|
||||||
</ContentBlock>
|
</ContentBlock>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user