@ng-doc/app
Version:
<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>
1 lines • 4.14 kB
Source Map (JSON)
{"version":3,"file":"ng-doc-app-components-theme-toggle.mjs","sources":["../../../../libs/app/components/theme-toggle/theme-toggle.component.ts","../../../../libs/app/components/theme-toggle/theme-toggle.component.html","../../../../libs/app/components/theme-toggle/ng-doc-app-components-theme-toggle.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, DOCUMENT, inject } from '@angular/core';\nimport { NgDocThemeService } from '@ng-doc/app/services/theme';\nimport {\n NgDocButtonIconComponent,\n NgDocIconComponent,\n NgDocTooltipDirective,\n} from '@ng-doc/ui-kit';\n\ninterface ToggleTheme {\n name: string;\n theme: string | null;\n}\n\n@Component({\n selector: 'ng-doc-theme-toggle',\n templateUrl: './theme-toggle.component.html',\n styleUrls: ['./theme-toggle.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NgDocButtonIconComponent, NgDocTooltipDirective, NgDocIconComponent],\n})\nexport class NgDocThemeToggleComponent {\n protected readonly themes: ToggleTheme[] = [\n { name: 'Auto', theme: 'auto' },\n { name: 'Light', theme: null },\n { name: 'Dark', theme: 'dark' },\n ];\n protected readonly documentElement = inject(DOCUMENT).documentElement;\n protected readonly themeService = inject(NgDocThemeService);\n\n get currentTheme(): ToggleTheme {\n const theme = this.documentElement.getAttribute('data-theme');\n\n return this.themes.find(({ theme: t }) => t === theme) ?? this.themes[0];\n }\n\n get nextTheme(): ToggleTheme {\n const index = this.themes.findIndex(({ theme }) => theme === this.currentTheme.theme);\n\n return this.themes[(index + 1) % this.themes.length];\n }\n\n toggleTheme(): void {\n const { theme } = this.nextTheme;\n\n this.themeService.set(theme ?? undefined);\n }\n}\n","<button ng-doc-button-icon size=\"large\" (click)=\"toggleTheme()\" [ngDocTooltip]=\"tooltipContent\">\n <ng-template #tooltipContent> \"{{ currentTheme.name }}\" theme </ng-template>\n\n @if (currentTheme === themes[0]) {\n <div class=\"letter\">A</div>\n } @else if (currentTheme === themes[1]) {\n <ng-doc-icon icon=\"sun\" size=\"24\"></ng-doc-icon>\n } @else {\n <ng-doc-icon icon=\"moon\" size=\"24\"></ng-doc-icon>\n }\n</button>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAoBa,yBAAyB,CAAA;AAPtC,IAAA,WAAA,GAAA;AAQqB,QAAA,IAAA,CAAA,MAAM,GAAkB;AACzC,YAAA,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;AAC/B,YAAA,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;AAC9B,YAAA,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;SAChC;AACkB,QAAA,IAAA,CAAA,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,eAAe;AAClD,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAmB5D,IAAA;AAjBC,IAAA,IAAI,YAAY,GAAA;QACd,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,YAAY,CAAC;QAE7D,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1E;AAEA,IAAA,IAAI,SAAS,GAAA;QACX,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,KAAK,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;AAErF,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CA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