@patternfly/react-core 6.3.0-prerelease.20 → 6.3.0-prerelease.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/components/package.json +1 -1
  3. package/deprecated/package.json +1 -1
  4. package/dist/dynamic/components/AboutModal/package.json +1 -1
  5. package/dist/dynamic/components/Accordion/package.json +1 -1
  6. package/dist/dynamic/components/ActionList/package.json +1 -1
  7. package/dist/dynamic/components/Alert/package.json +1 -1
  8. package/dist/dynamic/components/Avatar/package.json +1 -1
  9. package/dist/dynamic/components/BackToTop/package.json +1 -1
  10. package/dist/dynamic/components/Backdrop/package.json +1 -1
  11. package/dist/dynamic/components/BackgroundImage/package.json +1 -1
  12. package/dist/dynamic/components/Badge/package.json +1 -1
  13. package/dist/dynamic/components/Banner/package.json +1 -1
  14. package/dist/dynamic/components/Brand/package.json +1 -1
  15. package/dist/dynamic/components/Breadcrumb/package.json +1 -1
  16. package/dist/dynamic/components/Button/package.json +1 -1
  17. package/dist/dynamic/components/CalendarMonth/package.json +1 -1
  18. package/dist/dynamic/components/Card/package.json +1 -1
  19. package/dist/dynamic/components/Checkbox/package.json +1 -1
  20. package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
  21. package/dist/dynamic/components/CodeBlock/package.json +1 -1
  22. package/dist/dynamic/components/Content/package.json +1 -1
  23. package/dist/dynamic/components/DataList/package.json +1 -1
  24. package/dist/dynamic/components/DatePicker/package.json +1 -1
  25. package/dist/dynamic/components/DescriptionList/package.json +1 -1
  26. package/dist/dynamic/components/Divider/package.json +1 -1
  27. package/dist/dynamic/components/Drawer/package.json +1 -1
  28. package/dist/dynamic/components/Dropdown/package.json +1 -1
  29. package/dist/dynamic/components/DualListSelector/package.json +1 -1
  30. package/dist/dynamic/components/EmptyState/package.json +1 -1
  31. package/dist/dynamic/components/ExpandableSection/package.json +1 -1
  32. package/dist/dynamic/components/FileUpload/package.json +1 -1
  33. package/dist/dynamic/components/Form/package.json +1 -1
  34. package/dist/dynamic/components/FormSelect/package.json +1 -1
  35. package/dist/dynamic/components/HelperText/package.json +1 -1
  36. package/dist/dynamic/components/Hint/package.json +1 -1
  37. package/dist/dynamic/components/Icon/package.json +1 -1
  38. package/dist/dynamic/components/InputGroup/package.json +1 -1
  39. package/dist/dynamic/components/JumpLinks/package.json +1 -1
  40. package/dist/dynamic/components/Label/package.json +1 -1
  41. package/dist/dynamic/components/List/package.json +1 -1
  42. package/dist/dynamic/components/LoginPage/package.json +1 -1
  43. package/dist/dynamic/components/Masthead/package.json +1 -1
  44. package/dist/dynamic/components/Menu/package.json +1 -1
  45. package/dist/dynamic/components/MenuToggle/package.json +1 -1
  46. package/dist/dynamic/components/Modal/package.json +1 -1
  47. package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
  48. package/dist/dynamic/components/Nav/package.json +1 -1
  49. package/dist/dynamic/components/NotificationBadge/package.json +1 -1
  50. package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
  51. package/dist/dynamic/components/NumberInput/package.json +1 -1
  52. package/dist/dynamic/components/OverflowMenu/package.json +1 -1
  53. package/dist/dynamic/components/Page/package.json +1 -1
  54. package/dist/dynamic/components/Pagination/package.json +1 -1
  55. package/dist/dynamic/components/Panel/package.json +1 -1
  56. package/dist/dynamic/components/Popover/package.json +1 -1
  57. package/dist/dynamic/components/Progress/package.json +1 -1
  58. package/dist/dynamic/components/ProgressStepper/package.json +1 -1
  59. package/dist/dynamic/components/Radio/package.json +1 -1
  60. package/dist/dynamic/components/SearchInput/package.json +1 -1
  61. package/dist/dynamic/components/Select/package.json +1 -1
  62. package/dist/dynamic/components/Sidebar/package.json +1 -1
  63. package/dist/dynamic/components/SimpleList/package.json +1 -1
  64. package/dist/dynamic/components/Skeleton/package.json +1 -1
  65. package/dist/dynamic/components/SkipToContent/package.json +1 -1
  66. package/dist/dynamic/components/Slider/package.json +1 -1
  67. package/dist/dynamic/components/Spinner/package.json +1 -1
  68. package/dist/dynamic/components/Switch/package.json +1 -1
  69. package/dist/dynamic/components/Tabs/package.json +1 -1
  70. package/dist/dynamic/components/TextArea/package.json +1 -1
  71. package/dist/dynamic/components/TextInput/package.json +1 -1
  72. package/dist/dynamic/components/TextInputGroup/package.json +1 -1
  73. package/dist/dynamic/components/TimePicker/package.json +1 -1
  74. package/dist/dynamic/components/Timestamp/package.json +1 -1
  75. package/dist/dynamic/components/Title/package.json +1 -1
  76. package/dist/dynamic/components/ToggleGroup/package.json +1 -1
  77. package/dist/dynamic/components/Toolbar/package.json +1 -1
  78. package/dist/dynamic/components/Tooltip/package.json +1 -1
  79. package/dist/dynamic/components/TreeView/package.json +1 -1
  80. package/dist/dynamic/components/Truncate/package.json +1 -1
  81. package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
  82. package/dist/dynamic/components/Wizard/package.json +1 -1
  83. package/dist/dynamic/deprecated/components/Chip/package.json +1 -1
  84. package/dist/dynamic/deprecated/components/DragDrop/package.json +1 -1
  85. package/dist/dynamic/deprecated/components/DualListSelector/package.json +1 -1
  86. package/dist/dynamic/deprecated/components/Modal/package.json +1 -1
  87. package/dist/dynamic/deprecated/components/Tile/package.json +1 -1
  88. package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
  89. package/dist/dynamic/deprecated/components/package.json +1 -1
  90. package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
  91. package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
  92. package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
  93. package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
  94. package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
  95. package/dist/dynamic/helpers/constants/package.json +1 -1
  96. package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
  97. package/dist/dynamic/helpers/fileUtils/package.json +1 -1
  98. package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
  99. package/dist/dynamic/helpers/package.json +1 -1
  100. package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
  101. package/dist/dynamic/helpers/typeUtils/package.json +1 -1
  102. package/dist/dynamic/helpers/useInterval/package.json +1 -1
  103. package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
  104. package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
  105. package/dist/dynamic/helpers/util/package.json +1 -1
  106. package/dist/dynamic/layouts/Bullseye/package.json +1 -1
  107. package/dist/dynamic/layouts/Flex/package.json +1 -1
  108. package/dist/dynamic/layouts/Gallery/package.json +1 -1
  109. package/dist/dynamic/layouts/Grid/package.json +1 -1
  110. package/dist/dynamic/layouts/Level/package.json +1 -1
  111. package/dist/dynamic/layouts/Split/package.json +1 -1
  112. package/dist/dynamic/layouts/Stack/package.json +1 -1
  113. package/dist/dynamic/styles/package.json +1 -1
  114. package/dist/esm/components/Button/Button.d.ts +8 -0
  115. package/dist/esm/components/Button/Button.d.ts.map +1 -1
  116. package/dist/esm/components/Button/Button.js +18 -5
  117. package/dist/esm/components/Button/Button.js.map +1 -1
  118. package/dist/esm/components/Button/hamburgerIcon.d.ts +2 -0
  119. package/dist/esm/components/Button/hamburgerIcon.d.ts.map +1 -0
  120. package/dist/esm/components/Button/hamburgerIcon.js +7 -0
  121. package/dist/esm/components/Button/hamburgerIcon.js.map +1 -0
  122. package/dist/esm/components/ClipboardCopy/ClipboardCopyToggle.js +1 -1
  123. package/dist/esm/components/ClipboardCopy/ClipboardCopyToggle.js.map +1 -1
  124. package/dist/esm/components/MenuToggle/MenuToggle.d.ts +2 -0
  125. package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  126. package/dist/esm/components/MenuToggle/MenuToggle.js +4 -3
  127. package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
  128. package/dist/esm/components/Page/PageToggleButton.d.ts +4 -0
  129. package/dist/esm/components/Page/PageToggleButton.d.ts.map +1 -1
  130. package/dist/esm/components/Page/PageToggleButton.js +2 -2
  131. package/dist/esm/components/Page/PageToggleButton.js.map +1 -1
  132. package/dist/esm/demos/DashboardHeader.d.ts.map +1 -1
  133. package/dist/esm/demos/DashboardHeader.js +1 -2
  134. package/dist/esm/demos/DashboardHeader.js.map +1 -1
  135. package/dist/js/components/Button/Button.d.ts +8 -0
  136. package/dist/js/components/Button/Button.d.ts.map +1 -1
  137. package/dist/js/components/Button/Button.js +18 -5
  138. package/dist/js/components/Button/Button.js.map +1 -1
  139. package/dist/js/components/Button/hamburgerIcon.d.ts +2 -0
  140. package/dist/js/components/Button/hamburgerIcon.d.ts.map +1 -0
  141. package/dist/js/components/Button/hamburgerIcon.js +11 -0
  142. package/dist/js/components/Button/hamburgerIcon.js.map +1 -0
  143. package/dist/js/components/ClipboardCopy/ClipboardCopyToggle.js +1 -1
  144. package/dist/js/components/ClipboardCopy/ClipboardCopyToggle.js.map +1 -1
  145. package/dist/js/components/MenuToggle/MenuToggle.d.ts +2 -0
  146. package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  147. package/dist/js/components/MenuToggle/MenuToggle.js +4 -3
  148. package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
  149. package/dist/js/components/Page/PageToggleButton.d.ts +4 -0
  150. package/dist/js/components/Page/PageToggleButton.d.ts.map +1 -1
  151. package/dist/js/components/Page/PageToggleButton.js +2 -2
  152. package/dist/js/components/Page/PageToggleButton.js.map +1 -1
  153. package/dist/js/demos/DashboardHeader.d.ts.map +1 -1
  154. package/dist/js/demos/DashboardHeader.js +1 -2
  155. package/dist/js/demos/DashboardHeader.js.map +1 -1
  156. package/dist/styles/base-no-reset.css +41 -0
  157. package/dist/styles/base.css +41 -0
  158. package/dist/umd/assets/{output-DzgMn5vn.css → output-BDZoYci_.css} +12340 -12278
  159. package/dist/umd/react-core.min.js +3 -3
  160. package/helpers/package.json +1 -1
  161. package/layouts/package.json +1 -1
  162. package/next/package.json +1 -1
  163. package/package.json +6 -6
  164. package/src/components/Button/Button.tsx +34 -4
  165. package/src/components/Button/__tests__/Button.test.tsx +373 -92
  166. package/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +1 -1
  167. package/src/components/Button/examples/Button.md +49 -13
  168. package/src/components/Button/examples/ButtonHamburger.tsx +9 -0
  169. package/src/components/Button/examples/ButtonSettings.tsx +10 -0
  170. package/src/components/Button/hamburgerIcon.tsx +13 -0
  171. package/src/components/ClipboardCopy/ClipboardCopyToggle.tsx +1 -1
  172. package/src/components/ClipboardCopy/__tests__/ClipboardCopyToggle.test.tsx +7 -1
  173. package/src/components/ClipboardCopy/__tests__/__snapshots__/ClipboardCopyToggle.test.tsx.snap +0 -1
  174. package/src/components/Masthead/examples/MastheadBasic.tsx +1 -2
  175. package/src/components/Masthead/examples/MastheadBasicMixedContent.tsx +1 -2
  176. package/src/components/Masthead/examples/MastheadDisplayInline.tsx +1 -2
  177. package/src/components/Masthead/examples/MastheadDisplayStack.tsx +1 -2
  178. package/src/components/Masthead/examples/MastheadDisplayStackInlineResponsive.tsx +1 -2
  179. package/src/components/Masthead/examples/MastheadInsets.tsx +1 -2
  180. package/src/components/Masthead/examples/MastheadLogoCustomComponent.tsx +1 -2
  181. package/src/components/MenuToggle/MenuToggle.tsx +6 -1
  182. package/src/components/MenuToggle/__tests__/MenuToggle.test.tsx +59 -45
  183. package/src/components/MenuToggle/__tests__/__snapshots__/MenuToggle.test.tsx.snap +9 -9
  184. package/src/components/MenuToggle/examples/MenuToggle.md +14 -30
  185. package/src/components/MenuToggle/examples/MenuToggleCustomIcon.tsx +17 -0
  186. package/src/components/MenuToggle/examples/MenuToggleSettings.tsx +8 -0
  187. package/src/components/Page/PageToggleButton.tsx +9 -2
  188. package/src/components/Page/examples/PageCenteredSection.tsx +2 -5
  189. package/src/components/Page/examples/PageGroupSection.tsx +2 -5
  190. package/src/components/Page/examples/PageMainSectionPadding.tsx +2 -5
  191. package/src/components/Page/examples/PageMainSectionVariations.tsx +2 -5
  192. package/src/components/Page/examples/PageMultipleSidebarBody.tsx +2 -5
  193. package/src/components/Page/examples/PageUncontrolledNav.tsx +1 -4
  194. package/src/components/Page/examples/PageVerticalNav.tsx +2 -5
  195. package/src/components/Page/examples/PageWithOrWithoutFill.tsx +2 -5
  196. package/src/demos/DashboardHeader.tsx +2 -5
  197. package/src/demos/NotificationDrawer/examples/NotificationDrawerBasic.tsx +2 -5
  198. package/src/demos/NotificationDrawer/examples/NotificationDrawerGrouped.tsx +2 -5
  199. package/src/demos/RTL/examples/PaginatedTable.tsx +2 -9
  200. package/src/demos/examples/Masthead/MastheadWithHorizontalNav.tsx +1 -1
  201. package/src/demos/examples/Masthead/MastheadWithUtilitiesAndUserDropdownMenu.tsx +2 -5
  202. package/src/demos/examples/Nav/NavFlyout.tsx +3 -6
  203. package/src/demos/examples/Nav/NavHorizontal.tsx +1 -1
  204. package/src/demos/examples/Nav/NavHorizontalWithSubnav.tsx +2 -5
  205. package/src/demos/examples/Nav/NavManual.tsx +3 -6
  206. package/src/demos/examples/Page/PageContextSelector.tsx +3 -6
  207. package/src/demos/examples/Page/PageStickySectionBreadcrumb.tsx +2 -5
  208. package/src/demos/examples/Page/PageStickySectionGroup.tsx +2 -5
  209. package/src/demos/examples/Page/PageStickySectionGroupAlternate.tsx +2 -5
  210. package/src/demos/examples/Toolbar/ConsoleLogViewerToolbar.tsx +2 -3
  211. package/src/demos/examples/Wizard/InPageWithDrawer.tsx +1 -4
  212. package/src/demos/examples/Wizard/InPageWithDrawerInformationalStep.tsx +1 -4
@@ -23,25 +23,27 @@ import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-
23
23
  PatternFly supports several button styling variants to be used in different scenarios as needed. The following button variants can be assigned using the `variant` property.
24
24
 
25
25
  ```ts file="./ButtonVariations.tsx"
26
+
26
27
  ```
27
28
 
28
- | Variant | Description|
29
- | --- | ---|
30
- | Primary | Primary buttons are the most visually prominent variant. Use for the most important call to action.|
31
- | Secondary | Secondary buttons are less visually prominant than primary buttons. Use for general actions on a page that require less emphasis than primary buttons. |
32
- | Tertiary | Tertiary buttons are the least visually prominent variant. Use to retain a classic button format with less emphasis than primary or secondary buttons. |
33
- | Danger | Danger buttons may be used for actions that are potentially destructive or difficult/impossible to undo. Danger is an independent variant, but all button variants may use the the `isDanger` property to apply similar styling. |
34
- | Warning | Warning buttons may be used for actions that change an important setting or behavior, but not in a destructive or irreversible way. |
35
- | Link | Links are labeled, but have no background or border. Use for actions that require less emphasis, actions that navigate users to another page within the same window, and/or actions that navigate to external pages in a new window. Links may be placed inline with text using the `isInline` property.|
36
- | Plain | Plain buttons have no styling and are intended to be labeled with icons. |
37
- | Control | Control buttons can be labeled with text or icons. Primarily intended to be paired with other controls in an [input group](/components/input-group). |
38
- | Stateful | Stateful buttons are ideal for displaying the state of notifications. They have 3 states: `read`, `unread` and `attention`.
29
+ | Variant | Description |
30
+ | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
31
+ | Primary | Primary buttons are the most visually prominent variant. Use for the most important call to action. |
32
+ | Secondary | Secondary buttons are less visually prominant than primary buttons. Use for general actions on a page that require less emphasis than primary buttons. |
33
+ | Tertiary | Tertiary buttons are the least visually prominent variant. Use to retain a classic button format with less emphasis than primary or secondary buttons. |
34
+ | Danger | Danger buttons may be used for actions that are potentially destructive or difficult/impossible to undo. Danger is an independent variant, but all button variants may use the the `isDanger` property to apply similar styling. |
35
+ | Warning | Warning buttons may be used for actions that change an important setting or behavior, but not in a destructive or irreversible way. |
36
+ | Link | Links are labeled, but have no background or border. Use for actions that require less emphasis, actions that navigate users to another page within the same window, and/or actions that navigate to external pages in a new window. Links may be placed inline with text using the `isInline` property. |
37
+ | Plain | Plain buttons have no styling and are intended to be labeled with icons. |
38
+ | Control | Control buttons can be labeled with text or icons. Primarily intended to be paired with other controls in an [input group](/components/input-group). |
39
+ | Stateful | Stateful buttons are ideal for displaying the state of notifications. They have 3 states: `read`, `unread` and `attention`. |
39
40
 
40
41
  ### Disabled buttons
41
42
 
42
43
  To indicate that an action is currently unavailable, all button variations can be disabled using the `isDisabled` property.
43
44
 
44
45
  ```ts file="./ButtonDisabled.tsx"
46
+
45
47
  ```
46
48
 
47
49
  ### Small buttons
@@ -49,13 +51,15 @@ To indicate that an action is currently unavailable, all button variations can b
49
51
  To fit into tight spaces, primary, secondary, tertiary, danger, and warning button variations can be made smaller using the `"sm"` value for the `size` property.
50
52
 
51
53
  ```ts file="./ButtonSmall.tsx"
54
+
52
55
  ```
53
56
 
54
57
  ### Call to action (CTA) buttons
55
58
 
56
- CTA buttons and links direct users to complete an action. Primary, secondary, tertiary, and link button variants can be styled as CTAs using the `"lg"` value for the `size` property.
59
+ CTA buttons and links direct users to complete an action. Primary, secondary, tertiary, and link button variants can be styled as CTAs using the `"lg"` value for the `size` property.
57
60
 
58
61
  ```ts file="./ButtonCallToAction.tsx"
62
+
59
63
  ```
60
64
 
61
65
  ### Block level buttons
@@ -63,13 +67,15 @@ CTA buttons and links direct users to complete an action. Primary, secondary, te
63
67
  Block level buttons span the full width of the parent element and can be enabled using the `isBlock` property.
64
68
 
65
69
  ```ts file="./ButtonBlock.tsx"
70
+
66
71
  ```
67
72
 
68
73
  ### Progress indicators
69
74
 
70
- Progress indicators can be added to buttons to identify that an action is in progress after a click.
75
+ Progress indicators can be added to buttons to identify that an action is in progress after a click.
71
76
 
72
77
  ```ts file="./ButtonProgress.tsx"
78
+
73
79
  ```
74
80
 
75
81
  ### Links as buttons
@@ -77,6 +83,7 @@ Progress indicators can be added to buttons to identify that an action is in pro
77
83
  Buttons that link to another resource may take the form of primary, secondary, tertiary, or link variants. Use `component="a"` and an `href` property to designate the button's target link.
78
84
 
79
85
  ```ts file="./ButtonLinks.tsx"
86
+
80
87
  ```
81
88
 
82
89
  ### Inline link as span
@@ -84,6 +91,7 @@ Buttons that link to another resource may take the form of primary, secondary, t
84
91
  Inline links should use `component="span"` and the `isInline` property to wrap inline with surrounding text.
85
92
 
86
93
  ```ts file="./ButtonInlineSpanLink.tsx"
94
+
87
95
  ```
88
96
 
89
97
  ### Custom component
@@ -91,6 +99,7 @@ Inline links should use `component="span"` and the `isInline` property to wrap i
91
99
  In addition to being able to pass a string to the `component` property, you can provide more fine-tuned customization by passing a callback that returns a component.
92
100
 
93
101
  ```ts file="./ButtonCustomComponent.tsx"
102
+
94
103
  ```
95
104
 
96
105
  ### Aria-disabled examples
@@ -102,6 +111,7 @@ Buttons that are aria-disabled are similar to normal disabled buttons, except th
102
111
  Unlike normal disabled buttons, aria-disabled buttons can support tooltips. Furthermore, aria-disabled buttons can operate as links, which also support tooltips.
103
112
 
104
113
  ```ts file="./ButtonAriaDisabled.tsx"
114
+
105
115
  ```
106
116
 
107
117
  ### Button with count
@@ -109,6 +119,7 @@ Unlike normal disabled buttons, aria-disabled buttons can support tooltips. Furt
109
119
  Buttons can display a `count` in the form of a badge to indicate some value or number by passing in the `countOptions` prop as a `BadgeCountObject` object. The `BadgeCountObject` object will handle `count`, `isRead`, and `className` props for the badge count.
110
120
 
111
121
  ```ts file="./ButtonWithCount.tsx"
122
+
112
123
  ```
113
124
 
114
125
  ### Plain with no padding
@@ -116,6 +127,7 @@ Buttons can display a `count` in the form of a badge to indicate some value or n
116
127
  To display a plain/icon button inline with text, use `noPadding` prop in addition to `variant="plain"`.
117
128
 
118
129
  ```ts file="./ButtonPlainHasNoPadding.tsx"
130
+
119
131
  ```
120
132
 
121
133
  ### Stateful
@@ -123,13 +135,37 @@ To display a plain/icon button inline with text, use `noPadding` prop in additio
123
135
  Stateful buttons are ideal for displaying the state of notifications. Use `variant="stateful"` alongside with the `state` property, which can have these 3 values: `read`, `unread` (used as default) and `attention` (which means unread and requires attention).
124
136
 
125
137
  ```ts file="./ButtonStateful.tsx"
138
+
126
139
  ```
127
140
 
141
+ ## Animated examples
142
+
143
+ The following `<Button>` implementations have animations built into them. When using one of the following implementations, the `icon` property will be overridden due to the animations needing specific icons internally.
144
+
128
145
  ### Favorite
129
146
 
130
147
  You can pass both the `isFavorite` and `variant="plain"` properties into the `<Button>` to create a favorite button. Passing the `isFavorited` property will determine the current favorited state and update styling accordingly.
131
148
 
132
149
  ```ts file = "./ButtonFavorite.tsx"
150
+
151
+ ```
152
+
153
+ ### Settings
154
+
155
+ For a "settings" button with animations on hover and focus, you can pass the `isSettings` property into either a `variant="plain"` or `variant="control"` button.
156
+
157
+ ```ts file="./ButtonSettings.tsx"
158
+
159
+ ```
160
+
161
+ ### Hamburger
162
+
163
+ For a "hamburger" button (`fa-bars`) that will animate based on the `hamburgerVariant` property, you can pass the `isHamburger` property. This will render the default icon for a hamburger button, and updating the `hamburgerVariant` property with a value of either "expand" or "collapse" will change the icon accordingly with an animation on hover and focus.
164
+
165
+ When used within a PatternFly `<Masthead>`, the animations and icon updates will occur automatically. See one of our [full screen page demos](/components/page/react-demos) to see this in action.
166
+
167
+ ```ts file="./ButtonHamburger.tsx"
168
+
133
169
  ```
134
170
 
135
171
  ## Using router links
@@ -0,0 +1,9 @@
1
+ import { Button, Flex } from '@patternfly/react-core';
2
+
3
+ export const ButtonHamburger: React.FunctionComponent = () => (
4
+ <Flex>
5
+ <Button variant="plain" isExpanded={false} aria-label="Hamburger example" isHamburger />
6
+ <Button variant="plain" isExpanded={false} aria-label="Hamburger example" isHamburger hamburgerVariant="expand" />
7
+ <Button variant="plain" isExpanded={true} aria-label="Hamburger example" isHamburger hamburgerVariant="collapse" />
8
+ </Flex>
9
+ );
@@ -0,0 +1,10 @@
1
+ import { Button, Flex } from '@patternfly/react-core';
2
+
3
+ export const ButtonSettings: React.FunctionComponent = () => (
4
+ <Flex>
5
+ <Button isSettings variant="plain" aria-label="Settings" />
6
+ <Button isSettings variant="control">
7
+ Settings
8
+ </Button>
9
+ </Flex>
10
+ );
@@ -0,0 +1,13 @@
1
+ import styles from '@patternfly/react-styles/css/components/Button/button';
2
+ import { css } from '@patternfly/react-styles';
3
+
4
+ // Because this is such a specific icon that requires being wrapped in a pf-v[current version]-c-button element,
5
+ // we don't want to export this to consumers nor include it in the react-icons package as a custom icon.
6
+ export const hamburgerIcon = (
7
+ <svg viewBox="0 0 10 10" className="pf-v6-c-button--hamburger-icon pf-v6-svg" width="1em" height="1em">
8
+ <path className={css(styles.buttonHamburgerIconTop)} d="M1,1 L9,1"></path>
9
+ <path className={css(styles.buttonHamburgerIconMiddle)} d="M1,5 L9,5"></path>
10
+ <path className={css(styles.buttonHamburgerIconArrow)} d="M1,5 L1,5 L1,5"></path>
11
+ <path className={css(styles.buttonHamburgerIconBottom)} d="M9,9 L1,9"></path>
12
+ </svg>
13
+ );
@@ -27,7 +27,7 @@ export const ClipboardCopyToggle: React.FunctionComponent<ClipboardCopyTogglePro
27
27
  onClick={onClick}
28
28
  id={id}
29
29
  aria-labelledby={`${id} ${textId}`}
30
- aria-controls={contentId}
30
+ aria-controls={isExpanded ? contentId : undefined}
31
31
  aria-expanded={isExpanded}
32
32
  {...props}
33
33
  icon={
@@ -44,9 +44,15 @@ test('Renders with aria-labelledby concatenated from id and textId props', () =>
44
44
  expect(screen.getByRole('button')).toHaveAccessibleName('Toggle content Test content');
45
45
  });
46
46
 
47
- test('Renders with aria-controls with passed in contentId prop', () => {
47
+ test('Does not render with aria-controls when isExpanded is false', () => {
48
48
  render(<ClipboardCopyToggle {...requiredProps} />);
49
49
 
50
+ expect(screen.getByRole('button')).not.toHaveAttribute('aria-controls');
51
+ });
52
+
53
+ test('Renders with aria-controls with passed in contentId prop when isExpanded is true', () => {
54
+ render(<ClipboardCopyToggle isExpanded {...requiredProps} />);
55
+
50
56
  expect(screen.getByRole('button')).toHaveAttribute('aria-controls', requiredProps.contentId);
51
57
  });
52
58
 
@@ -3,7 +3,6 @@
3
3
  exports[`Matches snapshot 1`] = `
4
4
  <DocumentFragment>
5
5
  <button
6
- aria-controls="content-id"
7
6
  aria-expanded="false"
8
7
  aria-labelledby="main-id text-id"
9
8
  class="pf-v6-c-button pf-m-control"
@@ -7,13 +7,12 @@ import {
7
7
  MastheadContent,
8
8
  Button
9
9
  } from '@patternfly/react-core';
10
- import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
11
10
 
12
11
  export const MastheadBasic: React.FunctionComponent = () => (
13
12
  <Masthead id="basic-example">
14
13
  <MastheadMain>
15
14
  <MastheadToggle>
16
- <Button variant="plain" onClick={() => {}} aria-label="Global navigation" icon={<BarsIcon />} />
15
+ <Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
17
16
  </MastheadToggle>
18
17
  <MastheadBrand>
19
18
  <MastheadLogo component="a">Logo</MastheadLogo>
@@ -9,13 +9,12 @@ import {
9
9
  Flex,
10
10
  FlexItem
11
11
  } from '@patternfly/react-core';
12
- import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
13
12
 
14
13
  export const MastheadBasicMixedContent: React.FunctionComponent = () => (
15
14
  <Masthead id="basic-mixed">
16
15
  <MastheadMain>
17
16
  <MastheadToggle>
18
- <Button variant="plain" onClick={() => {}} aria-label="Global navigation" icon={<BarsIcon />} />
17
+ <Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
19
18
  </MastheadToggle>
20
19
  <MastheadBrand>
21
20
  <MastheadLogo component="a">Logo</MastheadLogo>
@@ -7,13 +7,12 @@ import {
7
7
  MastheadContent,
8
8
  Button
9
9
  } from '@patternfly/react-core';
10
- import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
11
10
 
12
11
  export const MastheadDisplayInline: React.FunctionComponent = () => (
13
12
  <Masthead id="inline-masthead" display={{ default: 'inline' }}>
14
13
  <MastheadMain>
15
14
  <MastheadToggle>
16
- <Button variant="plain" onClick={() => {}} aria-label="Global navigation" icon={<BarsIcon />} />
15
+ <Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
17
16
  </MastheadToggle>
18
17
  <MastheadBrand>
19
18
  <MastheadLogo component="a">Logo</MastheadLogo>
@@ -7,13 +7,12 @@ import {
7
7
  MastheadContent,
8
8
  Button
9
9
  } from '@patternfly/react-core';
10
- import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
11
10
 
12
11
  export const MastheadDisplayStack: React.FunctionComponent = () => (
13
12
  <Masthead id="stack-masthead" display={{ default: 'stack' }}>
14
13
  <MastheadMain>
15
14
  <MastheadToggle>
16
- <Button variant="plain" onClick={() => {}} aria-label="Global navigation" icon={<BarsIcon />} />
15
+ <Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
17
16
  </MastheadToggle>
18
17
  <MastheadBrand>
19
18
  <MastheadLogo component="a">Logo</MastheadLogo>
@@ -7,13 +7,12 @@ import {
7
7
  MastheadContent,
8
8
  Button
9
9
  } from '@patternfly/react-core';
10
- import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
11
10
 
12
11
  export const MastheadDisplayStackInlineResponsive: React.FunctionComponent = () => (
13
12
  <Masthead id="stack-inline-masthead" display={{ default: 'inline', lg: 'stack', '2xl': 'inline' }}>
14
13
  <MastheadMain>
15
14
  <MastheadToggle>
16
- <Button variant="plain" onClick={() => {}} aria-label="Global navigation" icon={<BarsIcon />} />
15
+ <Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
17
16
  </MastheadToggle>
18
17
  <MastheadBrand>
19
18
  <MastheadLogo component="a">Logo</MastheadLogo>
@@ -7,13 +7,12 @@ import {
7
7
  MastheadContent,
8
8
  Button
9
9
  } from '@patternfly/react-core';
10
- import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
11
10
 
12
11
  export const MastheadInsets: React.FunctionComponent = () => (
13
12
  <Masthead id="inset-masthead" inset={{ default: 'insetSm' }}>
14
13
  <MastheadMain>
15
14
  <MastheadToggle>
16
- <Button variant="plain" onClick={() => {}} aria-label="Global navigation" icon={<BarsIcon />} />
15
+ <Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
17
16
  </MastheadToggle>
18
17
  <MastheadBrand>
19
18
  <MastheadLogo component="a">Logo</MastheadLogo>
@@ -8,14 +8,13 @@ import {
8
8
  Button,
9
9
  Brand
10
10
  } from '@patternfly/react-core';
11
- import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
12
11
  import pfIcon from '../../assets/PF-HorizontalLogo-Color.svg';
13
12
 
14
13
  export const MastheadLogoCustomComponent: React.FunctionComponent = () => (
15
14
  <Masthead id="icon-router-link">
16
15
  <MastheadMain>
17
16
  <MastheadToggle>
18
- <Button variant="plain" onClick={() => {}} aria-label="Global navigation" icon={<BarsIcon />} />
17
+ <Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
19
18
  </MastheadToggle>
20
19
  <MastheadBrand>
21
20
  <MastheadLogo component={(props) => <a {...props} href="#" />}>
@@ -3,6 +3,7 @@ import styles from '@patternfly/react-styles/css/components/MenuToggle/menu-togg
3
3
  import { css } from '@patternfly/react-styles';
4
4
  import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
5
5
  import { BadgeProps } from '../Badge';
6
+ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
6
7
  import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
7
8
  import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
8
9
  import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
@@ -44,6 +45,8 @@ export interface MenuToggleProps
44
45
  isFullWidth?: boolean;
45
46
  /** Flag indicating the toggle contains placeholder text */
46
47
  isPlaceholder?: boolean;
48
+ /** Flag indicating whether the toggle is a settings toggle. This will override the icon property */
49
+ isSettings?: boolean;
47
50
  /** Elements to display before the toggle button. When included, renders the menu toggle as a split button. */
48
51
  splitButtonItems?: React.ReactNode[];
49
52
  /** Variant styles of the menu toggle */
@@ -100,6 +103,7 @@ class MenuToggleBase extends Component<MenuToggleProps, MenuToggleState> {
100
103
  isFullHeight,
101
104
  isFullWidth,
102
105
  isPlaceholder,
106
+ isSettings,
103
107
  splitButtonItems,
104
108
  variant,
105
109
  status,
@@ -144,7 +148,7 @@ class MenuToggleBase extends Component<MenuToggleProps, MenuToggleState> {
144
148
 
145
149
  const content = (
146
150
  <>
147
- {icon && <span className={css(styles.menuToggleIcon)}>{icon}</span>}
151
+ {(icon || isSettings) && <span className={css(styles.menuToggleIcon)}>{isSettings ? <CogIcon /> : icon}</span>}
148
152
  {isTypeahead ? children : children && <span className={css(styles.menuToggleText)}>{children}</span>}
149
153
  {isValidElement(badge) && <span className={css(styles.menuToggleCount)}>{badge}</span>}
150
154
  {isTypeahead ? (
@@ -177,6 +181,7 @@ class MenuToggleBase extends Component<MenuToggleProps, MenuToggleState> {
177
181
  isFullWidth && styles.modifiers.fullWidth,
178
182
  isDisabled && styles.modifiers.disabled,
179
183
  isPlaceholder && styles.modifiers.placeholder,
184
+ isSettings && styles.modifiers.settings,
180
185
  size === MenuToggleSize.sm && styles.modifiers.small,
181
186
  className
182
187
  );
@@ -8,7 +8,7 @@ import { render, screen } from '@testing-library/react';
8
8
  import styles from '@patternfly/react-styles/css/components/MenuToggle/menu-toggle';
9
9
  import '@testing-library/jest-dom';
10
10
 
11
- describe('menu toggle', () => {
11
+ describe('Old Snapshot tests - remove when refactoring', () => {
12
12
  test('renders successfully', () => {
13
13
  const { asFragment } = render(<MenuToggle>Toggle</MenuToggle>);
14
14
  expect(asFragment()).toMatchSnapshot();
@@ -53,54 +53,68 @@ describe('menu toggle', () => {
53
53
  const { asFragment } = render(<MenuToggle badge={<Badge>badge</Badge>}>Toggle</MenuToggle>);
54
54
  expect(asFragment()).toMatchSnapshot();
55
55
  });
56
+ });
56
57
 
57
- // Old snapshot tests end here; following tests should be kept when refactoring
58
- test(`Renders with class ${styles.modifiers.small} when size="sm" is passed`, () => {
59
- render(<MenuToggle size="sm">Toggle</MenuToggle>);
60
- expect(screen.getByRole('button')).toHaveClass(styles.modifiers.small);
61
- });
58
+ test(`Renders with class ${styles.modifiers.small} when size="sm" is passed`, () => {
59
+ render(<MenuToggle size="sm">Toggle</MenuToggle>);
60
+ expect(screen.getByRole('button')).toHaveClass(styles.modifiers.small);
61
+ });
62
62
 
63
- test(`Renders with class ${styles.modifiers.success} when status="success" is passed`, () => {
64
- render(<MenuToggle status="success">Toggle</MenuToggle>);
65
- expect(screen.getByRole('button')).toHaveClass(styles.modifiers.success);
66
- });
63
+ test(`Renders with class ${styles.modifiers.success} when status="success" is passed`, () => {
64
+ render(<MenuToggle status="success">Toggle</MenuToggle>);
65
+ expect(screen.getByRole('button')).toHaveClass(styles.modifiers.success);
66
+ });
67
67
 
68
- test(`Renders with class ${styles.modifiers.warning} when status="success" is passed`, () => {
69
- render(<MenuToggle status="warning">Toggle</MenuToggle>);
70
- expect(screen.getByRole('button')).toHaveClass(styles.modifiers.warning);
71
- });
68
+ test(`Renders with class ${styles.modifiers.warning} when status="success" is passed`, () => {
69
+ render(<MenuToggle status="warning">Toggle</MenuToggle>);
70
+ expect(screen.getByRole('button')).toHaveClass(styles.modifiers.warning);
71
+ });
72
72
 
73
- test(`Renders with class ${styles.modifiers.danger} when status="success" is passed`, () => {
74
- render(<MenuToggle status="danger">Toggle</MenuToggle>);
75
- expect(screen.getByRole('button')).toHaveClass(styles.modifiers.danger);
76
- });
73
+ test(`Renders with class ${styles.modifiers.danger} when status="success" is passed`, () => {
74
+ render(<MenuToggle status="danger">Toggle</MenuToggle>);
75
+ expect(screen.getByRole('button')).toHaveClass(styles.modifiers.danger);
76
+ });
77
77
 
78
- test('split toggle passes onClick', async () => {
79
- const mockClick = jest.fn();
80
- const user = userEvent.setup();
81
-
82
- render(
83
- <MenuToggle
84
- onClick={mockClick}
85
- splitButtonItems={[
86
- <MenuToggleCheckbox
87
- id="split-button-checkbox-with-text-disabled-example"
88
- key="split-checkbox-with-text-disabled"
89
- aria-label="Select all"
90
- >
91
- 10 selected
92
- </MenuToggleCheckbox>
93
- ]}
94
- aria-label="Menu toggle with checkbox split button and text"
95
- />
96
- );
97
-
98
- await user.click(screen.getByRole(`button`) as Element);
99
- expect(mockClick).toHaveBeenCalled();
100
- });
78
+ test('split toggle passes onClick', async () => {
79
+ const mockClick = jest.fn();
80
+ const user = userEvent.setup();
81
+
82
+ render(
83
+ <MenuToggle
84
+ onClick={mockClick}
85
+ splitButtonItems={[
86
+ <MenuToggleCheckbox
87
+ id="split-button-checkbox-with-text-disabled-example"
88
+ key="split-checkbox-with-text-disabled"
89
+ aria-label="Select all"
90
+ >
91
+ 10 selected
92
+ </MenuToggleCheckbox>
93
+ ]}
94
+ aria-label="Menu toggle with checkbox split button and text"
95
+ />
96
+ );
97
+
98
+ await user.click(screen.getByRole(`button`) as Element);
99
+ expect(mockClick).toHaveBeenCalled();
100
+ });
101
101
 
102
- test(`Renders with class ${styles.modifiers.placeholder} when isPlaceholder is passed`, () => {
103
- render(<MenuToggle isPlaceholder>Toggle</MenuToggle>);
104
- expect(screen.getByRole('button')).toHaveClass(styles.modifiers.placeholder);
105
- });
102
+ test(`Renders with class ${styles.modifiers.placeholder} when isPlaceholder is passed`, () => {
103
+ render(<MenuToggle isPlaceholder>Toggle</MenuToggle>);
104
+ expect(screen.getByRole('button')).toHaveClass(styles.modifiers.placeholder);
105
+ });
106
+
107
+ test(`Renders with class ${styles.modifiers.settings} when isSettings is passed`, () => {
108
+ render(<MenuToggle isSettings>Settings</MenuToggle>);
109
+
110
+ expect(screen.getByRole('button')).toHaveClass(styles.modifiers.settings);
111
+ });
112
+
113
+ test('Does not render custom icon when icon prop and isSettings are passed', () => {
114
+ render(
115
+ <MenuToggle isSettings icon={<div>Custom icon</div>}>
116
+ Settings
117
+ </MenuToggle>
118
+ );
119
+ expect(screen.queryByText('Custom icon')).not.toBeInTheDocument();
106
120
  });
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`menu toggle passes additional classes 1`] = `
3
+ exports[`Old Snapshot tests - remove when refactoring passes additional classes 1`] = `
4
4
  <DocumentFragment>
5
5
  <button
6
6
  aria-expanded="false"
@@ -40,7 +40,7 @@ exports[`menu toggle passes additional classes 1`] = `
40
40
  </DocumentFragment>
41
41
  `;
42
42
 
43
- exports[`menu toggle renders successfully 1`] = `
43
+ exports[`Old Snapshot tests - remove when refactoring renders successfully 1`] = `
44
44
  <DocumentFragment>
45
45
  <button
46
46
  aria-expanded="false"
@@ -80,7 +80,7 @@ exports[`menu toggle renders successfully 1`] = `
80
80
  </DocumentFragment>
81
81
  `;
82
82
 
83
- exports[`menu toggle shows badge 1`] = `
83
+ exports[`Old Snapshot tests - remove when refactoring shows badge 1`] = `
84
84
  <DocumentFragment>
85
85
  <button
86
86
  aria-expanded="false"
@@ -129,7 +129,7 @@ exports[`menu toggle shows badge 1`] = `
129
129
  </DocumentFragment>
130
130
  `;
131
131
 
132
- exports[`menu toggle shows icon 1`] = `
132
+ exports[`Old Snapshot tests - remove when refactoring shows icon 1`] = `
133
133
  <DocumentFragment>
134
134
  <button
135
135
  aria-expanded="false"
@@ -186,7 +186,7 @@ exports[`menu toggle shows icon 1`] = `
186
186
  </DocumentFragment>
187
187
  `;
188
188
 
189
- exports[`menu toggle shows isDisabled 1`] = `
189
+ exports[`Old Snapshot tests - remove when refactoring shows isDisabled 1`] = `
190
190
  <DocumentFragment>
191
191
  <button
192
192
  aria-expanded="false"
@@ -227,7 +227,7 @@ exports[`menu toggle shows isDisabled 1`] = `
227
227
  </DocumentFragment>
228
228
  `;
229
229
 
230
- exports[`menu toggle shows isExpanded 1`] = `
230
+ exports[`Old Snapshot tests - remove when refactoring shows isExpanded 1`] = `
231
231
  <DocumentFragment>
232
232
  <button
233
233
  aria-expanded="true"
@@ -267,7 +267,7 @@ exports[`menu toggle shows isExpanded 1`] = `
267
267
  </DocumentFragment>
268
268
  `;
269
269
 
270
- exports[`menu toggle shows isPlain 1`] = `
270
+ exports[`Old Snapshot tests - remove when refactoring shows isPlain 1`] = `
271
271
  <DocumentFragment>
272
272
  <button
273
273
  aria-expanded="false"
@@ -298,7 +298,7 @@ exports[`menu toggle shows isPlain 1`] = `
298
298
  </DocumentFragment>
299
299
  `;
300
300
 
301
- exports[`menu toggle shows isPrimary 1`] = `
301
+ exports[`Old Snapshot tests - remove when refactoring shows isPrimary 1`] = `
302
302
  <DocumentFragment>
303
303
  <button
304
304
  aria-expanded="false"
@@ -338,7 +338,7 @@ exports[`menu toggle shows isPrimary 1`] = `
338
338
  </DocumentFragment>
339
339
  `;
340
340
 
341
- exports[`menu toggle shows plain text 1`] = `
341
+ exports[`Old Snapshot tests - remove when refactoring shows plain text 1`] = `
342
342
  <DocumentFragment>
343
343
  <button
344
344
  aria-expanded="false"