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(notification): Adding links, updating styles - FRONT-4630 #3645

Merged
merged 9 commits into from
Sep 27, 2024
2 changes: 2 additions & 0 deletions src/implementations/twig/components/notification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ npm install --save @ecl/twig-component-notification
- **"icon"** (object of type "icon") (default: {})
- **"sr_icon"** (string) (default: ''): additional label for the icon; for screen readers
- **"title"** (string) (default: '')
- **"description"** (string) (default: '')
- **"links"** (array) (default: [])
- **"close"** (object of type "button") (default: {}): close button (optional)
- **"extra_classes"** (optional) (string) (default: '') Extra classes (space separated)
- **"extra_attributes"** (optional) (array) (default: []) Extra attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ exports[`EC Notification Info renders correctly 1`] = `
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan semper lorem, ac mollis lacus tincidunt eu. Duis scelerisque diam eu tempus fringilla.
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Lorem ipsum
</a>
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Nullam accumsan semper lorem
</a>
</div>
</div>
</div>
</jest>
Expand Down Expand Up @@ -192,6 +212,26 @@ exports[`EC Notification Info renders correctly with extra attributes 1`] = `
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan semper lorem, ac mollis lacus tincidunt eu. Duis scelerisque diam eu tempus fringilla.
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Lorem ipsum
</a>
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Nullam accumsan semper lorem
</a>
</div>
</div>
</div>
</jest>
Expand Down Expand Up @@ -257,6 +297,26 @@ exports[`EC Notification Info renders correctly with extra class names 1`] = `
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan semper lorem, ac mollis lacus tincidunt eu. Duis scelerisque diam eu tempus fringilla.
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Lorem ipsum
</a>
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Nullam accumsan semper lorem
</a>
</div>
</div>
</div>
</jest>
Expand Down Expand Up @@ -317,6 +377,26 @@ exports[`EC Notification Info renders correctly without description 1`] = `
>
Information notification
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Lorem ipsum
</a>
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Nullam accumsan semper lorem
</a>
</div>
</div>
</div>
</jest>
Expand Down Expand Up @@ -377,6 +457,26 @@ exports[`EC Notification Info renders correctly without title 1`] = `
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan semper lorem, ac mollis lacus tincidunt eu. Duis scelerisque diam eu tempus fringilla.
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Lorem ipsum
</a>
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Nullam accumsan semper lorem
</a>
</div>
</div>
</div>
</jest>
Expand Down Expand Up @@ -640,6 +740,26 @@ exports[`EU Notification Info renders correctly 1`] = `
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan semper lorem, ac mollis lacus tincidunt eu. Duis scelerisque diam eu tempus fringilla.
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Lorem ipsum
</a>
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Nullam accumsan semper lorem
</a>
</div>
</div>
</div>
</jest>
Expand Down Expand Up @@ -707,6 +827,26 @@ exports[`EU Notification Info renders correctly with extra attributes 1`] = `
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan semper lorem, ac mollis lacus tincidunt eu. Duis scelerisque diam eu tempus fringilla.
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Lorem ipsum
</a>
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Nullam accumsan semper lorem
</a>
</div>
</div>
</div>
</jest>
Expand Down Expand Up @@ -772,6 +912,26 @@ exports[`EU Notification Info renders correctly with extra class names 1`] = `
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan semper lorem, ac mollis lacus tincidunt eu. Duis scelerisque diam eu tempus fringilla.
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Lorem ipsum
</a>
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Nullam accumsan semper lorem
</a>
</div>
</div>
</div>
</jest>
Expand Down Expand Up @@ -832,6 +992,26 @@ exports[`EU Notification Info renders correctly without description 1`] = `
>
Information notification
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Lorem ipsum
</a>
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Nullam accumsan semper lorem
</a>
</div>
</div>
</div>
</jest>
Expand Down Expand Up @@ -892,6 +1072,26 @@ exports[`EU Notification Info renders correctly without title 1`] = `
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan semper lorem, ac mollis lacus tincidunt eu. Duis scelerisque diam eu tempus fringilla.
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Lorem ipsum
</a>
</div>
<div
class="ecl-notification__link"
>
<a
class="ecl-link"
href="/example"
>
Nullam accumsan semper lorem
</a>
</div>
</div>
</div>
</jest>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- "icon" (object of type "icon") (default: {})
- "sr_icon" (string) (default: ''): additional label for the icon; for screen readers
- "title" (string) (default: '')
- "description" (string) (default: '')
- "links" (array): An array of ECL links objects
- "close" (object of type "button") (default: {}): close button (optional)
- "extra_classes" (optional) (string) (default: '') Extra classes (space separated) for the select
- "extra_attributes" (optional) (array) (default: []) Extra attributes for select
Expand All @@ -23,6 +25,7 @@
{% set _sr_icon = sr_icon|default('') %}
{% set _title = title|default('') %}
{% set _close = close|default({}) %}
{% set _links = links|default([]) %}
{% set _description = description|default('') %}
{% set _css_class = 'ecl-notification' %}
{% set _extra_attributes = 'data-ecl-auto-init="Notification"' %}
Expand Down Expand Up @@ -67,23 +70,29 @@
extra_classes: 'ecl-notification__icon',
} only %}
<div class="ecl-notification__content">
{% if _close is not empty %}
{% include '@ecl/button/button.html.twig' with _close|merge({
type: 'button',
variant: 'tertiary',
extra_classes: 'ecl-notification__close',
extra_attributes: [{
name: 'data-ecl-notification-close',
}],
}) only %}
{% endif %}

{% if _title is not empty %}
<div class="ecl-notification__title">{{ _title }}</div>
{% endif %}
{% if _description is not empty %}
<div class="ecl-notification__description">{{ _description }}</div>
{% endif %}
{% if _close is not empty %}
{% include '@ecl/button/button.html.twig' with _close|merge({
type: 'button',
variant: 'tertiary',
extra_classes: 'ecl-notification__close',
extra_attributes: [{
name: 'data-ecl-notification-close',
}],
}) only %}
{% endif %}
{% if _title is not empty %}
<div class="ecl-notification__title">{{ _title }}</div>
{% endif %}
{% if _description is not empty %}
<div class="ecl-notification__description">{{ _description }}</div>
{% endif %}
{% if _links is not empty and _links is iterable %}
{% for _link in _links %}
<div class="ecl-notification__link">
{% include '@ecl/link/link.html.twig' with _link only %}
</div>
{% endfor %}
{% endif %}
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ const dataInfo = system === 'eu' ? dataInfoEu : dataInfoEc;
const dataSuccess = system === 'eu' ? dataSuccessEu : dataSuccessEc;
const dataError = system === 'eu' ? dataErrorEu : dataErrorEc;
const dataWarning = system === 'eu' ? dataWarningEu : dataWarningEc;
const dataLinks = [...dataInfo.links];

const getArgs = (data) => ({
show_close: true,
show_title: true,
title: data.title,
show_links: true,
description: data.description,
});

Expand All @@ -46,6 +48,14 @@ const getArgTypes = () => ({
category: 'Optional',
},
},
show_links: {
name: 'links',
type: { name: 'boolean' },
description: 'Show the notification links',
table: {
category: 'Optional',
},
},
title: {
name: 'title',
type: { name: 'string' },
Expand Down Expand Up @@ -80,6 +90,12 @@ const prepareData = (data, args) => {
delete clone.close;
}

if (args.show_links) {
clone.links = dataLinks;
} else {
clone.links = [];
}

// Other controls
if (clone.title) {
clone.title = args.title;
Expand Down
Loading
Loading