Skip to content

Commit 84a02d7

Browse files
anezthesjouni
andauthored
experiment: add menu-bar base styles and visual tests (#9637)
Co-authored-by: Jouni Koivuviita <jouni@vaadin.com>
1 parent c29bfc3 commit 84a02d7

32 files changed

+356
-6
lines changed

dev/menu-bar.html

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,24 @@
2828
import '@vaadin/tooltip';
2929
import '@vaadin/checkbox';
3030
import '@vaadin/checkbox-group';
31+
import '@vaadin/icon';
3132
import '@vaadin/radio-group';
3233
import '@vaadin/split-layout';
34+
import '@vaadin/vaadin-lumo-styles/vaadin-iconset.js';
35+
36+
function makeComponent(text) {
37+
const item = document.createElement('vaadin-menu-bar-item');
38+
item.textContent = text;
39+
return item;
40+
}
41+
42+
function makeIcon(img) {
43+
const item = document.createElement('vaadin-menu-bar-item');
44+
const icon = document.createElement('vaadin-icon');
45+
icon.setAttribute('icon', img);
46+
item.appendChild(icon);
47+
return item;
48+
}
3349

3450
const menuBar = document.querySelector('vaadin-menu-bar');
3551
menuBar.items = [
@@ -41,7 +57,7 @@
4157
{ text: 'Status bar', checked: true },
4258
],
4359
},
44-
{ text: 'Edit' },
60+
{ component: makeComponent('Edit') },
4561
{
4662
text: 'Share',
4763
children: [
@@ -60,6 +76,10 @@
6076
children: [{ text: 'To folder' }, { text: 'To trash' }],
6177
},
6278
{ text: 'Duplicate', tooltip: 'Create a duplicate' },
79+
{
80+
component: makeIcon('lumo:user'),
81+
children: [{ text: 'Archive' }, { text: 'Configure' }],
82+
},
6383
];
6484

6585
['dropdown-indicators', 'small', 'primary', 'tertiary', 'tertiary-inline', 'end-aligned'].forEach((variant) => {
@@ -122,9 +142,11 @@
122142
</div>
123143
</div>
124144
<vaadin-split-layout>
125-
<vaadin-menu-bar>
126-
<vaadin-tooltip slot="tooltip" hover-delay="500" hide-delay="500"></vaadin-tooltip>
127-
</vaadin-menu-bar>
145+
<div style="padding: 3px">
146+
<vaadin-menu-bar>
147+
<vaadin-tooltip slot="tooltip" hover-delay="500" hide-delay="500"></vaadin-tooltip>
148+
</vaadin-menu-bar>
149+
</div>
128150
<span>Resize to show overflow button</span>
129151
</vaadin-split-layout>
130152
</body>

packages/menu-bar/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"type": "module",
2222
"files": [
2323
"src",
24+
"!src/styles/*-base-styles.d.ts",
25+
"!src/styles/*-base-styles.js",
2426
"theme",
2527
"vaadin-*.d.ts",
2628
"vaadin-*.js",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import type { CSSResult } from 'lit';
7+
8+
export const menuBarStyles: CSSResult;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import { css } from 'lit';
7+
8+
export const menuBarStyles = css`
9+
:host {
10+
display: block;
11+
}
12+
13+
:host([hidden]) {
14+
display: none !important;
15+
}
16+
17+
[part='container'] {
18+
display: flex;
19+
flex-wrap: nowrap;
20+
margin: calc((var(--vaadin-focus-ring-width) + 1px) * -1);
21+
overflow: hidden;
22+
padding: calc(var(--vaadin-focus-ring-width) + 1px);
23+
position: relative;
24+
width: 100%;
25+
/* stylelint-disable length-zero-no-unit */
26+
--_gap: var(--vaadin-menu-bar-gap, 0px);
27+
--_bw: var(--vaadin-button-border-width, 1px);
28+
gap: var(--_gap);
29+
--_rad-button: var(--vaadin-button-border-radius, var(--vaadin-radius-m));
30+
--_rad: min(var(--_gap) * 1000, var(--_rad-button));
31+
}
32+
33+
::slotted(vaadin-menu-bar-button:not(:first-of-type)) {
34+
margin-inline-start: min(var(--_bw) * -1 + var(--_gap) * 1000, 0px);
35+
}
36+
37+
::slotted(vaadin-menu-bar-button) {
38+
border-radius: var(--_rad);
39+
}
40+
41+
::slotted([first-visible]),
42+
:host([has-single-button]) ::slotted([slot='overflow']) {
43+
border-start-start-radius: var(--_rad-button);
44+
border-end-start-radius: var(--_rad-button);
45+
}
46+
47+
::slotted(:is([last-visible], [slot='overflow'])) {
48+
border-start-end-radius: var(--_rad-button);
49+
border-end-end-radius: var(--_rad-button);
50+
}
51+
52+
:host([theme~='end-aligned']) ::slotted(vaadin-menu-bar-button[first-visible]),
53+
:host([theme~='end-aligned'][has-single-button]) ::slotted(vaadin-menu-bar-button) {
54+
margin-inline-start: auto;
55+
}
56+
`;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import type { CSSResult } from 'lit';
7+
8+
export const menuBarButtonStyles: CSSResult;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import { css } from 'lit';
7+
8+
export const menuBarButtonStyles = css`
9+
:host {
10+
flex-shrink: 0;
11+
}
12+
13+
:host([focus-ring]) {
14+
z-index: 1;
15+
}
16+
17+
:host([slot='overflow']) {
18+
margin-inline-end: 0;
19+
}
20+
21+
.vaadin-button-container {
22+
gap: inherit;
23+
}
24+
25+
:host(:not([slot='overflow']):not([theme~='icon'])[aria-haspopup]) [part='suffix'] {
26+
display: flex;
27+
align-items: center;
28+
gap: inherit;
29+
}
30+
31+
:host(:not([slot='overflow']):not([theme~='icon'])[aria-haspopup]) [part='suffix']::after {
32+
background: currentColor;
33+
content: '';
34+
height: var(--vaadin-icon-size, 1lh);
35+
mask-image: var(--_vaadin-icon-chevron-down);
36+
width: var(--vaadin-icon-size, 1lh);
37+
}
38+
39+
::slotted(vaadin-menu-bar-item) {
40+
padding: 0;
41+
gap: 0;
42+
}
43+
44+
::slotted(vaadin-menu-bar-item)::after {
45+
display: none;
46+
}
47+
`;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import type { CSSResult } from 'lit';
7+
8+
export const menuBarItemStyles: CSSResult;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import { contextMenuItemStyles } from '@vaadin/context-menu/src/styles/vaadin-context-menu-item-base-styles.js';
7+
8+
export const menuBarItemStyles = contextMenuItemStyles;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import type { CSSResult } from 'lit';
7+
8+
export const menuBarItemStyles: CSSResult;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import { itemStyles } from '@vaadin/item/src/styles/vaadin-item-core-styles.js';
7+
8+
export const menuBarItemStyles = [itemStyles];

0 commit comments

Comments
 (0)