-
Notifications
You must be signed in to change notification settings - Fork 77
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(menu-item): add component tokens #10654
Changes from 13 commits
610dacf
cf6cb0e
bbfd165
62de077
3bde181
1373136
8e167a3
15f1159
46a3951
103010f
08c44e4
975368f
ff948d7
70010c6
4b8167e
7ffd00a
4e85330
f60f4a3
6161a87
cd765b2
84b4dbb
7796368
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
/** | ||
* CSS Custom Properties | ||
* | ||
* These properties can be overridden using the component's tag as selector. | ||
* | ||
* @prop --calcite-menu-item-accent-color: Specifies the border color of the component when `active`. | ||
* @prop --calcite-menu-item-accent-color-hover: Specifies the border color of the component when hovered. | ||
* @prop --calcite-menu-background-color: Specifies the background color of the component. | ||
* @prop --calcite-menu-background-color-hover: Specifies the background color of the component when hovered. | ||
* @prop --calcite-menu-background-color-press: Specifies the background color of the component when active. | ||
* @prop --calcite-menu-item-sub-menu-border-color: Specifies the border color of sub-menu. | ||
* @prop --calcite-menu-item-sub-menu-corner-radius: Specifies the border radius of sub-menu. | ||
* @prop --calcite-menu-text-color: Specifies the text color of the component. | ||
* @prop --calcite-menu-text-color-hover: Specifies the text color of the component when hovered. | ||
* @prop --calcite-menu-text-color-press: Specifies the text color of the component when active. | ||
*/ | ||
|
||
:host { | ||
@apply flex | ||
items-center | ||
|
@@ -32,46 +49,70 @@ | |
cursor-pointer | ||
outline-none | ||
text-0 | ||
text-color-2 | ||
box-border | ||
bg-foreground-1 | ||
px-4 | ||
h-full | ||
w-full; | ||
text-decoration: none; | ||
border-block-end: theme("spacing[0.5]") solid transparent; | ||
padding-block-start: theme("spacing[0.5]"); | ||
border-block-end: theme("spacing[0.5]") solid var(--calcite-color-transparent); | ||
|
||
background-color: var(--calcite-menu-background-color, var(--calcite-color-foreground-1)); | ||
color: var(--calcite-menu-text-color, var(--calcite-internal-menu-item-text-color, var(--calcite-color-text-2))); | ||
|
||
&:hover, | ||
&:focus { | ||
background-color: var(--calcite-menu-background-color-hover, var(--calcite-color-foreground-2)); | ||
color: var(--calcite-menu-text-color-hover, var(--calcite-color-text-2)); | ||
} | ||
|
||
&:hover { | ||
@apply text-color-2 border-b-color-2; | ||
border-block-end-color: var(--calcite-menu-item-accent-color-hover, var(--calcite-color-border-2)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here. Remove the state from all tokens on :host There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Do we need to add a borderBlockEndColor when hovered ? Currently, navigation components do not add any border when hovered. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that makes sense, I think |
||
} | ||
|
||
&:focus { | ||
@apply text-color-2 focus-inset border-b-4; | ||
@apply focus-inset border-b-4; | ||
padding-block-start: theme("spacing.1"); | ||
border-block-end-width: theme("spacing.1"); | ||
} | ||
|
||
&:active { | ||
@apply bg-foreground-3 text-color-1; | ||
background-color: var(--calcite-menu-background-color-press, var(--calcite-color-foreground-3)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here. Remove the state from all tokens on :host |
||
color: var(--calcite-menu-text-color-press, var(--calcite-color-text-1)); | ||
} | ||
|
||
& span { | ||
display: inline-flex; | ||
} | ||
|
||
&.layout--vertical { | ||
@apply flex w-full justify-start; | ||
padding-block: 1rem; | ||
border-block-end: 0; | ||
border-inline-end: theme("spacing.1") solid transparent; | ||
border-inline-end: theme("spacing.1") solid var(--calcite-color-transparent); | ||
} | ||
} | ||
|
||
:host([active]) .content { | ||
@apply text-color-1; | ||
border-color: var(--calcite-color-brand); | ||
:host([layout="vertical"]) .content { | ||
@apply px-3; | ||
} | ||
|
||
:host([active]) { | ||
.content { | ||
background-color: var(--calcite-menu-background-color, (--calcite-color-foreground-3)); | ||
--calcite-internal-menu-item-text-color: var(--calcite-color-text-1); | ||
border-block-end-color: var(--calcite-menu-item-accent-color, var(--calcite-color-brand)); | ||
} | ||
.icon { | ||
--calcite-icon-color: var(--calcite-color-brand); | ||
--calcite-internal-menu-item-icon-color: var(--calcite-color-brand); | ||
} | ||
} | ||
:host([layout="vertical"]) .content { | ||
@apply px-3; | ||
|
||
.icon { | ||
color: var( | ||
--calcite-menu-text-color, | ||
var(--calcite-icon-color, var(--calcite-internal-menu-item-icon-color, var(--calcite-color-text-3))) | ||
); | ||
} | ||
|
||
.icon--start { | ||
|
@@ -88,7 +129,6 @@ | |
|
||
.icon--dropdown { | ||
@apply ms-auto me-0 ps-2 relative; | ||
--calcite-icon-color: var(--calcite-color-text-3); | ||
} | ||
|
||
:host([layout="vertical"]) .icon--end ~ .icon--dropdown { | ||
|
@@ -108,7 +148,6 @@ | |
|
||
.icon--breadcrumb { | ||
@apply ps-2 me-0; | ||
--calcite-icon-color: var(--calcite-color-text-3); | ||
} | ||
|
||
:host([layout="vertical"]) .icon--breadcrumb { | ||
|
@@ -130,32 +169,46 @@ | |
calcite-action { | ||
@apply relative h-auto; | ||
border-inline-start: 1px solid var(--calcite-color-foreground-1); | ||
--calcite-action-background-color: var(--calcite-menu-background-color); | ||
--calcite-action-text-color: var(--calcite-menu-text-color); | ||
|
||
&::after { | ||
@apply block w-px absolute -start-px; | ||
content: ""; | ||
inset-block: theme("spacing.3"); | ||
background-color: var(--calcite-color-border-3); | ||
} | ||
|
||
&:hover::after { | ||
@apply h-full; | ||
inset-block: 0; | ||
} | ||
|
||
&:hover, | ||
&:focus { | ||
--calcite-action-background-color-hover: var(--calcite-menu-background-color-hover); | ||
--calcite-action-text-color-press: var(--calcite-menu-text-color-press); | ||
} | ||
|
||
&:active { | ||
--calcite-action-background-color-press: var(--calcite-menu-background-color-press); | ||
} | ||
} | ||
|
||
// extends the broder block of calcite action when hovered on content | ||
.content:focus ~ calcite-action, | ||
.content:hover ~ calcite-action { | ||
@apply text-color-1; | ||
border-inline-start: 1px solid var(--calcite-color-border-3); | ||
} | ||
--calcite-action-text-color: var(--calcite-menu-text-color-press, var(--calcite-color-text-1)); | ||
|
||
.container:hover .dropdown-action { | ||
@apply bg-foreground-2; | ||
&::after { | ||
@apply h-full; | ||
inset-block: 0; | ||
} | ||
} | ||
|
||
.dropdown-menu-items { | ||
@apply absolute h-auto flex-col hidden overflow-visible min-w-full; | ||
border: 1px solid var(--calcite-color-border-3); | ||
background: var(--calcite-color-foreground-1); | ||
border: 1px solid var(--calcite-menu-item-sub-menu-border-color, var(--calcite-color-border-3)); | ||
inset-block-start: 100%; | ||
z-index: theme("zIndex.dropdown"); | ||
&.open { | ||
|
@@ -173,7 +226,8 @@ calcite-action { | |
} | ||
|
||
.dropdown--vertical.dropdown-menu-items { | ||
@apply relative rounded-none; | ||
@apply relative; | ||
border-radius: var(--calcite-menu-item-sub-menu-corner-radius, var(--calcite-corner-radius)); | ||
box-shadow: none; | ||
inset-block-start: 0; | ||
transform: none; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because these are on :host they should not have a state. Remove
-hover
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, i had state tokens earlier assuming
menu-item
&action
can have two different background colors.