From ec38c36c01969b0ae7c0a5c1ed56da1cd1579b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Curda?= Date: Mon, 20 May 2024 16:32:49 +0200 Subject: [PATCH] Feat(web-twig): Add Message and Link for ToastBar #DS-1213 --- .../Resources/components/Toast/ToastBar.twig | 4 +-- .../components/Toast/ToastBarLink.twig | 26 +++++++++++++++ .../components/Toast/ToastBarMessage.twig | 14 ++++++++ .../__snapshots__/toastBar.twig.snap.html | 32 +++++++++---------- .../components/Toast/stories/ToastColors.twig | 20 ++++++------ .../Toast/stories/ToastContentVariations.twig | 22 +++++++------ .../Toast/stories/ToastDynamicToastQueue.twig | 8 ++--- .../Toast/stories/ToastStaticToast.twig | 2 +- .../twig-components/toastBarLink.twig | 1 + .../twig-components/toastBarMessage.twig | 1 + 10 files changed, 87 insertions(+), 43 deletions(-) create mode 100644 packages/web-twig/src/Resources/components/Toast/ToastBarLink.twig create mode 100644 packages/web-twig/src/Resources/components/Toast/ToastBarMessage.twig create mode 100644 packages/web-twig/src/Resources/twig-components/toastBarLink.twig create mode 100644 packages/web-twig/src/Resources/twig-components/toastBarMessage.twig diff --git a/packages/web-twig/src/Resources/components/Toast/ToastBar.twig b/packages/web-twig/src/Resources/components/Toast/ToastBar.twig index d865fad5ae..0f83fe2c07 100644 --- a/packages/web-twig/src/Resources/components/Toast/ToastBar.twig +++ b/packages/web-twig/src/Resources/components/Toast/ToastBar.twig @@ -15,7 +15,7 @@ {%- set _rootDismissibleClassName = _isDismissible is same as(true) and _isTemplate is same as(false) ? _spiritClassPrefix ~ 'ToastBar--dismissible' : null -%} {%- set _boxClassName = _spiritClassPrefix ~ 'ToastBar__box' -%} {%- set _contentClassName = _spiritClassPrefix ~ 'ToastBar__content' -%} -{%- set _messageClassName = _spiritClassPrefix ~ 'ToastBar__message' -%} +{%- set _containerClassName = _spiritClassPrefix ~ 'ToastBar__container' -%} {%- set _isOpenClassName = _isOpen or _isTemplate ? 'is-open' : 'is-hidden' -%} {# Attributes #} @@ -53,7 +53,7 @@ {% endif %} {% endif %} -
+
{% block content %}{% endblock %}
diff --git a/packages/web-twig/src/Resources/components/Toast/ToastBarLink.twig b/packages/web-twig/src/Resources/components/Toast/ToastBarLink.twig new file mode 100644 index 0000000000..7b713f3007 --- /dev/null +++ b/packages/web-twig/src/Resources/components/Toast/ToastBarLink.twig @@ -0,0 +1,26 @@ +{# API #} +{%- set props = props | default([]) -%} +{%- set _color = props.color | default('inverted') -%} +{%- set _href = props.href -%} +{%- set _isDisabled = props.isDisabled | default(false) -%} +{%- set _isUnderlined = props.isUnderlined | default(true) -%} + +{# Class names #} +{%- set _colorClassName = _spiritClassPrefix ~ 'link-' ~ _color -%} +{%- set _rootDisabledClassName = _isDisabled ? _spiritClassPrefix ~ 'link-disabled' : null -%} +{%- set _rootUnderlinedClassName = _isUnderlined ? _spiritClassPrefix ~ 'link-underlined' : null -%} + +{# Miscellaneous #} +{%- set _styleProps = useStyleProps(props) -%} +{%- set _classNames = [ _colorClassName, _rootDisabledClassName, _rootUnderlinedClassName, _styleProps.className ] -%} +{%- set _allowedAttributes = [ 'target', 'title' ] -%} + + + {%- block content %}{% endblock %} + + diff --git a/packages/web-twig/src/Resources/components/Toast/ToastBarMessage.twig b/packages/web-twig/src/Resources/components/Toast/ToastBarMessage.twig new file mode 100644 index 0000000000..907d42a4c7 --- /dev/null +++ b/packages/web-twig/src/Resources/components/Toast/ToastBarMessage.twig @@ -0,0 +1,14 @@ +{# API #} +{%- set props = props | default([]) -%} + +{# Miscellaneous #} +{%- set _styleProps = useStyleProps(props) -%} +{%- set _classNames = [ _styleProps.className ] -%} + +
+ {% block content %}{% endblock %} +
diff --git a/packages/web-twig/src/Resources/components/Toast/__tests__/__snapshots__/toastBar.twig.snap.html b/packages/web-twig/src/Resources/components/Toast/__tests__/__snapshots__/toastBar.twig.snap.html index c0dcddfc02..9f8c70e788 100644 --- a/packages/web-twig/src/Resources/components/Toast/__tests__/__snapshots__/toastBar.twig.snap.html +++ b/packages/web-twig/src/Resources/components/Toast/__tests__/__snapshots__/toastBar.twig.snap.html @@ -7,8 +7,8 @@
-
-
+
+
Message only
@@ -18,11 +18,11 @@
-
+
-
+
Message with icon
@@ -32,11 +32,11 @@
-
+
-
+
Message with custom icon
@@ -46,8 +46,8 @@
-
-
+
+
Dismissible message with success color
@@ -60,8 +60,8 @@
-
-
+
+
@@ -70,11 +70,11 @@
-
+
-
+