Skip to content

Commit

Permalink
refactor: rename copy prop to copyable
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jul 8, 2020
1 parent c06efa2 commit 6872ffb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/components/CodeBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const defaultComponents = {
const CodeBlock = ({
children,
components: componentOverrides = {},
copy,
copyable,
live,
highlightedLines,
fileName,
Expand All @@ -30,7 +30,7 @@ const CodeBlock = ({
}) => {
const components = { ...defaultComponents, ...componentOverrides };
const formattedCode = useFormattedCode(children.trim(), formatOptions);
const [copied, copyCode] = useClipboard();
const [copied, copy] = useClipboard();
const [code, setCode] = useState(formattedCode);

useEffect(() => {
Expand Down Expand Up @@ -60,7 +60,7 @@ const CodeBlock = ({
)}
</div>

{(copy || fileName) && (
{(copyable || fileName) && (
<div className={styles.statusBar}>
<div className={styles.fileName}>
{fileName && (
Expand All @@ -73,7 +73,7 @@ const CodeBlock = ({
type="button"
className={styles.copyButton}
variant={Button.VARIANT.PLAIN}
onClick={() => copyCode(code)}
onClick={() => copy(code)}
size={Button.SIZE.SMALL}
>
<FeatherIcon name="copy" className={styles.copyButtonIcon} />
Expand All @@ -92,7 +92,7 @@ CodeBlock.propTypes = {
components: PropTypes.shape({
Preview: PropTypes.elementType,
}),
copy: PropTypes.bool,
copyable: PropTypes.bool,
children: PropTypes.string.isRequired,
formatOptions: PropTypes.object,
highlightedLines: PropTypes.string,
Expand All @@ -104,7 +104,7 @@ CodeBlock.propTypes = {
};

CodeBlock.defaultProps = {
copy: true,
copyable: true,
lineNumbers: false,
live: false,
preview: false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDXContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const components = {
...props
}) => (
<CodeBlock
copy={copy !== 'false'}
copyable={copy !== 'false'}
highlightedLines={lineHighlight}
language={className?.replace('language-', '')}
lineNumbers={lineNumbers === 'true'}
Expand Down

0 comments on commit 6872ffb

Please sign in to comment.