diff --git a/.gitignore b/.gitignore index 0bcb375debcc423dbfb961b4656bb5bdb897524c..1a6cd4d5502db860434233db4dfcdaf6ff1a9a72 100644 --- a/.gitignore +++ b/.gitignore @@ -90,3 +90,4 @@ typings/ /build .next badge-examples.json +supported-features.json diff --git a/frontend/components/markup-modal.js b/frontend/components/markup-modal.js index 7a45d8b7324eb5a30ff67c2e28d8aa5f0c92cdf8..93cca54bbb20c5349453c1fda912f543ca07b9cb 100644 --- a/frontend/components/markup-modal.js +++ b/frontend/components/markup-modal.js @@ -4,7 +4,7 @@ import Modal from 'react-modal'; import ClickToSelect from '@mapbox/react-click-to-select'; import resolveBadgeUrl from '../lib/badge-url'; import generateAllMarkup from '../lib/generate-image-markup'; -import { advertisedStyles } from '../../lib/supported-features'; +import { advertisedStyles } from '../../supported-features.json'; export default class MarkupModal extends React.Component { static propTypes = { diff --git a/frontend/components/usage.js b/frontend/components/usage.js index dd92550222a92839a370d1d7bddf11f0ea03cf02..448fad5755691d7199a76c584884a3e9c89a7aca 100644 --- a/frontend/components/usage.js +++ b/frontend/components/usage.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import StaticBadgeMaker from './static-badge-maker'; import DynamicBadgeMaker from './dynamic-badge-maker'; import { staticBadgeUrl } from '../lib/badge-url'; -import { advertisedStyles } from '../../lib/supported-features'; +import { advertisedStyles, logos } from '../../supported-features.json'; export default class Usage extends React.PureComponent { static propTypes = { @@ -66,7 +66,15 @@ export default class Usage extends React.PureComponent { ); } - render () { + static renderNamedLogos() { + const renderLogo = logo => <span className="nowrap">{logo}</span>; + const [first, ...rest] = logos; + return [renderLogo(first)].concat( + rest.reduce((result, logo) => result.concat([', ', renderLogo(logo)]), []) + ); + } + + render() { const { baseUri } = this.props; return ( <section> @@ -142,7 +150,7 @@ export default class Usage extends React.PureComponent { <p> Here are a few other parameters you can use: (connecting several with "&" is possible) </p> - <table> + <table className="usage"> <tbody> <tr> <td> @@ -161,8 +169,7 @@ export default class Usage extends React.PureComponent { <code>?logo=appveyor</code> </td> <td> - Insert one of the {} - <a href="https://github.com/badges/shields/tree/gh-pages/logo">named logos</a> + Insert one of the named logos ({this.constructor.renderNamedLogos()}) </td> </tr> <tr> diff --git a/lib/export-supported-features-cli.js b/lib/export-supported-features-cli.js new file mode 100644 index 0000000000000000000000000000000000000000..bed3cc0efdcd8c180838504cc110cd3e84e18d39 --- /dev/null +++ b/lib/export-supported-features-cli.js @@ -0,0 +1,19 @@ +'use strict'; + +const path = require('path'); +const glob = require('glob'); + +const supportedFeatures = { + logos: glob + .sync(`${__dirname}/../logo/*.svg`) + .map(filename => path.basename(filename, '.svg')), + advertisedStyles: [ + 'plastic', + 'flat', + 'flat-square', + 'for-the-badge', + 'social', + ], +}; + +console.log(JSON.stringify(supportedFeatures, null, 2)); diff --git a/lib/supported-features.js b/lib/supported-features.js deleted file mode 100644 index 28039e96d512192e85f221edf1909ad9efee24b5..0000000000000000000000000000000000000000 --- a/lib/supported-features.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -const advertisedStyles = [ - 'plastic', - 'flat', - 'flat-square', - 'for-the-badge', - 'social', -]; - -module.exports = { - advertisedStyles -}; diff --git a/package.json b/package.json index 29386be8fbd5b00894e4168e41f0edebd3ca9611..e09cde79115b32802921ce3f37538f09efe5f974 100644 --- a/package.json +++ b/package.json @@ -73,13 +73,14 @@ "depcheck": "check-node-version --node \">= 8.0\"", "postinstall": "npm run depcheck", "prebuild": "npm run depcheck", + "features": "node lib/export-supported-features-cli.js > supported-features.json", "examples": "node lib/export-badge-examples-cli.js > badge-examples.json", - "build": "npm run examples && next build && next export -o build/", + "build": "npm run examples && npm run features && next build && next export -o build/", "heroku-postbuild": "npm run build", "analyze": "ANALYZE=true LONG_CACHE=false BASE_URL=https://img.shields.io npm run build", "start:server": "HANDLE_INTERNAL_ERRORS=false RATE_LIMIT=false node server 8080 ::", "now-start": "node server", - "prestart": "npm run depcheck && npm run examples", + "prestart": "npm run depcheck && npm run examples && npm run features", "start": "concurrently --names server,frontend \"ALLOWED_ORIGIN=http://localhost:3000 npm run start:server\" \"BASE_URL=http://[::]:8080 next dev\"" }, "bin": { diff --git a/static/main.css b/static/main.css index 87d9256e8873a762b423750eadcd974d6e7355a7..0295f0e1a0eb81eec975544e6d365db0b185a9df 100644 --- a/static/main.css +++ b/static/main.css @@ -57,6 +57,23 @@ table.centered > tbody > tr > td:first-child { text-align: right; } +table.usage { + table-layout: fixed; + border-spacing: 20px 10px; +} + +.nowrap { + white-space: nowrap; +} + +table.usage td:first-of-type { + max-width: 300px; +} + +table.usage td:nth-of-type(2) { + max-width: 600px; +} + th, td { text-align: left;