Skip to content

Commit cf9e54e

Browse files
author
Eric Olkowski
committed
Updated examples and prop descriptions
1 parent b523188 commit cf9e54e

29 files changed

Lines changed: 61 additions & 95 deletions

packages/react-core/src/components/Button/Button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ export interface ButtonProps extends Omit<React.HTMLProps<HTMLButtonElement>, 'r
9696
isDanger?: boolean;
9797
/** Flag indicating whether content the button controls is expanded or not. Required when isHamburger is true. */
9898
isExpanded?: boolean;
99-
/** Flag indicating the button is a settings button. This will override the variant and icon properties. */
99+
/** Flag indicating the button is a settings button. This will override the icon property. */
100100
isSettings?: boolean;
101-
/** Flag indicating the button is a hamburger button. This will override the children, variant, and icon properties. */
101+
/** Flag indicating the button is a hamburger button. This will override the icon property. */
102102
isHamburger?: boolean;
103103
/** Adjusts and animates the hamburger icon to indicate what will happen upon clicking the button. */
104104
hamburgerVariant?: 'expand' | 'collapse';
Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,9 @@
1-
import { useState } from 'react';
21
import { Button, Flex } from '@patternfly/react-core';
32

4-
export const ButtonHamburger: React.FunctionComponent = () => {
5-
const [isHovered, setIsHovered] = useState(false);
6-
const [isExpanded, setIsExpanded] = useState(false);
7-
const [hamburgerVariant, setHamburgerVariant] = useState<'expand' | 'collapse'>('expand');
8-
9-
const handleClick = () => {
10-
setHamburgerVariant((prevVariant) => (prevVariant === 'expand' ? 'collapse' : 'expand'));
11-
setIsExpanded(!isExpanded);
12-
};
13-
14-
const onHoverFocus = () => {
15-
setIsHovered(true);
16-
};
17-
const onLeaveBlur = () => {
18-
setIsHovered(false);
19-
};
20-
21-
return (
22-
<Flex>
23-
<Button isExpanded={false} aria-label="Hamburger example default icon" isHamburger />
24-
<Button isExpanded={false} aria-label="Hamburger example expand icon" isHamburger hamburgerVariant="expand" />
25-
<Button isExpanded={true} aria-label="Hamburger example collapse icon" isHamburger hamburgerVariant="collapse" />
26-
<Button
27-
isHamburger
28-
aria-label="Hamburger example dynamic icon"
29-
onClick={handleClick}
30-
isExpanded={isExpanded}
31-
onMouseOver={onHoverFocus}
32-
onMouseLeave={onLeaveBlur}
33-
onFocus={onHoverFocus}
34-
onBlur={onLeaveBlur}
35-
hamburgerVariant={isHovered ? hamburgerVariant : undefined}
36-
/>
37-
</Flex>
38-
);
39-
};
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+
);

packages/react-core/src/components/Button/examples/ButtonSettings.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { Button, Flex } from '@patternfly/react-core';
22

33
export const ButtonSettings: React.FunctionComponent = () => (
44
<Flex>
5-
<Button isSettings aria-label="Settings" />
6-
<Button isSettings>Settings</Button>
5+
<Button isSettings variant="plain" aria-label="Settings" />
6+
<Button isSettings variant="control">
7+
Settings
8+
</Button>
79
</Flex>
810
);

packages/react-core/src/components/Masthead/examples/MastheadBasic.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const MastheadBasic: React.FunctionComponent = () => (
1212
<Masthead id="basic-example">
1313
<MastheadMain>
1414
<MastheadToggle>
15-
<Button isHamburger onClick={() => {}} aria-label="Global navigation" />
15+
<Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
1616
</MastheadToggle>
1717
<MastheadBrand>
1818
<MastheadLogo component="a">Logo</MastheadLogo>

packages/react-core/src/components/Masthead/examples/MastheadBasicMixedContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const MastheadBasicMixedContent: React.FunctionComponent = () => (
1414
<Masthead id="basic-mixed">
1515
<MastheadMain>
1616
<MastheadToggle>
17-
<Button isHamburger onClick={() => {}} aria-label="Global navigation" />
17+
<Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
1818
</MastheadToggle>
1919
<MastheadBrand>
2020
<MastheadLogo component="a">Logo</MastheadLogo>

packages/react-core/src/components/Masthead/examples/MastheadDisplayInline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const MastheadDisplayInline: React.FunctionComponent = () => (
1212
<Masthead id="inline-masthead" display={{ default: 'inline' }}>
1313
<MastheadMain>
1414
<MastheadToggle>
15-
<Button isHamburger onClick={() => {}} aria-label="Global navigation" />
15+
<Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
1616
</MastheadToggle>
1717
<MastheadBrand>
1818
<MastheadLogo component="a">Logo</MastheadLogo>

packages/react-core/src/components/Masthead/examples/MastheadDisplayStack.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const MastheadDisplayStack: React.FunctionComponent = () => (
1212
<Masthead id="stack-masthead" display={{ default: 'stack' }}>
1313
<MastheadMain>
1414
<MastheadToggle>
15-
<Button isHamburger onClick={() => {}} aria-label="Global navigation" />
15+
<Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
1616
</MastheadToggle>
1717
<MastheadBrand>
1818
<MastheadLogo component="a">Logo</MastheadLogo>

packages/react-core/src/components/Masthead/examples/MastheadDisplayStackInlineResponsive.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const MastheadDisplayStackInlineResponsive: React.FunctionComponent = ()
1212
<Masthead id="stack-inline-masthead" display={{ default: 'inline', lg: 'stack', '2xl': 'inline' }}>
1313
<MastheadMain>
1414
<MastheadToggle>
15-
<Button isHamburger onClick={() => {}} aria-label="Global navigation" />
15+
<Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
1616
</MastheadToggle>
1717
<MastheadBrand>
1818
<MastheadLogo component="a">Logo</MastheadLogo>

packages/react-core/src/components/Masthead/examples/MastheadInsets.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const MastheadInsets: React.FunctionComponent = () => (
1212
<Masthead id="inset-masthead" inset={{ default: 'insetSm' }}>
1313
<MastheadMain>
1414
<MastheadToggle>
15-
<Button isHamburger onClick={() => {}} aria-label="Global navigation" />
15+
<Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
1616
</MastheadToggle>
1717
<MastheadBrand>
1818
<MastheadLogo component="a">Logo</MastheadLogo>

packages/react-core/src/components/Masthead/examples/MastheadLogoCustomComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const MastheadLogoCustomComponent: React.FunctionComponent = () => (
1414
<Masthead id="icon-router-link">
1515
<MastheadMain>
1616
<MastheadToggle>
17-
<Button isHamburger onClick={() => {}} aria-label="Global navigation" />
17+
<Button variant="plain" isHamburger onClick={() => {}} aria-label="Global navigation" />
1818
</MastheadToggle>
1919
<MastheadBrand>
2020
<MastheadLogo component={(props) => <a {...props} href="#" />}>

0 commit comments

Comments
 (0)