Skip to content

Commit

Permalink
tw29613664 - add unpublished indicator (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: Jay Darnell <“jay.darnell@gmail.com”>
  • Loading branch information
JayDarnell and Jay Darnell authored Sep 12, 2024
1 parent dad990f commit cf9354b
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 8 deletions.
34 changes: 34 additions & 0 deletions assets/scss/custom/_unpublished.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@mixin unpublished-page {
background-color: #fff4f4;

&:before {
content: "- UNPUBLISHED -";
display: block;
text-align: center;
font-size: 1.3333rem;
padding: 1rem 0;
margin: 0;
font-family: var(--bold-font-family);
font-weight: 300;
line-height: 1.3;
background-color: transparent;
}
}

@mixin unpublished-component {
@include unpublished-page;

&:before {
font-size: 1rem;
padding: .5rem 0;
line-height: 1;
}
}

.node--unpublished {
@include unpublished-page;
}

.paragraph--unpublished {
@include unpublished-component;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% set entity = context.getProperty('entity') %}
{% set entity_type = context.getProperty('entity_type') %}

{% set item_id = item_id|default("accordion-item-" ~ random()) %}

{% set heading_level = heading_level|default(2) %}
{%
set button_attributes = create_attribute({
'class': [
'accordion-button',
'collapsed'
],
'type': 'button',
'data-bs-toggle': 'collapse',
'data-bs-target': '#' ~ item_id,
'aria-controls': item_id,
'aria-expanded': 'false'
})
%}

{%
set content_attributes = create_attribute({
'id': item_id,
'class': [
'accordion-collapse',
'collapse',
'js-accordion-keep-open'
],
'aria-labelledby': 'heading--' ~ item_id
})
%}

{% if opened %}
{% set button_attributes = button_attributes.setAttribute('aria-expanded', 'true') %}
{% set button_attributes = button_attributes.removeClass('collapsed') %}
{% set content_attributes = content_attributes.addClass('show') %}
{% endif %}

{%
set classes = [
'accordion-item',
entity_type ? entity_type,
not entity.isPublished() ? entity_type ~ '--unpublished',
]
%}

<div{{attributes.addClass(classes)}}>
<h{{heading_level}} class="accordion-header" id="heading--{{ item_id }}">
<button{{button_attributes}}>
{{ title }}
</button>
</h{{heading_level}}>
<div{{content_attributes}}>
<div class="accordion-body">
{{ content }}
</div>
</div>
</div>

24 changes: 16 additions & 8 deletions templates/patterns/simple_card/pattern-simple-card.html.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
{% set entity = context.getProperty('entity') %}
{% set entity_type = context.getProperty('entity_type') %}

{%
set classes = [
'card',
height ? 'h-100',
entity_type ? entity_type,
not entity.isPublished() ? entity_type ~ '--unpublished',
]
%}

{% set attributes = attributes.addClass('h-100') %}

{% if variant and variant|lower == 'horizontal' %}
{% if height %}
{% set attributes = attributes.addClass('h-100') %}
{% endif %}
<div{{ attributes.addClass('card') }}>
<div{{attributes.addClass(classes)}}>
<div class="row g-0">
<div class="{{ image_col_classes|default('col-md-4') }}">
{{ image|add_class('img-fluid rounded-start') }}
Expand All @@ -29,10 +40,7 @@
</div>
</div>
{% else %}
{% if height %}
{% set attributes = attributes.addClass('h-100') %}
{% endif %}
<div{{ attributes.addClass('card') }}>
<div{{attributes.addClass(classes)}}>
{% if image and image_position != 'bottom' %}
{{ image|add_class('card-img-top') }}
{% endif %}
Expand Down

0 comments on commit cf9354b

Please sign in to comment.