-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export context-menu list-box styles as CSS literals (#5360)
- Loading branch information
1 parent
a818756
commit a6edd66
Showing
6 changed files
with
81 additions
and
72 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/context-menu/theme/lumo/vaadin-context-menu-list-box-styles.js
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,44 @@ | ||
import '@vaadin/vaadin-lumo-styles/color.js'; | ||
import '@vaadin/vaadin-lumo-styles/spacing.js'; | ||
import '@vaadin/vaadin-lumo-styles/style.js'; | ||
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
|
||
const contextMenuListBox = css` | ||
:host { | ||
--_lumo-list-box-item-selected-icon-display: block; | ||
} | ||
/* Normal item */ | ||
[part='items'] ::slotted([role='menuitem']) { | ||
-webkit-tap-highlight-color: var(--lumo-primary-color-10pct); | ||
cursor: default; | ||
outline: none; | ||
border-radius: var(--lumo-border-radius-m); | ||
padding-left: calc(var(--lumo-border-radius-m) / 4); | ||
padding-right: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4); | ||
} | ||
/* Hovered item */ | ||
/* TODO a workaround until we have "focus-follows-mouse". After that, use the hover style for focus-ring as well */ | ||
[part='items'] ::slotted([role='menuitem']:hover:not([disabled])), | ||
[part='items'] ::slotted([role='menuitem'][expanded]:not([disabled])) { | ||
background-color: var(--lumo-primary-color-10pct); | ||
} | ||
/* RTL styles */ | ||
:host([dir='rtl']) [part='items'] ::slotted([role='menuitem']) { | ||
padding-left: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4); | ||
padding-right: calc(var(--lumo-border-radius-m) / 4); | ||
} | ||
/* Focused item */ | ||
@media (pointer: coarse) { | ||
[part='items'] ::slotted([role='menuitem']:hover:not([expanded]):not([disabled])) { | ||
background-color: transparent; | ||
} | ||
} | ||
`; | ||
|
||
registerStyles('vaadin-context-menu-list-box', contextMenuListBox, { moduleId: 'lumo-context-menu-list-box' }); | ||
|
||
export { contextMenuListBox }; |
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
35 changes: 35 additions & 0 deletions
35
packages/context-menu/theme/material/vaadin-context-menu-list-box-styles.js
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,35 @@ | ||
import '@vaadin/vaadin-material-styles/color.js'; | ||
import '@vaadin/vaadin-material-styles/typography.js'; | ||
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
|
||
const contextMenuListBox = css` | ||
[part='items'] ::slotted([role='menuitem']) { | ||
min-height: 36px; | ||
padding: 8px 32px 8px 10px; | ||
font-size: var(--material-small-font-size); | ||
line-height: 24px; | ||
} | ||
:host([dir='rtl']) [part='items'] ::slotted([role='menuitem']) { | ||
padding: 8px 10px 8px 32px; | ||
} | ||
[part='items'] ::slotted([role='menuitem']:hover:not([disabled])) { | ||
background-color: var(--material-secondary-background-color); | ||
} | ||
[part='items'] ::slotted([role='menuitem'][focused]:not([disabled])) { | ||
background-color: var(--material-divider-color); | ||
} | ||
@media (pointer: coarse) { | ||
[part='items'] ::slotted([role='menuitem']:hover:not([disabled])), | ||
[part='items'] ::slotted([role='menuitem'][focused]:not([disabled])) { | ||
background-color: transparent; | ||
} | ||
} | ||
`; | ||
|
||
registerStyles('vaadin-context-menu-list-box', contextMenuListBox, { moduleId: 'material-context-menu-list-box' }); | ||
|
||
export { contextMenuListBox }; |
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