From 338665214afa9268e8e09c0d71812a40fab8ab0b Mon Sep 17 00:00:00 2001 From: Daniela Muller <62384394+danimuller20@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:09:58 -0300 Subject: [PATCH] feat: update alert (#1115) * feat: adjust alert component * chore: change icon link to chevron * test: update snapshot * chore: update alert text size and gap * chore: update ocean icons version * test: update snapshot * test: update breadcrumbs test * chore: update snapshot * chore: update snapshot * style: update alert caption font weight * feat: update button alert caption * chore: update alert documentation * chore: update responsive link hover color in alert variants * feat: update link size in alert component --- .../ocean-core/src/components/_alert.scss | 65 +++++++++- packages/ocean-react/package.json | 2 +- .../Accordion/__tests__/Accordion.test.tsx | 4 +- packages/ocean-react/src/Alert/Alert.tsx | 15 ++- .../src/Alert/__tests__/Alert.test.tsx | 122 +++++++++--------- .../src/Alert/stories/Alert.stories.mdx | 29 +++-- .../Breadcrumb/__tests__/Breadcrumb.test.tsx | 51 +++++++- .../CrossSellCard/__tests__/CrossSellCard.tsx | 4 +- .../src/Date/__tests__/DatePicker.test.tsx | 2 +- .../src/Date/__tests__/DateRange.test.tsx | 4 +- .../__tests__/FormControl.test.tsx | 2 +- .../src/Search/__tests__/Search.test.tsx | 2 +- .../src/Select/__tests__/Select.test.tsx | 2 +- .../src/Snackbar/__tests__/Snackbar.test.tsx | 2 +- .../src/TopBar/__tests__/TopBar.test.tsx | 68 +++++----- .../HTMLDivElement.test.tsx.snap | 6 +- yarn.lock | 8 +- 17 files changed, 252 insertions(+), 136 deletions(-) diff --git a/packages/ocean-core/src/components/_alert.scss b/packages/ocean-core/src/components/_alert.scss index 30ec5a3de..4953a0a86 100644 --- a/packages/ocean-core/src/components/_alert.scss +++ b/packages/ocean-core/src/components/_alert.scss @@ -1,7 +1,7 @@ .ods-alert { align-items: flex-start; background-color: $color-interface-light-up; - border-radius: $border-radius-md; + border-radius: $border-radius-sm; color: $color-interface-dark-down; display: flex; flex-direction: column; @@ -13,11 +13,19 @@ padding: $spacing-stack-xs; @include media-breakpoint-up(sm) { + flex-direction: row; + &__button--mobile { display: none; } } + &--with-button-no-title { + @include media-breakpoint-up(sm) { + font-size: $font-size-xxs; + } + } + &--error { background-color: $color-status-negative-up; @@ -33,9 +41,23 @@ background-color: $color-status-negative-pure; } + .ods-btn--primary:hover, + .ods-btn--primary:focus { + background-color: $color-status-negative-down; + } + + .ods-btn--primary:active { + background-color: $color-status-negative-deep; + } + .ods-link { color: $color-status-negative-pure; } + + .ods-link:hover, + .ods-link:focus { + color: $color-status-negative-down; + } } &--warning { @@ -53,9 +75,23 @@ background-color: $color-status-warning-deep; } + .ods-btn--primary:hover, + .ods-btn--primary:focus { + background-color: $color-status-warning-down; + } + + .ods-btn--primary:active { + background-color: $color-status-warning-deep; + } + .ods-link { color: $color-status-warning-deep; } + + .ods-link:hover, + .ods-link:focus { + color: $color-status-warning-down; + } } &--success { @@ -73,15 +109,30 @@ background-color: $color-status-positive-deep; } + .ods-btn--primary:hover, + .ods-btn--primary:focus { + background-color: $color-status-positive-down; + } + + .ods-btn--primary:active { + background-color: $color-status-positive-deep; + } + .ods-link { color: $color-status-positive-deep; } + + .ods-link:hover, + .ods-link:focus { + color: $color-status-positive-down; + } } &__text { display: flex; flex: 1; flex-direction: column; + gap: $spacing-stack-xxxs; } &__icon { @@ -96,7 +147,7 @@ } &--mobile { - margin-top: $spacing-stack-xxs; + margin: $spacing-stack-xxs-extra 0 0 $spacing-inline-md; } .ods-btn { @@ -118,7 +169,13 @@ &__title { color: $color-brand-primary-down; font-size: $font-size-xxs; - font-weight: $font-weight-bold; - line-height: $line-height-comfy; + font-weight: $font-weight-extrabold; + line-height: $line-height-loose; + } + + &__content { + &--no-title { + padding-top: 0; + } } } diff --git a/packages/ocean-react/package.json b/packages/ocean-react/package.json index 59d18c1bf..571ff44e7 100644 --- a/packages/ocean-react/package.json +++ b/packages/ocean-react/package.json @@ -34,7 +34,7 @@ }, "dependencies": { "@reach/auto-id": "0.16.0", - "@useblu/ocean-icons-react": "1.4.0", + "@useblu/ocean-icons-react": "1.23.1", "chart.js": "^3.9.1", "classnames": "2.3.1", "date-fns": "^2.29.1", diff --git a/packages/ocean-react/src/Accordion/__tests__/Accordion.test.tsx b/packages/ocean-react/src/Accordion/__tests__/Accordion.test.tsx index b2e12e207..f42b4a758 100644 --- a/packages/ocean-react/src/Accordion/__tests__/Accordion.test.tsx +++ b/packages/ocean-react/src/Accordion/__tests__/Accordion.test.tsx @@ -35,7 +35,7 @@ test('renders element properly', () => { > @@ -81,7 +81,7 @@ test('render element opened', () => { > diff --git a/packages/ocean-react/src/Alert/Alert.tsx b/packages/ocean-react/src/Alert/Alert.tsx index 301cbd79e..5315465bd 100644 --- a/packages/ocean-react/src/Alert/Alert.tsx +++ b/packages/ocean-react/src/Alert/Alert.tsx @@ -62,12 +62,13 @@ const Alert = React.forwardRef( 'ods-alert', `ods-alert--${type}`, longSize && 'ods-alert--long', + button && !title && 'ods-alert--with-button-no-title', className )} {...rest} > {longSize ? ( - <> +
( )}
{title &&
{children}
} - +
) : ( <>
( {alertIcon}
{title &&
{title}
} -
{children}
+
+ {children} +
{button && (
@@ -106,7 +113,7 @@ const Alert = React.forwardRef(
{button && (
- + {button}
diff --git a/packages/ocean-react/src/Alert/__tests__/Alert.test.tsx b/packages/ocean-react/src/Alert/__tests__/Alert.test.tsx index d274c3c36..9fac52c5b 100644 --- a/packages/ocean-react/src/Alert/__tests__/Alert.test.tsx +++ b/packages/ocean-react/src/Alert/__tests__/Alert.test.tsx @@ -66,52 +66,20 @@ describe('Alert', () => { setup({ title: 'Test Title', size: 'long' }); expect(document.querySelector('.ods-alert')).toMatchInlineSnapshot(` - - `); - }); - - test('checks short description snapshot', () => { - setup({ title: 'Test Title', size: 'short' }); - - expect(document.querySelector('.ods-alert')).toMatchInlineSnapshot(` -