Skip to content

Commit 2c5f593

Browse files
authored
chore(topbar): add justify center to topbar actions (#3584)
1 parent 4c634a7 commit 2c5f593

File tree

5 files changed

+74
-6
lines changed

5 files changed

+74
-6
lines changed

.changeset/ninety-masks-report.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@twilio-paste/topbar": minor
3+
"@twilio-paste/core": minor
4+
---
5+
6+
[Topbar] Add third value to `justify` prop type on TopbarActions, "center", allowing actions within the topbar to be center justified. For use with ProgressSteps in the Wizard flow.

packages/paste-core/components/topbar/src/Topbar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const Topbar = React.forwardRef<HTMLDivElement, TopbarProps>(
3939
display="flex"
4040
justifyContent="space-between"
4141
alignItems="center"
42+
columnGap="space70"
4243
zIndex="zIndex40"
4344
>
4445
{children}

packages/paste-core/components/topbar/src/TopbarActions.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ResponsiveValue } from "@twilio-paste/styling-library";
44
import type { HTMLPasteProps } from "@twilio-paste/types";
55
import * as React from "react";
66

7-
type Justify = "start" | "end";
7+
type Justify = "start" | "end" | "center";
88
export interface TopbarActionsProps extends HTMLPasteProps<"div"> {
99
/**
1010
* Recommended: Account Switcher, User Dialog, Product Switcher, Search Input, etc.
@@ -22,10 +22,11 @@ export interface TopbarActionsProps extends HTMLPasteProps<"div"> {
2222
*/
2323
element?: BoxElementProps["element"];
2424
/**
25-
* Used to control where the actions are aligned visually, to the start or end of the container.
25+
* Used to control where the actions are aligned visually, to the start or end or center of the container.
2626
*
2727
* @type {Justify}
2828
* @memberof TopbarActionsProps
29+
* @default "end"
2930
*/
3031
justify?: Justify;
3132
/**
@@ -36,13 +37,19 @@ export interface TopbarActionsProps extends HTMLPasteProps<"div"> {
3637
*/
3738
display?: ResponsiveValue<"none" | "flex">;
3839
}
40+
3941
const TopbarActions = React.forwardRef<HTMLDivElement, TopbarActionsProps>(
40-
({ children, element = "TOPBAR_ACTIONS", justify, display = "flex", ...props }, ref) => {
42+
({ children, element = "TOPBAR_ACTIONS", justify = "end", display = "flex", ...props }, ref) => {
43+
const justifyContentValue = {
44+
start: "flex-start",
45+
end: "flex-end",
46+
center: "center",
47+
};
4148
return (
4249
<Box
4350
{...safelySpreadBoxProps(props)}
4451
display={display}
45-
justifyContent={justify === "start" ? "flex-start" : "flex-end"}
52+
justifyContent={justifyContentValue[justify]}
4653
flexShrink={justify === "start" ? null : 0}
4754
flexWrap="wrap"
4855
flexGrow={1}

packages/paste-core/components/topbar/stories/topbar.stories.tsx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import type { StoryFn } from "@storybook/react";
22
import { Button } from "@twilio-paste/button";
3+
import { Heading } from "@twilio-paste/heading";
34
import { ProductFlexIcon } from "@twilio-paste/icons/esm/ProductFlexIcon";
45
import { UserIcon } from "@twilio-paste/icons/esm/UserIcon";
56
import { Paragraph } from "@twilio-paste/paragraph";
7+
import {
8+
ProgressStepComplete,
9+
ProgressStepCurrent,
10+
ProgressStepError,
11+
ProgressStepIncomplete,
12+
ProgressStepSeparator,
13+
ProgressSteps,
14+
} from "@twilio-paste/progress-steps";
615
import {
716
Sidebar,
817
SidebarBody,
@@ -271,3 +280,48 @@ export const OverlayCompactTopbar: StoryFn = () => {
271280
OverlayCompactTopbar.parameters = {
272281
padding: false,
273282
};
283+
284+
export const TopbarActionsExample: StoryFn = () => {
285+
return (
286+
<Topbar id={useUID()}>
287+
<TopbarActions justify="start">
288+
<Heading as="h4" variant="heading30" marginBottom="space0">
289+
Wizard title
290+
</Heading>
291+
</TopbarActions>
292+
<TopbarActions justify="center">
293+
<ProgressSteps>
294+
<ProgressStepComplete as="button" onClick={() => {}}>
295+
Label
296+
</ProgressStepComplete>
297+
<ProgressStepSeparator />
298+
<ProgressStepCurrent as="button" onClick={() => {}}>
299+
Label
300+
</ProgressStepCurrent>
301+
<ProgressStepSeparator />
302+
<ProgressStepIncomplete as="button" onClick={() => {}} disabled>
303+
Label
304+
</ProgressStepIncomplete>
305+
<ProgressStepSeparator />
306+
<ProgressStepIncomplete as="button" onClick={() => {}} disabled>
307+
Label
308+
</ProgressStepIncomplete>
309+
<ProgressStepSeparator />
310+
<ProgressStepIncomplete as="button" onClick={() => {}} disabled>
311+
Label
312+
</ProgressStepIncomplete>
313+
<ProgressStepSeparator />
314+
<ProgressStepIncomplete as="button" onClick={() => {}} disabled>
315+
Label
316+
</ProgressStepIncomplete>
317+
</ProgressSteps>
318+
</TopbarActions>
319+
<TopbarActions justify="end">
320+
<Button variant="secondary">Cancel</Button>
321+
</TopbarActions>
322+
</Topbar>
323+
);
324+
};
325+
TopbarActionsExample.parameters = {
326+
padding: false,
327+
};

packages/paste-core/components/topbar/type-docs.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,10 +2076,10 @@
20762076
},
20772077
"justify": {
20782078
"type": "Justify",
2079-
"defaultValue": null,
2079+
"defaultValue": "end",
20802080
"required": false,
20812081
"externalProp": false,
2082-
"description": "Used to control where the actions are aligned visually, to the start or end of the container."
2082+
"description": "Used to control where the actions are aligned visually, to the start or end or center of the container."
20832083
},
20842084
"key": {
20852085
"type": "Key",

0 commit comments

Comments
 (0)