Skip to content

Commit

Permalink
Dark mode: Title bars (#2350)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Déramond <[email protected]>
  • Loading branch information
louismaximepiton and julien-deramond authored Nov 8, 2023
1 parent 7fa6a42 commit 6b93b32
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 19 deletions.
9 changes: 4 additions & 5 deletions scss/_title-bars.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.title-bar {
// scss-docs-start title-bar-css-vars
--#{$prefix}title-bar-bg: #{$title-bar-bg};
--#{$prefix}title-bar-color: #{$title-bar-color};
--#{$prefix}title-bar-image-ratio: #{$title-bar-image-ratio};
--#{$prefix}title-bar-padding-y: #{$title-bar-padding-y};
--#{$prefix}title-bar-font-size: #{$title-bar-font-size};
Expand All @@ -9,6 +11,8 @@
--#{$prefix}title-bar-border-color: #{$title-bar-border-color};
// scss-docs-end title-bar-css-vars

color: var(--#{$prefix}title-bar-color);
background-color: var(--#{$prefix}title-bar-bg);
border-bottom: var(--#{$prefix}title-bar-border-width) solid var(--#{$prefix}title-bar-border-color);

@include media-breakpoint-up(md) {
Expand All @@ -21,11 +25,6 @@
--#{$prefix}title-bar-letter-spacing: #{$title-bar-letter-spacing-xl};
}

&.bg-dark,
&.bg-secondary {
--#{$prefix}title-bar-border-color: #{$title-bar-border-color-dark};
}

> [class*="container"] {
display: flex;
align-items: flex-end;
Expand Down
8 changes: 6 additions & 2 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2065,21 +2065,25 @@ $figure-caption-color: $gray-900 !default; // Boosted mod: instead
// Title bars

// scss-docs-start title-bars-variables
$title-bar-bg: var(--#{$prefix}body-bg) !default;
$title-bar-color: var(--#{$prefix}body-color) !default;
$title-bar-image-ratio: 1.8em !default;
$title-bar-padding-y: .3333333em !default;
$title-bar-font-size: $h2-font-size !default;
$title-bar-line-height: $display-line-height !default;
$title-bar-letter-spacing: $h2-spacing !default;
$title-bar-border-width: calc(var(--#{$prefix}border-width) * .5) !default; // stylelint-disable-line function-disallowed-list
$title-bar-border-color: $gray-500 !default;
$title-bar-border-color: var(--#{$prefix}border-color-translucent) !default;

$title-bar-font-size-md: $display2-size !default;
$title-bar-letter-spacing-md: $display2-spacing !default;

$title-bar-font-size-xl: $display1-size !default;
$title-bar-letter-spacing-xl: $display1-spacing !default;

$title-bar-border-color-dark: $gray-700 !default;
// fusv-disable
$title-bar-border-color-dark: $gray-700 !default; // Deprecated in v5.3.3
// fusv-enable
// scss-docs-end title-bars-variables
// End mod

Expand Down
19 changes: 10 additions & 9 deletions site/content/docs/5.3/components/title-bars.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,32 @@ See them in action in our [examples page]({{<docsref "/examples/title-bars">}}).

## Background color

To change the appearance of a title bar, use our [background utilities]({{<docsref "/utilities/background">}}). Orange branded background utilities are `.bg-dark`, `.bg-white` and `.bg-supporting-*`.'
To change the appearance of a title bar, use our [background utilities]({{<docsref "/utilities/background">}}). Orange branded background utilities are `.bg-dark`, `.bg-white` and `.bg-supporting-*`.

Title bars can be displayed with `.bg-black`, `.bg-dark`, `.bg-white` or with the default background color. When using `.bg-black`, `.bg-dark`, `.bg-white` or the default background color, illustrations can be included as an option, but it's not necessary.

Title bars can be displayed with black or white backgrounds. When using black or white backgrounds, illustrations can be included as an option, but it's not necessary.
Supporting colors can also be used as the background color for title bars, but not the supporting light and dark tint colors. When using one of the supporting colors, illustrations must be used.

The image should not overlap on title and the title shouldn't wrap. If this happens, please **transform your title bar** into a white/black one without any image.
The image should not overlap on title and the title shouldn't wrap. If this happens, please transform your title bar into a title bar with `.bg-black`, `.bg-dark`, `.bg-white` or with the default background color without any image.

{{< example class="p-0">}}
<div class="bg-body title-bar">
<div class="title-bar">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
</div>
</div>

<div class="mt-3"></div>

<div class="bg-dark title-bar">
<div class="bg-dark title-bar" data-bs-theme="dark">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
</div>
</div>

<div class="mt-3"></div>

<div class="bg-supporting-green title-bar">
<div class="bg-supporting-green title-bar" data-bs-theme="light">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
<picture>
Expand All @@ -68,7 +69,7 @@ Several options are available to add an image in a title bar.
We **strongly recommend** to use `srcset` attribute as it is [well supported](https://caniuse.com/srcset) by browsers and allows you to load an image depending on the user's device. However, it might introduce a delay to display the image while resizing.

{{< example class="p-0">}}
<div class="bg-supporting-pink title-bar">
<div class="bg-supporting-pink title-bar" data-bs-theme="light">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
<picture>
Expand All @@ -87,7 +88,7 @@ We **strongly recommend** to use `srcset` attribute as it is [well supported](ht
### HTML `<svg>` tag

{{< example class="p-0">}}
<div class="bg-supporting-purple title-bar">
<div class="bg-supporting-purple title-bar" data-bs-theme="light">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
<svg aria-hidden="true" focusable="false" width="1.8em"><use xlink:href="/docs/{{< param docs_version >}}/assets/img/boosted-sprite.svg#document"/></svg>
Expand All @@ -98,7 +99,7 @@ We **strongly recommend** to use `srcset` attribute as it is [well supported](ht
### HTML `<img>` tag

{{< example class="p-0">}}
<div class="bg-supporting-green title-bar">
<div class="bg-supporting-green title-bar" data-bs-theme="light">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
<img src="/docs/{{< param docs_version >}}/assets/img/title-bars-illustrations/illustration-320.png" alt="" class="d-sm-none">
Expand Down
52 changes: 52 additions & 0 deletions site/content/docs/5.3/dark-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -5158,6 +5158,58 @@ sitemap_exclude: true
</ul>
</div>

### Title bars

<h4 class="mt-3">No theme</h4>

<div class="border border-tertiary p-3">
<div class="title-bar">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
</div>
</div>
</div>

<h4 class="mt-3">Dark theme on container</h4>

<div class="border border-tertiary p-3 bg-body" data-bs-theme="dark">
<div class="title-bar">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
</div>
</div>
</div>

<h4 class="mt-3">Light theme on container</h4>

<div class="border border-tertiary p-3 bg-body" data-bs-theme="light">
<div class="title-bar">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
</div>
</div>
</div>

<h4 class="mt-3">Dark theme on component</h4>

<div class="border border-tertiary p-3" style="background-color: #282d55;">
<div class="title-bar" data-bs-theme="dark">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
</div>
</div>
</div>

<h4 class="mt-3">Light theme on component</h4>

<div class="border border-tertiary p-3" style="background-color: #b5e8f7">
<div class="title-bar" data-bs-theme="light">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
</div>
</div>
</div>

### Tooltips

<h4 class="mt-3">No theme</h4>
Expand Down
6 changes: 3 additions & 3 deletions site/content/docs/5.3/examples/title-bars/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
---

<main>
<div class="bg-body title-bar">
<div class="title-bar">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
</div>
</div>

<div class="b-example-divider"></div>

<div class="bg-supporting-pink title-bar">
<div class="bg-supporting-pink title-bar" data-bs-theme="light">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
<picture>
Expand All @@ -46,7 +46,7 @@ <h4 class="alert-heading">Background image</h4>

<div class="b-example-divider"></div>

<div class="bg-supporting-blue title-bar">
<div class="bg-supporting-blue title-bar" data-bs-theme="light">
<div class="container-xxl">
<h1 class="display-1">Title</h1>
<div class="col example-title-bar-custom-background"></div>
Expand Down

0 comments on commit 6b93b32

Please sign in to comment.