🎨(react) enhance alert component styles
update alert token and css files with new css variables introduce with the new tokens architectures
This commit is contained in:
committed by
NathanVss
parent
bccdebd770
commit
3e62cdb929
@@ -11,11 +11,12 @@ export const AlertAdditionalExpandable = (props: AlertProps) => {
|
|||||||
const [expanded, onExpand] = useControllableState(
|
const [expanded, onExpand] = useControllableState(
|
||||||
false,
|
false,
|
||||||
props.expanded,
|
props.expanded,
|
||||||
props.onExpand,
|
props.onExpand
|
||||||
);
|
);
|
||||||
|
|
||||||
const iconButton = (
|
const iconButton = (
|
||||||
<Button
|
<Button
|
||||||
|
variant={props.type}
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
size="nano"
|
size="nano"
|
||||||
aria-label={
|
aria-label={
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export const AlertClose = (props: AlertProps) => {
|
|||||||
return (
|
return (
|
||||||
props.canClose && (
|
props.canClose && (
|
||||||
<Button
|
<Button
|
||||||
|
variant={props.type}
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
size="small"
|
size="small"
|
||||||
icon={<span className="material-icons">close</span>}
|
icon={<span className="material-icons">close</span>}
|
||||||
@@ -59,7 +60,8 @@ export const AlertButtons = (props: AlertProps) => {
|
|||||||
<>
|
<>
|
||||||
{props.tertiaryLabel && (
|
{props.tertiaryLabel && (
|
||||||
<Button
|
<Button
|
||||||
color="tertiary-text"
|
color="tertiary"
|
||||||
|
variant={props.type}
|
||||||
onClick={props.tertiaryOnClick}
|
onClick={props.tertiaryOnClick}
|
||||||
{...props.tertiaryProps}
|
{...props.tertiaryProps}
|
||||||
>
|
>
|
||||||
@@ -68,7 +70,8 @@ export const AlertButtons = (props: AlertProps) => {
|
|||||||
)}
|
)}
|
||||||
{props.primaryLabel && (
|
{props.primaryLabel && (
|
||||||
<Button
|
<Button
|
||||||
color="primary-text"
|
variant={props.type}
|
||||||
|
color="secondary"
|
||||||
onClick={props.primaryOnClick}
|
onClick={props.primaryOnClick}
|
||||||
{...props.primaryProps}
|
{...props.primaryProps}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
@mixin alert-variant($context) {
|
||||||
|
background-color: color-mix(
|
||||||
|
in srgb,
|
||||||
|
var(--c--contextuals--background--semantic--#{$context}--tertiary),
|
||||||
|
transparent 70%
|
||||||
|
);
|
||||||
|
|
||||||
|
border-color: var(--c--contextuals--border--semantic--#{$context}--tertiary);
|
||||||
|
border-left-color: var(--c--contextuals--border--semantic--#{$context}--tertiary);
|
||||||
|
color: var(--c--contextuals--content--semantic--#{$context}--primary) !important;
|
||||||
|
.c__alert__icon {
|
||||||
|
color: var(--c--contextuals--content--semantic--#{$context}--primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.c__alert__additional {
|
||||||
|
font-weight: var(--c--components--alert--additional-font-weight);
|
||||||
|
color: var(--c--contextuals--content--semantic--#{$context}--secondary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.c__alert {
|
.c__alert {
|
||||||
padding: 0.75rem 1rem;
|
padding: 0.75rem 1rem;
|
||||||
background-color: var(--c--components--alert--background-color);
|
background-color: var(--c--components--alert--background-color);
|
||||||
@@ -8,8 +28,8 @@
|
|||||||
font-weight: var(--c--components--alert--font-weight);
|
font-weight: var(--c--components--alert--font-weight);
|
||||||
color: var(--c--components--alert--color);
|
color: var(--c--components--alert--color);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border-color: var(--c--theme--colors--greyscale-300);
|
border-color: var(--c--components--alert--border-color);
|
||||||
border-left-color: var(--c--theme--colors--greyscale-600);
|
border-left-color: var(--c--components--alert--border-left-color);
|
||||||
|
|
||||||
&__icon {
|
&__icon {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -40,7 +60,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-additional {
|
&-additional {
|
||||||
|
|
||||||
&__buttons {
|
&__buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
@@ -48,12 +67,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.c__alert__additional {
|
&:not(.c__alert--neutral),
|
||||||
font-weight: var(--c--components--alert--additional-font-weight);
|
&.c__alert--expandable {
|
||||||
color: var(--c--components--alert--additional-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:not(.c__alert--neutral), &.c__alert--expandable {
|
|
||||||
.c__alert__additional {
|
.c__alert__additional {
|
||||||
padding-left: 2rem;
|
padding-left: 2rem;
|
||||||
}
|
}
|
||||||
@@ -62,41 +77,22 @@
|
|||||||
&__actions {
|
&__actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--info {
|
&--info {
|
||||||
border-color: var(--c--theme--colors--info-300);
|
@include alert-variant("info");
|
||||||
border-left-color: var(--c--theme--colors--info-600);
|
|
||||||
|
|
||||||
.c__alert__icon {
|
|
||||||
color: var(--c--theme--colors--info-600);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&--success {
|
&--success {
|
||||||
border-color: var(--c--theme--colors--success-300);
|
@include alert-variant("success");
|
||||||
border-left-color: var(--c--theme--colors--success-600);
|
|
||||||
|
|
||||||
.c__alert__icon {
|
|
||||||
color: var(--c--theme--colors--success-600);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&--warning {
|
&--warning {
|
||||||
border-color: var(--c--theme--colors--warning-300);
|
@include alert-variant("warning");
|
||||||
border-left-color: var(--c--theme--colors--warning-600);
|
|
||||||
|
|
||||||
.c__alert__icon {
|
|
||||||
color: var(--c--theme--colors--warning-600);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&--error {
|
&--error {
|
||||||
border-color: var(--c--theme--colors--danger-300);
|
@include alert-variant("error");
|
||||||
border-left-color: var(--c--theme--colors--danger-600);
|
|
||||||
|
|
||||||
.c__alert__icon {
|
|
||||||
color: var(--c--theme--colors--danger-600);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,8 +58,12 @@ export const CustomButtons: Story = {
|
|||||||
canClose: true,
|
canClose: true,
|
||||||
buttons: (
|
buttons: (
|
||||||
<div style={{ display: "flex", gap: "0.5rem" }}>
|
<div style={{ display: "flex", gap: "0.5rem" }}>
|
||||||
<Button color="primary">Primary</Button>
|
<Button variant="brand" color="primary">
|
||||||
<Button color="secondary">Secondary</Button>
|
Primary
|
||||||
|
</Button>
|
||||||
|
<Button variant="brand" color="secondary">
|
||||||
|
Secondary
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ import { DefaultTokens } from "@openfun/cunningham-tokens";
|
|||||||
|
|
||||||
export const tokens = (defaults: DefaultTokens) => {
|
export const tokens = (defaults: DefaultTokens) => {
|
||||||
return {
|
return {
|
||||||
"background-color": defaults.theme.colors["greyscale-100"],
|
"background-color": defaults.contextuals.background.semantic.neutral.tertiary,
|
||||||
"border-radius": "4px",
|
"border-radius": "4px",
|
||||||
"font-weight": defaults.theme.font.weights.medium,
|
"border-color": defaults.contextuals.border.semantic.neutral.primary,
|
||||||
color: defaults.theme.colors["greyscale-900"],
|
"border-left-color": defaults.contextuals.border.semantic.neutral.primary,
|
||||||
|
"font-weight": defaults.globals.font.weights.medium,
|
||||||
|
color: defaults.contextuals.content.semantic.neutral.primary,
|
||||||
"icon-size": "19px",
|
"icon-size": "19px",
|
||||||
"additional-font-weight": defaults.theme.font.weights.regular,
|
"additional-font-weight": defaults.globals.font.weights.regular,
|
||||||
"additional-color": defaults.theme.colors["greyscale-700"],
|
"additional-color": defaults.contextuals.content.semantic.neutral.primary,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user