Skip to content

Commit a3a54f2

Browse files
feat: add disabled prop to AppHeader for menu button control (#392)
[Storybook Link](https://wandelbotsgmbh.github.io/wandelbots-js-react-components/overview.html) --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent aaae7b4 commit a3a54f2

File tree

2 files changed

+36
-33
lines changed

2 files changed

+36
-33
lines changed

src/components/AppHeader.tsx

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export type AppHeaderProps = {
3737
apps?: AppItem[]
3838
/** Callback when an app is selected */
3939
onAppSelect?: (app: AppItem) => void
40+
/** Disable the menu button */
41+
disabled?: boolean
4042
/** Additional styling */
4143
sx?: SxProps
4244
}
@@ -47,7 +49,14 @@ export type AppHeaderProps = {
4749
*/
4850
export const AppHeader = externalizeComponent(
4951
observer((props: AppHeaderProps) => {
50-
const { appIcon, appName, apps = [], onAppSelect, sx } = props
52+
const {
53+
appIcon,
54+
appName,
55+
apps = [],
56+
onAppSelect,
57+
disabled = false,
58+
sx,
59+
} = props
5160
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)
5261
const isMenuOpen = Boolean(anchorEl)
5362

@@ -77,30 +86,26 @@ export const AppHeader = externalizeComponent(
7786
position="static"
7887
sx={{
7988
boxShadow: "none",
80-
backgroundImage: "none",
81-
"& .MuiAppBar-root": {
82-
backgroundImage: "none",
83-
backgroundColor: "transparent",
89+
background: (theme) => theme.palette.backgroundPaperElevation?.[1],
90+
"& label, a, span": {
91+
textWrap: "nowrap",
8492
},
8593
...sx,
8694
}}
8795
>
8896
<Toolbar sx={{ minHeight: "62px !important" }}>
8997
{/* App Icon */}
90-
<Box sx={{ mr: 2, display: "flex", alignItems: "center" }}>
98+
<Box sx={{ mr: 1, display: "flex", alignItems: "center" }}>
9199
{appIcon}
92100
</Box>
93101

94102
{/* App Name and Dropdown */}
95103
<Box sx={{ display: "flex", alignItems: "center", flexGrow: 1 }}>
96104
<Typography
97-
variant="h6"
98-
component="div"
105+
component="h1"
99106
sx={{
100-
fontWeight: 700,
101-
fontSize: "20px",
102-
lineHeight: "24px",
103-
letterSpacing: 0,
107+
fontWeight: "bold",
108+
fontSize: "1rem",
104109
}}
105110
>
106111
{appName}
@@ -114,12 +119,13 @@ export const AppHeader = externalizeComponent(
114119
aria-controls="app-menu"
115120
aria-haspopup="true"
116121
onClick={handleMenuOpen}
122+
disabled={disabled}
117123
sx={{
118-
ml: 2,
119-
width: 30,
120-
height: 30,
121-
borderRadius: "8px",
122-
padding: "5px",
124+
ml: 1,
125+
width: 28,
126+
height: 28,
127+
borderRadius: "6px",
128+
padding: 0,
123129
backgroundColor: (theme) =>
124130
alpha(theme.palette.common.white, 0.1),
125131
opacity: 1,
@@ -128,9 +134,9 @@ export const AppHeader = externalizeComponent(
128134
alpha(theme.palette.common.white, 0.16),
129135
},
130136
"& .MuiSvgIcon-root": {
131-
fontSize: "10px",
132-
width: "10px",
133-
height: "8px",
137+
fontSize: "8px",
138+
width: "8px",
139+
height: "6px",
134140
},
135141
}}
136142
>
@@ -175,21 +181,13 @@ export const AppHeader = externalizeComponent(
175181
}}
176182
>
177183
{apps.map((app) => (
178-
<MenuItem
179-
key={app.id}
180-
onClick={() => handleAppSelect(app)}
181-
sx={{
182-
display: "flex",
183-
alignItems: "center",
184-
gap: 2,
185-
py: 1.5,
186-
px: 2,
187-
}}
188-
>
184+
<MenuItem key={app.id} onClick={() => handleAppSelect(app)}>
189185
<Box sx={{ display: "flex", alignItems: "center" }}>
190186
{app.icon}
191187
</Box>
192-
<Typography variant="body1">{app.name}</Typography>
188+
<Typography variant="body1" sx={{ ml: 2 }}>
189+
{app.name}
190+
</Typography>
193191
</MenuItem>
194192
))}
195193
</Menu>

stories/AppHeader.stories.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ const meta: Meta<typeof AppHeader> = {
2929
description: "Array of available apps to navigate to",
3030
control: false,
3131
},
32+
disabled: {
33+
description: "Disable the menu button",
34+
control: "boolean",
35+
},
3236
onAppSelect: {
3337
description: "Callback when an app is selected from the dropdown",
3438
action: "app selected",
@@ -75,12 +79,13 @@ export const Interactive: Story = {
7579
appIcon: <Home />,
7680
appName: "Robot Control Studio",
7781
apps: sampleApps,
82+
disabled: false,
7883
},
7984
parameters: {
8085
docs: {
8186
description: {
8287
story:
83-
"Interactive example showing the app header with a dropdown menu. Click the dropdown arrow to see the available apps. The background will blur when the menu is open.",
88+
"Interactive example showing the app header with a dropdown menu. Click the dropdown arrow to see the available apps. The background will blur when the menu is open. Toggle the 'disabled' control to disable the menu button.",
8489
},
8590
},
8691
},

0 commit comments

Comments
 (0)