diff options
author | August Skare <post@augustskare.no> | 2018-10-26 15:33:30 +0800 |
---|---|---|
committer | August Skare <post@augustskare.no> | 2018-10-26 15:33:30 +0800 |
commit | 0f97771d5ae728b10afd532bcb75a93ab66775e8 (patch) | |
tree | e5a8db5400e06dc9b5a76509806d0741921ec3ff /packages | |
parent | 74f05153704d4a9cff355fd8b322b98a1805638c (diff) | |
download | dexon-0x-contracts-0f97771d5ae728b10afd532bcb75a93ab66775e8.tar dexon-0x-contracts-0f97771d5ae728b10afd532bcb75a93ab66775e8.tar.gz dexon-0x-contracts-0f97771d5ae728b10afd532bcb75a93ab66775e8.tar.bz2 dexon-0x-contracts-0f97771d5ae728b10afd532bcb75a93ab66775e8.tar.lz dexon-0x-contracts-0f97771d5ae728b10afd532bcb75a93ab66775e8.tar.xz dexon-0x-contracts-0f97771d5ae728b10afd532bcb75a93ab66775e8.tar.zst dexon-0x-contracts-0f97771d5ae728b10afd532bcb75a93ab66775e8.zip |
fix props drilling to far down
Diffstat (limited to 'packages')
-rw-r--r-- | packages/dev-tools-pages/ts/components/Code.tsx | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/packages/dev-tools-pages/ts/components/Code.tsx b/packages/dev-tools-pages/ts/components/Code.tsx index 753965568..e9a503f0b 100644 --- a/packages/dev-tools-pages/ts/components/Code.tsx +++ b/packages/dev-tools-pages/ts/components/Code.tsx @@ -63,13 +63,10 @@ const Base = -webkit-overflow-scrolling: touch; `; -const StyledCodeDiff = - styled.code < - any > - ` +const StyledCodeDiff = styled(({ gutterLength, children, ...props }: any) => <code {...props}>{children}</code>)` ::before { content: ''; - width: calc(.75rem + ${props => props.gutterLength}ch); + width: calc(0.75rem + ${props => props.gutterLength}ch); background-color: #e2e5e6; position: absolute; top: 0; @@ -87,8 +84,8 @@ const StyledCodeDiff = content: attr(data-test); font-size: 0.875rem; width: ${props => props.gutterLength}; - padding-left: .375rem; - padding-right: .375rem; + padding-left: 0.375rem; + padding-right: 0.375rem; position: absolute; top: 50%; left: 0; @@ -162,16 +159,18 @@ class Code extends React.Component<CodeProps, CodeState> { const { language, light, diff, children, gutterLength } = this.props; const { hlCode } = this.state; - const Code = diff ? StyledCodeDiff : 'code'; + let Code = 'code'; + let codeProps = {}; + if (diff) { + codeProps = { gutterLength }; + Code = StyledCodeDiff as any; + } return ( <Container> <Base language={language} diff={diff} light={light}> <StyledPre> - <Code - gutterLength={gutterLength} - dangerouslySetInnerHTML={hlCode ? { __html: this.state.hlCode } : null} - > + <Code {...codeProps} dangerouslySetInnerHTML={hlCode ? { __html: this.state.hlCode } : null}> {hlCode === undefined ? children : null} </Code> </StyledPre> |