-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a menu title for floating menu (#319)
* feat: extract menu title from FloatingMenu * feat: use `MenuTitle` in `FloatingMenu` * feat: add `MenuTitle` to `Menu` story
- Loading branch information
1 parent
98dccbf
commit bece139
Showing
12 changed files
with
126 additions
and
19 deletions.
There are no files selected for viewing
Binary file modified
BIN
+3.97 KB
(120%)
playwright/visual.test.ts-snapshots/Menu-Menu-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.67 KB
playwright/visual.test.ts-snapshots/Menu-MenuTitle-Default-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.68 KB
(120%)
playwright/visual.test.ts-snapshots/Menu-Without-Title-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright 2025 New Vector Ltd | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
* Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
.menu-title { | ||
color: var(--cpd-color-text-secondary); | ||
padding-inline: var(--cpd-space-4x); | ||
padding-block-end: calc(var(--cpd-space-2x) - var(--cpd-border-width-1)); | ||
border-block-end: var(--cpd-border-width-1) solid var(--cpd-color-gray-400); | ||
margin-block: var(--cpd-space-2x); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2025 New Vector Ltd | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
* Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
import { MenuTitle as MenuTitleComponent } from "./MenuTitle"; | ||
import { Meta, StoryFn } from "@storybook/react"; | ||
import React, { ComponentProps } from "react"; | ||
|
||
export default { | ||
title: "Menu/MenuTitle", | ||
component: MenuTitleComponent, | ||
tags: ["autodocs"], | ||
argTypes: {}, | ||
args: { | ||
title: "Title", | ||
}, | ||
} as Meta<typeof MenuTitleComponent>; | ||
|
||
const Template: StoryFn<typeof MenuTitleComponent> = ( | ||
args: ComponentProps<typeof MenuTitleComponent>, | ||
) => { | ||
return <MenuTitleComponent {...args} />; | ||
}; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright 2025 New Vector Ltd | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
* Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
import { describe, expect, it } from "vitest"; | ||
import { render } from "@testing-library/react"; | ||
import { MenuTitle } from "./MenuTitle.tsx"; | ||
import React from "react"; | ||
|
||
describe("MenuTitle", () => { | ||
it("renders", () => { | ||
const { asFragment } = render(<MenuTitle title="Title" />); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2025 New Vector Ltd | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
* Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
import React from "react"; | ||
import { Text } from "../Typography/Text.tsx"; | ||
import styles from "./MenuTitle.module.css"; | ||
import classnames from "classnames"; | ||
|
||
interface MenuTitleProps { | ||
/** | ||
* The title of the menu. | ||
*/ | ||
title: string; | ||
/** | ||
* The id of the menu title. | ||
*/ | ||
id?: string; | ||
/** | ||
* The CSS class. | ||
*/ | ||
className?: string; | ||
} | ||
|
||
export const MenuTitle: React.FC<MenuTitleProps> = ({ | ||
title, | ||
id, | ||
className, | ||
}) => { | ||
const classes = classnames(styles["menu-title"], className); | ||
|
||
return ( | ||
<Text as="h3" id={id} className={classes} size="sm" weight="semibold"> | ||
{title} | ||
</Text> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`MenuTitle > renders 1`] = ` | ||
<DocumentFragment> | ||
<h3 | ||
class="_typography_489030 _font-body-sm-semibold_489030 _menu-title_7bbc38" | ||
> | ||
Title | ||
</h3> | ||
</DocumentFragment> | ||
`; |