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

VOTE-2180 hero component styling updates #788

Merged
merged 1 commit into from
Jun 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ settings:
-
value: dark
label: Dark
-
value: homepage
label: Homepage
allowed_values_function: ''
module: options
locked: false
Expand Down
2 changes: 2 additions & 0 deletions web/themes/custom/votegov/src/sass/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $bg-light: #F0F0F0; // gray-cool-2
$bg-light-medium: #D3D3D3; // gray-cool-20 is this just for the horizontal rule?
$bg-light-cool: #E2EDF2; // blue-warm-10
$bg-light-warm: #E7E5DD; // hero-background
$bg-hero-default: #a9cfd2;

//High Contrast Colors.
$bg-high-contrast: #0A0A2A;
Expand All @@ -25,3 +26,4 @@ $link-high-contrast: #0000FF;
$link-high-contrast-hover: #010156;
$btn-bg-high-contrast: $link-high-contrast;
$btn-bg-high-contrast-hover: $link-high-contrast-hover;
$btn-secondary-bg-high-contrast-hover: #FFFF00;
98 changes: 78 additions & 20 deletions web/themes/custom/votegov/src/sass/components/hero.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
@use "mixins" as *;

.vote-hero {
background-color: $bg-light-warm;
--vote-hero-bg: #{$bg-hero-default};
--vote-hero-heading: #{$base-dark};
--vote-hero-text: #{$base-dark};
@include u-position('relative');
background-color: var(--vote-hero-bg);
color: var(--vote-hero-text);

[data-theme="contrast"] & {
--vote-hero-bg: #{$bg-high-contrast};
--vote-hero-heading: #{$base-white};
--vote-hero-text: #{$base-white};
}
}

.vote-hero__container {
Expand All @@ -15,60 +26,107 @@

.vote-hero__image {
@include at-media('tablet-lg') {
@include grid-col(5);
@include u-position('relative');
margin-inline-start: calc(100% / 12);
@include u-position('absolute');
@include vote-fill;
z-index: 1;
}

img {
@include u-display('block');
object-fit: cover;

@include at-media-max('tablet-lg') {
aspect-ratio: 2 / 1;
}

@include at-media('tablet-lg') {
@include u-position('absolute');
@include u-top(0);
@include u-bottom(0);
@include u-width('auto');
@include u-height('full');
@include u-maxw('none');
inset-inline-start: 0;
margin-inline-start: auto;
width: calc(50% - (100%/12) - 1rem);
}

@include at-media('widescreen') {
width: calc(50% - 8rem);
}
}
}

.vote-hero__callout {
@include vote-block-padding-y--narrow;
@include u-padding-top(5);
@include u-padding-bottom(6);

@include at-media('tablet-lg') {
@include grid-col(6);
@include u-padding-bottom(15);
@include u-position('relative');
@include u-display('flex');
@include u-flex-direction('column');
@include u-padding-bottom(10);
min-height: 20rem;
z-index: 2;

&:not(:has(nav)) {
@include u-padding-top(15);
@include u-padding-top(10);
}
}

@include at-media('desktop') {
min-height: 28rem;
}

@include at-media-max('tablet-lg') {
@include grid-container;
}
}

.vote-hero__content {
@include at-media('tablet-lg') {
@include u-display('flex');
@include u-flex-direction('column');
@include u-flex('justify-center');
@include u-flex('fill');
}

> * + * {
@include u-margin-top(3);
@include u-margin-top(2);
}
}

.vote-hero__heading {
@include u-font('serif', 12);
color: var(--vote-hero-heading);

@include at-media('tablet-lg') {
@include u-font-size('body', 14);
@include u-font-size('body', 15);
}
}

.vote-hero--dark {
background-color: $base-dark;
color: $base-white;
.vote-hero--homepage {
@include at-media-max('tablet-lg') {
--vote-hero-bg: #{$base-dark};
--vote-hero-heading: #{$base-white};
--vote-hero-text: #{$base-white};
}

@include at-media('tablet-lg') {
.vote-hero__image img {
width: 65%;

[data-theme="contrast"] & {
width: calc(50% - (100%/12) + 15rem);
object-position: center right;
clip-path: rect(0 100% 100% 16rem);
}

.vote-hero__heading {
color: $base-white;
// Needed to flip the image horizontal for rtl languages.
[dir="rtl"] & {
transform: scaleX(-1);
}
}
}
}

.vote-hero--dark {
--vote-hero-bg: #{$base-dark};
--vote-hero-heading: #{$base-white};
--vote-hero-text: #{$base-white};
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,4 @@
// targeting the div wrapping the breadcrumb block and add margin top to the following element
.block.system-breadcrumb-block + * {
@include u-margin-top(5);

@include at-media('tablet') {
@include u-margin-top(10);
}
}
23 changes: 11 additions & 12 deletions web/themes/custom/votegov/src/sass/uswds-overrides/usa-button.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@use "uswds-core" as *;
@use "variables" as *;
@use "mixins" as *;

.usa-button {
.usa-form & {
Expand Down Expand Up @@ -33,12 +34,10 @@
}
}

&:hover,
&:focus,
&.usa-focus,
&.usa-button--hover
{
@include hover {
@include u-text-decoration('no-underline');
--usa-button-bg: #{$base-primary-hover};
color: var(--usa-button-text);

[data-theme="contrast"] & {
--usa-button-bg: #{$btn-bg-high-contrast-hover};
Expand All @@ -49,25 +48,25 @@
--usa-button-bg: #{$ac-warm};

[data-theme="contrast"] & {
--usa-button-bg: #{$btn-bg-high-contrast};
--usa-button-bg: #{$bg-hero-default};
--usa-button-text: #{$text-high-contrast};
}

&.usa-button--active {
--usa-button-bg: #{$ac-warm-hover};

[data-theme="contrast"] & {
--usa-button-bg: #{$btn-bg-high-contrast-hover};
--usa-button-bg: #{$btn-secondary-bg-high-contrast-hover};
--usa-button-text: #{$text-high-contrast};
}
}

&:hover,
&:focus,
&.usa-focus,
&.usa-button--hover {
@include hover {
--usa-button-bg: #{$ac-warm-hover};

[data-theme="contrast"] & {
--usa-button-bg: #{$btn-bg-high-contrast-hover};
--usa-button-bg: #{$btn-secondary-bg-high-contrast-hover};
--usa-button-text: #{$text-high-contrast};
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
<div class="vote-hero__container">
<div class="vote-hero__callout">
{{ drupal_entity('block', 'votegov_breadcrumbs') }}
<h1 class="vote-hero__heading">
{{ title }}
</h1>
{{ node.field_subtitle.value | check_markup(node.field_subtitle.format) }}
<div class="vote-hero__content">
<h1 class="vote-hero__heading">
{{ title }}
</h1>
<div class="vote-hero__text usa-intro">
{{ node.field_subtitle.value | check_markup(node.field_subtitle.format) }}
</div>
</div>
</div>
{% if node.field_media.value %}
<div class="vote-hero__image">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,24 @@
{{ title_suffix }}
<div class="vote-hero__container">
<div class="vote-hero__callout">
<h1 class="vote-hero__heading">
{{ content.field_heading | field_value }}
</h1>
{% if content.field_body | render %}
<div class="vote-hero__text usa-intro">
{{ content.field_body | field_value }}
</div>
{% if paragraph.field_background_color.value == 'dark' %}
{{ drupal_entity('block', 'votegov_breadcrumbs') }}
{% endif %}
{% include '@votegov/component/button.html.twig' with {
'href': paragraph.field_link.0.url,
'label': paragraph.field_link.0.title,
'secondary': true
} %}
<div class="vote-hero__content">
<h1 class="vote-hero__heading">
{{ content.field_heading | field_value }}
</h1>
{% if content.field_body | render %}
<div class="vote-hero__text usa-intro">
{{ content.field_body | field_value }}
</div>
{% endif %}
{% include '@votegov/component/button.html.twig' with {
'href': paragraph.field_link.0.url,
'label': paragraph.field_link.0.title,
'secondary': true
} %}
</div>
</div>
{% if content.field_media | render %}
<div class="vote-hero__image">
Expand Down