Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dropdown-indicators Lumo variant to menu-bar button #7381

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions packages/menu-bar/test/visual/lumo/menu-bar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,71 @@ describe('menu-bar', () => {
await visualDiff(document.body, `${dir}-end-aligned-overflow-button`);
});
});

describe('dropdown-indicators', () => {
function makeIcon(img) {
const icon = document.createElement('vaadin-icon');
icon.setAttribute('icon', img);
return icon;
}

beforeEach(async () => {
div = document.createElement('div');
div.style.padding = '10px';

element = fixtureSync('<vaadin-menu-bar></vaadin-menu-bar>', div);
await nextRender();

element.items = [
{ text: 'Home' },
{
text: 'Actions',
children: [{ text: 'Notifications' }, { text: 'Mark as read' }],
},
{ text: 'Manage' },
{
text: 'Reports',
children: [{ text: 'View Reports' }, { text: 'Generate Report' }],
},
{ text: 'Help' },
];
});

it('dropdown-indicators', async () => {
div.style.width = '300px';
element.setAttribute('theme', 'dropdown-indicators');
await visualDiff(div, `${dir}-dropdown-indicators`);
});

it('dropdown-indicators small', async () => {
div.style.width = '250px';
element.setAttribute('theme', 'dropdown-indicators small');
await visualDiff(div, `${dir}-dropdown-indicators-small`);
});

it('dropdown-indicators tertiary', async () => {
div.style.width = '200px';
element.setAttribute('theme', 'dropdown-indicators tertiary');
await visualDiff(div, `${dir}-dropdown-indicators-tertiary`);
});

it('dropdown-indicators tertiary-inline', async () => {
div.style.width = '200px';
element.setAttribute('theme', 'dropdown-indicators tertiary-inline');
await visualDiff(div, `${dir}-dropdown-indicators-tertiary-inline`);
});

it('dropdown-indicators icon', async () => {
element.setAttribute('theme', 'dropdown-indicators');
const items = [...element.items];
items[1].text = null;
items[1].component = makeIcon('lumo:chevron-down');
items[1].theme = 'dropdown-indicators icon';
element.items = items;
await nextRender();
await visualDiff(div, `${dir}-dropdown-indicators-icon`);
});
});
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
vursen marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arrow still seems to be slightly unaligned in tertiary-inline.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked it locally and the pseudo-element is aligned correctly:

Screenshot 2024-05-07 at 10 03 13

Also to me it seems like the arrow looks the same on Mac and Windows. So probably we could keep it this way.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions packages/menu-bar/theme/lumo/vaadin-menu-bar-button-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@ const menuBarButton = css`
margin-right: 0;
}

:host([theme~='dropdown-indicators']:not([slot='overflow']):not([theme~='icon'])[aria-haspopup]) [part='suffix'] {
margin-inline-start: 0;
width: 1em;
height: 1em;
line-height: 1;
font-size: var(--lumo-icon-size-s);
position: relative;
inset-inline-start: 0.15em;
}

/* prettier-ignore */
:host([theme~='dropdown-indicators']:not([slot='overflow']):not([theme~='icon'])[aria-haspopup]) [part='suffix']::after {
font-family: lumo-icons;
content: var(--lumo-icons-dropdown);
}

/* prettier-ignore */
:host([theme~='dropdown-indicators']:not([slot='overflow']):not([theme~='icon'])[theme~='tertiary'][aria-haspopup]) [part='suffix'] {
inset-inline-start: 0.05em;
}

/* prettier-ignore */
:host([theme~='dropdown-indicators']:not([slot='overflow']):not([theme~='icon'])[theme~='tertiary-inline'][aria-haspopup]) [part='suffix'] {
inset-inline-start: 0;
}

/* RTL styles */
:host([dir='rtl']) {
margin-left: calc(var(--lumo-space-xs) / 2);
Expand Down
Loading