use lodash isUndefined function

This commit is contained in:
August Skare 2018-11-20 15:10:59 +01:00
parent 117726c6d8
commit ea18050589
2 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import * as _ from 'lodash';
import { colors } from 'ts/variables'; import { colors } from 'ts/variables';
@ -49,10 +50,10 @@ const Base =
CodeProps > CodeProps >
` `
font-size: .875rem; font-size: .875rem;
color: ${props => (props.language === undefined ? colors.white : 'inherit')}; color: ${props => (_.isUndefined(props.language) ? colors.white : 'inherit')};
background-color: ${props => background-color: ${props =>
props.isLight ? 'rgba(255,255,255,.15)' : props.language === undefined ? colors.black : '#F1F4F5'}; props.isLight ? 'rgba(255,255,255,.15)' : _.isUndefined(props.language) ? colors.black : '#F1F4F5'};
white-space: ${props => (props.language === undefined ? 'nowrap' : '')}; white-space: ${props => (_.isUndefined(props.language) ? 'nowrap' : '')};
position: relative; position: relative;
${props => ${props =>
@ -149,7 +150,7 @@ class Code extends React.Component<CodeProps, CodeState> {
<Container> <Container>
<Base language={language} isDiff={isDiff} isLight={isLight}> <Base language={language} isDiff={isDiff} isLight={isLight}>
<StyledPre isDiff={isDiff}> <StyledPre isDiff={isDiff}>
{hlCode === undefined ? ( {_.isUndefined(hlCode) ? (
<code>{children}</code> <code>{children}</code>
) : ( ) : (
<StyledCodeDiff <StyledCodeDiff

View File

@ -1,5 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import * as _ from 'lodash';
import { ContextInterface } from 'ts/context'; import { ContextInterface } from 'ts/context';
import { media } from 'ts/variables'; import { media } from 'ts/variables';
@ -69,7 +70,7 @@ const ContentBlock: React.StatelessComponent<ContentBlockProps> = props => {
return ( return (
<Base> <Base>
<Title color={props.colors}>{props.title}</Title> <Title color={props.colors}>{props.title}</Title>
{children === undefined ? null : <Content>{children}</Content>} {_.isUndefined(children) ? null : <Content>{children}</Content>}
</Base> </Base>
); );
}; };