8000 Add a template for the new link component by msayoung · Pull Request #220 · localgovdrupal/localgov_base · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a template for the new link component #220

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

Merged
merged 6 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions css/base/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ body {
--ia-block-bg-color: var(--color-white);
--ia-block-bg-color-promoted: var(--color-white);

/* Link component */
--link-icon-margin: var(--spacing-smaller);

/* Link and summary component */
--link-and-summary-title-icon-margin: var(--spacing-smaller);

/* Featured Subsite */
--featured-subsite-bg-color: var(--color-grey-light);

Expand Down
2 changes: 1 addition & 1 deletion css/components/link-and-summary.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

.link-block__title-icon {
flex-shrink: 0;
margin-right: var(--spacing-smaller);
margin-right: var(--link-and-summary-title-icon-margin);
}

.link-block__title {
Expand Down
10 changes: 10 additions & 0 deletions css/components/link.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.link-wrapper {
display: flex;
align-items: center;
}

.link-icon {
flex-shrink: 0;
margin-right: var(--link-icon-margin);
}

3 changes: 3 additions & 0 deletions css/components/link.ie11.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.link-icon {
margin-right: 0.5rem;
}
6 changes: 6 additions & 0 deletions localgov_base.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ link-and-summary:
css/components/link-and-summary.ie11.css: {}
css/components/link-and-summary.css: {}

link:
css:
theme:
css/components/link.ie11.css: {}
css/components/link.css: {}

key-contacts:
css:
theme:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<div class="link-block__title-wrapper">
{% include "@localgov_base/includes/icons/icon.html.twig" with {
icon_name: title_icon,
icon_wrapper_element: 'div',
icon_classes: 'link-block__title-icon',
}
%}
Expand All @@ -77,4 +76,4 @@
{{ content|without('localgov_link') }}
</div>

</div>
</div>
81 changes: 81 additions & 0 deletions templates/paragraphs/paragraph--localgov-link.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{#
/**
* @file
* Default theme implementation to display a paragraph.
*
* Available variables:
* - paragraph: Full paragraph entity.
* Only method names starting with "get", "has", or "is" and a few common
* methods such as "id", "label", and "bundle" are available. For example:
* - paragraph.getCreatedTime() will return the paragraph creation timestamp.
* - paragraph.id(): The paragraph ID.
* - paragraph.bundle(): The type of the paragraph, for example, "image" or "text".
* - paragraph.getOwnerId(): The user ID of the paragraph author.
* See Drupal\paragraphs\Entity\Paragraph for a full list of public properties
* and methods for the paragraph object.
* - content: All paragraph items. Use {{ content }} to print them all,
* or print a subset such as {{ content.field_example }}. Use
* {{ content|without('field_example') }} to temporarily suppress the printing
* of a given child element.
* - attributes: HTML attributes for the containing element.
* The attributes.class element may contain one or more of the following
* classes:
* - paragraphs: The current template type (also known as a "theming hook").
* - paragraphs--type-[type]: The current paragraphs type. For example, if the paragraph is an
* "Image" it would result in "paragraphs--type--image". Note that the machine
* name will often be in a short form of the human readable label.
* - paragraphs--view-mode--[view_mode]: The View Mode of the paragraph; for example, a
* preview would result in: "paragraphs--view-mode--preview", and
* default: "paragraphs--view-mode--default".
* - view_mode: View mode; for example, "preview" or "full".
* - logged_in: Flag for authenticated user status. Will be true when the
* current user is a logged-in member.
* - is_admin: Flag for admin user status. Will be true when the current user
* is an administrator.
*
* @see template_preprocess_paragraph()
*
* @ingroup themeable
*/
#}

{%
set classes = [
'link',
'paragraph',
'paragraph--type--' ~ paragraph.bundle|clean_class,
view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
not paragraph.isPublished() ? 'paragraph--unpublished'
]
%}

{% if not localgov_base_remove_css %}
{{ attach_library('localgov_base/link') }}
{% endif %}

{% set title_icon = 'chevron-right' %}

<div{{ attributes.addClass(classes) }}>

{% if paragraph.localgov_url.value %}
<div class="link-wrapper">
{% include "@localgov_base/includes/icons/icon.html.twig" with {
icon_name: title_icon,
icon_classes: 'link-icon',
}
%}
<div class="link-content">
<a href="{{ content.localgov_url.content }}">
{{ content.localgov_title.0 }}
</a>
</div>
</div>
{% endif %}

{% if content|without('localgov_url','localgov_title') %}
<div class="link-block__content">
{{ content|without('localgov_url','localgov_title') }}
</div>
{% endif %}

</div>
0