-
Notifications
You must be signed in to change notification settings - Fork 78
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(alert): add component tokens #10218
Changes from all commits
1514217
403ca2d
6787eee
7d18aec
c52f2cb
2dbbeda
4db49bd
48a1243
0ee7704
4812669
1e873d2
3bfe325
7e20e2d
3cfbfc0
e375968
fe7f900
7b5c727
c272167
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 |
---|---|---|
|
@@ -4,19 +4,22 @@ | |
* These properties can be overridden using the component's tag as selector. | ||
* | ||
* @prop --calcite-alert-width: Specifies the width of the component. | ||
* @prop --calcite-alert-background-color: Specifies the component's background color. | ||
* @prop --calcite-alert-corner-radius: Specifies the component's border radius. | ||
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. As a user I might want to override the icon color rendered via prop, or the component's shadow. 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. @alisonailea @jcfranco Should we add tokens for these use cases? 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. Let's discuss customizing the icon and progress color separately. The design spec has both sharing the color defined by |
||
* @prop --calcite-alert-shadow: Specifies the component's shadow. | ||
*/ | ||
|
||
$border-style: 1px solid var(--calcite-color-border-3); | ||
|
||
:host { | ||
--calcite-alert-edge-distance: theme("spacing.8"); | ||
--calcite-alert-dismiss-progress-background: var(--calcite-color-transparent-tint); | ||
--calcite-internal-alert-edge-distance: theme("spacing.8"); | ||
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. This should be alert-size not edge-distance 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.
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 updated this to |
||
@apply block; | ||
|
||
inline-size: var(--calcite-alert-width); | ||
} | ||
|
||
.container { | ||
@apply bg-foreground-1 | ||
box-border | ||
@apply box-border | ||
fixed | ||
flex | ||
items-center | ||
|
@@ -26,17 +29,22 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
my-0 | ||
opacity-0 | ||
pointer-events-none | ||
shadow-2 | ||
text-start | ||
w-full | ||
z-toast; | ||
|
||
border-radius: var(--calcite-border-radius); | ||
--tw-shadow: 0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08); | ||
--tw-shadow-colored: 0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color); | ||
box-shadow: var( | ||
--calcite-alert-shadow, | ||
(var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)) | ||
); | ||
background-color: var(--calcite-alert-background-color, var(--calcite-color-foreground-1)); | ||
border-radius: var(--calcite-alert-corner-radius, var(--calcite-border-radius)); | ||
border-block-start: 0 solid transparent; | ||
border-inline: $border-style; | ||
border-block-end: $border-style; | ||
inline-size: var(--calcite-alert-width); | ||
max-inline-size: calc(100% - (var(--calcite-alert-edge-distance) * 2)); | ||
max-inline-size: calc(100% - (var(--calcite-internal-alert-edge-distance) * 2)); | ||
transition: | ||
opacity var(--calcite-internal-animation-timing-slow) $easing-function, | ||
all var(--calcite-animation-timing) ease-in-out; | ||
|
@@ -47,19 +55,19 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
inset-inline-start: 0; | ||
} | ||
&[class*="bottom"] { | ||
transform: translate3d(0, var(--calcite-alert-edge-distance), 0); | ||
inset-block-end: var(--calcite-alert-edge-distance); | ||
transform: translate3d(0, var(--calcite-internal-alert-edge-distance), 0); | ||
inset-block-end: var(--calcite-internal-alert-edge-distance); | ||
} | ||
&[class*="top"] { | ||
transform: translate3d(0, calc(-1 * var(--calcite-alert-edge-distance)), 0); | ||
inset-block-start: var(--calcite-alert-edge-distance); | ||
transform: translate3d(0, calc(-1 * var(--calcite-internal-alert-edge-distance)), 0); | ||
inset-block-start: var(--calcite-internal-alert-edge-distance); | ||
} | ||
&[class*="start"] { | ||
inset-inline-start: var(--calcite-alert-edge-distance); | ||
inset-inline-start: var(--calcite-internal-alert-edge-distance); | ||
inset-inline-end: auto; | ||
} | ||
&[class*="end"] { | ||
inset-inline-end: var(--calcite-alert-edge-distance); | ||
inset-inline-end: var(--calcite-internal-alert-edge-distance); | ||
inset-inline-start: auto; | ||
} | ||
} | ||
|
@@ -68,13 +76,11 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
@apply flex flex-col items-center justify-center p-0; | ||
margin-block: auto; | ||
margin-inline-end: auto; | ||
padding-inline-start: var(--calcite-alert-spacing-token-large); | ||
} | ||
|
||
.close { | ||
@apply bg-transparent border-none cursor-pointer flex items-center justify-end outline-none self-stretch text-color-3; | ||
-webkit-appearance: none; | ||
padding: var(--calcite-alert-spacing-token-large); | ||
|
||
@apply focus-base; | ||
&:focus { | ||
|
@@ -83,11 +89,12 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
|
||
&:hover, | ||
&:focus { | ||
@apply bg-foreground-2 text-color-1; | ||
@apply text-color-1; | ||
background-color: var(--calcite-color-foreground-2); | ||
} | ||
|
||
&:active { | ||
@apply bg-foreground-3; | ||
background-color: var(--calcite-color-foreground-3); | ||
} | ||
} | ||
|
||
|
@@ -129,7 +136,7 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
block; | ||
block-size: 2px; | ||
content: ""; | ||
background-color: var(--calcite-alert-dismiss-progress-background); | ||
background-color: var(--calcite-color-transparent-tint); | ||
inset-inline-end: 0; | ||
} | ||
} | ||
|
@@ -140,8 +147,6 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
|
||
.text-container { | ||
@apply box-border flex flex-auto min-w-0 flex-col break-words; | ||
padding-block: var(--calcite-alert-spacing-token-small); | ||
padding-inline: var(--calcite-alert-spacing-token-large) var(--calcite-alert-spacing-token-small); | ||
} | ||
|
||
.footer { | ||
|
@@ -151,12 +156,6 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
|
||
// scale variables | ||
:host([scale="s"]) { | ||
--calcite-alert-width: 40em; | ||
--calcite-alert-spacing-token-small: theme("spacing.2"); | ||
--calcite-alert-spacing-token-large: theme("spacing.3"); | ||
--calcite-alert-footer-height: theme("height.8"); | ||
--calcite-alert-footer-divider-gap: theme("spacing[0.5]"); | ||
|
||
@include slotted("title", "*") { | ||
@apply text-n1-wrap; | ||
} | ||
|
@@ -170,17 +169,22 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
@apply mx-2; | ||
} | ||
.container { | ||
--calcite-alert-min-height: 3.5rem; | ||
--calcite-internal-alert-min-height: 3.5rem; | ||
inline-size: var(--calcite-alert-width, 40em); | ||
} | ||
.close { | ||
padding: theme("spacing.3"); | ||
} | ||
.icon { | ||
padding-inline-start: theme("spacing.3"); | ||
} | ||
.text-container { | ||
padding-block: theme("spacing.2"); | ||
padding-inline: theme("spacing.3") theme("spacing.2"); | ||
} | ||
} | ||
|
||
:host([scale="m"]) { | ||
--calcite-alert-width: 50em; | ||
--calcite-alert-spacing-token-small: theme("spacing.3"); | ||
--calcite-alert-spacing-token-large: theme("spacing.4"); | ||
--calcite-alert-footer-height: theme("height.12"); | ||
--calcite-alert-footer-divider-gap: theme("spacing.1"); | ||
|
||
@include slotted("title", "*") { | ||
@apply text-0-wrap; | ||
} | ||
|
@@ -194,17 +198,22 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
@apply mx-3; | ||
} | ||
.container { | ||
--calcite-alert-min-height: 4.1875rem; | ||
--calcite-internal-alert-min-height: 4.1875rem; | ||
inline-size: var(--calcite-alert-width, 50em); | ||
} | ||
.close { | ||
padding: theme("spacing.4"); | ||
} | ||
.icon { | ||
padding-inline-start: theme("spacing.4"); | ||
} | ||
.text-container { | ||
padding-block: theme("spacing.3"); | ||
padding-inline: theme("spacing.4") theme("spacing.3"); | ||
} | ||
} | ||
|
||
:host([scale="l"]) { | ||
--calcite-alert-width: 60em; | ||
--calcite-alert-spacing-token-small: theme("spacing.4"); | ||
--calcite-alert-spacing-token-large: theme("spacing.5"); | ||
--calcite-alert-footer-height: theme("height.16"); | ||
--calcite-alert-footer-divider-gap: theme("spacing.2"); | ||
|
||
@include slotted("title", "*") { | ||
@apply text-1-wrap mb-1; | ||
} | ||
|
@@ -218,7 +227,18 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
@apply mx-4; | ||
} | ||
.container { | ||
--calcite-alert-min-height: 5.625rem; | ||
--calcite-internal-alert-min-height: 5.625rem; | ||
inline-size: var(--calcite-alert-width, 60em); | ||
} | ||
.close { | ||
padding: theme("spacing.5"); | ||
} | ||
.icon { | ||
padding-inline-start: theme("spacing.5"); | ||
} | ||
.text-container { | ||
padding-block: theme("spacing.4"); | ||
padding-inline: theme("spacing.5") theme("spacing.4"); | ||
} | ||
} | ||
|
||
|
@@ -227,10 +247,10 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
@apply border-t-2 opacity-100; | ||
pointer-events: initial; | ||
&[class*="bottom"] { | ||
transform: translate3d(0, calc(-1 * var(--calcite-alert-edge-distance)), inherit); | ||
transform: translate3d(0, calc(-1 * var(--calcite-internal-alert-edge-distance)), inherit); | ||
} | ||
&[class*="top"] { | ||
transform: translate3d(0, var(--calcite-alert-edge-distance), inherit); | ||
transform: translate3d(0, var(--calcite-internal-alert-edge-distance), inherit); | ||
} | ||
} | ||
} | ||
|
@@ -241,17 +261,18 @@ $border-style: 1px solid var(--calcite-color-border-3); | |
|
||
@include slotted("title", "*") { | ||
@apply text-0-wrap | ||
text-color-1 | ||
font-medium; | ||
|
||
color: var(--calcite-color-text-1); | ||
} | ||
|
||
@include slotted("message", "*") { | ||
@apply text-n1-wrap | ||
text-color-2 | ||
m-0 | ||
inline | ||
font-normal; | ||
margin-inline-end: theme("margin.2"); | ||
color: var(--calcite-color-text-2); | ||
} | ||
|
||
@include slotted("link", "*") { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { html } from "../../support/formatting"; | ||
import { SLOTS } from "../components/alert/resources"; | ||
|
||
export const alertTokens = { | ||
calciteAlertWidth: "", | ||
calciteAlertBackgroundColor: "", | ||
calciteAlertCornerRadius: "", | ||
calciteAlertShadow: "", | ||
}; | ||
|
||
export const alert = html`<calcite-alert label="this is a default alert" scale="s" open> | ||
<div slot="${SLOTS.title}">Test title</div> | ||
<div slot="${SLOTS.message}">Test message</div> | ||
</calcite-alert>`; |
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.
Where are these tokens applied?
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.
--calcite-alert-width
is being applied in.container
:inline-size: var(--calcite-alert-width, auto);
and in
scales
:inline-size: var(--calcite-alert-width, 40rem);
--calcite-alert-background-color
is being applied in.container
:background-color: var(--calcite-alert-background-color, var(--calcite-color-foreground-1));