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 (
- {exampleUrl}
-
+ -
+
+
URL
-
Markdown
-
reStructuredText
-
AsciiDoc
-
{colors.map((color, i) => (
{' '}
- {}
+ />
|
- |
-
- {badgeUrl}
- |
-
--
+
+ }
+ rhs={
+
+ - Dash
+
+ }
+ />
+ __
+
+ }
+ rhs={
+
+ _ Underscore
+
+ }
+ />
+ _ or Space
+
+ }
+ rhs={
+
+ Space
+
+ }
+ />
+
-
- {baseUrl}
- /badge/<SUBJECT>-<STATUS>-<COLOR>.svg
-
+
- Dashes --
- |
- → | -
- - Dash
- |
-
- Underscores __
- |
- → | -
- _ Underscore
- |
-
- _ or Space
- |
- → | -
- Space
- |
-
-
+
+
-
+
+
-
+
+
The following styles are available. Flat is the default. Examples are @@ -189,92 +254,101 @@ export default class Usage extends React.PureComponent { Here are a few other parameters you can use: (connecting several with "&" is possible)
-
- ?label=healthinesses
- |
- - Override the default left-hand-side text ( - - URL-Encoding - - {} needed for spaces or special characters!) - | -
- ?logo=appveyor
- |
- - Insert one of the named logos from ( - {this.constructor.renderNamedLogos()}) or{' '} - - simple-icons - - | -
- ?logo=data:image/png;base64,…
- |
- Insert custom logo image (≥ 14px high) | -
- ?logoColor=violet
- |
- - Set the color of the logo (hex, rgb, rgba, hsl, hsla and css - named colors supported) - | -
- ?logoWidth=40
- |
- Set the horizontal space to give to the logo | -
- ?link=http://left&link=http://right
- |
- - Specify what clicking on the left/right of a badge should do - (esp. for social badge style) - | -
- ?colorA=abcdef
- |
- - Set background of the left part (hex, rgb, rgba, hsl, hsla and - css named colors supported) - | -
- ?colorB=fedcba
- |
- - Set background of the right part (hex, rgb, rgba, hsl, hsla and - css named colors supported) - | -
- ?maxAge=3600
- |
- - Set the HTTP cache lifetime in secs (rules are applied to infer - a default value on a per-badge basis, any values specified below - the default will be ignored) - | -
We support .svg, .json, .png{' '}
diff --git a/package-lock.json b/package-lock.json
index 0866b41281..3220c73c4f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1213,6 +1213,27 @@
"lazy-ass": "1.6.0"
}
},
+ "@emotion/is-prop-valid": {
+ "version": "0.6.8",
+ "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.6.8.tgz",
+ "integrity": "sha512-IMSL7ekYhmFlILXcouA6ket3vV7u9BqStlXzbKOF9HBtpUPMMlHU+bBxrLOa2NvleVwNIxeq/zL8LafLbeUXcA==",
+ "dev": true,
+ "requires": {
+ "@emotion/memoize": "^0.6.6"
+ }
+ },
+ "@emotion/memoize": {
+ "version": "0.6.6",
+ "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.6.6.tgz",
+ "integrity": "sha512-h4t4jFjtm1YV7UirAFuSuFGyLa+NNxjdkq6DpFLANNQY5rHueFZHVY+8Cu1HYVP6DrheB0kv4m5xPjo7eKT7yQ==",
+ "dev": true
+ },
+ "@emotion/unitless": {
+ "version": "0.7.3",
+ "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.3.tgz",
+ "integrity": "sha512-4zAPlpDEh2VwXswwr/t8xGNDGg8RQiPxtxZ3qQEXyQsBV39ptTdESCjuBvGze1nLMVrxmTIKmnO/nAV8Tqjjzg==",
+ "dev": true
+ },
"@iamstarkov/listr-update-renderer": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/@iamstarkov/listr-update-renderer/-/listr-update-renderer-0.4.1.tgz",
@@ -1865,6 +1886,17 @@
"integrity": "sha1-Lk57RJa5OmVKHIAEInbeTk7rIOM=",
"dev": true
},
+ "babel-plugin-styled-components": {
+ "version": "1.9.2",
+ "resolved": "https://registry.npmjs.org/babel-plugin-styled-components/-/babel-plugin-styled-components-1.9.2.tgz",
+ "integrity": "sha512-McnheW8RkBkur/mQw7rEwQO/oUUruQ/nIIj5LIRpsVL8pzG1oo1Y53xyvAYeOfamIrl4/ta7g1G/kuTR1ekO3A==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-annotate-as-pure": "^7.0.0",
+ "babel-plugin-syntax-jsx": "^6.18.0",
+ "lodash": "^4.17.10"
+ }
+ },
"babel-plugin-syntax-jsx": {
"version": "6.18.0",
"resolved": "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz",
@@ -3445,6 +3477,12 @@
"randomfill": "^1.0.3"
}
},
+ "css-color-keywords": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz",
+ "integrity": "sha1-/qJhbcZ2spYmhrOvjb2+GAskTgU=",
+ "dev": true
+ },
"css-select": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz",
@@ -3461,6 +3499,17 @@
"resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.0.tgz",
"integrity": "sha1-AQKz0UYw34bD65+p9UVicBBs+ZA="
},
+ "css-to-react-native": {
+ "version": "2.2.2",
+ "resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-2.2.2.tgz",
+ "integrity": "sha512-w99Fzop1FO8XKm0VpbQp3y5mnTnaS+rtCvS+ylSEOK76YXO5zoHQx/QMB1N54Cp+Ya9jB9922EHrh14ld4xmmw==",
+ "dev": true,
+ "requires": {
+ "css-color-keywords": "^1.0.0",
+ "fbjs": "^0.8.5",
+ "postcss-value-parser": "^3.3.0"
+ }
+ },
"css-tree": {
"version": "1.0.0-alpha.28",
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.28.tgz",
@@ -8754,6 +8803,12 @@
"integrity": "sha512-D2JKK2DTuVYQqquBWco3K6UfSVyVwmd58dgNqh+TgxHOZdTmR8I130gjMbVCkemDl/EzqDA62417cJxKL3/FFA==",
"dev": true
},
+ "memoize-one": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-4.0.3.tgz",
+ "integrity": "sha512-QmpUu4KqDmX0plH4u+tf0riMc1KHE1+lw95cMrLlXQAFOx/xnBtwhZ52XJxd9X2O6kwKBqX32kmhbhlobD0cuw==",
+ "dev": true
+ },
"memory-fs": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz",
@@ -12667,6 +12722,12 @@
"integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=",
"dev": true
},
+ "postcss-value-parser": {
+ "version": "3.3.1",
+ "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz",
+ "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==",
+ "dev": true
+ },
"prelude-ls": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
@@ -14948,6 +15009,53 @@
"integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
"dev": true
},
+ "styled-components": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-4.1.2.tgz",
+ "integrity": "sha512-NdvWatJ2WLqZxAvto+oH0k7GAC/TlAUJTrHoXJddjbCrU6U23EmVbb9LXJBF+d6q6hH+g9nQYOWYPUeX/Vlc2w==",
+ "dev": true,
+ "requires": {
+ "@emotion/is-prop-valid": "^0.6.8",
+ "@emotion/unitless": "^0.7.0",
+ "babel-plugin-styled-components": ">= 1",
+ "css-to-react-native": "^2.2.2",
+ "memoize-one": "^4.0.0",
+ "prop-types": "^15.5.4",
+ "react-is": "^16.6.0",
+ "stylis": "^3.5.0",
+ "stylis-rule-sheet": "^0.0.10",
+ "supports-color": "^5.5.0"
+ },
+ "dependencies": {
+ "has-flag": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
+ "dev": true
+ },
+ "stylis": {
+ "version": "3.5.4",
+ "resolved": "https://registry.npmjs.org/stylis/-/stylis-3.5.4.tgz",
+ "integrity": "sha512-8/3pSmthWM7lsPBKv7NXkzn2Uc9W7NotcwGNpJaa3k7WMM1XDCA4MgT5k/8BIexd5ydZdboXtU90XH9Ec4Bv/Q==",
+ "dev": true
+ },
+ "stylis-rule-sheet": {
+ "version": "0.0.10",
+ "resolved": "https://registry.npmjs.org/stylis-rule-sheet/-/stylis-rule-sheet-0.0.10.tgz",
+ "integrity": "sha512-nTbZoaqoBnmK+ptANthb10ZRZOGC+EmTLLUxeYIuHNkEKcmKgXX1XWKkUBT2Ac4es3NybooPe0SmvKdhKJZAuw==",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+ "dev": true,
+ "requires": {
+ "has-flag": "^3.0.0"
+ }
+ }
+ }
+ },
"styled-jsx": {
"version": "2.2.6",
"resolved": "http://registry.npmjs.org/styled-jsx/-/styled-jsx-2.2.6.tgz",
diff --git a/package.json b/package.json
index ac07e42ad8..535c047233 100644
--- a/package.json
+++ b/package.json
@@ -181,6 +181,7 @@
"sinon": "^7.2.2",
"sinon-chai": "^3.3.0",
"snap-shot-it": "^6.2.7",
+ "styled-components": "^4.1.2",
"tmp": "0.0.33",
"url": "^0.11.0"
},
diff --git a/pages/_document.js b/pages/_document.js
new file mode 100644
index 0000000000..d2e1e66bca
--- /dev/null
+++ b/pages/_document.js
@@ -0,0 +1,31 @@
+// https://www.styled-components.com/docs/advanced#nextjs
+
+import Document, { Head, Main, NextScript } from 'next/document'
+import React from 'react'
+import { ServerStyleSheet } from 'styled-components'
+
+export default class MyDocument extends Document {
+ static getInitialProps({ renderPage }) {
+ const sheet = new ServerStyleSheet()
+ const page = renderPage(App => props =>
+ sheet.collectStyles(