|
| 1 | +/** |
| 2 | + * Copyright (c) 2017-present, Facebook, Inc. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +const React = require('react') |
| 9 | + |
| 10 | +const CompLibrary = require('../../core/CompLibrary.js') |
| 11 | + |
| 12 | +const MarkdownBlock = CompLibrary.MarkdownBlock /* Used to read markdown */ |
| 13 | +const Container = CompLibrary.Container |
| 14 | +const GridBlock = CompLibrary.GridBlock |
| 15 | + |
| 16 | +class HomeSplash extends React.Component { |
| 17 | + render() { |
| 18 | + const { siteConfig, language = '' } = this.props |
| 19 | + const { baseUrl, docsUrl } = siteConfig |
| 20 | + const docsPart = `${docsUrl ? `${docsUrl}/` : ''}` |
| 21 | + const langPart = `${language ? `${language}/` : ''}` |
| 22 | + const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}` |
| 23 | + |
| 24 | + const SplashContainer = props => ( |
| 25 | + <div className="homeContainer"> |
| 26 | + <div className="homeSplashFade"> |
| 27 | + <div className="wrapper homeWrapper">{props.children}</div> |
| 28 | + </div> |
| 29 | + </div> |
| 30 | + ) |
| 31 | + |
| 32 | + const Logo = props => ( |
| 33 | + <div className="projectLogo"> |
| 34 | + <img src={props.img_src} alt="Project Logo" /> |
| 35 | + </div> |
| 36 | + ) |
| 37 | + |
| 38 | + const ProjectTitle = () => ( |
| 39 | + <div> |
| 40 | + <h2 className="projectTitle">Puppeteer Testing Library</h2> |
| 41 | + <div className="projectTaglineWrapper"> |
| 42 | + <p className="projectTagline"> |
| 43 | + Simple and complete Puppeteer DOM testing utilities that encourage |
| 44 | + good testing practices |
| 45 | + </p> |
| 46 | + </div> |
| 47 | + </div> |
| 48 | + ) |
| 49 | + |
| 50 | + const PromoSection = props => ( |
| 51 | + <div className="section promoSection"> |
| 52 | + <div className="promoRow"> |
| 53 | + <div className="pluginRowBlock">{props.children}</div> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + ) |
| 57 | + |
| 58 | + const Button = props => ( |
| 59 | + <div className="pluginWrapper buttonWrapper"> |
| 60 | + <a className="button" href={props.href} target={props.target}> |
| 61 | + {props.children} |
| 62 | + </a> |
| 63 | + </div> |
| 64 | + ) |
| 65 | + |
| 66 | + return ( |
| 67 | + <SplashContainer> |
| 68 | + <Logo img_src={`${baseUrl}img/puppeteer-275x275.png`} /> |
| 69 | + <div className="inner"> |
| 70 | + <ProjectTitle siteConfig={siteConfig} /> |
| 71 | + <PromoSection> |
| 72 | + <Button href={docUrl('pptr-testing-library/intro')}> |
| 73 | + Read the Docs |
| 74 | + </Button> |
| 75 | + </PromoSection> |
| 76 | + </div> |
| 77 | + </SplashContainer> |
| 78 | + ) |
| 79 | + } |
| 80 | +} |
| 81 | + |
| 82 | +class Index extends React.Component { |
| 83 | + render() { |
| 84 | + const { config: siteConfig, language = '' } = this.props |
| 85 | + const { baseUrl } = siteConfig |
| 86 | + |
| 87 | + const Block = props => ( |
| 88 | + <Container |
| 89 | + padding={['bottom', 'top']} |
| 90 | + id={props.id} |
| 91 | + background={props.background} |
| 92 | + > |
| 93 | + <GridBlock |
| 94 | + align={props.align || 'center'} |
| 95 | + imageAlign={props.imageAlign || 'center'} |
| 96 | + contents={props.children} |
| 97 | + layout={props.layout} |
| 98 | + /> |
| 99 | + </Container> |
| 100 | + ) |
| 101 | + |
| 102 | + const FeatureCallout = () => ( |
| 103 | + <Container className="" background={'light'} padding={['top', 'bottom']}> |
| 104 | + <div style={{ textAlign: 'center' }}> |
| 105 | + <p> |
| 106 | + <i> |
| 107 | + The more your tests resemble the way your software is used, <br /> |
| 108 | + the more confidence they can give you. |
| 109 | + </i> |
| 110 | + </p> |
| 111 | + <MarkdownBlock> |
| 112 | + `npm install --save-dev pptr-testing-library` |
| 113 | + </MarkdownBlock> |
| 114 | + </div> |
| 115 | + </Container> |
| 116 | + ) |
| 117 | + |
| 118 | + const Features = () => ( |
| 119 | + <React.Fragment> |
| 120 | + <Block layout="threeColumn"> |
| 121 | + {[ |
| 122 | + { |
| 123 | + content: |
| 124 | + 'Tests only break when your app breaks, not implementation details', |
| 125 | + image: `${baseUrl}img/wrench-128x128.png`, |
| 126 | + imageAlign: 'top', |
| 127 | + title: 'Write Maintainable Tests', |
| 128 | + }, |
| 129 | + { |
| 130 | + content: 'Interact with your app the same way as your users', |
| 131 | + image: `${baseUrl}img/check-128x128.png`, |
| 132 | + imageAlign: 'top', |
| 133 | + title: 'Develop with Confidence', |
| 134 | + }, |
| 135 | + { |
| 136 | + content: |
| 137 | + 'Built-in selectors use semantic HTML and ARIA roles to help you write inclusive code', |
| 138 | + image: `${baseUrl}img/tada-128x128.png`, |
| 139 | + imageAlign: 'top', |
| 140 | + title: 'Accessible by Default', |
| 141 | + }, |
| 142 | + ]} |
| 143 | + </Block> |
| 144 | + </React.Fragment> |
| 145 | + ) |
| 146 | + |
| 147 | + return ( |
| 148 | + <div> |
| 149 | + <HomeSplash siteConfig={siteConfig} language={language} /> |
| 150 | + <div className="mainContainer"> |
| 151 | + <FeatureCallout /> |
| 152 | + <Features /> |
| 153 | + </div> |
| 154 | + </div> |
| 155 | + ) |
| 156 | + } |
| 157 | +} |
| 158 | + |
| 159 | +module.exports = Index |
0 commit comments