2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-05-27 14:46:01 +03:00
Files
bootstrap/site/assets/scss/_navbar.scss
T
Mark Otto 015d729445 Add dark mode support
Heavily WIP still, but this begins the process of implementing dark mode for our docs and across the project itself.

- Color modes are toggled in the docs navbar with a custom toggler, which stores the select color mode in local storage.
- Color modes can also be set via data attribute thanks to `data-theme` (with light or dark options available currently).
- Docs are heavily WIP for demonstrating the dark mode.
- In order to best implement color modes, I've spiked out a number of new Sass and CSS variables (e.g., `--bs-secondary-bg` and `--bs-tertiary-bg`). In addition, I've added new global CSS variables like `--bs-border-color` and more. So, in addition to general color modes and theming support, we get greater real-time customization, too.

Todos and open questions:

- [ ] Do we refer to these as themes or color modes?
- [ ] Do we provide a color mode toggler JS plugin?
- [ ] Update all components to better utilize global CSS variables so they can be more easily themed (e.g., see `$dropdown-*` Sass variable changes in the diff).
2022-04-18 18:45:51 -07:00

120 lines
2.3 KiB
SCSS

.bd-navbar {
padding: .75rem 0;
background-color: transparent;
background-image: linear-gradient(to bottom, rgba(var(--bd-violet-rgb), 1), rgba(var(--bd-violet-rgb), .95));
box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15), inset 0 -1px 0 rgba(0, 0, 0, .15);
.navbar-toggler {
padding: 0;
margin-right: -.5rem;
border: 0;
&:first-child {
margin-left: -.5rem;
}
.bi {
width: 1.5rem;
height: 1.5rem;
}
&:focus {
box-shadow: none;
}
}
.navbar-brand {
transition: .2s ease-in-out transform; // stylelint-disable-line property-disallowed-list
&:hover {
transform: rotate(-5deg) scale(1.1);
}
}
.navbar-toggler,
.nav-link {
padding-right: $spacer * .25;
padding-left: $spacer * .25;
color: rgba($white, .85);
&:hover,
&:focus {
color: $white;
}
&.active {
font-weight: 600;
color: $white;
}
}
.navbar-nav-svg {
display: inline-block;
vertical-align: -.125rem;
}
.offcanvas-lg {
background-color: var(--bd-violet);
border-left: 0;
@include media-breakpoint-down(lg) {
box-shadow: $box-shadow-lg;
}
}
.dropdown-toggle {
&:focus {
outline: 0;
}
}
.dropdown-menu {
--#{$variable-prefix}dropdown-min-width: 12rem;
--#{$variable-prefix}dropdown-link-hover-bg: rgba(var(--bd-violet-rgb), .1);
@include rfs(.875rem, --#{$variable-prefix}dropdown-font-size);
box-shadow: $dropdown-box-shadow;
}
.dropdown-item.current {
font-weight: 600;
background-image: escape-svg($dropdown-active-icon);
background-repeat: no-repeat;
background-position: right $dropdown-item-padding-x top .6rem;
background-size: .75rem .75rem;
}
}
.bd-theme-toggle {
width: 1rem;
height: 1rem;
cursor: pointer;
}
.bd-theme-toggle-checkbox {
position: absolute;
z-index: -1;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0 0 0 0);
clip-path: inset(100%);
white-space: nowrap;
~ .bd-theme-toggle-light { display: none; }
~ .bd-theme-toggle-dark { display: block; }
&:checked {
~ .bd-theme-toggle-light { display: block; }
~ .bd-theme-toggle-dark { display: none; }
}
}
.bd-theme-toggle-light {
color: var(--bs-warning);
}
.bd-theme-toggle-dark {
color: var(--bs-navbar-brand-color);
}