Skip to content

Commit

Permalink
demo: bootstrap 5.3 and dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bastienmoulia authored and maxokorokov committed Oct 25, 2023
1 parent fdc5f86 commit 99c2162
Show file tree
Hide file tree
Showing 21 changed files with 124 additions and 47 deletions.
3 changes: 2 additions & 1 deletion demo/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
</div>

<div class="demo-site-versions navbar-nav flex-row ms-md-auto me-4">
<ngbd-demo-theme></ngbd-demo-theme>
<ngbd-demo-versions></ngbd-demo-versions>
</div>

Expand Down Expand Up @@ -136,7 +137,7 @@
<router-outlet></router-outlet>
</div>

<footer class="footer bg-light">
<footer class="footer bg-body-tertiary">
<div class="container-fluid p-3 p-md-5">
<p>
Designed and built by the
Expand Down
3 changes: 2 additions & 1 deletion demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Component, NgZone, OnInit } from '@angular/core';
import { ActivatedRoute, RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
import { NgbdDemoVersionsComponent } from './demo-versions.component';
import { NgbdDemoThemeComponent } from './demo-theme.component';

import { COMPONENT_LIST } from './shared/component-list';
import { environment } from '../environments/environment';
Expand All @@ -13,7 +14,7 @@ import { of } from 'rxjs';
standalone: true,
selector: 'ngbd-app',
templateUrl: './app.component.html',
imports: [RouterLink, RouterLinkActive, RouterOutlet, NgbdDemoVersionsComponent],
imports: [RouterLink, RouterLinkActive, RouterOutlet, NgbdDemoVersionsComponent, NgbdDemoThemeComponent],
})
export class AppComponent implements OnInit {
downloadCount = '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p>A responsive navbar can be achieved with an <code>ngbCollapse</code> directive.</p>

<nav class="navbar navbar-expand-lg navbar-light bg-light mb-3">
<nav class="navbar navbar-expand-lg navbar-light bg-body-tertiary mb-3">
<div class="container-fluid">
<a class="navbar-brand" [routerLink]="'.'">Responsive navbar</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
property should be dynamically set based on the screen resolution. This is left as an exercise to the reader.
</p>

<nav class="navbar navbar-expand-md navbar-light bg-light">
<nav class="navbar navbar-expand-md navbar-light bg-body-tertiary">
<div class="container-fluid">
<span class="navbar-brand">Dropdowns in navbar</span>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h4 class="modal-title">Modal title</h4>
<p>One fine body&hellip;</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" (click)="modal.close('Close click')">Close</button>
<button type="button" class="btn btn-secondary" (click)="modal.close('Close click')">Close</button>
</div>
</ng-template>

Expand Down Expand Up @@ -91,7 +91,7 @@ <h4 class="modal-title">Modal title</h4>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" (click)="modal.close('Close click')">Close</button>
<button type="button" class="btn btn-secondary" (click)="modal.close('Close click')">Close</button>
</div>
</ng-template>

Expand Down
14 changes: 7 additions & 7 deletions demo/src/app/default/default.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ <h3 class="text-secondary mb-3">The angular way</h3>
</main>

<div class="masthead-followup">
<div class="row m-0 border border-white">
<div class="row m-0 border border-secondary">
<div
class="col-12 col-md-4 p-3 p-md-5 bg-light border border-white d-flex flex-column align-items-center align-items-md-start"
class="col-12 col-md-4 p-3 p-md-5 bg-body-tertiary border border-secondary d-flex flex-column align-items-center align-items-md-start"
>
<svg
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -54,7 +54,7 @@ <h3>Native</h3>
</div>

<div
class="col-12 col-md-4 p-3 p-md-5 bg-light border border-white d-flex flex-column align-items-center align-items-md-start"
class="col-12 col-md-4 p-3 p-md-5 bg-body-tertiary border border-secondary d-flex flex-column align-items-center align-items-md-start"
>
<svg
fill="currentColor"
Expand Down Expand Up @@ -83,7 +83,7 @@ <h3>Widgets</h3>
</div>

<div
class="col-12 col-md-4 p-3 p-md-5 bg-light border border-white d-flex flex-column align-items-center align-items-md-start"
class="col-12 col-md-4 p-3 p-md-5 bg-body-tertiary border border-secondary d-flex flex-column align-items-center align-items-md-start"
>
<svg
fill="currentColor"
Expand All @@ -109,7 +109,7 @@ <h3>Quality</h3>
<div class="w-100"></div>

<div
class="col-12 col-md-4 p-3 p-md-5 bg-light border border-white d-flex flex-column align-items-center align-items-md-start"
class="col-12 col-md-4 p-3 p-md-5 bg-body-tertiary border border-secondary d-flex flex-column align-items-center align-items-md-start"
>
<svg
fill="currentColor"
Expand All @@ -134,7 +134,7 @@ <h3>Accessible</h3>
</div>

<div
class="col-12 col-md-4 p-3 p-md-5 bg-light border border-white d-flex flex-column align-items-center align-items-md-start"
class="col-12 col-md-4 p-3 p-md-5 bg-body-tertiary border border-secondary d-flex flex-column align-items-center align-items-md-start"
>
<svg
fill="currentColor"
Expand All @@ -160,7 +160,7 @@ <h3>Team</h3>
</div>

<div
class="col-12 col-md-4 p-3 p-md-5 bg-light border border-white d-flex flex-column align-items-center align-items-md-start"
class="col-12 col-md-4 p-3 p-md-5 bg-body-tertiary border border-secondary d-flex flex-column align-items-center align-items-md-start"
>
<svg
fill="currentColor"
Expand Down
75 changes: 75 additions & 0 deletions demo/src/app/demo-theme.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgFor } from '@angular/common';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';

interface Theme {
id: string;
name: string;
icon: string;
}

@Component({
selector: 'ngbd-demo-theme',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgFor, NgbDropdownModule],
template: `
<div class="nav-item" ngbDropdown>
<a class="nav-link" ngbDropdownToggle id="demo-site-theme" role="button">
<span class="bi bi-{{ currentTheme.icon }}"></span>
</a>
<div ngbDropdownMenu aria-labelledby="demo-site-theme" class="dropdown-menu dropdown-menu-end">
<button
ngbDropdownItem
*ngFor="let theme of themes"
[class.active]="theme.id === currentTheme.id"
(click)="setTheme(theme)"
>
<span class="bi bi-{{ theme.icon }} me-2"></span>{{ theme.name }}
</button>
</div>
</div>
`,
})
export class NgbdDemoThemeComponent {
themes: Theme[] = [
{ id: 'auto', name: 'Auto', icon: 'circle-half' },
{ id: 'light', name: 'Light', icon: 'sun-fill' },
{ id: 'dark', name: 'Dark', icon: 'moon-stars-fill' },
];
currentTheme: Theme = { id: 'auto', name: 'auto', icon: 'circle-half' };

constructor() {
const theme = this.themes.find((t) => t.id === localStorage.getItem('theme'));
if (theme) {
this.currentTheme = theme;
}
this.setTheme(this.getPreferredTheme());

window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if (this.currentTheme.id !== 'light' || this.currentTheme.id !== ('dark' as any)) {
this.setTheme(this.getPreferredTheme());
}
});
}

getPreferredTheme(): Theme {
if (this.currentTheme) {
return this.currentTheme;
} else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
return this.themes.find((t) => t.id === 'dark')!;
} else {
return this.themes.find((t) => t.id === 'light')!;
}
}

setTheme(theme: Theme): void {
this.currentTheme = theme;
localStorage.setItem('theme', theme.id);
if (theme.id === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-bs-theme', 'dark');
} else {
document.documentElement.setAttribute('data-bs-theme', theme.id);
}
}
}
4 changes: 2 additions & 2 deletions demo/src/app/shared/api-docs/api-docs-class.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="api-doc-component" [class.deprecated]="apiDocs.deprecated">
<h3 [id]="apiDocs.className">
<a routerLink="." fragment="{{ apiDocs.className }}" ngbdFragment title="Anchor link to: {{ apiDocs.className }}">
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: black"></i>
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: var(--bs-heading-color)"></i>
</a>
{{ apiDocs.className }}
<a
Expand All @@ -11,7 +11,7 @@ <h3 [id]="apiDocs.className">
target="_blank"
title="Link to Github: {{ apiDocs.className }}"
>
<i class="bi bi-github" style="font-size: 1.5rem; color: black"></i>
<i class="bi bi-github" style="font-size: 1.5rem; color: var(--bs-heading-color)"></i>
</a>
</h3>
<ngbd-api-docs-badge
Expand Down
4 changes: 2 additions & 2 deletions demo/src/app/shared/api-docs/api-docs-config.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div (click)="trackSourceClick()" class="api-doc-component" [class.deprecated]="apiDocs.deprecated">
<h3 [id]="apiDocs.className">
<a routerLink="." fragment="{{ apiDocs.className }}" ngbdFragment title="Anchor link to: {{ apiDocs.className }}">
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: black"></i>
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: var(--bs-heading-color)"></i>
</a>
{{ apiDocs.className }}
<a
Expand All @@ -10,7 +10,7 @@ <h3 [id]="apiDocs.className">
target="_blank"
title="Link to Github: {{ apiDocs.className }}"
>
<i class="bi bi-github" style="font-size: 1.5rem; color: black"></i>
<i class="bi bi-github" style="font-size: 1.5rem; color: var(--bs-heading-color)"></i>
</a>
</h3>
<ngbd-api-docs-badge
Expand Down
4 changes: 2 additions & 2 deletions demo/src/app/shared/api-docs/api-docs.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="api-doc-component" [class.deprecated]="apiDocs.deprecated">
<h3 [id]="apiDocs.className">
<a routerLink="." [fragment]="apiDocs.className" ngbdFragment title="Anchor link to: {{ apiDocs.className }}">
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: black"></i>
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: var(--bs-heading-color)"></i>
</a>
{{ apiDocs.className }}
<a
Expand All @@ -11,7 +11,7 @@ <h3 [id]="apiDocs.className">
target="_blank"
title="Link to Github: {{ apiDocs.className }}"
>
<i class="bi bi-github" style="font-size: 1.5rem; color: black"></i>
<i class="bi bi-github" style="font-size: 1.5rem; color: var(--bs-heading-color)"></i>
</a>
</h3>
<ngbd-api-docs-badge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</div>

<div class="col-12 col-lg-10">
<header class="bg-light pt-4 pb-md-5 px-4 px-lg-5 d-flex d-md-block align-items-center title">
<header class="bg-body-tertiary pt-4 pb-md-5 px-4 px-lg-5 d-flex d-md-block align-items-center title">
<h1 class="mb-4 me-auto me-md-none">{{ component | titlecase }}</h1>

<ul
Expand Down
8 changes: 4 additions & 4 deletions demo/src/app/shared/examples-page/demo.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="component-demo">
<h2 [id]="id">
<a routerLink="." [fragment]="id" ngbdFragment title="Anchor link to demo: {{ id }}">
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: black"></i>
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: var(--bs-heading-color)"></i>
</a>
<span>{{ demoTitle }}</span>
<button
type="button"
class="btn btn-light me-2 toggle-code"
class="btn btn-outline-secondary me-2 toggle-code"
[class.active]="showCode"
(click)="showCode = !showCode; trackShowCodeClick()"
>
Expand All @@ -21,7 +21,7 @@ <h2 [id]="id">
*ngIf="showStackblitz"
role="button"
(click)="trackStackBlitzClick()"
class="stackblitz btn btn-light"
class="stackblitz btn btn-outline-secondary"
target="_blank"
href="stackblitzes/{{ component }}/{{ id }}/stackblitz.html"
title="Edit in StackBlitz"
Expand All @@ -31,7 +31,7 @@ <h2 [id]="id">
</a>
</h2>
<div class="card">
<div *ngIf="showCode" class="bg-light border-bottom tabset-code">
<div *ngIf="showCode" class="bg-body-tertiary border-bottom tabset-code">
<ul
ngbNav
#nav="ngbNav"
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/shared/overview/overview-section.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { NgbdFragment } from '../fragment/fragment.directive';
template: `
<h2 [id]="section.fragment">
<a class="title-fragment" routerLink="." [fragment]="section.fragment">
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: black"></i>
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: var(--bs-heading-color)"></i>
</a>
{{ section.title }}
</h2>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/shared/page-wrapper/page-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { NgbdOverviewSection } from '../overview/overview';
template: `
<h2 [id]="fragment">
<a class="title-fragment" routerLink="." [fragment]="fragment">
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: black"></i>
<i class="bi bi-link-45deg" style="font-size: 1.75rem; color: var(--bs-heading-color)"></i>
</a>
{{ title }}
</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</div>

<div class="col-12 col-lg-10">
<header class="bg-light pt-4 pb-md-5 px-4 px-lg-5 d-flex d-md-block align-items-center title">
<header class="bg-body-tertiary pt-4 pb-md-5 px-4 px-lg-5 d-flex d-md-block align-items-center title">
<h1 class="mt-0">{{ pageTitle }}</h1>

<ul class="nav nav-tabs px-4 px-lg-5 content-tabset justify-content-md-start justify-content-end">
Expand Down
2 changes: 1 addition & 1 deletion demo/src/public/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="en" data-bs-theme="auto">
<head>
<meta charset="utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
Expand Down
Loading

0 comments on commit 99c2162

Please sign in to comment.