Skip to content

Commit

Permalink
Merge pull request #5657 from pat270/LPS-192418
Browse files Browse the repository at this point in the history
feat(@clayui/navigation-bar): Adds fluidSize prop to customize container-fluid width
  • Loading branch information
matuzalemsteles authored Aug 3, 2023
2 parents d6b28ef + a0568ae commit d3d90de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/clay-navigation-bar/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ export interface IProps
| Array<React.ReactElement<React.ComponentProps<typeof Item>>>
| React.ReactElement<React.ComponentProps<typeof Item>>;

/**
* Set a maximum width on container-fluid.
*/
fluidSize?:
| React.ComponentProps<typeof ClayLayout.Container>['fluidSize']
| false;

/**
* Determines the style of the Navigation Bar
*/
Expand All @@ -54,6 +61,7 @@ function ClayNavigationBar(props: IProps): JSX.Element & {
function ClayNavigationBar({
children,
className,
fluidSize,
inverted = false,
itemAriaCurrent: ariaCurrent = true,
spritemap,
Expand Down Expand Up @@ -93,7 +101,7 @@ function ClayNavigationBar({
<NavigationBarContext.Provider
value={{ariaCurrent: ariaCurrent ? 'page' : null}}
>
<ClayLayout.ContainerFluid>
<ClayLayout.ContainerFluid size={fluidSize}>
<ClayButton
aria-expanded={expanded}
className={classNames(
Expand Down Expand Up @@ -139,7 +147,7 @@ function ClayNavigationBar({
timeout={prefersReducedMotion ? 0 : 250}
>
<div>
<ClayLayout.ContainerFluid>
<ClayLayout.ContainerFluid size={fluidSize}>
<ul className="navbar-nav">{children}</ul>
</ClayLayout.ContainerFluid>
</div>
Expand Down
11 changes: 10 additions & 1 deletion packages/clay-navigation-bar/stories/NavigationBar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export const NavigationBar = (args: any) => {
const [triggerName, setTriggerName] = useState<string>(args.active);

return (
<ClayNavigationBar inverted={args.inverted} triggerLabel={triggerName}>
<ClayNavigationBar
fluidSize={args.fluidSize}
inverted={args.inverted}
triggerLabel={triggerName}
>
<ClayNavigationBar.Item active={args.active === 'Item 1'}>
<ClayLink href="#">Item 1</ClayLink>
</ClayNavigationBar.Item>
Expand Down Expand Up @@ -47,9 +51,14 @@ NavigationBar.argTypes = {
control: {type: 'select'},
options: ['Item 1', 'Item 2', 'Item 3', 'Item 4'],
},
fluidSize: {
control: {type: 'select'},
options: [undefined, false, 'sm', 'md', 'lg', 'xl'],
},
};

NavigationBar.args = {
active: 'Item 1',
fluidSize: 'xl',
inverted: false,
};

0 comments on commit d3d90de

Please sign in to comment.