|
| 1 | +import figma from '@figma/code-connect'; |
| 2 | +import { Label, LabelGroup } from '@patternfly/react-core'; |
| 3 | + |
| 4 | +// Documentation for LabelGroups can be found at https://www.patternfly.org/components/label |
| 5 | + |
| 6 | +const sharedProps = { |
| 7 | + closableLabels: ( |
| 8 | + <> |
| 9 | + <Label onClose={() => {}}>Label</Label> |
| 10 | + <Label onClose={() => {}}>Label</Label> |
| 11 | + <Label onClose={() => {}}>Label</Label> |
| 12 | + <Label onClose={() => {}}>Label</Label> |
| 13 | + <Label onClose={() => {}}>Label</Label> |
| 14 | + <Label onClose={() => {}}>Label</Label> |
| 15 | + <Label onClose={() => {}}>Label</Label> |
| 16 | + <Label onClose={() => {}}>Label</Label> |
| 17 | + <Label onClose={() => {}}>Label</Label> |
| 18 | + </> |
| 19 | + ), |
| 20 | + editableLabels: ( |
| 21 | + <> |
| 22 | + <Label |
| 23 | + color="grey" |
| 24 | + isCompact |
| 25 | + onClose={() => {}} |
| 26 | + closeBtnAriaLabel="Custom close button for compact editable label" |
| 27 | + onEditCancel={() => {}} |
| 28 | + onEditComplete={() => {}} |
| 29 | + isEditable |
| 30 | + editableProps={{ |
| 31 | + 'aria-label': `Editable compact label with text`, |
| 32 | + id: 'compact-editable-label1' |
| 33 | + }} |
| 34 | + > |
| 35 | + Label |
| 36 | + </Label> |
| 37 | + <Label |
| 38 | + color="grey" |
| 39 | + isCompact |
| 40 | + onClose={() => {}} |
| 41 | + closeBtnAriaLabel="Custom close button for compact editable label" |
| 42 | + onEditCancel={() => {}} |
| 43 | + onEditComplete={() => {}} |
| 44 | + isEditable |
| 45 | + editableProps={{ |
| 46 | + 'aria-label': `Editable compact label with text`, |
| 47 | + id: 'compact-editable-label1' |
| 48 | + }} |
| 49 | + > |
| 50 | + Label |
| 51 | + </Label> |
| 52 | + <Label |
| 53 | + color="grey" |
| 54 | + isCompact |
| 55 | + onClose={() => {}} |
| 56 | + closeBtnAriaLabel="Custom close button for compact editable label" |
| 57 | + onEditCancel={() => {}} |
| 58 | + onEditComplete={() => {}} |
| 59 | + isEditable |
| 60 | + editableProps={{ |
| 61 | + 'aria-label': `Editable compact label with text`, |
| 62 | + id: 'compact-editable-label2' |
| 63 | + }} |
| 64 | + > |
| 65 | + Label |
| 66 | + </Label> |
| 67 | + <Label |
| 68 | + color="grey" |
| 69 | + isCompact |
| 70 | + onClose={() => {}} |
| 71 | + closeBtnAriaLabel="Custom close button for compact editable label" |
| 72 | + onEditCancel={() => {}} |
| 73 | + onEditComplete={() => {}} |
| 74 | + isEditable |
| 75 | + editableProps={{ |
| 76 | + 'aria-label': `Editable compact label with text`, |
| 77 | + id: 'compact-editable-label3' |
| 78 | + }} |
| 79 | + > |
| 80 | + Label |
| 81 | + </Label> |
| 82 | + <Label |
| 83 | + color="grey" |
| 84 | + isCompact |
| 85 | + onClose={() => {}} |
| 86 | + closeBtnAriaLabel="Custom close button for compact editable label" |
| 87 | + onEditCancel={() => {}} |
| 88 | + onEditComplete={() => {}} |
| 89 | + isEditable |
| 90 | + editableProps={{ |
| 91 | + 'aria-label': `Editable compact label with text`, |
| 92 | + id: 'compact-editable-label4' |
| 93 | + }} |
| 94 | + > |
| 95 | + Label |
| 96 | + </Label> |
| 97 | + <Label |
| 98 | + color="grey" |
| 99 | + isCompact |
| 100 | + onClose={() => {}} |
| 101 | + closeBtnAriaLabel="Custom close button for compact editable label" |
| 102 | + onEditCancel={() => {}} |
| 103 | + onEditComplete={() => {}} |
| 104 | + isEditable |
| 105 | + editableProps={{ |
| 106 | + 'aria-label': `Editable compact label with text`, |
| 107 | + id: 'compact-editable-label5' |
| 108 | + }} |
| 109 | + > |
| 110 | + Label |
| 111 | + </Label> |
| 112 | + <Label |
| 113 | + color="grey" |
| 114 | + isCompact |
| 115 | + onClose={() => {}} |
| 116 | + closeBtnAriaLabel="Custom close button for compact editable label" |
| 117 | + onEditCancel={() => {}} |
| 118 | + onEditComplete={() => {}} |
| 119 | + isEditable |
| 120 | + editableProps={{ |
| 121 | + 'aria-label': `Editable compact label with text`, |
| 122 | + id: 'compact-editable-label6' |
| 123 | + }} |
| 124 | + > |
| 125 | + Label |
| 126 | + </Label> |
| 127 | + <Label |
| 128 | + color="grey" |
| 129 | + isCompact |
| 130 | + onClose={() => {}} |
| 131 | + closeBtnAriaLabel="Custom close button for compact editable label" |
| 132 | + onEditCancel={() => {}} |
| 133 | + onEditComplete={() => {}} |
| 134 | + isEditable |
| 135 | + editableProps={{ |
| 136 | + 'aria-label': `Editable compact label with text`, |
| 137 | + id: 'compact-editable-label7' |
| 138 | + }} |
| 139 | + > |
| 140 | + Label |
| 141 | + </Label> |
| 142 | + <Label |
| 143 | + color="grey" |
| 144 | + isCompact |
| 145 | + onClose={() => {}} |
| 146 | + closeBtnAriaLabel="Custom close button for compact editable label" |
| 147 | + onEditCancel={() => {}} |
| 148 | + onEditComplete={() => {}} |
| 149 | + isEditable |
| 150 | + editableProps={{ |
| 151 | + 'aria-label': `Editable compact label with text`, |
| 152 | + id: 'compact-editable-label8' |
| 153 | + }} |
| 154 | + > |
| 155 | + Label |
| 156 | + </Label> |
| 157 | + </> |
| 158 | + ) |
| 159 | +}; |
| 160 | + |
| 161 | +figma.connect( |
| 162 | + LabelGroup, |
| 163 | + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/PatternFly-6--Components?node-id=2800-1075', |
| 164 | + { |
| 165 | + props: { |
| 166 | + ...sharedProps, |
| 167 | + // boolean |
| 168 | + numLabels: figma.boolean('Has collapsed labels', { |
| 169 | + true: 6, |
| 170 | + false: undefined |
| 171 | + }), |
| 172 | + |
| 173 | + // enum |
| 174 | + addLabelControl: figma.enum('Type', { |
| 175 | + 'Label management': ( |
| 176 | + <Label variant="add" onClick={() => {}}> |
| 177 | + Add label |
| 178 | + </Label> |
| 179 | + ) |
| 180 | + }) |
| 181 | + }, |
| 182 | + example: (props) => ( |
| 183 | + <LabelGroup |
| 184 | + addLabelControl={props.addLabelControl} |
| 185 | + categoryName="Group label" |
| 186 | + isClosable |
| 187 | + numLabels={props.numLabels} |
| 188 | + onClick={() => {}} |
| 189 | + > |
| 190 | + {props.closableLabels} |
| 191 | + </LabelGroup> |
| 192 | + ) |
| 193 | + } |
| 194 | +); |
| 195 | + |
| 196 | +figma.connect( |
| 197 | + LabelGroup, |
| 198 | + 'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/PatternFly-6--Components?node-id=2800-1075', |
| 199 | + { |
| 200 | + variant: { Type: 'Label management' }, |
| 201 | + props: { |
| 202 | + ...sharedProps, |
| 203 | + // boolean |
| 204 | + numLabels: figma.boolean('Has collapsed labels', { |
| 205 | + true: 6, |
| 206 | + false: undefined |
| 207 | + }), |
| 208 | + |
| 209 | + // enum |
| 210 | + addLabelControl: figma.enum('Type', { |
| 211 | + 'Label management': ( |
| 212 | + <Label variant="add" onClick={() => {}}> |
| 213 | + Add label |
| 214 | + </Label> |
| 215 | + ) |
| 216 | + }) |
| 217 | + }, |
| 218 | + example: (props) => ( |
| 219 | + <LabelGroup |
| 220 | + addLabelControl={props.addLabelControl} |
| 221 | + categoryName="Group label" |
| 222 | + isClosable |
| 223 | + numLabels={props.numLabels} |
| 224 | + onClick={() => {}} |
| 225 | + > |
| 226 | + {props.editableLabels} |
| 227 | + </LabelGroup> |
| 228 | + ) |
| 229 | + } |
| 230 | +); |
0 commit comments