Skip to content

Commit

Permalink
Merge pull request #220 from omnifed/219-feature-setup-figma-code-con…
Browse files Browse the repository at this point in the history
…nect

219 feature setup figma code connect
  • Loading branch information
caseybaggz committed Jun 28, 2024
2 parents 60037ad + 09ac817 commit 127992f
Show file tree
Hide file tree
Showing 11 changed files with 980 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/publish-figma.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 🚀 Publish to Figma

on:
push:
paths:
- figma/src/**/*.figma.tsx
branches:
- main

env:
CI: true
FIGMA_ACCESS_TOKEN: ${{ secrets.FIGMA_ACCESS_TOKEN }}

jobs:
publish-npm-next:
runs-on: ubuntu-latest
name: Publish Figma Code Connect
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9.1.4
- uses: actions/setup-node@v4
with:
cache: 'pnpm'

- run: pnpm install
- run: pnpm run figma:publish
working-directory: ./figma
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ packages/styled-system/helpers.mjs

docs/styled-system
packages/*/styled-system
packages/*/styled-system-studio
packages/*/styled-system-studio

## Figma

figma/.env
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default tseslint.config(
'./configs/tsconfig.json',
'./tests/tsconfig.json',
'./docs/tsconfig.json',
'./figma/tsconfig.json',
],
tsconfigRootDir: import.meta.dirname,
},
Expand Down Expand Up @@ -89,6 +90,17 @@ export default tseslint.config(
files: ['tests/**/*.ts', 'tests/**/*.tsx'],
},

{
name: 'figma',
files: ['figma/**/*.ts', 'figma/**/*.tsx'],
plugins: {
react,
},
...reactRecommended,
...reactHooks.recommended,
rules: {},
},

// this must be last
eslintConfigPrettier,
)
18 changes: 18 additions & 0 deletions figma/figma.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"codeConnect": {
"parser": "react",
"include": [
"src/**",
"node_modules/@cerberus/react/**",
"node_modules/@cerberus/icons/**"
],
"importPaths": {
"@cerberus-design/react": "@cerberus/react",
"@cerberus-design/icons": "@cerberus/icons"
},
"paths": {
"@cerberus-design/react": "node_modules/@cerberus/react",
"@cerberus-design/icons": "node_modules/@cerberus/icons"
}
}
}
22 changes: 22 additions & 0 deletions figma/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "figma",
"version": "1.0.0",
"description": "The Figma Code Connect config for Cerberus Design",
"scripts": {
"figma:publish": "npx figma connect publish",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@cerberus-design/icons": "workspace:*",
"@cerberus-design/react": "workspace:*",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@figma/code-connect": "^1.0.1",
"@types/react": "^18"
},
"keywords": [],
"author": "",
"license": "ISC"
}
72 changes: 72 additions & 0 deletions figma/src/button.figma.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import figma from '@figma/code-connect'
import { Button } from '@cerberus-design/react'

const SELECTION =
'https://www.figma.com/design/ducwqOCxoxcWc3ReV3FYd8/Digital-University-Component-Library?node-id=8637-3339&m=dev'

const imports = ["import { Button } from '@cerberus/react'"]

const props = {
palette: figma.enum('Palette', {
action: 'action',
danger: 'danger',
}),
shape: figma.enum('Shape', {
sharp: 'sharp',
rounded: 'rounded',
}),
usage: figma.enum('Usage', {
filled: 'filled',
outline: 'outline',
text: 'text',
}),
// Figma specific
text: figma.textContent('Action'),
icon: figma.children('*'),
}

figma.connect(Button, SELECTION, {
imports,
props,
example: (props) => {
return (
<Button palette={props.palette} shape={props.shape} usage={props.usage}>
{props.text}
</Button>
)
},
})

figma.connect(Button, SELECTION, {
imports,
variant: {
'Show Icon': 'True',
'Icon Position': 'start',
},
props,
example: (props) => {
return (
<Button palette={props.palette} shape={props.shape} usage={props.usage}>
{props.icon}
{props.text}
</Button>
)
},
})

figma.connect(Button, SELECTION, {
imports,
variant: {
'Show Icon': 'True',
'Icon Position': 'end',
},
props,
example: (props) => {
return (
<Button palette={props.palette} shape={props.shape} usage={props.usage}>
{props.text}
{props.icon}
</Button>
)
},
})
21 changes: 21 additions & 0 deletions figma/src/icons/arrow-left-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import figma from '@figma/code-connect'
import { ArrowLeft } from '@cerberus-design/icons'

figma.connect(
ArrowLeft,
'https://www.figma.com/design/ducwqOCxoxcWc3ReV3FYd8/Digital-University-Component-Library?node-id=8702-3542&m=dev',

{
imports: ["import { ArrowLeft } from '@cerberus/icons'"],
props: {
size: figma.enum('Size', {
sm: 16,
md: 20,
lg: 24,
xl: 32,
}),
},

example: (props) => <ArrowLeft size={props.size} />,
},
)
21 changes: 21 additions & 0 deletions figma/src/icons/arrow-right-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import figma from '@figma/code-connect'
import { ArrowRight } from '@cerberus-design/icons'

figma.connect(
ArrowRight,
'https://www.figma.com/design/ducwqOCxoxcWc3ReV3FYd8/Digital-University-Component-Library?node-id=8688-3388&m=dev',

{
imports: ["import { ArrowRight } from '@cerberus/icons'"],
props: {
size: figma.enum('Size', {
sm: 16,
md: 20,
lg: 24,
xl: 32,
}),
},

example: (props) => <ArrowRight size={props.size} />,
},
)
11 changes: 11 additions & 0 deletions figma/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../tsconfig.base.json",
"include": ["src/*.figma.tsx"],
"exclude": ["build", "node_modules"],

"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}
Loading

0 comments on commit 127992f

Please sign in to comment.