diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 53f97333f..54ba671d2 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -37,6 +37,7 @@ jobs:
with:
node-version: "14"
cache: yarn
+ cache-dependency-path: 'yarn.lock'
- name: Install dependencies
run: yarn --prefer-offline
@@ -237,6 +238,41 @@ jobs:
name: lucide-preact-package-json
path: packages/lucide-preact/package.json
+ lucide-static:
+ if: github.repository == 'lucide-icons/lucide'
+ runs-on: ubuntu-latest
+ needs: [pre-build, lucide-font]
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v2.4.0
+ with:
+ node-version: "14"
+ cache: yarn
+
+ - name: Install dependencies
+ run: yarn --prefer-offline
+
+ - name: Set Auth Token
+ run: npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
+
+ # - name: Set new version
+ # run: yarn workspace lucide-static version --new-version ${{ needs.pre-build.outputs.VERSION }} --no-git-tag-version
+
+ - name: Move Font
+ run: cp -r lucide-font packages/lucide-static/font
+
+ - name: Build
+ run: yarn workspace lucide-static build
+
+ - name: Publish
+ run: yarn workspace lucide-static publish
+
+ - name: Upload package.json
+ uses: actions/upload-artifact@v2
+ with:
+ name: lucide-static-package-json
+ path: packages/lucide-static/package.json
+
lucide-font:
if: github.repository == 'lucide-icons/lucide'
runs-on: ubuntu-latest
@@ -277,27 +313,14 @@ jobs:
- name: Build Icon Font
run: |
- mkdir build
- list=(-200 -300 "" -500 -600)
- command=''
- for name in "${list[@]}"
- do
- subcommand="(yarn build:outline-icons --outputDir=converted_icons${name} && fontcustom compile "./converted_icons${name}" -h -n "lucide${name}" -o ./build -F)"
- if [ -z "$command" ]
- then
- command="$subcommand";
- else
- command="$command & $subcommand";
- fi
- done
-
- eval $command
+ mkdir lucide-font
+ yarn build:outline-icons --outputDir=converted_icons && fontcustom compile "./converted_icons" -h -n "lucide" -o ./lucide-font -F
- name: "Upload to Artifacts"
uses: actions/upload-artifact@v1
with:
name: lucide-font
- path: build
+ path: lucide-font
lucide-flutter:
if: github.repository == 'lucide-icons/lucide'
diff --git a/icons/alarm-clock-off.svg b/icons/alarm-clock-off.svg
index 99fbb762e..9cecaf32d 100644
--- a/icons/alarm-clock-off.svg
+++ b/icons/alarm-clock-off.svg
@@ -9,9 +9,9 @@
stroke-linecap="round"
stroke-linejoin="round"
>
-
+
+
+
+```
+
+## Usage
+
+Checkout the [codesandbox examples](https://codesandbox.io/s/using-the-svg-sprite-lz1kk).
+
+### SVG Files
+
+#### Svg file as image
+
+To use it in for example html:
+
+``` html
+
+
+```
+
+``` css
+.home-icon {
+ background-image: url(~lucide-static/icons/home.svg)
+}
+```
+Make sure you have the correct webpack loaders to make this work. [url-loader](https://v4.webpack.js.org/loaders/url-loader/)
+
+#### Svg file Inline
+
+You can simply import each svg by targeting `lucide-static/icons/{icon-name}.svg`.
+To use svgs in your project you can for example use a [svg loader](https://v4.webpack.js.org/loaders/svg-inline-loader/).
+
+```js
+import arrowRightIcon from 'lucide-static/icons/arrow-right'
+
+// return string of a svg
+```
+
+### SVG Sprite
+
+You may need additional loader for this.
+
+```html
+
+
+
+
+
+
+
+```
+
+If you'd prefer, you can use CSS to hold your base SVG properties
+
+```css
+.lucide-icon {
+ width: 24px;
+ height: 24px;
+ stroke: currentColor;
+ fill: none;
+ stroke-width: 2;
+ stroke-linecap: round;
+ stroke-linejoin: round;
+}
+```
+
+and update the svg as follows
+
+```svg
+
+
+```
+
+### Icon Font
+
+```css
+@import("~lucide-static/font/Lucide.css")
+```
+
+```html
+
This is a lucide icon ${messageSquare}
+ + + + `) +}) + +app.listen(port, () => { + console.log(`Example app listening at http://localhost:${port}`) +}) +``` + +## Contributing + +For more info on how to contribute please see the [contribution guidelines](https://github.com/lucide-icons/lucide/blob/master/CONTRIBUTING.md). + +Caught a mistake or want to contribute to the documentation? [Edit this page on Github](https://github.com/lucide-icons/lucide/blob/master/README.md) + +## Community + +Join the community on our [Discord](https://discord.gg/EH6nSts) server! + +## License + +Lucide is totally free for commercial use and personally use, this software is licensed under the [ISC License](https://github.com/lucide-icons/lucide/blob/master/LICENSE). diff --git a/packages/lucide-static/package.json b/packages/lucide-static/package.json new file mode 100644 index 000000000..ccf143869 --- /dev/null +++ b/packages/lucide-static/package.json @@ -0,0 +1,24 @@ +{ + "name": "lucide-static", + "description": "Lucide is a community-run fork of Feather Icons, open for anyone to contribute icons.", + "version": "0.16.18-rc.0", + "license": "ISC", + "homepage": "https://lucide.dev", + "bugs": "https://github.com/lucide-icons/lucide/issues", + "repository": { + "type": "git", + "url": "https://github.com/lucide-icons/lucide.git" + }, + "main": "lib/index.js", + "scripts": { + "move:icons": "cp -r ../../icons icons", + "move:tags": "cp ../../tags.json tags.json", + "build": "yarn clean && yarn move:icons && yarn move:tags && yarn build:lib", + "build:lib": "yarn --cwd ../../ babel-node packages/lucide-static/scripts/buildLib.js", + "clean": "rm -rf lib && rm -rf build && rm -rf icons && rm -f sprite.svg && rm -f tags.json" + }, + "devDependencies": { + "prettier": "^2.3.2", + "svgson": "^5.2.1" + } +} diff --git a/packages/lucide-static/scripts/buildLib.js b/packages/lucide-static/scripts/buildLib.js new file mode 100644 index 000000000..49f3fe8ae --- /dev/null +++ b/packages/lucide-static/scripts/buildLib.js @@ -0,0 +1,47 @@ +/* eslint-disable import/no-extraneous-dependencies */ +import fs from 'fs'; +import path from 'path'; +import getArgumentOptions from 'minimist'; +import { parseSync } from 'svgson'; + +// import renderIconsObject from '../../../scripts/render/renderIconsObject'; +import { appendFile, readSvgDirectory, toCamelCase } from '../../../scripts/helpers'; +import readSvgs from './readSvgs'; +import generateSprite from './generateSprite'; +import generateIconNodes from './generateIconNodes'; + +const cliArguments = getArgumentOptions(process.argv.slice(2)); +const createDirectory = dir => { + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } +}; + +const PACKAGE_DIR = path.resolve(__dirname, '../'); +const ICONS_DIR = path.join(PACKAGE_DIR, 'icons'); +const LIB_DIR = path.join(PACKAGE_DIR, cliArguments.output || 'lib'); +const ICON_MODULE_DIR = path.join(LIB_DIR, 'icons'); + +createDirectory(LIB_DIR); +createDirectory(ICON_MODULE_DIR); + +const svgFiles = readSvgDirectory(ICONS_DIR); +const svgs = readSvgs(svgFiles, ICONS_DIR); + +svgs.forEach(({ name, contents }) => { + const componentName = toCamelCase(name); + const importString = `module.exports.${componentName} = require('./icons/${name}');\n`; + appendFile(importString, `index.js`, LIB_DIR); + + const exportString = `module.exports = \`${contents}\`;\n`; + appendFile(exportString, `${name}.js`, ICON_MODULE_DIR); +}); + +const parsedSvgs = svgs.map(({ name, contents }) => ({ + name, + contents, + parsedSvg: parseSync(contents), +})); + +generateSprite(parsedSvgs, PACKAGE_DIR); +generateIconNodes(parsedSvgs, PACKAGE_DIR); diff --git a/packages/lucide-static/scripts/generateIconNodes.js b/packages/lucide-static/scripts/generateIconNodes.js new file mode 100644 index 000000000..b4c1e955b --- /dev/null +++ b/packages/lucide-static/scripts/generateIconNodes.js @@ -0,0 +1,13 @@ +import { writeFile } from '../../../scripts/helpers'; + +export default function generateIconNodes(parsedSvgs, packageDir) { + const iconNodes = parsedSvgs.reduce((acc, { name, parsedSvg }) => { + acc[name] = parsedSvg.children.map(({ name, attributes }) => [name, attributes]); + + return acc; + }, {}); + + const iconNodesStringified = JSON.stringify(iconNodes, null, 2); + + writeFile(iconNodesStringified, 'icon-nodes.json', packageDir); +} diff --git a/packages/lucide-static/scripts/generateSprite.js b/packages/lucide-static/scripts/generateSprite.js new file mode 100644 index 000000000..0461b5431 --- /dev/null +++ b/packages/lucide-static/scripts/generateSprite.js @@ -0,0 +1,39 @@ +/* eslint-disable import/no-extraneous-dependencies */ +import { stringify } from 'svgson'; +import { format } from 'prettier'; +import { appendFile } from '../../../scripts/helpers'; + +export default function generateSprite(svgs, packageDir) { + const symbols = svgs.map(({ name, parsedSvg }) => ({ + name: 'symbol', + type: 'element', + attributes: { + id: name, + }, + children: parsedSvg.children, + })); + + const spriteSvgObject = { + name: 'svg', + type: 'element', + attributes: { + xmlns: 'http://www.w3.org/2000/svg', + version: '1.1', + }, + children: [ + { + name: 'defs', + type: 'element', + children: symbols, + }, + ], + }; + + const spriteSvg = stringify(spriteSvgObject); + const prettifiedSprite = format(spriteSvg, { parser: 'babel' }).replace(/;/g, ''); + + const xmlMeta = `\n`; + + appendFile(xmlMeta, `sprite.svg`, packageDir); + appendFile(prettifiedSprite, `sprite.svg`, packageDir); +} diff --git a/packages/lucide-static/scripts/readSvgs.js b/packages/lucide-static/scripts/readSvgs.js new file mode 100644 index 000000000..efd3d3bf6 --- /dev/null +++ b/packages/lucide-static/scripts/readSvgs.js @@ -0,0 +1,17 @@ +/* eslint-disable import/no-extraneous-dependencies */ +import { basename } from 'path'; +import { readSvg } from '../../../scripts/helpers'; + +/** + * Build an object in the format: `{