Skip to content

Commit 10b8bcd

Browse files
committed
feat(Page): added responsive docked nav
1 parent 911223a commit 10b8bcd

File tree

7 files changed

+369
-117
lines changed

7 files changed

+369
-117
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ export interface ButtonProps extends Omit<React.HTMLProps<HTMLButtonElement>, 'r
109109
hamburgerVariant?: 'expand' | 'collapse';
110110
/** @beta Flag indicating the button is a circle button. Intended for buttons that only contain an icon.. */
111111
isCircle?: boolean;
112+
/** @beta Flag indicating the button is a dock variant button. For use in docked navigation. */
113+
isDock?: boolean;
114+
/** @beta Flag indicating the dock button should display text. Only applies when isDock is true. */
115+
isTextExpanded?: boolean;
112116
/** @hide Forwarded ref */
113117
innerRef?: React.Ref<any>;
114118
/** Adds count number to button */
@@ -134,6 +138,8 @@ const ButtonBase: React.FunctionComponent<ButtonProps> = ({
134138
isHamburger,
135139
hamburgerVariant,
136140
isCircle,
141+
isDock = false,
142+
isTextExpanded = false,
137143
spinnerAriaValueText,
138144
spinnerAriaLabelledBy,
139145
spinnerAriaLabel,
@@ -265,6 +271,8 @@ const ButtonBase: React.FunctionComponent<ButtonProps> = ({
265271
size === ButtonSize.sm && styles.modifiers.small,
266272
size === ButtonSize.lg && styles.modifiers.displayLg,
267273
isCircle && styles.modifiers.circle,
274+
isDock && styles.modifiers.dock,
275+
isTextExpanded && styles.modifiers.textExpanded,
268276
className
269277
)}
270278
disabled={isButtonElement ? isDisabled : null}

packages/react-core/src/components/Masthead/MastheadLogo.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ export interface MastheadLogoProps extends React.DetailedHTMLProps<
1111
className?: string;
1212
/** Component type of the masthead logo. */
1313
component?: React.ElementType<any> | React.ComponentType<any>;
14+
/** @beta Flag indicating the logo is a compact variant. Used in docked layouts. */
15+
isCompact?: boolean;
1416
}
1517

1618
export const MastheadLogo: React.FunctionComponent<MastheadLogoProps> = ({
1719
children,
1820
className,
1921
component,
22+
isCompact = false,
2023
...props
2124
}: MastheadLogoProps) => {
2225
let Component = component as any;
@@ -28,7 +31,11 @@ export const MastheadLogo: React.FunctionComponent<MastheadLogoProps> = ({
2831
}
2932
}
3033
return (
31-
<Component className={css(styles.mastheadLogo, className)} {...(Component === 'a' && { tabIndex: 0 })} {...props}>
34+
<Component
35+
className={css(styles.mastheadLogo, isCompact && styles.modifiers.compact, className)}
36+
{...(Component === 'a' && { tabIndex: 0 })}
37+
{...props}
38+
>
3239
{children}
3340
</Component>
3441
);

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ export interface MenuToggleProps
5151
isCircle?: boolean;
5252
/** Flag indicating whether the toggle is a settings toggle. This will override the icon property */
5353
isSettings?: boolean;
54+
/** @beta Flag indicating the toggle is a dock variant. For use in docked navigation. */
55+
isDock?: boolean;
56+
/** @beta Flag indicating the dock toggle should display text. Only applies when isDock is true. */
57+
isTextExpanded?: boolean;
5458
/** Elements to display before the toggle button. When included, renders the menu toggle as a split button. */
5559
splitButtonItems?: React.ReactNode[];
5660
/** Variant styles of the menu toggle */
@@ -85,6 +89,8 @@ class MenuToggleBase extends Component<MenuToggleProps> {
8589
isFullHeight: false,
8690
isPlaceholder: false,
8791
isCircle: false,
92+
isDock: false,
93+
isTextExpanded: false,
8894
size: 'default',
8995
ouiaSafe: true
9096
};
@@ -102,6 +108,8 @@ class MenuToggleBase extends Component<MenuToggleProps> {
102108
isPlaceholder,
103109
isCircle,
104110
isSettings,
111+
isDock,
112+
isTextExpanded,
105113
splitButtonItems,
106114
variant,
107115
status,
@@ -185,6 +193,8 @@ class MenuToggleBase extends Component<MenuToggleProps> {
185193
isDisabled && styles.modifiers.disabled,
186194
isPlaceholder && styles.modifiers.placeholder,
187195
isSettings && styles.modifiers.settings,
196+
isDock && styles.modifiers.dock,
197+
isTextExpanded && styles.modifiers.textExpanded,
188198
size === MenuToggleSize.sm && styles.modifiers.small,
189199
className
190200
);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export interface NavProps
3939
'aria-label'?: string;
4040
/** The nav variant to use. Docked is in beta. */
4141
variant?: 'default' | 'horizontal' | 'horizontal-subnav' | 'docked';
42+
/** @beta Flag indicating the docked nav should display text. Only applies when variant is docked. */
43+
isTextExpanded?: boolean;
4244
/** Value to overwrite the randomly generated data-ouia-component-id.*/
4345
ouiaId?: number | string;
4446
/** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
@@ -119,6 +121,7 @@ class Nav extends Component<NavProps, { isScrollable: boolean; flyoutRef: React.
119121
ouiaId,
120122
ouiaSafe,
121123
variant,
124+
isTextExpanded = false,
122125
...props
123126
} = this.props;
124127
const isHorizontal = ['horizontal', 'horizontal-subnav'].includes(variant);
@@ -156,6 +159,7 @@ class Nav extends Component<NavProps, { isScrollable: boolean; flyoutRef: React.
156159
isHorizontal && styles.modifiers.horizontal,
157160
variant === 'docked' && styles.modifiers.docked,
158161
variant === 'horizontal-subnav' && styles.modifiers.subnav,
162+
isTextExpanded && styles.modifiers.textExpanded,
159163
this.state.isScrollable && styles.modifiers.scrollable,
160164
className
161165
)}

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ export interface PageProps extends React.HTMLProps<HTMLDivElement> {
2222
className?: string;
2323
/** @beta Indicates the layout variant */
2424
variant?: 'default' | 'docked';
25+
/** @beta Flag indicating the docked nav is expanded on mobile. Only applies when variant is docked. */
26+
isDockExpanded?: boolean;
27+
/** @beta Flag indicating the docked nav should display text. Only applies when variant is docked. */
28+
isDockTextExpanded?: boolean;
2529
/** Masthead component (e.g. <Masthead />) */
2630
masthead?: React.ReactNode;
31+
dockedMasthead?: React.ReactNode;
2732
/** Sidebar component for a side nav, recommended to be a PageSidebar. If set to null, the page grid layout
2833
* will render without a sidebar.
2934
*/
@@ -232,7 +237,10 @@ class Page extends Component<PageProps, PageState> {
232237
className,
233238
children,
234239
variant,
240+
isDockExpanded = false,
241+
isDockTextExpanded = false,
235242
masthead,
243+
dockedMasthead,
236244
sidebar,
237245
notificationDrawer,
238246
isNotificationDrawerExpanded,
@@ -349,9 +357,18 @@ class Page extends Component<PageProps, PageState> {
349357
>
350358
{skipToContent}
351359
{variant === 'docked' ? (
352-
<div className={css(styles.pageDock)}>
353-
<div className={css(styles.pageDockMain)}>{masthead}</div>
354-
</div>
360+
<>
361+
{masthead}
362+
<div
363+
className={css(
364+
styles.pageDock,
365+
isDockExpanded && styles.modifiers.expanded,
366+
isDockTextExpanded && styles.modifiers.textExpanded
367+
)}
368+
>
369+
<div className={css(styles.pageDockMain)}>{dockedMasthead}</div>
370+
</div>
371+
</>
355372
) : (
356373
masthead
357374
)}

packages/react-core/src/demos/Page.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import CloudIcon from '@patternfly/react-icons/dist/esm/icons/cloud-icon';
1818
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
1919
import pfLogo from '@patternfly/react-core/src/demos/assets/PF-HorizontalLogo-Color.svg';
2020
import pfIconLogo from '@patternfly/react-core/src/demos/assets/PF-IconLogo-color.svg';
21+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
22+
import ThIcon from '@patternfly/react-icons/dist/esm/icons/th-icon';
2123

2224
- All examples set the `isManagedSidebar` prop on the Page component to have the sidebar automatically close for smaller screen widths. You can also manually control this behavior by not adding the `isManagedSidebar` prop and instead:
2325
1. Add an onNavToggle callback to PageHeader

0 commit comments

Comments
 (0)