diff options
Diffstat (limited to 'packages/dev-tools-pages')
-rw-r--r-- | packages/dev-tools-pages/ts/components/compiler.tsx | 3 | ||||
-rw-r--r-- | packages/dev-tools-pages/ts/components/footer.tsx | 3 | ||||
-rw-r--r-- | packages/dev-tools-pages/ts/components/list.tsx | 3 | ||||
-rw-r--r-- | packages/dev-tools-pages/ts/highlight.tsx | 36 |
4 files changed, 23 insertions, 22 deletions
diff --git a/packages/dev-tools-pages/ts/components/compiler.tsx b/packages/dev-tools-pages/ts/components/compiler.tsx index c535795aa..d576e3b72 100644 --- a/packages/dev-tools-pages/ts/components/compiler.tsx +++ b/packages/dev-tools-pages/ts/components/compiler.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import styled from 'styled-components'; +import * as _ from 'lodash'; import { colors, media } from 'ts/variables'; @@ -75,7 +76,7 @@ const Compiler: React.StatelessComponent<{}> = () => ( <Container> <Breakout> <Cards> - {cards.map(card => ( + {_.map(cards, card => ( <Card key={card.title.split(' ').join('-')}> <Dt>{card.title}</Dt> <Dd>{card.body}</Dd> diff --git a/packages/dev-tools-pages/ts/components/footer.tsx b/packages/dev-tools-pages/ts/components/footer.tsx index 110d21443..4b911ce35 100644 --- a/packages/dev-tools-pages/ts/components/footer.tsx +++ b/packages/dev-tools-pages/ts/components/footer.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import styled from 'styled-components'; +import * as _ from 'lodash'; import { context as compiler } from 'ts/context/compiler'; import { context as cov } from 'ts/context/cov'; @@ -19,7 +20,7 @@ const Footer: React.StatelessComponent<{}> = () => ( <Top> <Alpha>Other tools by 0x</Alpha> <List> - {tools.map(({ title, subtitle, icon }) => ( + {_.map(tools, ({ title, subtitle, icon }) => ( <ListItem key={title}> <ListLink href="#"> <Icon as={icon} /> diff --git a/packages/dev-tools-pages/ts/components/list.tsx b/packages/dev-tools-pages/ts/components/list.tsx index 12d5d67a9..6d4839e88 100644 --- a/packages/dev-tools-pages/ts/components/list.tsx +++ b/packages/dev-tools-pages/ts/components/list.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import styled from 'styled-components'; +import * as _ from 'lodash'; import { media } from 'ts/variables'; @@ -42,7 +43,7 @@ const List: React.StatelessComponent<ListProps> = props => ( <StyledList> {props.children !== undefined ? props.children - : props.items.map((bullet, index) => <StyledItem key={index}>{bullet}</StyledItem>)} + : _.map(props.items, (bullet, index) => <StyledItem key={index}>{bullet}</StyledItem>)} </StyledList> ); diff --git a/packages/dev-tools-pages/ts/highlight.tsx b/packages/dev-tools-pages/ts/highlight.tsx index cef03904a..02f4a753e 100644 --- a/packages/dev-tools-pages/ts/highlight.tsx +++ b/packages/dev-tools-pages/ts/highlight.tsx @@ -1,6 +1,7 @@ import * as hljs from 'highlight.js/lib/highlight'; import * as javascript from 'highlight.js/lib/languages/javascript'; import * as json from 'highlight.js/lib/languages/json'; +import * as _ from 'lodash'; hljs.registerLanguage('javascript', javascript); hljs.registerLanguage('json', json); @@ -16,28 +17,25 @@ const PATCH_TYPES: PatchInterface = { }; function diffHighlight(language: string, code: any, gutter: any): string { - return code - .split(/\r?\n/g) - .map((line: string, index: number) => { - let type; - let currentLine = line; + return _.map(code.split(/\r?\n/g), (line: string, index: number) => { + let type; + let currentLine = line; - if (/^-{3} [^-]+ -{4}$|^\*{3} [^*]+ \*{4}$|^@@ [^@]+ @@$/.test(currentLine)) { - type = 'chunk'; - } else if (/^Index: |^[+\-*]{3}|^[*=]{5,}$/.test(currentLine)) { - type = 'header'; - } else { - type = PATCH_TYPES[currentLine[0]] || 'null'; - currentLine = currentLine.replace(/^[+\-! ]/, ''); - } + if (/^-{3} [^-]+ -{4}$|^\*{3} [^*]+ \*{4}$|^@@ [^@]+ @@$/.test(currentLine)) { + type = 'chunk'; + } else if (/^Index: |^[+\-*]{3}|^[*=]{5,}$/.test(currentLine)) { + type = 'header'; + } else { + type = PATCH_TYPES[currentLine[0]] || 'null'; + currentLine = currentLine.replace(/^[+\-! ]/, ''); + } - const g = gutter[index]; + const g = gutter[index]; - return `<span data-gutter="${g !== undefined ? `${g}x` : ''}" class="line-${type}">${ - hljs.highlight(language, currentLine).value - }</span>`; - }) - .join('\n'); + return `<span data-gutter="${g !== undefined ? `${g}x` : ''}" class="line-${type}">${ + hljs.highlight(language, currentLine).value + }</span>`; + }).join('\n'); } interface HighlightProps { |