Skip to content

feat(CC-batch-1): added batch 1 #11827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions packages/code-connect/components/AboutModal/AboutModal.figma.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import figma from '@figma/code-connect';
import { AboutModal } from '@patternfly/react-core';

figma.connect(
AboutModal,
'https://www.figma.com/design/aEBBvq0J3EPXxHvv6WgDx9/PatternFly-6--Components-Test?node-id=2879-13973&t=15CEJpGgVui7qP5Q-11',
{
props: {
// string
productName: figma.string('Product name'),

trademark: 'Copyright © 2024',
brandImageSrc: 'Brand Image Source',
brandImageAlt: 'Brand Image Alt Text',
backgroundImageSrc: '/assets/images/background.png',

// children
children: figma.children('*')
},
example: (props) => (
// Documentation for AboutModal can be found at https://www.patternfly.org/components/about-modal
<AboutModal
productName={props.productName}
trademark={props.trademark}
brandImageSrc={props.brandImageSrc}
brandImageAlt={props.brandImageAlt}
backgroundImageSrc={props.backgroundImageSrc}
>
{props.children}
</AboutModal>
)
}
);
30 changes: 30 additions & 0 deletions packages/code-connect/components/Accordion/Accordion.figma.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import figma from '@figma/code-connect';
import { Accordion } from '@patternfly/react-core';

figma.connect(
Accordion,
'https://www.figma.com/file/aEBBvq0J3EPXxHvv6WgDx9/PatternFly-6%3A-Components-Test?node-id=2621-623',
{
props: {
// enum
isBordered: figma.enum('Type', {
Bordered: true,
'Large Bordered': true
}),
displaySize: figma.enum('Type', {
'Large Bordered': 'lg'
}),
togglePosition: figma.enum('Caret position', {
Left: 'start'
}),

children: figma.children('*')
},
example: (props) => (
// Documentation for Accordion can be found at https://www.patternfly.org/components/accordion
<Accordion togglePosition={props.togglePosition} isBordered={props.isBordered} displaySize={props.displaySize}>
{props.children}
</Accordion>
)
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import figma from '@figma/code-connect';
import { AccordionItem, AccordionToggle, AccordionContent } from '@patternfly/react-core';

figma.connect(
AccordionToggle,
'https://www.figma.com/design/aEBBvq0J3EPXxHvv6WgDx9/PatternFly-6--Components-Test?node-id=1423-687',
{
props: {
// string
expandText: figma.string('Expand Text'),

// enum
toggleTextExpanded: figma.enum('State', {
Default: figma.string('Toggle Text'),
Hover: figma.string('Toggle Text'),
Expanded: figma.string('Toggle Text Expanded')
}),
isExpanded: figma.enum('State', { Expanded: true }),

children: figma.children('*')
},
example: (props) => (
// Documentation for Accordion can be found at https://www.patternfly.org/components/accordion
<AccordionItem isExpanded={props.isExpanded}>
<AccordionToggle onClick={() => {}} id="<your-id>">
{props.toggleTextExpanded}
</AccordionToggle>
<AccordionContent id="accordion-content-example">
<p>{props.expandText}</p>
</AccordionContent>
</AccordionItem>
)
}
);
17 changes: 17 additions & 0 deletions packages/code-connect/components/ActionList/ActionList.figma.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import figma from '@figma/code-connect';
import { ActionList } from '@patternfly/react-core';

figma.connect(
ActionList,
'https://www.figma.com/design/aEBBvq0J3EPXxHvv6WgDx9/PatternFly-6--Components-Test?node-id=6780-15839&m=dev',
{
props: {
Copy link
Contributor

@kmcfaul kmcfaul May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's worth adding the isIconList prop here or if there is no distinction in figma. In React this boolean prop adds a class for icon-only lists that removes some additional padding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can look for Action icons only, and set isIconList based on that.

isIconList: figma.enum('Type', { 'Action icons only': true }),
children: figma.children('*')
},
example: (props) => (
// Documentation for ActionList can be found at https://www.patternfly.org/components/action-list
<ActionList isIconList={props.isIconList}>{props.children}</ActionList>
)
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import figma from '@figma/code-connect';
import { BackgroundImage } from '@patternfly/react-core';

figma.connect(
BackgroundImage,
'https://www.figma.com/file/aEBBvq0J3EPXxHvv6WgDx9/PatternFly-6%3A-Components-Test?node-id=5047-695',
{
props: {
src: figma.string('Background Image Source')
},
example: (props) => (
// Documentation for BackgroundImage can be found at https://www.patternfly.org/components/background-image
<BackgroundImage src={props.src} />
)
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import figma from '@figma/code-connect';
import { ClipboardCopy } from '@patternfly/react-core';

figma.connect(
ClipboardCopy,
'https://www.figma.com/design/aEBBvq0J3EPXxHvv6WgDx9/PatternFly-6--Components-Test?node-id=9914-75835&m=dev',
{
props: {
// enum
isActive: figma.enum('State', { Active: true }),
isReadOnly: figma.enum('State', { 'Read only': true }),
isExpanded: figma.enum('State', { Expanded: true }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way in figma to make an expandable clipboardCopy variant? If so, then isExpanded can be passed, but also the variant needs to be 'expansion'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create an expansion var that references figma.enum('State', { Expanded... }

false: undefined should be included to return "undefined" if state === !expanded, otherwise Figma will complain

      expansion: figma.enum('State', { 
        Expanded: 'expansion',
        false: undefined
      }),

expansion: figma.enum('State', {
Expanded: 'expansion',
false: undefined
}),

children: figma.children('*')
},
example: (props) => (
// Documentation for ClipboardCopy can be found at https://www.patternfly.org/components/clipboard-copy
<ClipboardCopy
isReadOnly={props.isReadOnly}
variant={props.expansion}
isExpanded={props.isExpanded}
isActive={props.isActive}
>
{props.children}
</ClipboardCopy>
)
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import figma from '@figma/code-connect';
import { ClipboardCopy } from '@patternfly/react-core';

/**
* PatternFly AccordionToggle integration for Figma Code Connect
* @patternfly https://www.patternfly.org/components/clipboard-copy
*/

figma.connect(
ClipboardCopy,
'https://www.figma.com/design/aEBBvq0J3EPXxHvv6WgDx9/PatternFly-6--Components-Test?node-id=9914-75768&m=dev',
{
props: {
children: figma.children('*')
},
example: (props) => <ClipboardCopy variant="inline-compact">{props.children}</ClipboardCopy>
}
);
33 changes: 33 additions & 0 deletions packages/code-connect/figma.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"codeConnect": {
"parser": "react",
"include": [
"components/AboutModal/*.tsx",
"components/Accordion/*.tsx",
"components/ActionList/*.tsx",
"components/BackgroundImage/*.tsx",
"components/ClipboardCopy/*.tsx"
],
"paths": {
"src/components": "src/components"
},
"aliases": {
"@patternfly/react-core": "."
},
"importPaths": {
"src/components": "src/components"
},
"options": {
"instanceSwapper": {
"enabled": true
},
"development": {
"enabled": true,
"verbose": true
},
"production": {
"enabled": false
}
}
}
}
Loading