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

UHF-9497 #909

Merged
merged 12 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
2 changes: 1 addition & 1 deletion dist/css/ckeditor.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/css/styles.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hdbt.theme
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Functions to support theming in the hdbt theme.
*/

declare(strict_types = 1);
declare(strict_types=1);

use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Language\LanguageInterface;
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/scss/05_objects/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,6 @@ p > a.hds-button.hds-button--supplementary:first-child {
--outline-width: 3px;
}

// Hide target blank explanation text from others than screen-readers
.hds-button__target-blank {
@include visually-hidden;
}

// Combat ckeditor leaking spans from inside buttons and hds setting these spans stupid paddings and margins
:not(.hds-button) > .hds-button__label {
margin: 0;
Expand Down
4 changes: 2 additions & 2 deletions src/scss/06_components/paragraphs/_banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
padding-top: $spacing-double;
}

a.banner__button {
.component--banner .banner a[data-hds-component='button'] {
margin: $spacing-double auto 0;
}

Expand Down Expand Up @@ -76,7 +76,7 @@ a.banner__button {
}

&.component--banner-has-icon {
.banner__button {
a {
@include breakpoint($breakpoint-l) {
margin-left: auto;
margin-right: 0;
Expand Down
10 changes: 9 additions & 1 deletion templates/module/helfi_api_base/helfi-link.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

{# Check if we want to render old link icons, the new links with data-hds="button" use pseudo elements instead #}
{% set render_old_link = false %}
{% if 'data-hds-component' not in attributes|keys or attributes['data-hds-component'] != 'button' %}

{% if
('data-hds-component' not in attributes|keys or attributes['data-hds-component'] != 'button') and
('data-hds-component' not in url.options.attributes|keys or url.options.attributes['data-hds-component'] != 'button')
%}
{% set render_old_link = true %}
{% endif %}

Expand All @@ -24,6 +28,10 @@
{% endif %}
{% endif %}

{% if 'data-open-in-new-tab' in url.options.attributes|keys %}
<span class="visually-hidden">({{ 'The link opens in a new tab'|t({}, {'context': 'Explanation for users that the link opens in a new tab instead of the expected current tab'}) }}.)</span>
{% endif %}

{% if 'data-is-external' in attributes|keys %}
{%- set attribute_icon -%}
{%- if render_old_link -%}
Expand Down
44 changes: 8 additions & 36 deletions templates/navigation/link-button.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* - label: String for the label visible in link.
* - url: String for the url to link to.
* - type: primary, secondary or supplementary type of button.
* - size: small or unset.
* - open_in_a_new_window: Boolean for opening in a new window and showing explanation.
* - icon: Boolean if first icon is enabled
* - icon_type: String for first icon type
* - class: Optional String to be added to the class list
*
* Usage example:
* {% include '@hdbt/navigation/link-button.html.twig' with {
Expand All @@ -21,44 +19,18 @@
*
* TODO: UHF-8793 Refactor hds-button (https://helsinkisolutionoffice.atlassian.net/browse/UHF-8793).
*/
#}

{% if type == 'primary' %}
{% set type_class = 'hds-button--primary' %}
{% elseif type == 'secondary' %}
{% set type_class = 'hds-button--secondary' %}
{% elseif type == 'supplementary' %}
{% set type_class = 'hds-button--supplementary' %}
{% endif %}

{% set classes = [
'hds-button',
'hds-button--link',
type_class,
size == 'small' ? 'hds-button--small',
class,
] %}


{% set explain = null %}
{% set link_options = {class: classes|join(' ')} %}
#}
{% set link_options = {
'data-hds-component':'button',
'data-hds-variant': type,
} %}

{% if open_in_a_new_window %}
{%- set explain -%}
<span class="hds-button__target-blank">({{ 'The link opens in a new tab'|t({}, {'context': 'Explanation for users that the link opens in a new tab instead of the expected current tab'}) }}.)</span>
{%- endset -%}
{% set link_options = link_options|merge({target: '_blank'}) %}
{% set link_options = link_options|merge({target: '_blank', 'data-open-in-new-tab': true}) %}
{% endif %}

{% if icon == true %}
{% set link_options = link_options|merge({'data-selected-icon': icon_type}) %}
{% set link_options = link_options|merge({'data-hds-icon-start': icon_type}) %}
{% endif %}

{% set title %}
<span class="hds-button__label">
{{ label }}
{{ explain }}
</span>
{% endset %}

{{ link(title, url, link_options) }}
{{ link(label, url, link_options) }}
6 changes: 2 additions & 4 deletions templates/paragraphs/paragraph--banner.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@
{% set link = content.field_banner_link.0['#url'] %}
{% set text = content.field_banner_link.0['#title'] %}
{% set link_type = content.field_banner_link_design[0]['#markup'] %}
{% set open_in_a_new_window = content.field_banner_link.0['#options']['target_new'] %}
{% set icon = content.field_banner_link.0['#options']['icon'] %}

{% set open_in_a_new_window = link.options.target_new %}
{% set icon = link.options.icon %}
{% block paragraph %}
{% if has_content %}
{% embed "@hdbt/misc/component.twig" with
Expand Down Expand Up @@ -75,7 +74,6 @@
type: link_type|clean_class,
label: text,
url: link,
class: 'banner__button',
open_in_a_new_window: open_in_a_new_window,
icon: icon ? true : false,
icon_type: icon ? icon|clean_class,
Expand Down
4 changes: 0 additions & 4 deletions templates/paragraphs/paragraph--hearings.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
type: 'primary',
label: 'See all hearings'|t({},{'context': 'See all hearings link text'}),
url: 'https://kerrokantasi.hel.fi/hearings/list?lang=' ~ current_langcode,
class: 'hearings__link',
is_external: true,
} %}
{% else %}
<section class="hearings__results">
Expand All @@ -36,8 +34,6 @@
type: 'primary',
label: 'See all already closed hearings'|t({},{'context': 'See closed hearings link text'}),
url: 'https://kerrokantasi.hel.fi/hearings/list?lang=' ~ current_langcode,
class: 'hearings__link',
is_external: true,
} %}
{% endif %}
{% endblock component_content %}
Expand Down
Loading