diff --git a/dangerfile.js b/dangerfile.js index 67d0702b1a..5215e66716 100644 --- a/dangerfile.js +++ b/dangerfile.js @@ -35,7 +35,8 @@ const helperTests = fileMatch('lib/**/*.spec.js') const packageJson = fileMatch('package.json') const packageLock = fileMatch('package-lock.json') const capitals = fileMatch('**/*[A-Z]*.js') -const underscores = fileMatch('**/*_*.js') +// _document.js is used by convention by Next. +const underscores = fileMatch('**/*_*.js', '!pages/_document.js') const targetBranch = danger.github.pr.base.ref message( diff --git a/frontend/components/badge-examples.js b/frontend/components/badge-examples.js index 30d8af1c48..48162ab431 100644 --- a/frontend/components/badge-examples.js +++ b/frontend/components/badge-examples.js @@ -1,6 +1,27 @@ import React from 'react' import PropTypes from 'prop-types' +import styled from 'styled-components' import { badgeUrlFromPath, staticBadgeUrl } from '../../lib/make-badge-url' +import { Badge } from './common' +import { StyledCode } from './snippet' + +const ExampleTable = styled.table` + min-width: 50%; + margin: auto; + + th, + td { + text-align: left; + } +` + +const ClickableTh = styled.th` + cursor: pointer; +` + +const ClickableCode = styled(StyledCode)` + cursor: pointer; +` export default class BadgeExamples extends React.Component { static propTypes = { @@ -47,21 +68,12 @@ export default class BadgeExamples extends React.Component { return ( - - {title}: - + {title}: - + - - {exampleUrl} - + {exampleUrl} ) @@ -80,13 +92,11 @@ export default class BadgeExamples extends React.Component { }, []) return ( -
- - - {flattened.map(exampleData => this.renderExample(exampleData))} - -
-
+ + + {flattened.map(exampleData => this.renderExample(exampleData))} + + ) } } diff --git a/frontend/components/category-headings.js b/frontend/components/category-headings.js index f0ffb1552b..77c9bde1d1 100644 --- a/frontend/components/category-headings.js +++ b/frontend/components/category-headings.js @@ -1,13 +1,14 @@ import React from 'react' import PropTypes from 'prop-types' import { Link } from 'react-router-dom' +import { H3 } from './common' const CategoryHeading = ({ category }) => { const { id, name } = category return ( -

{name}

+

{name}

) } diff --git a/frontend/components/category-headings.spec.js b/frontend/components/category-headings.spec.js index 1614635744..1a8a72482d 100644 --- a/frontend/components/category-headings.spec.js +++ b/frontend/components/category-headings.spec.js @@ -2,6 +2,7 @@ import React from 'react' import { shallow } from 'enzyme' import { expect } from 'chai' import { CategoryHeading, CategoryHeadings } from './category-headings' +import { H3 } from './common' import './enzyme-conf.spec' @@ -14,7 +15,7 @@ describe('', function() { it('contains the expected heading', function() { const wrapper = shallow() - expect(wrapper).to.contain(

Example category

) + expect(wrapper).to.contain(

Example category

) }) }) diff --git a/frontend/components/common.js b/frontend/components/common.js new file mode 100644 index 0000000000..bb43ba2354 --- /dev/null +++ b/frontend/components/common.js @@ -0,0 +1,97 @@ +import React from 'react' +import styled, { css } from 'styled-components' + +const nonBreakingSpace = '\u00a0' + +const BaseFont = styled.div` + font-family: Lekton, sans-serif; + color: #534; +` + +const H2 = styled.h2` + font-style: italic; + + margin-top: 12mm; + font-variant: small-caps; + + ::before { + content: '☙ '; + } + + ::after { + content: ' ❧'; + } +` + +const H3 = styled.h3` + font-style: italic; +` + +const BadgeWrapper = styled.span` + padding: 2px; + height: ${({ height }) => height}; + vertical-align: middle; + display: ${({ display }) => display}; + + ${({ clickable }) => + clickable && + css` + cursor: pointer; + `}; +` + +const Badge = ({ + src, + alt = '', + display = 'inline', + height = '20px', + clickable = false, + ...rest +}) => ( + + {src ? {alt} : nonBreakingSpace} + +) + +const StyledInput = styled.input` + height: 15px; + border: solid #b9a; + border-width: 0 0 1px 0; + padding: 0; + + text-align: center; + + color: #534; + + :focus { + outline: 0; + } +` + +const InlineInput = styled(StyledInput)` + width: 70px; + margin-left: 5px; + margin-right: 5px; +` + +const BlockInput = styled(StyledInput)` + width: 40%; + background-color: transparent; +` + +const VerticalSpace = styled.hr` + border: 0; + display: block; + height: 3mm; +` + +export { + nonBreakingSpace, + BaseFont, + H2, + H3, + Badge, + InlineInput, + BlockInput, + VerticalSpace, +} diff --git a/frontend/components/dynamic-badge-maker.js b/frontend/components/dynamic-badge-maker.js index 36ff017c80..3af3bd0a3b 100644 --- a/frontend/components/dynamic-badge-maker.js +++ b/frontend/components/dynamic-badge-maker.js @@ -1,6 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import { dynamicBadgeUrl } from '../lib/badge-url' +import { InlineInput } from './common' export default class DynamicBadgeMaker extends React.Component { static propTypes = { @@ -52,49 +53,42 @@ export default class DynamicBadgeMaker extends React.Component { {' '} - {} - this.setState({ label: event.target.value })} placeholder="label" - />{' '} - {} - + this.setState({ url: event.target.value })} placeholder="url" - />{' '} - {} - + this.setState({ query: event.target.value })} placeholder="query" - />{' '} - {} - + this.setState({ color: event.target.value })} placeholder="color" - />{' '} - {} - + this.setState({ prefix: event.target.value })} placeholder="prefix" - />{' '} - {} - + this.setState({ suffix: event.target.value })} placeholder="suffix" - />{' '} - {} + /> ) diff --git a/frontend/components/footer.js b/frontend/components/footer.js index 51ea2d1328..41f2f54967 100644 --- a/frontend/components/footer.js +++ b/frontend/components/footer.js @@ -1,10 +1,17 @@ import React from 'react' import PropTypes from 'prop-types' +import styled from 'styled-components' import resolveUrl from '../lib/resolve-url' +import { H2 } from './common' + +const SpacedA = styled.a` + margin-left: 10px; + margin-right: 10px; +` const Footer = ({ baseUrl }) => (
-

Like This?

+

Like This?

( and we might bring it to you!

-

- Status - GitHub +

+ Status + GitHub

) diff --git a/frontend/components/footer.spec.js b/frontend/components/footer.spec.js index fba5ff0488..7eebaf3077 100644 --- a/frontend/components/footer.spec.js +++ b/frontend/components/footer.spec.js @@ -1,5 +1,5 @@ import React from 'react' -import { shallow } from 'enzyme' +import { shallow, render } from 'enzyme' import { expect } from 'chai' import Footer from './footer' @@ -11,7 +11,7 @@ describe('