Skip to content
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
20 changes: 19 additions & 1 deletion src/recipes/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export interface AlertRecipeOptions {
size?: AlertSize
dismissed?: boolean
fullWidth?: boolean
interactive?: boolean
hovered?: boolean
focused?: boolean
active?: boolean
disabled?: boolean
loading?: boolean
}

export function getAlertClasses(opts: AlertRecipeOptions = {}): string {
Expand All @@ -31,6 +37,12 @@ export function getAlertClasses(opts: AlertRecipeOptions = {}): string {
size: sizeInput,
dismissed = false,
fullWidth = false,
interactive = false,
hovered = false,
focused = false,
active = false,
disabled = false,
loading = false,
} = opts

const variant = resolveOption({
Expand All @@ -52,6 +64,12 @@ export function getAlertClasses(opts: AlertRecipeOptions = {}): string {
`sp-alert--${variant}`,
`sp-alert--${size}`,
dismissed && 'sp-alert--dismissed',
fullWidth && 'sp-alert--full'
fullWidth && 'sp-alert--full',
interactive && 'sp-alert--interactive',
hovered && 'sp-alert--hover is-hover',
focused && 'sp-alert--focus is-focus',
active && 'sp-alert--active is-active',
disabled && 'sp-alert--disabled',
loading && 'sp-alert--loading'
)
}
43 changes: 43 additions & 0 deletions src/styles/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,12 @@
font-family: var(--sp-font-family-sans);
font-size: var(--sp-font-sm-size);
line-height: var(--sp-font-sm-line-height);
transition:
background-color var(--sp-duration-fast) var(--sp-easing-out),
color var(--sp-duration-fast) var(--sp-easing-out),
box-shadow var(--sp-duration-fast) var(--sp-easing-out),
border-color var(--sp-duration-fast) var(--sp-easing-out),
opacity var(--sp-duration-fast) var(--sp-easing-out);
}

.sp-alert--dismissed {
Expand Down Expand Up @@ -1555,6 +1561,43 @@
border-color: var(--sp-component-alert-neutral-border);
}

.sp-alert--interactive {
cursor: pointer;
}

.sp-alert--interactive:hover,
.sp-alert--hover,
.sp-alert.is-hover {
opacity: var(--sp-opacity-hover);
}

.sp-alert--interactive:active,
.sp-alert--active,
.sp-alert.is-active {
opacity: var(--sp-opacity-active);
}

.sp-alert--interactive:focus-visible,
.sp-alert--focus,
.sp-alert.is-focus {
outline: none;
box-shadow: 0 0 0 calc(var(--sp-focus-ring-width) + var(--sp-component-border-width)) var(--sp-color-focus-primary);
}

.sp-alert:disabled,
.sp-alert[aria-disabled="true"],
.sp-alert--disabled {
opacity: var(--sp-opacity-disabled);
pointer-events: none;
cursor: not-allowed;
}

.sp-alert--loading,
.sp-alert[aria-busy="true"] {
opacity: var(--sp-opacity-active);
pointer-events: none;
}

/* AVATARS -------------------------------------------------------------- */
.sp-avatar {
display: inline-flex;
Expand Down
Loading