From b158a6d7226fb50ecedcc07da8ef30e5e5690e46 Mon Sep 17 00:00:00 2001 From: August Skare Date: Thu, 18 Oct 2018 13:28:44 +0200 Subject: initial commit --- packages/dev-tools-pages/ts/components/Button.tsx | 26 +++++ packages/dev-tools-pages/ts/components/Code.tsx | 114 +++++++++++++++++++++ .../dev-tools-pages/ts/components/Container.tsx | 9 ++ .../dev-tools-pages/ts/components/ContentBlock.tsx | 47 +++++++++ packages/dev-tools-pages/ts/components/Footer.tsx | 91 ++++++++++++++++ packages/dev-tools-pages/ts/components/Header.tsx | 59 +++++++++++ packages/dev-tools-pages/ts/components/Hero.tsx | 37 +++++++ .../dev-tools-pages/ts/components/InlineCode.tsx | 8 ++ packages/dev-tools-pages/ts/components/List.tsx | 33 ++++++ packages/dev-tools-pages/ts/components/Main.tsx | 33 ++++++ .../dev-tools-pages/ts/components/MetaTags.tsx | 28 +++++ packages/dev-tools-pages/ts/components/Tabs.tsx | 79 ++++++++++++++ .../dev-tools-pages/ts/components/Typography.tsx | 17 +++ .../dev-tools-pages/ts/components/meta_tags.tsx | 25 ----- .../dev-tools-pages/ts/components/ui/button.tsx | 59 ----------- .../dev-tools-pages/ts/components/ui/container.tsx | 55 ---------- packages/dev-tools-pages/ts/components/ui/text.tsx | 74 ------------- .../dev-tools-pages/ts/components/withContext.tsx | 23 +++++ packages/dev-tools-pages/ts/context/compiler.tsx | 14 +++ packages/dev-tools-pages/ts/context/cov.tsx | 14 +++ packages/dev-tools-pages/ts/context/index.tsx | 5 + packages/dev-tools-pages/ts/context/profiler.tsx | 14 +++ packages/dev-tools-pages/ts/context/trace.tsx | 14 +++ packages/dev-tools-pages/ts/globalStyles.tsx | 76 ++++++++++++++ packages/dev-tools-pages/ts/globals.d.ts | 10 ++ packages/dev-tools-pages/ts/icons/logos/0x.svg | 1 + .../dev-tools-pages/ts/icons/logos/compiler.svg | 3 + packages/dev-tools-pages/ts/icons/logos/cov.svg | 3 + .../dev-tools-pages/ts/icons/logos/profiler.svg | 3 + packages/dev-tools-pages/ts/icons/logos/trace.svg | 1 + packages/dev-tools-pages/ts/index.tsx | 42 ++++++-- packages/dev-tools-pages/ts/pages/Base.tsx | 28 +++++ packages/dev-tools-pages/ts/pages/Compiler.tsx | 53 ++++++++++ packages/dev-tools-pages/ts/pages/Cov.tsx | 53 ++++++++++ packages/dev-tools-pages/ts/pages/Profiler.tsx | 53 ++++++++++ packages/dev-tools-pages/ts/pages/Trace.tsx | 53 ++++++++++ packages/dev-tools-pages/ts/pages/landing.tsx | 27 ----- packages/dev-tools-pages/ts/utils/utils.ts | 32 ------ 38 files changed, 1033 insertions(+), 283 deletions(-) create mode 100644 packages/dev-tools-pages/ts/components/Button.tsx create mode 100644 packages/dev-tools-pages/ts/components/Code.tsx create mode 100644 packages/dev-tools-pages/ts/components/Container.tsx create mode 100644 packages/dev-tools-pages/ts/components/ContentBlock.tsx create mode 100644 packages/dev-tools-pages/ts/components/Footer.tsx create mode 100644 packages/dev-tools-pages/ts/components/Header.tsx create mode 100644 packages/dev-tools-pages/ts/components/Hero.tsx create mode 100644 packages/dev-tools-pages/ts/components/InlineCode.tsx create mode 100644 packages/dev-tools-pages/ts/components/List.tsx create mode 100644 packages/dev-tools-pages/ts/components/Main.tsx create mode 100644 packages/dev-tools-pages/ts/components/MetaTags.tsx create mode 100644 packages/dev-tools-pages/ts/components/Tabs.tsx create mode 100644 packages/dev-tools-pages/ts/components/Typography.tsx delete mode 100644 packages/dev-tools-pages/ts/components/meta_tags.tsx delete mode 100644 packages/dev-tools-pages/ts/components/ui/button.tsx delete mode 100644 packages/dev-tools-pages/ts/components/ui/container.tsx delete mode 100644 packages/dev-tools-pages/ts/components/ui/text.tsx create mode 100644 packages/dev-tools-pages/ts/components/withContext.tsx create mode 100644 packages/dev-tools-pages/ts/context/compiler.tsx create mode 100644 packages/dev-tools-pages/ts/context/cov.tsx create mode 100644 packages/dev-tools-pages/ts/context/index.tsx create mode 100644 packages/dev-tools-pages/ts/context/profiler.tsx create mode 100644 packages/dev-tools-pages/ts/context/trace.tsx create mode 100644 packages/dev-tools-pages/ts/globalStyles.tsx create mode 100644 packages/dev-tools-pages/ts/icons/logos/0x.svg create mode 100644 packages/dev-tools-pages/ts/icons/logos/compiler.svg create mode 100644 packages/dev-tools-pages/ts/icons/logos/cov.svg create mode 100644 packages/dev-tools-pages/ts/icons/logos/profiler.svg create mode 100644 packages/dev-tools-pages/ts/icons/logos/trace.svg create mode 100644 packages/dev-tools-pages/ts/pages/Base.tsx create mode 100644 packages/dev-tools-pages/ts/pages/Compiler.tsx create mode 100644 packages/dev-tools-pages/ts/pages/Cov.tsx create mode 100644 packages/dev-tools-pages/ts/pages/Profiler.tsx create mode 100644 packages/dev-tools-pages/ts/pages/Trace.tsx delete mode 100644 packages/dev-tools-pages/ts/pages/landing.tsx delete mode 100644 packages/dev-tools-pages/ts/utils/utils.ts (limited to 'packages/dev-tools-pages/ts') diff --git a/packages/dev-tools-pages/ts/components/Button.tsx b/packages/dev-tools-pages/ts/components/Button.tsx new file mode 100644 index 000000000..e676961c8 --- /dev/null +++ b/packages/dev-tools-pages/ts/components/Button.tsx @@ -0,0 +1,26 @@ +import styled from 'styled-components'; + +import { withContext, Props } from './withContext'; + +interface ButtonProps extends Props { + large?: boolean; +} + +const Button = + styled.button < + ButtonProps > + ` + font-family: inherit; + font-size: ${props => (props.large ? '1.125rem' : '.875rem')}; + font-weight: 500; + white-space: nowrap; + vertical-align: middle; + background-color: ${props => props.colors.secondary}; + color: #000; + border: 0; + border-radius: 5rem; + padding: ${props => (props.large ? '1.125rem 2.375rem' : '.5625rem 1.25rem')}; + display: inline-block; +`; + +export default withContext(Button); diff --git a/packages/dev-tools-pages/ts/components/Code.tsx b/packages/dev-tools-pages/ts/components/Code.tsx new file mode 100644 index 000000000..42d4234f1 --- /dev/null +++ b/packages/dev-tools-pages/ts/components/Code.tsx @@ -0,0 +1,114 @@ +import * as React from 'react'; +import styled from 'styled-components'; + +import BaseButton from './Button'; + +interface CodeProps { + children: React.ReactNode; + language?: string; +} + +interface CodeState { + hlCode?: string; + copied?: boolean; +} + +const Button = styled(BaseButton)` + opacity: 0; + position: absolute; + top: 1rem; + right: 1rem; + transition: opacity 0.2s; +`; + +const Base = + styled.div < + CodeProps > + ` + color: ${props => (props.language === undefined ? '#FFF' : 'inherit')}; + background-color: ${props => (props.language === undefined ? '#000' : '#F1F4F5')}; + white-space: ${props => (props.language === undefined ? 'nowrap' : '')}; + position: relative; + &:hover ${Button} { + opacity: 1; + } +`; + +const StyledCode = styled.code` + padding: 1.5rem; + display: block; + overflow-y: scroll; + -webkit-overflow-scrolling: touch; +`; + +const StyledPre = styled.pre` + margin: 0; +`; + +const StyledCopyInput = styled.textarea` + height: 0; + position: absolute; + top: 0; + right: 0; + z-index: -1; +`; + +const CopyInput = StyledCopyInput as any; + +class Code extends React.Component { + code = React.createRef(); + + state: CodeState = {}; + + constructor(props: CodeProps) { + super(props); + } + + async componentDidMount() { + const { language, children } = this.props; + + if (language !== undefined) { + const { highlight } = await import(/* webpackChunkName: 'highlight.js' */ 'highlight.js'); + const { value: hlCode } = highlight(language, children as string); + this.setState({ hlCode }); + } + } + + handleCopy = async () => { + try { + if ('clipboard' in navigator) { + await (navigator as any).clipboard.writeText(this.props.children); + this.setState({ copied: true }); + } else { + this.code.current.focus(); + this.code.current.select(); + document.execCommand('copy'); + this.setState({ copied: true }); + } + } catch (error) { + this.setState({ copied: false }); + } + }; + + render() { + const { language, children } = this.props; + + return ( + + + {this.state.hlCode !== undefined ? ( + + ) : ( + {this.props.children} + )} + + + {!('clipboard' in navigator) ? ( +