Skip to content

Commit

Permalink
implement code connect for segmentedControl
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Aug 14, 2024
1 parent f372a4f commit c4659ff
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 11 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"@babel/plugin-transform-modules-commonjs": "7.24.1",
"@babel/preset-react": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@figma/code-connect": "1.0.4",
"@figma/code-connect": "1.0.5",
"@primer/css": "^21.0.1",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-commonjs": "25.0.4",
Expand Down Expand Up @@ -250,4 +250,4 @@
"optional": true
}
}
}
}
58 changes: 58 additions & 0 deletions packages/react/src/SegmentedControl/SegmentedControl.figma.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react'
import {SegmentedControl} from './SegmentedControl'
import figma from '@figma/code-connect'

/**
* -- This file was auto-generated by `figma connect create` --
* `props` includes a mapping from Figma properties and variants to
* suggested values. You should update this to match the props of your
* code component, and update the `example` function to return the
* code example you'd like to see in Figma
*/

figma.connect(
SegmentedControl,
'https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=16122-79604&t=LhKEppN9LJfzQQ49-4',
{
props: {
items: figma.children(['SegmentedControl.Button']),
size: figma.enum('size', {
medium: 'medium',
small: 'small',
}),
},
example: ({size, items}) => <SegmentedControl size={size}>{items}</SegmentedControl>,
},
)

figma.connect(
SegmentedControl.Button,
'https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=16121-61223&m=dev',
{
props: {
label: figma.string('label'),
selected: figma.enum('state', {selected: true}),
leadingIcon: figma.boolean('leadingIcon?', {
true: figma.instance('icon'),
false: undefined,
}),
},
example: ({selected, label, leadingIcon}) => (
<SegmentedControl.Button selected={selected} leadingIcon={leadingIcon}>
{label}
</SegmentedControl.Button>
),
},
)

figma.connect(
SegmentedControl.IconButton,
'https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=16231-63571&m=dev',
{
props: {
selected: figma.enum('state', {selected: true}),
leadingIcon: figma.instance('icon'),
},
example: ({selected, leadingIcon}) => <SegmentedControl.IconButton selected={selected} icon={leadingIcon} />,
},
)

0 comments on commit c4659ff

Please sign in to comment.