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

feat: update alert #1115

Merged
merged 27 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ec5bdd5
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Apr 16, 2024
dd449a5
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Apr 18, 2024
db5e3fe
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 May 15, 2024
5d5a933
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 May 16, 2024
9374583
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Jun 11, 2024
6a6bf59
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Jun 14, 2024
745da9d
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Jun 17, 2024
58939ae
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Jun 18, 2024
0ec2aff
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Jun 19, 2024
fb8429c
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Jun 20, 2024
100afd5
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Jun 21, 2024
3d5a4f4
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Jun 26, 2024
863d6e4
Merge branch 'master' of github.com:ocean-ds/ocean-web
danimuller20 Jun 26, 2024
9dfa30b
feat: adjust alert component
danimuller20 Jun 26, 2024
b6382ab
chore: change icon link to chevron
danimuller20 Jun 27, 2024
5ed7810
test: update snapshot
danimuller20 Jun 27, 2024
d538b5c
chore: update alert text size and gap
danimuller20 Jun 28, 2024
a8d2157
chore: update ocean icons version
danimuller20 Jun 28, 2024
55ce6d5
test: update snapshot
danimuller20 Jun 28, 2024
ad28aaf
test: update breadcrumbs test
danimuller20 Jun 28, 2024
3d8bd63
chore: update snapshot
danimuller20 Jul 1, 2024
ba0174c
chore: update snapshot
danimuller20 Jul 1, 2024
3ea981e
style: update alert caption font weight
danimuller20 Jul 1, 2024
09d3bfd
feat: update button alert caption
danimuller20 Jul 1, 2024
87dbba6
chore: update alert documentation
danimuller20 Jul 1, 2024
76ed6b9
chore: update responsive link hover color in alert variants
danimuller20 Jul 2, 2024
64c3ee9
feat: update link size in alert component
danimuller20 Jul 2, 2024
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
65 changes: 61 additions & 4 deletions packages/ocean-core/src/components/_alert.scss
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -96,7 +147,7 @@
}

&--mobile {
margin-top: $spacing-stack-xxs;
margin: $spacing-stack-xxs-extra 0 0 $spacing-inline-md;
}

.ods-btn {
Expand All @@ -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;
}
}
}
2 changes: 1 addition & 1 deletion packages/ocean-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test('renders element properly', () => {
>
<path
clip-rule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
d="M5.293 7.293a1 1 0 0 1 1.414 0L10 10.586l3.293-3.293a1 1 0 1 1 1.414 1.414l-4 4a1 1 0 0 1-1.414 0l-4-4a1 1 0 0 1 0-1.414z"
fill-rule="evenodd"
/>
</svg>
Expand Down Expand Up @@ -81,7 +81,7 @@ test('render element opened', () => {
>
<path
clip-rule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
d="M5.293 7.293a1 1 0 0 1 1.414 0L10 10.586l3.293-3.293a1 1 0 1 1 1.414 1.414l-4 4a1 1 0 0 1-1.414 0l-4-4a1 1 0 0 1 0-1.414z"
fill-rule="evenodd"
/>
</svg>
Expand Down
15 changes: 11 additions & 4 deletions packages/ocean-react/src/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
'ods-alert',
`ods-alert--${type}`,
longSize && 'ods-alert--long',
button && !title && 'ods-alert--with-button-no-title',
className
)}
{...rest}
>
{longSize ? (
<>
<div>
<div
className={classNames(
'ods-alert__header',
Expand All @@ -82,7 +83,7 @@ const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
)}
</div>
{title && <div className="alert__content">{children}</div>}
</>
</div>
) : (
<>
<div
Expand All @@ -94,7 +95,13 @@ const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
{alertIcon}
<div className="ods-alert__text">
{title && <div className="ods-alert__title">{title}</div>}
<div className="alert__content">{children}</div>
<div
className={classNames('alert__content', {
'alert__content--no-title': !title,
})}
>
{children}
</div>
</div>
{button && (
<div className="ods-alert__button">
Expand All @@ -106,7 +113,7 @@ const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
</div>
{button && (
<div className="ods-alert__button--mobile">
<Link size="sm" onClick={buttonAction} icon="externalLink">
<Link size="tiny" onClick={buttonAction} icon="linkChevron">
{button}
</Link>
</div>
Expand Down
122 changes: 63 additions & 59 deletions packages/ocean-react/src/Alert/__tests__/Alert.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,52 +66,20 @@ describe('Alert', () => {
setup({ title: 'Test Title', size: 'long' });

expect(document.querySelector('.ods-alert')).toMatchInlineSnapshot(`
<div
class="ods-alert ods-alert--default ods-alert--long"
role="alert"
>
<div
class="ods-alert__header ods-alert__header--margin"
class="ods-alert ods-alert--default ods-alert--long"
role="alert"
>
mock-information-circle-outline
<div
class="ods-alert__title"
>
Test Title
</div>
</div>
<div
class="alert__content"
>
<div
class="ods-alert__content"
>
Hello There!
</div>
</div>
</div>
`);
});

test('checks short description snapshot', () => {
setup({ title: 'Test Title', size: 'short' });

expect(document.querySelector('.ods-alert')).toMatchInlineSnapshot(`
<div
class="ods-alert ods-alert--default"
role="alert"
>
<div
class="ods-alert__header"
>
mock-information-circle-outline
<div
class="ods-alert__text"
>
<div>
<div
class="ods-alert__title"
class="ods-alert__header ods-alert__header--margin"
>
Test Title
mock-information-circle-outline
<div
class="ods-alert__title"
>
Test Title
</div>
</div>
<div
class="alert__content"
Expand All @@ -124,37 +92,73 @@ describe('Alert', () => {
</div>
</div>
</div>
</div>
`);
});

test('checks short description snapshot', () => {
setup({ title: 'Test Title', size: 'short' });

expect(document.querySelector('.ods-alert')).toMatchInlineSnapshot(`
<div
class="ods-alert ods-alert--default"
role="alert"
>
<div
class="ods-alert__header"
>
mock-information-circle-outline
<div
class="ods-alert__text"
>
<div
class="ods-alert__title"
>
Test Title
</div>
<div
class="alert__content"
>
<div
class="ods-alert__content"
>
Hello There!
</div>
</div>
</div>
</div>
</div>
`);
});

test('checks custom icon', () => {
setup({ icon: <StarOutline /> });

expect(document.querySelector('.ods-alert')).toMatchInlineSnapshot(`
<div
class="ods-alert ods-alert--default ods-alert--long"
role="alert"
>
<div
class="ods-alert__header"
class="ods-alert ods-alert--default ods-alert--long"
role="alert"
>
<div
class="ods-alert__icon"
>
mock-start-circle-outline
</div>
<div
class="alert__content"
>
<div>
<div
class="ods-alert__content"
class="ods-alert__header"
>
Hello There!
<div
class="ods-alert__icon"
>
mock-start-circle-outline
</div>
<div
class="alert__content"
>
<div
class="ods-alert__content"
>
Hello There!
</div>
</div>
</div>
</div>
</div>
</div>
`);
});
});
29 changes: 15 additions & 14 deletions packages/ocean-react/src/Alert/stories/Alert.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,21 @@ You can set the `button` that display on the alert.

## CSS

| Global class | Description |
| ---------------------------- | ------------------------------------------------------- |
| .ods-alert | Styles applied to the root element. |
| .ods-alert--long | Styles applied to the root element when is long size. |
| .ods-alert--error | Styles applied to the root element with a error type. |
| .ods-alert--warning | Styles applied to the root element with a warning type. |
| .ods-alert--success | Styles applied to the root element with a success type. |
| .ods-alert\_\_header | Styles applied to the header element. |
| .ods-alert\_\_header--margin | Styles applied to the header element with bottom margin |
| .ods-alert\_\_icon | Styles applied to the icon element. |
| .ods-alert\_\_title | Styles applied to the title element. |
| .ods-alert\_\_content | Styles applied to the content element. |
| .ods-alert\_\_button | Styles applied to the button element. |
| .ods-alert\_\_button--mobile | Styles applied to the button element in mobile view. |
| Global class | Description |
| -------------------------------- | ---------------------------------------------------------------- |
| .ods-alert | Styles applied to the root element. |
| .ods-alert--long | Styles applied to the root element when is long size. |
| .ods-alert--with-button-no-title | Styles applied to the root element has button and without title. |
| .ods-alert--error | Styles applied to the root element with a error type. |
| .ods-alert--warning | Styles applied to the root element with a warning type. |
| .ods-alert--success | Styles applied to the root element with a success type. |
| .ods-alert\_\_header | Styles applied to the header element. |
| .ods-alert\_\_header--margin | Styles applied to the header element with bottom margin |
| .ods-alert\_\_icon | Styles applied to the icon element. |
| .ods-alert\_\_title | Styles applied to the title element. |
| .ods-alert\_\_content | Styles applied to the content element. |
| .ods-alert\_\_button | Styles applied to the button element. |
| .ods-alert\_\_button--mobile | Styles applied to the button element in mobile view. |

If that's not sufficient, you can check the [implementation of the component](https://github.com/ocean-ds/ocean-web/blob/master/packages/ocean-react/src/Alert/Alert.tsx) for more detail.

Expand Down
Loading
Loading