diff --git a/packages/code-connect/components/Menu/Menu.figma.tsx b/packages/code-connect/components/Menu/Menu.figma.tsx new file mode 100644 index 00000000000..1134b7c4f3e --- /dev/null +++ b/packages/code-connect/components/Menu/Menu.figma.tsx @@ -0,0 +1,234 @@ +import figma from '@figma/code-connect'; +import { + Divider, + DrilldownMenu, + Menu, + MenuContent, + MenuSearch, + MenuGroup, + MenuItem, + MenuList, + MenuSearchInput, + SearchInput, + MenuItemAction +} from '@patternfly/react-core'; +import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; + +// TODO: DESIGN: Create menu group +// TODO: DESIGN: Create menu list +// Documentation for Menu can be found at https://www.patternfly.org/components/menu + +figma.connect( + Menu, + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/branch/Em2QWrHDxDS4LUxo58Hust/PatternFly-6--Components?node-id=2590-18585', + { + props: { + hasSearchDivider: figma.boolean('Show search input', { + true: , + false: undefined + }), + searchInput: figma.boolean('Show search input', { + true: ( + + + {}} /> + + + ), + false: undefined + }), + isPlain: figma.enum('Menu', { 'Plain Menu': true }), + menuItems: figma.children('.MenuItem') + }, + example: (props) => ( + {}} isPlain={props.isPlain}> + {props.searchInput} + {props.hasSearchDivider} + + {props.menuItems} + + + ) + } +); + +// static example, grouping components don't exist in Figma design +figma.connect( + Menu, + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/branch/Em2QWrHDxDS4LUxo58Hust/PatternFly-6--Components?node-id=2590-18585', + { + variant: { Menu: 'Titled Groups' }, + props: { + // ...sharedProps, + isPlain: figma.enum('Menu', { 'Plain Menu': true }) + }, + example: (props) => ( + {}} isPlain={props.isPlain}> + + + + + Link not in group + + + + + + + + Link 1 + + Link 2 + + + + + + + Link 1 + + + Link 2 + + + + + + ) + } +); + +// static example, grouping components don't exist in Figma design +const drilldownMenuModel = { + id: 'drilldown-drilldownMenuStart', + children: ( + + + Start rollout + + + + + Application grouping + + + Group A + Group B + Group C + + } + > + Application grouping + + Count + + + Labels + + + Label 1 + Label 2 + Label 3 + + } + > + Labels + + Annotations + + ) +}; + +figma.connect( + Menu, + 'https://www.figma.com/design/aEBBvq0J3EPXxHvv6WgDx9/PatternFly-6--Components-Test?node-id=2590-18585', + { + variant: { Menu: 'Drill Down Start' }, + props: { + ...drilldownMenuModel, + + // boolean + showSearchInput: figma.boolean('Show search input', { + true: true, + false: undefined + }), + + // enum + isPlain: figma.enum('Menu', { 'Plain Menu': true }), + actions: figma.enum('Menu', { + 'With Actions': ( + } actionId="code" onClick={() => {}} aria-label="Code" /> + ) + }), + onSelect: figma.enum('Menu', { 'Option Select': () => {} }), + drilldown: figma.enum('Menu', { + 'Drill Down Breadcrumbs': { + containsDrilldown: true, + drilldownItemPath: 'drilldownPath', + drilledInMenus: 'menuDrilledIn', + activeMenu: 'activeMenu', + onDrillIn: () => {}, + onDrillOut: () => {}, + drilldownMenu: drilldownMenuModel, + onGetMenuHeight: () => {}, + onSelect: () => {} + }, + 'Drill Down Start': { + containsDrilldown: true, + drilldownItemPath: 'drilldownPath', + drilledInMenus: 'menuDrilledIn', + activeMenu: 'activeMenu', + onDrillIn: () => {}, + onDrillOut: () => {}, + drilldownMenu: drilldownMenuModel, + onGetMenuHeight: () => {}, + onSelect: () => {} + }, + 'Drill Down Return': { + containsDrilldown: true, + drilldownItemPath: 'drilldownPath', + drilledInMenus: 'menuDrilledIn', + activeMenu: 'activeMenu', + onDrillIn: () => {}, + onDrillOut: () => {}, + drilldownMenu: drilldownMenuModel, + onGetMenuHeight: () => {}, + onSelect: () => {} + } + }), + + children: figma.children('*') + }, + + example: (props) => ( + + + {props.children} + + + ) + } +); diff --git a/packages/code-connect/components/Menu/MenuItem.figma.tsx b/packages/code-connect/components/Menu/MenuItem.figma.tsx new file mode 100644 index 00000000000..d673e1ee5d7 --- /dev/null +++ b/packages/code-connect/components/Menu/MenuItem.figma.tsx @@ -0,0 +1,125 @@ +import figma from '@figma/code-connect'; +import { Divider, MenuItem, MenuItemAction, MenuFooter } from '@patternfly/react-core'; +// import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; +import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; +import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; + +// TODO: File bug with Figma CC. The description prop is not working as expected. Strings behind boolean props are working in other components, however they +// do not work here. My assumption is that prepending/appending periods to the string is causing the issue and as a matter of consistency, should not be used. +// TODO: DESIGN: "Show Descr. has a trailing space in the prop. Remove trailing space. +// doesn't but should +// description: figma.boolean('Show Descr. ', { +// true: 'This is a description', +// false: undefined +// }), + +// Menu Item Separator +figma.connect( + MenuItem, + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/branch/Em2QWrHDxDS4LUxo58Hust/PatternFly-6--Components?node-id=2579-17546', + { + variant: { 'Menu Item': 'Separator' }, + props: {}, + example: () => + } +); + +// Menu Item Footer +figma.connect( + MenuFooter, + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/branch/Em2QWrHDxDS4LUxo58Hust/PatternFly-6--Components?node-id=2579-17546', + { + variant: { 'Menu Item': 'Footer' }, + props: { + children: figma.children('*') + }, + example: (props) => {props.children} + } +); + +// Base Menu Item +// Menu Item Group Header +figma.connect( + MenuItem, + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/branch/Em2QWrHDxDS4LUxo58Hust/PatternFly-6--Components?node-id=2579-17546', + { + props: { + // string + menuItemText: figma.string('Menu item Text'), + + // boolean + icon: figma.boolean('Show Leading Icon', { true: , false: undefined }), + action: figma.boolean('Show action icon', { true: , false: undefined }), + + // description: figma.boolean('showDescr', { true: figma.string('Descr. Text'), false: undefined }), + description: 'This is a description', // figma bug, cannot use string directly, needs to be wrapped in an object + + // enum + isDisabled: figma.enum('State', { Disabled: true }), + isDanger: figma.enum('Menu Item', { Danger: true }), + isExternalLink: figma.enum('Menu Item', { 'With external link on hover': true }), + actions: figma.boolean('Show action icon', { + true: ( + } + actionId="code" + // eslint-disable-next-line no-console + onClick={() => console.log('clicked on code icon')} + aria-label="Code" + /> + ), + false: undefined + }), + to: figma.enum('Menu Item', { 'With external link on hover': '#to-link' }) + }, + example: (props) => ( + + {props.menuItemText} + + ) + } +); + +figma.connect( + MenuItem, + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/PatternFly-6--Components?node-id=2579-17546', + { + variant: { 'Menu Item': 'Option Select' }, + props: { + menuItemText: figma.string('Menu item Text'), + hasCheckbox: figma.enum('Menu Item', { 'Checkbox select': true }), + + isSelected: figma.enum('State', { + Default: undefined, + Hover: undefined, + Selected: true, + Disabled: undefined + }), + + isDisabled: figma.enum('State', { Disabled: true }) + }, + example: (props) => ( + } + isSelected={props.isSelected} + isDisabled={props.isDisabled} + itemId="" + onSelect={() => {}} + role="listbox" + activeItemId="" + > + {props.menuItemText} + + ) + } +); diff --git a/packages/code-connect/components/Menu/MenuToggle.figma.tsx b/packages/code-connect/components/Menu/MenuToggle.figma.tsx new file mode 100644 index 00000000000..060ac712b30 --- /dev/null +++ b/packages/code-connect/components/Menu/MenuToggle.figma.tsx @@ -0,0 +1,58 @@ +import figma from '@figma/code-connect'; +import { Avatar, MenuToggle } from '@patternfly/react-core'; +import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg'; +import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; + +// Documentation for MenuToggle can be found at https://www.patternfly.org/components/menu-toggle + +figma.connect( + MenuToggle, + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/PatternFly-6--Components?node-id=7829-30614', + { + props: { + // boolean + hasCheckbox: figma.boolean('Show Checkbox'), + showAvatar: figma.boolean('Show Avatar', { + true: , + false: undefined + }), + showBadge: figma.boolean('Show Badge', { + true: figma.children('Badge'), + false: undefined + }), + showCustomIcon: figma.boolean('Show Custom Icon', { + true: , + false: undefined + }), + toggleText: figma.boolean('Toggle text', { + true: figma.string('✏️ Toggle Text'), + false: undefined + }), + + // enum + isDisabled: figma.enum('State', { Disabled: true }), + status: figma.enum('State', { + Danger: 'danger', + Warning: 'warning', + Success: 'success' + }), + variant: figma.enum('Style', { + 'Plain - Icon': 'plain', + 'Plain text': 'plainText' + }) + }, + example: (props) => ( + + {props.toggleText} + + ) + } +); diff --git a/packages/code-connect/components/Menu/MenuToggleWithButtonStyle.figma.tsx b/packages/code-connect/components/Menu/MenuToggleWithButtonStyle.figma.tsx new file mode 100644 index 00000000000..b2b4d6157d2 --- /dev/null +++ b/packages/code-connect/components/Menu/MenuToggleWithButtonStyle.figma.tsx @@ -0,0 +1,49 @@ +import figma from '@figma/code-connect'; +import { Avatar, MenuToggle } from '@patternfly/react-core'; +import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg'; +import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; + +// Documentation for MenuToggle can be found at https://www.patternfly.org/components/menu-toggle-with-button-style + +figma.connect( + MenuToggle, + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/PatternFly-6--Components?node-id=36729-9067', + { + props: { + // boolean + hasCheckbox: figma.boolean('Show Checkbox'), + showBadge: figma.boolean('Show Badge', { + true: figma.children('Badge'), + false: undefined + }), + showCustomIcon: figma.boolean('Show Custom Icon', { + true: , + false: undefined + }), + showAvatar: figma.boolean('Show Avatar', { + true: , + false: undefined + }), + toggleText: figma.boolean('Toggle text', { + true: figma.string('✏️ Toggle Text'), + false: undefined + }), + + // enum + isDisabled: figma.enum('State', { Disabled: true }), + isSelected: figma.enum('State', { Selected: true }) + }, + example: (props) => ( + + {props.toggleText} + + ) + } +); diff --git a/packages/code-connect/components/Menu/MenuTypeaheadToggle.figma.tsx b/packages/code-connect/components/Menu/MenuTypeaheadToggle.figma.tsx new file mode 100644 index 00000000000..a94efd90753 --- /dev/null +++ b/packages/code-connect/components/Menu/MenuTypeaheadToggle.figma.tsx @@ -0,0 +1,46 @@ +import figma from '@figma/code-connect'; +import { MenuToggle, Avatar } from '@patternfly/react-core'; +import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; + +// Documentation for MenuToggle can be found at https://www.patternfly.org/components/menu-typeahead-toggle + +figma.connect( + MenuToggle, + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/PatternFly-6--Components?node-id=36729-9027', + { + props: { + // boolean + hasCheckbox: figma.boolean('Show Checkbox'), + showBadge: figma.boolean('Show Badge', { + true: figma.children('Badge'), + false: undefined + }), + showCustomIcon: figma.boolean('Show Custom Icon', { + true: , + false: undefined + }), + showAvatar: figma.boolean('Show Avatar', { + true: , + false: undefined + }), + toggleText: figma.boolean('Toggle text', { + true: figma.string('✏️ Toggle Text'), + false: undefined + }), + + // enum + isSelected: figma.enum('State', { Selected: true }) + }, + example: (props) => ( + + {props.toggleText} + + ) + } +); diff --git a/packages/code-connect/figma.config.json b/packages/code-connect/figma.config.json index 2537e14be2b..3e77f3d990b 100644 --- a/packages/code-connect/figma.config.json +++ b/packages/code-connect/figma.config.json @@ -1,13 +1,9 @@ { "codeConnect": { - "parser": "react", - "include": [ - "components/DatePicker/*.tsx", - "components/EmptyState/*.tsx", - "components/FileUpload/*.tsx", - "components/Hint/*.tsx", - "components/InlineEdit/*.tsx" - ], + "include": ["components/Menu/*.tsx"], + "documentUrlSubstitutions": { + "https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/PatternFly-6--Components": "https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/branch/Em2QWrHDxDS4LUxo58Hust/PatternFly-6--Components" + }, "paths": { "src/components": "src/components" }, @@ -30,4 +26,4 @@ } } } -} \ No newline at end of file +}