Skip to content

Commit

Permalink
feat(code-connect): connect Search, Select, RadioButton, RadioButtonG…
Browse files Browse the repository at this point in the history
…roup (#16782)

* feat(code-connect): connect Select and FluidSelect

* chore: fix

* feat(code-connect): connect select and radio button

* feat(code-connect): radio button and radio button group

* chore: typo

* feat(code-connect): connect search

* Update README.md
  • Loading branch information
alisonjoseph authored Jun 24, 2024
1 parent 412ce20 commit 5e000ea
Show file tree
Hide file tree
Showing 10 changed files with 450 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/react/code-connect/Checkbox/Checkbox.figma.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ figma.connect(
checked: figma.enum('Selection', {
Checked: true,
}),
helperText: figma.string('Helper text'),
helperText: figma.boolean('Helper message', {
true: figma.string('Helper text'),
}),
invalid: figma.enum('State', {
Invalid: true,
}),
Expand Down
5 changes: 3 additions & 2 deletions packages/react/code-connect/Checkbox/CheckboxGroup.figma.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ figma.connect(
{
props: {
// horizontal: figma.boolean('Horizontal'), // missing in React
//helpermessage: figma.boolean('Helper message'), show/hide helper text in figma, in react if message is there it displays
// warnMessage: figma.boolean('Warning message'), // you can have a component in a warn state while hiding warning message in Figma, not supported in code
// errorMessage: figma.boolean('Error message'), // you can have a component in a error state while hiding error message in Figma, not supported in code
children: figma.children(['Checkbox']),
helperText: figma.string('Helper text'),
helperText: figma.boolean('Helper message', {
true: figma.string('Helper text'),
}),
readOnly: figma.enum('State', {
'Read-only': true,
}),
Expand Down
5 changes: 3 additions & 2 deletions packages/react/code-connect/Dropdown/Dropdown.figma.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ figma.connect(
'https://www.figma.com/file/YAnB1jKx0yCUL29j6uSLpg/(v11)-All-themes---Carbon-Design-System?type=design&node-id=14032-290635&mode=dev',
{
props: {
helperText: figma.string('Helper text'),
helperText: figma.boolean('Show helper', {
true: figma.string('Helper text'),
}),
size: figma.enum('Size', {
Large: 'lg',
Medium: 'md',
Expand Down Expand Up @@ -45,7 +47,6 @@ figma.connect(
// Fixed: 'fixed',
Inline: 'inline',
}),
// showhelper: figma.boolean('Show helper'), // this doesn't exist in code, if helperText exists it will display
// selectedtext: figma.string('Selected text'), // what is this used for in Figma?
// unselectedtext: figma.string('Unselected text'),// what is this used for in Figma?
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ figma.connect(
disabled: figma.enum('State', {
Disabled: true,
}),
helperText: figma.string('Helper text'),
helperText: figma.boolean('Show helper', {
true: figma.string('Helper text'),
}),
hideLabel: figma.boolean('Show label', {
true: false,
false: true,
Expand All @@ -41,7 +43,6 @@ figma.connect(
}),
warnText: figma.string('Warning text'),
// value, text field in Figma
// showhelper: figma.boolean('Show helper'), // this doesn't exist in code, if helperText exists it will display
},
example: ({
disabled,
Expand Down
75 changes: 75 additions & 0 deletions packages/react/code-connect/RadioButton/RadioButton.figma.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* Copyright IBM Corp. 2016, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

// @ts-nocheck
import React from 'react';
import { RadioButton, RadioButtonSkeleton } from '@carbon/react';
import figma from '@figma/code-connect';

figma.connect(
RadioButton,
'https://www.figma.com/design/YAnB1jKx0yCUL29j6uSLpg/(v11)-All-themes---Carbon-Design-System?node-id=2930-23442&t=yFGI7EFVWv0vtqIk-4',
{
props: {
labelText: figma.string('Value text'),
labelPosition: figma.enum('Position', {
Right: 'right',
}),
hideLabel: figma.boolean('Value', {
true: false,
false: true,
}),
disabled: figma.enum('State', {
Disabled: true,
}),
defaultChecked: figma.boolean('Selected'),
// Below props are set on RadioButtonGroup only in code
//
// labeltext: figma.string('Label text'),
// warningtext: figma.string('Warning text'),
// helpermessage: figma.boolean('Helper message'),
// warningmessage: figma.boolean('Warning message'),
// errormessage: figma.boolean('Error message'),
// helpertext: figma.string('Helper text'),
// errortext: figma.string('Error text'),
// label: figma.boolean('Label'),
// state: figma.enum('State', {
// 'Read-only': 'read-only',
// Invalid: 'invalid',
// Warning: 'warning',
// }),
},
example: ({
labelText,
labelPosition,
hideLabel,
disabled,
defaultChecked,
}) => (
<RadioButton
labelText={labelText}
labelPosition={labelPosition}
hideLabel={hideLabel}
disabled={disabled}
defaultChecked={defaultChecked}
/>
),
}
);

figma.connect(
RadioButtonSkeleton,
'https://www.figma.com/design/YAnB1jKx0yCUL29j6uSLpg/(v11)-All-themes---Carbon-Design-System?node-id=2930-23442&t=yFGI7EFVWv0vtqIk-4',
{
variant: { State: 'Skeleton' },
example: () => {
// Disclaimer: Code Connect is currently in beta and integration with Carbon
// React is in an exploratory phase. Code sample below may be incomplete.
<RadioButtonSkeleton />;
},
}
);
64 changes: 64 additions & 0 deletions packages/react/code-connect/RadioButton/RadioButtonGroup.figma.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright IBM Corp. 2016, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

// @ts-nocheck
import React from 'react';
import { RadioButtonGroup } from '@carbon/react';
import figma from '@figma/code-connect';

figma.connect(
RadioButtonGroup,
'https://www.figma.com/design/YAnB1jKx0yCUL29j6uSLpg/(v11)-All-themes---Carbon-Design-System?node-id=2927-28166&t=yFGI7EFVWv0vtqIk-4',
{
props: {
children: figma.children(['Radio button']),
disabled: figma.enum('State', {
Disabled: true,
}),
helperText: figma.boolean('Helper message', {
true: figma.string('Helper text'),
}),
warnText: figma.string('Warning text'),
warn: figma.enum('State', {
Warning: true,
}),
invalidText: figma.string('Error text'),
invalid: figma.enum('State', {
Invalid: true,
}),
legendText: figma.string('Label text'),
orientation: figma.boolean('Horizontal', {
false: 'vertical',
}),
},
example: ({
children,
disabled,
helperText,
warnText,
warn,
invalidText,
invalid,
orientation,
legendText,
}) => (
// Disclaimer: Code Connect is currently in beta and integration with Carbon
// React is in an exploratory phase. Code sample below may be incomplete.
<RadioButtonGroup
disabled={disabled}
helperText={helperText}
warnText={warnText}
warn={warn}
invalidText={invalidText}
invalid={invalid}
orientation={orientation}
legendText={legendText}>
{children}
</RadioButtonGroup>
),
}
);
51 changes: 51 additions & 0 deletions packages/react/code-connect/Search/FluidSearch.figma.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright IBM Corp. 2016, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

// @ts-nocheck
import React from 'react';
import {
unstable__FluidSearch as FluidSearch,
// unstable__FluidSearchSkeleton as FluidSearchSkeleton,
} from '@carbon/react';
import figma from '@figma/code-connect';

figma.connect(
FluidSearch,
'https://www.figma.com/design/YAnB1jKx0yCUL29j6uSLpg/(v11)-All-themes---Carbon-Design-System?node-id=15503-270751&t=6KMXKibN414b97hv-4',
{
props: {
placeholder: figma.string('Placeholder text'),
labelText: figma.string('Label text'),
disabled: figma.enum('State', {
Disabled: true,
}),
},
example: ({ placeholder, labelText, disabled }) => (
// Disclaimer: Code Connect is currently in beta and integration with Carbon
// React is in an exploratory phase. Code sample below may be incomplete.
<FluidSearch
placeholder={placeholder}
labelText={labelText}
disabled={disabled}
/>
),
}
);

// missing from Figma
// figma.connect(
// FluidSearchSkeleton,
// 'https://www.figma.com/design/YAnB1jKx0yCUL29j6uSLpg/(v11)-All-themes---Carbon-Design-System?node-id=15503-270751&t=6KMXKibN414b97hv-4',
// {
// variant: { State: 'Skeleton' },
// example: () => (
// // Disclaimer: Code Connect is currently in beta and integration with Carbon
// // React is in an exploratory phase. Code sample below may be incomplete.
// <FluidSearchSkeleton />
// ),
// }
// );
75 changes: 75 additions & 0 deletions packages/react/code-connect/Search/Search.figma.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* Copyright IBM Corp. 2016, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

// @ts-nocheck
import React from 'react';
import { Search, ExpandableSearch, TextInputSkeleton } from '@carbon/react';
import figma from '@figma/code-connect';

figma.connect(
Search,
'https://www.figma.com/design/YAnB1jKx0yCUL29j6uSLpg/(v11)-All-themes---Carbon-Design-System?node-id=2805-21056&t=6KMXKibN414b97hv-4',
{
props: {
size: figma.enum('Size', {
Large: 'lg',
Medium: 'md',
Small: 'sm',
}),
placeholder: figma.string('Placeholder text'),
disabled: figma.enum('State', {
Disabled: true,
}),
},
example: ({ size, placeholder, disabled }) => (
// Disclaimer: Code Connect is currently in beta and integration with Carbon
// React is in an exploratory phase. Code sample below may be incomplete.
<Search size={size} placeholder={placeholder} disabled={disabled} />
),
}
);

figma.connect(
ExpandableSearch,
'https://www.figma.com/design/YAnB1jKx0yCUL29j6uSLpg/(v11)-All-themes---Carbon-Design-System?node-id=2805-21056&t=6KMXKibN414b97hv-4',
{
variant: { Expanded: 'True' }, // <--doesn't work
props: {
size: figma.enum('Size', {
Large: 'lg',
Medium: 'md',
Small: 'sm',
}),
placeholder: figma.string('Placeholder text'),
disabled: figma.enum('State', {
Disabled: true,
}),
},
example: ({ size, placeholder, disabled }) => (
// Disclaimer: Code Connect is currently in beta and integration with Carbon
// React is in an exploratory phase. Code sample below may be incomplete.
<ExpandableSearch
size={size}
placeholder={placeholder}
disabled={disabled}
/>
),
}
);

figma.connect(
TextInputSkeleton,
'https://www.figma.com/design/YAnB1jKx0yCUL29j6uSLpg/(v11)-All-themes---Carbon-Design-System?node-id=2805-21056&t=6KMXKibN414b97hv-4',
{
variant: { State: 'Skeleton' },
example: () => (
// Disclaimer: Code Connect is currently in beta and integration with Carbon
// React is in an exploratory phase. Code sample below may be incomplete.
<TextInputSkeleton hideLabel />
),
}
);
64 changes: 64 additions & 0 deletions packages/react/code-connect/Select/FluidSelect.Figma.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright IBM Corp. 2016, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

// @ts-nocheck
import React from 'react';
import {
unstable__FluidSelect as FluidSelect,
SelectItem,
} from '@carbon/react';
import figma from '@figma/code-connect';

figma.connect(
FluidSelect,
'https://www.figma.com/design/YAnB1jKx0yCUL29j6uSLpg/(v11)-All-themes---Carbon-Design-System?node-id=17650-275243&t=LS77peWFGhwOdxIw-4',
{
props: {
disabled: figma.enum('State', {
Disabled: true,
}),
labelText: figma.string('Label text'),
warn: figma.enum('State', {
Warning: true,
}),
warnText: figma.string('Warning text'),
invalid: figma.enum('State', {
Error: true,
}),
invalidText: figma.string('Error text'),
// showtooltip: figma.boolean('Show tooltip'), // not supported in react
// labelText: figma.boolean('Show tooltip', {
// true: 'add tooltip icon code here ',
// false: figma.string('Label text'),
// }),
},
example: ({
labelText,
warnText,
invalidText,
warn,
invalid,
disabled,
}) => (
// Disclaimer: Code Connect is currently in beta and integration with Carbon
// React is in an exploratory phase. Code sample below may be incomplete.
<FluidSelect
labelText={labelText}
warnText={warnText}
warn={warn}
invalidText={invalidText}
invalid={invalid}
disabled={disabled}>
<SelectItem value="" text="" />
<SelectItem value="option-1" text="Option 1" />
<SelectItem value="option-2" text="Option 2" />
<SelectItem value="option-3" text="Option 3" />
<SelectItem value="option-4" text="Option 4" />
</FluidSelect>
),
}
);
Loading

0 comments on commit 5e000ea

Please sign in to comment.