Skip to content
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

Toasts: Updated to Match Figma #2708

Merged
merged 2 commits into from
Jul 23, 2024
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
11 changes: 6 additions & 5 deletions stencil-workspace/src/components/modus-toast/modus-toast.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.modus-toast {
align-items: center;
background-color: $modus-toast-bg;
border: $rem-1px solid $modus-toast-border-color;
border: $rem-1px solid transparent;
border-radius: $rem-4px;
box-shadow: 0 0 8px rgba(36, 35, 45, 0.3);
color: $modus-toast-color;
Expand All @@ -13,6 +13,7 @@
font-size: $rem-14px;
height: 2.6875rem;
padding: 0 $rem-16px;
width: 370px;

.icon {
align-items: center;
Expand Down Expand Up @@ -51,7 +52,7 @@
@each $color, $value in $modus-toast-variants {
&.#{$color} {
background-color: var(--modus-toast-#{$color}-bg, map-get($value, 'bg'));
border-color: var(--modus-toast-#{$color}-border-color, map-get($value, 'border-color'));
border-color: var(--modus-toast-#{$color}-bg, map-get($value, 'border-color'));
color: var(
--modus-toast-#{$color}-color,
if(map-get($value, 'color') == null, $modus-toast-color, map-get($value, 'color'))
Expand All @@ -60,8 +61,8 @@
.close {
svg path {
fill: var(
--modus-toast-#{$color}-close-btn-color,
if(map-get($value, 'close-button') == null, $modus-toast-close-btn-color, map-get($value, 'close-button'))
--modus-toast-#{$color}-color,
if(map-get($value, 'close-button') == null, $modus-toast-color, map-get($value, 'close-button'))
);
}
}
Expand All @@ -75,7 +76,7 @@
}
} @else {
svg:not(.icon-close) path {
fill: var(--modus-toast-#{$color}-border-color, map-get($value, 'border-color'));
fill: var(--modus-toast-#{$color}-color, map-get($value, 'border-color'));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('modus-toast', () => {
<mock:shadow-root>
<div class="default modus-toast" role="status">
<div class="icon">
<svg class="icon-info" fill="none" height="18" viewBox="0 0 24 24" width="18" xmlns="http://www.w3.org/2000/svg">
<svg class="icon-info" fill="currentColor" height="18" viewBox="0 0 24 24" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M12 21C16.968 21 21 16.968 21 12C21 7.032 16.968 3 12 3C7.032 3 3 7.032 3 12C3 16.968 7.032 21 12 21ZM11 7H13V9H11V7ZM11 11H13L13 17H11L11 11Z" fill="currentColor" fill-rule="evenodd"></path>
<mask height="18" id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" width="18" x="3" y="3">
<path clip-rule="evenodd" d="M12 21C16.968 21 21 16.968 21 12C21 7.032 16.968 3 12 3C7.032 3 3 7.032 3 12C3 16.968 7.032 21 12 21ZM11 7H13V9H11V7ZM11 11H13L13 17H11L11 11Z" fill="white" fill-rule="evenodd"></path>
Expand All @@ -39,7 +39,7 @@ describe('modus-toast', () => {
<mock:shadow-root>
<div class="default modus-toast" role="alert">
<div class="icon">
<svg class="icon-info" fill="none" height="18" viewBox="0 0 24 24" width="18" xmlns="http://www.w3.org/2000/svg">
<svg class="icon-info" fill="currentColor" height="18" viewBox="0 0 24 24" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M12 21C16.968 21 21 16.968 21 12C21 7.032 16.968 3 12 3C7.032 3 3 7.032 3 12C3 16.968 7.032 21 12 21ZM11 7H13V9H11V7ZM11 11H13L13 17H11L11 11Z" fill="currentColor" fill-rule="evenodd"></path>
<mask height="18" id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" width="18" x="3" y="3">
<path clip-rule="evenodd" d="M12 21C16.968 21 21 16.968 21 12C21 7.032 16.968 3 12 3C7.032 3 3 7.032 3 12C3 16.968 7.032 21 12 21ZM11 7H13V9H11V7ZM11 11H13L13 17H11L11 11Z" fill="white" fill-rule="evenodd"></path>
Expand Down
10 changes: 5 additions & 5 deletions stencil-workspace/src/components/modus-toast/modus-toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export class ModusToast {
private timerId: NodeJS.Timeout;

iconByType: Map<string, HTMLElement> = new Map([
['danger', <IconWarning color={'#C81922'} size={'18'} />],
['dark', <IconInfo color={'white'} size={'18'} />],
['danger', <IconWarning size={'18'} />],
['dark', <IconInfo size={'18'} />],
['default', <IconInfo size={'18'} />],
['primary', <IconInfo color={'#0D6AA8'} size={'18'} />],
['primary', <IconInfo size={'18'} />],
['secondary', <IconHelp size={'18'} />],
['success', <IconCheckCircle color={'#5E9331'} size={'18'} />],
['success', <IconCheckCircle size={'18'} />],
['tertiary', <IconInfo size={'18'} />],
['warning', <IconError color={'#FFBE00'} size={'18'} />],
['warning', <IconError size={'18'} />],
]);

classByType: Map<string, string> = new Map([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
$modus-toast-bg: var(--modus-toast-bg, $col_white) !default;
$modus-toast-border-color: var(--modus-toast-border-color, #252a2e4d) !default;
$modus-toast-color: var(--modus-toast-color, #252a2e) !default;
$modus-toast-close-btn-color: var(--modus-toast-close-btn-color, #252a2e) !default;
$modus-toast-variants: (
'primary': (
'bg': #dcedf9,
'border-color': #0063a3,
'color': #0063a3,
'close-button': #0e416c,
'bg': #0063a3,
'color': #fff,
),
'secondary': (
'bg': #cbcdd6,
'border-color': #252a2e,
),
'dark': (
'bg': #252a2e,
'border-color': #252a2e,
'color': #fff,
'close-button': #fff,
),
'success': (
'bg': #e0eccf,
'border-color': #4a821f,
'bg': #006638,
'color': #fff,
),
'danger': (
'bg': #fbd4d7,
'border-color': #ab1f26,
),
'warning': (
'bg': #fff2cc,
'border-color': #e49325,
'bg': #ab1f26,
'color': #fff,
),
);
55 changes: 18 additions & 37 deletions stencil-workspace/src/global/themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -326,37 +326,31 @@

// Toasts
--modus-toast-bg: var(--modus-white);
--modus-toast-border-color: #252a2e4d;
--modus-toast-color: var(--modus-body-color);
--modus-toast-close-btn-color: var(--modus-body-color);

// Primary
--modus-toast-primary-bg: var(--modus-blue-pale);
--modus-toast-primary-border-color: var(--modus-primary);
--modus-toast-primary-color: var(--modus-primary);
--modus-toast-primary-close-btn-color: var(--modus-blue-dark);
--modus-toast-primary-bg: var(--modus-primary);
--modus-toast-primary-color: var(--modus-white);

// Secondary
--modus-toast-secondary-bg: var(--modus-tertiary);
--modus-toast-secondary-border-color: var(--modus-trimble-gray);
--modus-toast-secondary-bg: #252a2e;
--modus-toast-secondary-color: var(--modus-white);

// Dark
--modus-toast-dark-bg: var(--modus-dark);
--modus-toast-dark-border-color: var(--modus-dark);
--modus-toast-dark-color: var(--modus-white);
--modus-toast-dark-close-btn-color: var(--modus-white);

// Success
--modus-toast-success-bg: var(--modus-green-pale);
--modus-toast-success-border-color: #4a821f;
--modus-toast-success-bg: #006638;
--modus-toast-success-color: var(--modus-white);

// Danger
--modus-toast-danger-bg: var(--modus-red-pale);
--modus-toast-danger-border-color: var(--modus-red-dark);
--modus-toast-danger-bg: var(--modus-red-dark);
--modus-toast-danger-color: var(--modus-white);

// Warning
--modus-toast-warning-bg: var(--modus-yellow-pale);
--modus-toast-warning-border-color: var(--modus-yellow-dark);
// Warning (deprecated)
--modus-toast-warning-bg: var(--modus-yellow-dark);

// Table
--modus-table-bg: var(--modus-white);
Expand Down Expand Up @@ -488,7 +482,6 @@

// Border
--modus-alert-primary-border-color: var(--modus-primary);
--modus-alert-dark-border-color: var(--modus-gray-8);
--modus-alert-success-border-color: var(--modus-success);
--modus-alert-danger-border-color: var(--modus-danger);
--modus-alert-warning-border-color: var(--modus-warning);
Expand Down Expand Up @@ -701,33 +694,21 @@
--modus-toast-color: var(--modus-white);
--modus-toast-close-btn-color: var(--modus-white);

// Primary
--modus-toast-primary-bg: #019aeb80;
--modus-toast-primary-border-color: var(--modus-primary);
--modus-toast-primary-color: var(--modus-toast-color);
--modus-toast-primary-close-btn-color: var(--modus-toast-close-btn-color);
// Toast Primary

// Secondary
--modus-toast-secondary-bg: #6a6e7980;
--modus-toast-secondary-border-color: var(--modus-secondary);
// Secondary (Dark)
--modus-toast-secondary-bg: #fff;
--modus-toast-secondary-color: #252a2e;

// Dark
--modus-toast-dark-bg: #171c1eb3;
--modus-toast-dark-border-color: var(--modus-dark);
--modus-toast-dark-color: var(--modus-toast-color);
--modus-toast-dark-close-btn-color: var(--modus-toast-close-btn-color);
// Dark (Deprecated)

// Success
--modus-toast-success-bg: #1e8a4480;
--modus-toast-success-border-color: var(--modus-success);
--modus-toast-success-bg: #4ea646;
--modus-toast-success-color: #252a2e;

// Danger
--modus-toast-danger-bg: #da212c80;
--modus-toast-danger-border-color: var(--modus-danger);

// Warning
--modus-toast-warning-bg: #fbad2680;
--modus-toast-warning-border-color: var(--modus-warning);
// Warning (Deprecated)

// Table
--modus-table-bg: var(--modus-gray-10);
Expand Down
2 changes: 1 addition & 1 deletion stencil-workspace/src/icons/svgs/icon-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const IconInfo: FunctionalComponent<IconProps> = (props: IconProps) => (
width={props.size ?? 16}
onClick={() => props.onClick()}
viewBox="0 0 24 24"
fill="none"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg">
<path
fill-rule="evenodd"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,47 @@ import { Anchor } from '@storybook/addon-docs';

[Modus Toast](https://modus.trimble.com/components/toasts/) web components are referenced using the `<modus-toast>` custom HTML element.

<Anchor storyId="components-toast--default" />

### Default

<modus-toast type="default">Default</modus-toast>

<Anchor storyId="components-toast--danger" />

### Danger

<modus-toast type="danger">Danger</modus-toast>

<Anchor storyId="components-toast--dark" />

### Dark

<modus-toast type="dark">Dark</modus-toast>

<Anchor storyId="components-toast--primary" />

### Primary

<modus-toast type="primary">Primary</modus-toast>

<Anchor storyId="components-toast--secondary" />
<Anchor storyId="components-toast--primary" />

### Secondary

<modus-toast type="secondary">Secondary</modus-toast>

<Anchor storyId="components-toast--success" />
<Anchor storyId="components-toast--secondary" />

### Success

<modus-toast type="success">Success</modus-toast>

<Anchor storyId="components-toast--warning" />
<Anchor storyId="components-toast--success" />

### Danger

### Warning
<modus-toast type="danger">Danger</modus-toast>

<modus-toast type="warning">Warning</modus-toast>
<Anchor storyId="components-toast--danger" />

```html
<modus-toast type="default">Default</modus-toast>
<modus-toast type="danger">Danger</modus-toast>
<modus-toast type="dark">Dark</modus-toast>
<modus-toast type="primary">Primary</modus-toast>
<modus-toast type="secondary">Secondary</modus-toast>
<modus-toast type="success">Success</modus-toast>
<modus-toast type="warning">Warning</modus-toast>
<modus-toast type="danger">Danger</modus-toast>
```

### Properties

| Name | Description | Type | Options | Default Value | Required |
| ------------- | -------------------------------- | --------- | ------------------------------------------------------------------------- | ------------- | -------- |
| `aria-label` | The toast's aria-label | `string` | | |
| `delay` | Time taken to dismiss the toast | `number` | | 15000 |
| `dismissible` | Whether the toast is dismissible | `boolean` | | false |
| `role` | Role taken by the toast | `string` | 'alert', 'log', 'marquee', 'status', 'timer' | 'status' |
| `show-icon` | Whether to show the toast's | `boolean` | | false |
| `type` | The toast's type | `string` | 'danger', 'dark', 'default', 'primary', 'secondary', 'success', 'warning' | 'default' |
| Name | Description | Type | Options | Default Value |
| ------------- | -------------------------------- | --------- | -------------------------------------------- | ------------- |
| `aria-label` | The toast's aria-label | `string` | | |
| `delay` | Time taken to dismiss the toast | `number` | | 15000 |
| `dismissible` | Whether the toast is dismissible | `boolean` | | false |
| `role` | Role taken by the toast | `string` | 'alert', 'log', 'marquee', 'status', 'timer' | 'status' |
| `show-icon` | Whether to show the toast's | `boolean` | | false |
| `type` | The toast's type | `string` | 'danger', 'primary', 'secondary', 'success', | 'primary' |

### DOM Events

Expand Down
Loading