Skip to content

Commit

Permalink
feat(topbar): add new look for application drawer trigger button when…
Browse files Browse the repository at this point in the history
… triggerGroupShortName is set (#282)
  • Loading branch information
NiklasRamstrom authored Jun 13, 2024
1 parent bc7fb66 commit c2ed8cb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
18 changes: 18 additions & 0 deletions components/topbar/src/application-drawer.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { makeStyles, shorthands, tokens } from "@fluentui/react-components";

const triggerSpacingWithGroup = tokens.spacingHorizontalS;

export const useApplicationDrawrStyles = makeStyles({
drawer: {
...shorthands.borderRight(0),
Expand Down Expand Up @@ -48,6 +50,10 @@ export const useApplicationDrawrStyles = makeStyles({
...shorthands.gap(tokens.spacingHorizontalS),
...shorthands.padding(tokens.spacingVerticalXS, tokens.spacingHorizontalM),
},
drawerTriggerApplicationWithGroup: {
...shorthands.gap(triggerSpacingWithGroup),
...shorthands.padding(tokens.spacingVerticalXS, triggerSpacingWithGroup),
},
drawerTriggerApplicationIcon: {
display: "flex",
color: tokens.colorNeutralForeground2,
Expand All @@ -61,6 +67,18 @@ export const useApplicationDrawrStyles = makeStyles({
drawerTriggerApplicationText: {
color: tokens.colorNeutralForeground2,
},
drawerTriggerTextWithGroup: {
marginLeft: triggerSpacingWithGroup,
color: tokens.colorNeutralForeground2,
},
triggerDividerWithGroup: {
...shorthands.border("0.5px", "solid", tokens.colorNeutralForeground2),
...shorthands.borderRadius("1px"),
height: "12px",
boxSizing: "border-box",
marginTop: "1px",
marginLeft: triggerSpacingWithGroup,
},
applicationGroupTitle: {
display: "flex",
alignItems: "center",
Expand Down
19 changes: 17 additions & 2 deletions components/topbar/src/application-drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,25 @@ const DrawerTrigger = (
onMouseLeave={() => setHover(false)}
>
{<ApplicationAreaIcon applicationArea={applicationArea} />}
<Divider vertical style={{ padding: "0 0 0 12px" }}></Divider>
{currentSelection?.triggerGroupShortName
? (
<>
<Body1Strong className={styles.drawerTriggerTextWithGroup}>
{currentSelection?.triggerGroupShortName}
</Body1Strong>
<div className={styles.triggerDividerWithGroup}></div>
</>
)
: <Divider vertical style={{ padding: "0 0 0 12px" }}></Divider>}
{currentSelection
? (
<div className={styles.drawerTriggerApplication}>
<div
className={mergeClasses(
styles.drawerTriggerApplication,
currentSelection?.triggerGroupShortName
&& styles.drawerTriggerApplicationWithGroup
)}
>
<div
className={mergeClasses(
styles.drawerTriggerApplicationIcon,
Expand Down
8 changes: 7 additions & 1 deletion components/topbar/src/application-drawer.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ export type SingleApplicationDrawerContent = {
icon: JSX.Element;
/** Label to show in opened drawer. */
label: string;
/** Label to show in drawer trigger button when drawer is closed.
/**
* @deprecated
* Label to show in drawer trigger button when drawer is closed.
* If not set, label will be used.
* Unused for content with children.
*/
triggerLabel?: string;
/**
* Group label to show before triggerLabel
*/
triggerGroupShortName?: string;
};

export type ApplicationDrawerProps = {
Expand Down
2 changes: 2 additions & 0 deletions examples/src/components/top-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const Navbar = () => {
icon: <FishIcon />,
label: "Fisk",
id: "fisk",
triggerGroupShortName: "FISH",
},
{
icon: <CatIcon />,
Expand All @@ -98,6 +99,7 @@ export const Navbar = () => {
label: "Add",
triggerLabel: "ADD trigger",
id: "add",
triggerGroupShortName: "ADD",
},
];

Expand Down

0 comments on commit c2ed8cb

Please sign in to comment.