diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-07-22 19:27:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-07-23 08:52:25 +0000 |
commit | 78edec0e2d8a3e1216d99234554276cb05505ac4 (patch) | |
tree | 6f1a3cfda8731ef3a19f5ae57c928054a0c5624f /build | |
parent | Initial commit. (diff) | |
download | bootstrap-icons-78edec0e2d8a3e1216d99234554276cb05505ac4.tar.xz bootstrap-icons-78edec0e2d8a3e1216d99234554276cb05505ac4.zip |
Adding upstream version 1.9.1+dfsg.upstream/1.9.1+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | build/build-pages.js | 62 | ||||
-rw-r--r-- | build/build-svgs.js | 55 | ||||
-rw-r--r-- | build/font/css.hbs | 24 | ||||
-rw-r--r-- | build/font/html.hbs | 53 | ||||
-rw-r--r-- | build/font/scss.hbs | 36 | ||||
-rw-r--r-- | build/vnu-jar.js | 48 |
6 files changed, 278 insertions, 0 deletions
diff --git a/build/build-pages.js b/build/build-pages.js new file mode 100644 index 0000000..911524d --- /dev/null +++ b/build/build-pages.js @@ -0,0 +1,62 @@ +#!/usr/bin/env node + +'use strict' + +const fs = require('fs').promises +const path = require('path') +const picocolors = require('picocolors') + +const iconsDir = path.join(__dirname, '../icons/') +const pagesDir = path.join(__dirname, '../docs/content/icons/') + +const VERBOSE = process.argv.includes('--verbose') + +function capitalizeFirstLetter(string) { + return (string.charAt(0).toUpperCase() + string.slice(1)).split('-').join(' ') +} + +async function main(file) { + const iconBasename = path.basename(file, path.extname(file)) + const iconTitle = capitalizeFirstLetter(iconBasename) + const pageName = path.join(pagesDir, `${iconBasename}.md`) + + const pageTemplate = `--- +title: ${iconTitle} +categories: +tags: +--- +` + + try { + await fs.access(pageName, fs.F_OK) + + if (VERBOSE) { + console.log(`${picocolors.cyan(iconBasename)}: Page already exists; skipping`) + } + } catch { + await fs.writeFile(pageName, pageTemplate) + console.log(picocolors.green(`${iconBasename}: Page created`)) + } +} + +(async () => { + try { + const basename = path.basename(__filename) + const timeLabel = picocolors.cyan(`[${basename}] finished`) + + console.log(picocolors.cyan(`[${basename}] started`)) + console.time(timeLabel) + + const files = await fs.readdir(iconsDir) + + await Promise.all(files.map(file => main(file))) + + const filesLength = files.length + + console.log(picocolors.green('\nSuccess, %s page%s prepared!'), filesLength, filesLength !== 1 ? 's' : '') + console.timeEnd(timeLabel) + } catch (error) { + console.error(error) + process.exit(1) + } +})() diff --git a/build/build-svgs.js b/build/build-svgs.js new file mode 100644 index 0000000..c889ce5 --- /dev/null +++ b/build/build-svgs.js @@ -0,0 +1,55 @@ +#!/usr/bin/env node + +'use strict' + +const fs = require('fs').promises +const path = require('path') +const process = require('process') +const picocolors = require('picocolors') +const { loadConfig, optimize } = require('svgo') + +const iconsDir = path.join(__dirname, '../icons/') + +const VERBOSE = process.argv.includes('--verbose') + +async function processFile(file, config) { + const filepath = path.join(iconsDir, file) + const basename = path.basename(file, '.svg') + + const originalSvg = await fs.readFile(filepath, 'utf8') + const { data: optimizedSvg } = await optimize(originalSvg, { path: filepath, ...config }) + + // svgo will always add a final newline when in pretty mode + const resultSvg = optimizedSvg.trim() + + if (resultSvg !== originalSvg) { + await fs.writeFile(filepath, resultSvg, 'utf8') + } + + if (VERBOSE) { + console.log(`- ${basename}`) + } +} + +(async () => { + try { + const basename = path.basename(__filename) + const timeLabel = picocolors.cyan(`[${basename}] finished`) + + console.log(picocolors.cyan(`[${basename}] started`)) + console.time(timeLabel) + + const files = await fs.readdir(iconsDir) + const config = await loadConfig(path.join(__dirname, '../svgo.config.js')) + + await Promise.all(files.map(file => processFile(file, config))) + + const filesLength = files.length + + console.log(picocolors.green('\nSuccess, prepared %s icon%s!'), filesLength, filesLength !== 1 ? 's' : '') + console.timeEnd(timeLabel) + } catch (error) { + console.error(error) + process.exit(1) + } +})() diff --git a/build/font/css.hbs b/build/font/css.hbs new file mode 100644 index 0000000..f651092 --- /dev/null +++ b/build/font/css.hbs @@ -0,0 +1,24 @@ +@font-face { + font-display: block; + font-family: "{{ name }}"; + src: {{{ fontSrc }}}; +} + +.{{prefix}}::before, +[class^="{{prefix}}-"]::before, +[class*=" {{prefix}}-"]::before { + display: inline-block; + font-family: {{ name }} !important; + font-style: normal; + font-weight: normal !important; + font-variant: normal; + text-transform: none; + line-height: 1; + vertical-align: -.125em; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +{{# each codepoints }} +.{{ ../prefix }}-{{ @key }}::before { content: "\\{{ codepoint this }}"; } +{{/ each }} diff --git a/build/font/html.hbs b/build/font/html.hbs new file mode 100644 index 0000000..0639a3a --- /dev/null +++ b/build/font/html.hbs @@ -0,0 +1,53 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>{{ name }}</title> + + <style> + .icons { + display: grid; + max-width: 100%; + grid-template-columns: repeat(auto-fit, minmax(100px, 1fr) ); + gap: 1.25rem; + } + .icon { + background-color: var(--bs-light); + border-radius: .25rem; + } + .bi { + margin: .25rem; + font-size: 2.5rem; + } + .label { + font-family: var(--bs-font-monospace); + } + .label { + display: inline-block; + width: 100%; + overflow: hidden; + padding: .25rem; + font-size: .625rem; + text-overflow: ellipsis; + white-space: nowrap; + } + </style> + + <link rel="stylesheet" href="/assets/css/bootstrap.min.css"> + <link rel="stylesheet" href="{{ name }}.css"> +</head> +<body class="text-center"> + + <h1>{{ name }}</h1> + + <div class="icons"> + {{# each assets }} + <div class="icon"> + <{{ ../tag }} class="{{ ../prefix }} {{ ../prefix }}-{{ @key }}"></{{ ../tag }}> + <div class="label">{{ @key }}</div> + </div> + {{/ each }} + </div> + +</body> +</html> diff --git a/build/font/scss.hbs b/build/font/scss.hbs new file mode 100644 index 0000000..eb67a50 --- /dev/null +++ b/build/font/scss.hbs @@ -0,0 +1,36 @@ +${{ name }}-font: "{{ name }}" !default; +${{ name }}-font-dir: "{{ fontsUrl }}" !default; +${{ name }}-font-file: #{${{ name }}-font-dir}/#{${{ name }}-font} !default; +${{ name }}-font-hash: "8d200481aa7f02a2d63a331fc782cfaf" !default; +${{ name }}-font-src: url("#{${{ name }}-font-file}.woff2?#{${{ name }}-font-hash}") format("woff2"), url("#{${{ name }}-font-file}.woff?#{${{ name }}-font-hash}") format("woff") !default; + +@font-face { + font-display: block; + font-family: ${{ name }}-font; + src: ${{ name }}-font-src; +} + +.{{prefix}}::before, +[class^="{{prefix}}-"]::before, +[class*=" {{prefix}}-"]::before { + display: inline-block; + font-family: ${{ name }}-font !important; + font-style: normal; + font-weight: normal !important; + font-variant: normal; + text-transform: none; + line-height: 1; + vertical-align: -.125em; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +${{ name }}-map: ( +{{# each codepoints }} + "{{ @key }}": "\\{{ codepoint this }}", +{{/ each }} +); + +{{# each codepoints }} +.{{ ../prefix }}-{{ @key }}::before { content: map-get(${{ ../name }}-map, "{{ @key }}"); } +{{/ each }} diff --git a/build/vnu-jar.js b/build/vnu-jar.js new file mode 100644 index 0000000..6885015 --- /dev/null +++ b/build/vnu-jar.js @@ -0,0 +1,48 @@ +#!/usr/bin/env node + +/*! + * Script to run vnu-jar if Java is available. + * Copyright 2017-2022 The Bootstrap Authors + * Copyright 2017-2022 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ + +'use strict' + +const { execFile, spawn } = require('child_process') +const vnu = require('vnu-jar') + +execFile('java', ['-version'], (error, stdout, stderr) => { + if (error) { + console.error('Skipping vnu-jar test; Java is missing.') + return + } + + const is32bitJava = !/64-Bit/.test(stderr) + + // vnu-jar accepts multiple ignores joined with a `|`. + // Also note that the ignores are string regular expressions. + const ignores = [ + ].join('|') + + const args = [ + '-jar', + `"${vnu}"`, + '--asciiquotes', + '--skip-non-html', + '--Werror', + `--filterpattern "${ignores}"`, + '_site/' + ] + + // For the 32-bit Java we need to pass `-Xss512k` + if (is32bitJava) { + args.splice(0, 0, '-Xss512k') + } + + return spawn('java', args, { + shell: true, + stdio: 'inherit' + }) + .on('exit', process.exit) +}) |