Skip to content

Commit

Permalink
feat(alert): add announcement connotation (VIV-1830) (#1840)
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelbt authored Jul 8, 2024
1 parent 9202a3d commit b1a980f
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libs/components/src/lib/alert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Use the `open` attribute to toggle the alert open state.

Use the `connotation` attribute to change the alert's icon and icon color.

- Type: `'accent'` | `'information'` | `'success'` | `'warning'` | `'alert'`
- Type: `'accent'` | `'information'` | `'success'` | `'warning'` | `'alert'` | `'announcement'`
- Default: `undefined`

Note that each connotation comes with a default icon (that you can override with the `icon` attribute).
Expand All @@ -85,6 +85,7 @@ Note that each connotation comes with a default icon (that you can override with
<vwc-option value="warning" text="warning"></vwc-option>
<vwc-option value="alert" text="alert"></vwc-option>
<vwc-option value="information" text="information"></vwc-option>
<vwc-option value="announcement" text="announcement"></vwc-option>
</vwc-select>

<script>
Expand Down
2 changes: 1 addition & 1 deletion libs/components/src/lib/alert/alert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
border-radius-variables;
@use '../../../../../dist/libs/tokens/scss/tokens.constants' as constants;
@use '../../../../shared/src/lib/sass/mixins/connotation/config' with (
$connotations: accent success information alert warning,
$connotations: accent success information alert warning announcement,
$shades: primary primary-text,
$default: accent
);
Expand Down
2 changes: 2 additions & 0 deletions libs/components/src/lib/alert/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ export type AlertConnotation =
| Connotation.Information
| Connotation.Success
| Connotation.Warning
| Connotation.Announcement
| Connotation.Alert;

const connotationIconMap = new Map([
[Connotation.Accent, 'megaphone-line'],
[Connotation.Information, 'info-line'],
[Connotation.Success, 'check-circle-line'],
[Connotation.Warning, 'warning-line'],
[Connotation.Announcement, 'sparkles-line'],
[Connotation.Alert, 'error-line'],
]);

Expand Down
33 changes: 33 additions & 0 deletions libs/components/src/lib/alert/ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,36 @@ async function testResponsiveAlert({ page }: { page: Page }) {
);
}
test('alert in mobile screens', testResponsiveAlert);

async function testConnotationAlert({ page }: { page: Page }) {
const template = `
<div style="margin: 5px; height: 250px; transform: translateY(0px);">
<vwc-alert text="accent" connotation="accent" open placement="top-start"></vwc-alert>
<vwc-alert text="information" connotation="information" open placement="top"></vwc-alert>
<vwc-alert text="success" connotation="success" open placement="top-end"></vwc-alert>
<vwc-alert text="warning" connotation="warning" open placement="bottom-start"></vwc-alert>
<vwc-alert text="alert" connotation="alert" open placement="bottom"></vwc-alert>
<vwc-alert text="announcement" connotation="announcement" open placement="bottom-end"></vwc-alert>
</div>
`;

await page.setViewportSize({ width: 560, height: 500 });

await loadComponents({
page,
components,
});
await loadTemplate({
page,
template,
});

const testWrapper = await page.$('#wrapper');

await page.waitForLoadState('networkidle');

expect(await testWrapper?.screenshot()).toMatchSnapshot(
'./snapshots/alert-connotation.png'
);
}
test('alert in connotation', testConnotationAlert);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b1a980f

Please sign in to comment.