|
| 1 | +import React from 'react' |
| 2 | +import figma from '@figma/code-connect' |
| 3 | +import {Button, ButtonPrimary, ButtonSecondary, ButtonOutline, ButtonTransparent} from 'rn-base-component' |
| 4 | + |
| 5 | +const BUTTON_FIGMA_URL = '<FIGMA_BUTTON>' |
| 6 | +const buttonProps = { |
| 7 | + disabled: figma.enum('state', { |
| 8 | + disabled: true, |
| 9 | + }), |
| 10 | + leftIcon: figma.boolean('leading_icon', { |
| 11 | + true: figma.boolean('is_icon_only', { |
| 12 | + true: undefined, |
| 13 | + false: figma.instance('leading_icon_swap'), |
| 14 | + }), |
| 15 | + false: undefined, |
| 16 | + }), |
| 17 | + rightIcon: figma.boolean('trailing_icon', { |
| 18 | + true: figma.boolean('is_icon_only', { |
| 19 | + true: undefined, |
| 20 | + false: figma.instance('trailing_icon_swap'), |
| 21 | + }), |
| 22 | + false: undefined, |
| 23 | + }), |
| 24 | + children: figma.boolean('is_icon_only', { |
| 25 | + true: figma.instance('icon_swap'), |
| 26 | + false: figma.string('button_text'), |
| 27 | + }), |
| 28 | +} |
| 29 | + |
| 30 | +figma.connect(ButtonPrimary, BUTTON_FIGMA_URL, { |
| 31 | + variant: {type: 'contained', hierarchy: 'primary'}, |
| 32 | + props: buttonProps, |
| 33 | + example: props => <ButtonPrimary {...props} />, |
| 34 | +}) |
| 35 | + |
| 36 | +figma.connect(ButtonSecondary, BUTTON_FIGMA_URL, { |
| 37 | + variant: {type: 'contained', hierarchy: 'tertiary'}, |
| 38 | + props: buttonProps, |
| 39 | + example: props => <ButtonSecondary {...props} />, |
| 40 | +}) |
| 41 | + |
| 42 | +figma.connect(ButtonOutline, BUTTON_FIGMA_URL, { |
| 43 | + variant: {type: 'outlined'}, |
| 44 | + props: buttonProps, |
| 45 | + example: props => <ButtonOutline {...props} />, |
| 46 | +}) |
| 47 | + |
| 48 | +figma.connect(ButtonTransparent, BUTTON_FIGMA_URL, { |
| 49 | + variant: {type: 'ghost'}, |
| 50 | + props: buttonProps, |
| 51 | + example: props => <ButtonTransparent {...props} />, |
| 52 | +}) |
| 53 | + |
| 54 | +figma.connect(Button, BUTTON_FIGMA_URL, { |
| 55 | + variant: {type: 'link'}, |
| 56 | + props: buttonProps, |
| 57 | + example: props => <Button {...props} />, |
| 58 | +}) |
0 commit comments