@jihu-fe/svgs
v2.39.0
Published
SVG Assets for GitLab
Downloads
4,414
Readme
Gitlab SVGs
This repository manages all SVG Assets for GitLab by creating SVG sprites out of icons, and optimizing SVG illustrations.
Previewing the SVG library
Visit the GitLab SVG Previewer website to see, reference, and search through all available icons and illustrations.
Requirements
- You’ll need yarn and node installed. On a Mac, you can install yarn with
brew install yarn
. - For the first time, or after updating from the
main
branch, useyarn install
to install the latest dependencies.
Commands
yarn run svg
- Runs all tasks that are available. You can also run this task to release a new version.
All output is saved to the dist
folder where it’s referenced from our main applications.
Adding icons or illustrations
If you're adding a third-party logo or trademark, refer to this section.
Review the following documentation:
Make sure you have the latest from the
main
branch in your local copy of the gitlab-svgs repository, then create a new local branch.# Retrieve the latest updates git pull # Create a new local branch git checkout -b new-branch-name
Make sure that your dependencies are up to date by running
yarn install
.Export the icons or illustrations as a
.svg
file where:- Icons are placed in the
sprite_icons
folder. Read instructions below on exporting icons. - Illustrations are placed in the
illustrations/
folder. There are subfolders for illustration categories, like empty states or logos.
- Icons are placed in the
If you are not compressing an SVG during export, you can use SVGO to optimize it after you export.
# Optimize our `huge_test.svg` file yarn run svgo ./path/to/huge_test.svg
After adding the new SVGs, execute the following commands to verify your changes locally at http://localhost:3333/
# Starts a local server to preview your changes yarn run dev
Test icons by changing the settings in the Icon configuration panel of the local preview site and ensuring that the icon changes color and size (there are a few icons that intentionally don’t change color).
If you are happy with the new/modified SVG, commit and push all changes (including the ones to the
dist
folder) and create a merge request.# After committing your changes, use this to create a remote branch. A link will then be available to create the merge request. git push -u origin new-branch-name
Assign the merge request to a maintainer of the GitLab SVGs project. You can find the maintainers on the GitLab project overview page.
Adding third-party logos or trademarks
- See the process for adding third-party trademarks to GitLab in the handbook.
- Place approved assets in the
/illustrations/third-party-logos
directory.
Exporting icons from Figma
Icons should only be exported after they have been added to the Pajamas UI Kit in Figma. This ensures that it’s the final version of the icon that gets exported, and the export settings are retained for developer handoff if it’s ever needed.
- Confirm that the icon follows the icon design guidelines.
- Make sure the parent frame around the icon has no background fill.
- Select the icon and in the right properties panel add SVG as the export option. This should be done whether or not you are using the Advanced SVG Export plugin. If you want to optimize the icon during export use the following process, otherwise export the icon via the properties panel and skip to the next step.
- Install the Advanced SVG Export plugin. The plugin uses SVGO under the hood. Use the default settings.
- Select the icon and run the plugin, exporting to the
sprite_icons
folder. - Open the resulting SVG file in your text editor and remove
fill="none"
from the main<svg>
element.
- After adding the new SVGs, execute the following commands to verify your changes locally at http://localhost:3333/
# Starts a local server to preview your changes yarn run dev
Brand icons for companies or products, which may have specific color requirements, should be named starting with brand-
, for example, brand-slack.svg
. These icons may have something different than fill="#000"
to prevent color from being overridden.
Preview Application
The application for previewing is based on NUXT and is located in the folder svgpreviewer
.
You can run it locally through yarn run dev
then it will available under http://localhost:3333/
.
With yarn run generate
you can generate the static output to the public
folder.
File icons
This package also bundles file icons based off PKief/vscode-material-icon-theme.
During the CI build, the following steps are done:
- vscode-material-icon-theme is downloaded based on the version in build_scripts/file_icons_version.
- Then all file types used in src/file_icon_map are copied to the
file_icons
folder. - From there they are bundled in icons sprites
- Unused file icons are copied into
file_icons_unused
Publishing a new version
Every time a file is added, deleted, modified or renamed within the sprite_icons
or illustrations
folders and the change is merged into the main
branch, a new minor version of the package is published.
Contributing
GitLab is an open source project and we are happy to accept community contributions. Please refer to CONTRIBUTING.md for details.