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

adds template/css for responsive media with text #469

Merged
merged 1 commit into from
Jul 10, 2023
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
67 changes: 67 additions & 0 deletions css/components/media-with-text.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @file
* Basic styling for Media with text paragraph.
*/

.media-with-text--featured {
background-color: var(--color-grey-lightest);
border: var(--border);
}

.media-with-text {
container-type: inline-size;
}

.media-with-text--featured .media-with-text__body {
padding: 1rem;
}

@container (min-width: 500px) {
.media-with-text--media-left .media-with-text__inner,
.media-with-text--media-right .media-with-text__inner {
display: flex;
justify-content: space-between;
}
}

.media-with-text--media-one-quarter .media-with-text__body,
.media-with-text--media-three-quarters .media-with-text__media {
flex-basis: 75%;
}

.media-with-text--media-one-quarter .media-with-text__media,
.media-with-text--media-three-quarters .media-with-text__body {
flex-basis: 25%;
}

.media-with-text--media-one-third .media-with-text__media,
.media-with-text--media-two-thirds .media-with-text__body {
flex-basis: 33%;
}

.media-with-text--media-one-half .media-with-text__body,
.media-with-text--media-one-half .media-with-text__media {
flex-basis: 50%;
}

.media-with-text--media-one-third .media-with-text__body,
.media-with-text--media-two-thirds .media-with-text__media {
flex-basis: 66%;
}

.media-with-text--media-left .media-with-text__body,
.media-with-text--media-right .media-with-text__body {
width: 100%
}

.media-with-text--media-left .media-with-text__body {
padding-left: var(--spacing);
}

.media-with-text--media-right .media-with-text__body {
padding-right: var(--spacing);
}

.media-with-text--media-top .media-with-text__media {
margin-bottom: var(--spacing);
}
5 changes: 5 additions & 0 deletions localgov_base.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ image-with-caption:
theme:
css/components/image-with-caption.css: {}

media-with-text:
css:
theme:
css/components/media-with-text.css: {}

quote:
css:
theme:
Expand Down
87 changes: 87 additions & 0 deletions templates/paragraphs/paragraph--localgov-media-with-text.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{#
/**
* @file
* Default theme implementation to display a Media with text 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.
* - heading: Title (heading element).
* - link: Link element.
* - media_position: Postion of the media item in the paragraph (Media position
* field's value: 'top', 'bottom', 'left' or 'right').
* - style: Paragraph's style (Style field's value: 'default' or 'featured').
*
* @see template_preprocess_paragraph()
*
* @ingroup themeable
*/
#}
{%
set classes = [
'paragraph',
'paragraph--type--' ~ paragraph.bundle|clean_class,
view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
not paragraph.isPublished() ? 'paragraph--unpublished',
'media-with-text',
'media-with-text--' ~ style|clean_class,
'media-with-text--media-' ~ media_position|clean_class,
media_size ? 'media-with-text--media-' ~ media_size|clean_class
]
%}

{{ attach_library('localgov_base/media-with-text') }}

{% block paragraph %}
<section{{attributes.addClass(classes)}}>
<div class="media-with-text__inner">
{% block content %}
{% if media_position == 'left' or media_position == 'top' %}
<div class="media-with-text__media">
{{ content.localgov_media_item }}
</div>
<div class="media-with-text__body">
{{ heading }}
{{ content.localgov_text }}
{{ link }}
</div>
{% else %}
<div class="media-with-text__body">
{{ heading }}
{{ content.localgov_text }}
{{ link }}
</div>
<div class="media-with-text__media">
{{ content.localgov_media_item }}
</div>
{% endif %}
{% endblock %}
</div>
</section>
{% endblock paragraph %}