Skip to content

Commit 88d2b81

Browse files
authored
feat(icons): add script to automatically pull icons from Figma (#1747)
* feat: add script to pull icons automatically from Figma * chore: run script to update all icons from Figma source of truth * feat: add GitHub action workflow file * chore: update CONTRIBUTION readme for contributing icons
1 parent deb819e commit 88d2b81

File tree

10 files changed

+1825
-2447
lines changed

10 files changed

+1825
-2447
lines changed

.changeset/brave-signs-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@launchpad-ui/icons": patch
3+
---
4+
5+
feat: add script to sync icon package from Figma file and initial sync of icons

.github/workflows/sync-icons.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Sync icons
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
jobs:
11+
sync-icons:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Get Tokens
15+
uses: launchdarkly/gh-actions/actions/[email protected]
16+
with:
17+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
18+
ssm_parameter_pairs: |
19+
/production/common/launchpad-ui/figma-file-key = FIGMA_FILE_KEY,
20+
/production/common/launchpad-ui/figma-access-token = FIGMA_ACCESS_TOKEN
21+
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Setup PNPM
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: 9
31+
run_install: false
32+
33+
- name: Setup Node
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 20
37+
cache: pnpm
38+
39+
- name: Install dependencies
40+
run: pnpm install
41+
42+
- name: Sync Icons
43+
run: pnpm nx @launchpad-ui/icons:sync
44+
env:
45+
CI: true
46+
NX_NO_DAEMON: true
47+
48+
- name: Connect Icons
49+
run: pnpm nx @launchpad-ui/icons:connect
50+
env:
51+
CI: true
52+
NX_NO_DAEMON: true
53+
54+
- name: Detect changes
55+
id: changes
56+
run: |
57+
git status --short
58+
if git diff --quiet && git diff --cached --quiet; then
59+
echo "changed=false" >> "$GITHUB_OUTPUT"
60+
echo "No changes detected."
61+
else
62+
echo "changed=true" >> "$GITHUB_OUTPUT"
63+
echo "Changes detected."
64+
fi
65+
66+
- name: Add changeset
67+
if: steps.changes.outputs.changed == 'true'
68+
run: npx changeset add --empty
69+
env:
70+
CI: true
71+
NX_NO_DAEMON: true
72+
73+
- name: Create Pull Request
74+
if: steps.changes.outputs.changed == 'true'
75+
id: cpr
76+
uses: peter-evans/create-pull-request@v6
77+
with:
78+
branch: ci/sync-icons
79+
delete-branch: true
80+
commit-message: "feat(icons): sync & connect icons"
81+
title: "feat(icons): sync & connect icons"
82+
body: |
83+
Automated icon sync & connect run.
84+
Commands executed:
85+
- pnpm nx @launchpad-ui/icons:sync
86+
- pnpm nx @launchpad-ui/icons:connect
87+
88+
Diff:
89+
${{ env.DIFF_BODY }}
90+
labels: |
91+
icons
92+
assignees: ${{ github.actor }}
93+
94+
- name: No-op (no changes)
95+
if: steps.changes.outputs.changed != 'true'
96+
run: echo "No changes detected, skipping changeset and PR creation."

CONTRIBUTING.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ The following is a set of guidelines for contributing to LaunchPad and its packa
99
- [How Can I Contribute?](#how-can-i-contribute)
1010
- [Code Contribution Guide](#code-contribution-guide)
1111
- [Common Tasks](#common-tasks)
12+
- [Installation](#installation)
13+
- [Storybook](#storybook)
14+
- [Running Tests](#running-tests)
15+
- [Adding Dependencies to Packages](#adding-dependencies-to-packages)
16+
- [Adding Icons to LaunchPad](#adding-icons-to-launchpad)
1217
- [Styleguides](#styleguides)
1318

14-
---
1519

1620
## How Can I Contribute?
1721

@@ -42,7 +46,6 @@ If you'd like to help by writing code and filing a pull request for a feature en
4246

4347
To learn how to contribute code in LaunchPad, follow the guide below.
4448

45-
---
4649

4750
## Code Contribution Guide
4851

@@ -136,13 +139,10 @@ $ pnpm chromatic --project-token PROJECT_TOKEN --branch-name FORKED_BRANCH --bui
136139

137140
If you updated the `components`, `icons`, or `tokens` package your PR will be decorated with preview releases ([example](https://github.com/launchdarkly/launchpad-ui/pull/1686#issuecomment-2898653450)) which will allow you to install them to your project to test/verify. This is helpful for bug fixes or ensuring no regressions result from a refactoring and/or style changes.
138141

139-
---
140142

141143
## Common Tasks
142144

143-
## Running LaunchPad locally
144-
145-
### Installation
145+
### Local setup
146146

147147
[pnpm](https://pnpm.io/) is the package manager used in this monorepo.
148148

@@ -183,12 +183,19 @@ $ pnpm test
183183

184184
### Adding Icons to LaunchPad
185185

186-
- Add the SVG body content into a new symbol entry with id `lp-icon-{name}` in the `/src/image/sprite.svg` file in the `@launchpad/icons` package.
187-
- Add its `id` (minus prefix `lp-icon`) to the icons array in `/src/types.ts`.
188-
- Run `pnpm storybook` and visit the `Components/Icons` page to ensure your icon was generated properly.
189-
- Run `pnpm nx run @launchpad-ui/icons:connect` (https://github.com/figma/code-connect/blob/main/cli/scripts/README.md) to update the icons Figma Code Connect file.
186+
_Do not add icons manually. LaunchPad icons are managed in Figma and synced to the `@launchpad-ui/icons` package via a script._
187+
188+
To add a new icon to LaunchPad:
189+
190+
- Create a branch in the LaunchPad Figma library and add your icon to the /Icons page.
191+
- Make sure your new icon is reviewed by design. You can always ping `@uxteam` in #ask-launchpad-design-system if you need help making your icon or to get a review.
192+
- Merge the icon to the LaunchPad Figma library
193+
- Run the `sync-icons` GitHub action. This action does the following:
194+
- Runs `pnpm nx run @launchpad-ui/icons:sync` to build the icons from Figma
195+
- Runs `pnpm nx run @launchpad-ui/icons:connect` to update the icons [Figma Code Connect](https://github.com/figma/code-connect/blob/main/cli/scripts/README.md) file.
196+
- Opens a pull request for you
197+
- Open the `Components/Icons` page on the PR deployed Chromatic storybook to ensure your icon was generated properly.
190198

191-
---
192199

193200
## Styleguides
194201

0 commit comments

Comments
 (0)