@dataengineeringformachinelearning/viking-ui 1.0.2 → 3.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +217 -38
- package/dist/core/brand-icons.d.ts +29 -0
- package/dist/core/icons.d.ts +132 -0
- package/dist/core/integration-brand-icons.d.ts +18 -0
- package/dist/core/lucide-paths.generated.d.ts +90 -0
- package/dist/core/types.d.ts +56 -0
- package/dist/core/uid.d.ts +2 -0
- package/dist/deml-components.css +1122 -0
- package/dist/design-tokens.css +688 -0
- package/dist/elements/button/viking-button.d.ts +14 -0
- package/dist/elements/card/viking-card.d.ts +8 -0
- package/dist/elements/core/dom.d.ts +4 -0
- package/dist/elements/core/styles.d.ts +2 -0
- package/dist/elements/modal/viking-modal.d.ts +15 -0
- package/dist/fonts/inter/InterVariable-Italic.woff2 +0 -0
- package/dist/fonts/inter/InterVariable.woff2 +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4051 -0
- package/dist/lib/accordion/accordion.d.ts +19 -0
- package/dist/lib/app-header/app-header.d.ts +8 -0
- package/dist/lib/app-sidebar/app-sidebar.d.ts +10 -0
- package/dist/lib/auth-panel/auth-panel.d.ts +13 -0
- package/dist/lib/autocomplete/autocomplete.d.ts +25 -0
- package/dist/lib/avatar/avatar.d.ts +14 -0
- package/dist/lib/badge/badge.d.ts +16 -0
- package/dist/lib/bar/bar.d.ts +4 -0
- package/dist/lib/brand/brand.d.ts +8 -0
- package/dist/lib/breadcrumbs/breadcrumbs.d.ts +10 -0
- package/dist/lib/button/button-group.d.ts +6 -0
- package/dist/lib/button/button.d.ts +25 -0
- package/dist/lib/calendar/calendar.d.ts +22 -0
- package/dist/lib/callout/callout.d.ts +14 -0
- package/dist/lib/card/card-title.d.ts +12 -0
- package/dist/lib/card/card.d.ts +19 -0
- package/dist/lib/carousel/carousel.d.ts +13 -0
- package/dist/lib/chart/chart-zoom.d.ts +14 -0
- package/dist/lib/chart/chart.d.ts +119 -0
- package/dist/lib/chart-card-header/chart-card-header.d.ts +10 -0
- package/dist/lib/chart-empty-state/chart-empty-state.d.ts +13 -0
- package/dist/lib/chart-panel/chart-panel.d.ts +10 -0
- package/dist/lib/checkbox/checkbox.d.ts +13 -0
- package/dist/lib/color-picker/color-picker.d.ts +16 -0
- package/dist/lib/command/command.d.ts +23 -0
- package/dist/lib/composer/composer.d.ts +15 -0
- package/dist/lib/confirm-dialog/confirm-dialog.d.ts +18 -0
- package/dist/lib/confirm-dialog/dialog.service.d.ts +28 -0
- package/dist/lib/context/context.d.ts +17 -0
- package/dist/lib/core/brand-icons.d.ts +29 -0
- package/dist/lib/core/cva.d.ts +15 -0
- package/dist/lib/core/icons.d.ts +132 -0
- package/dist/lib/core/integration-brand-icons.d.ts +18 -0
- package/dist/lib/core/lucide-paths.generated.d.ts +90 -0
- package/dist/lib/date-picker/date-picker.d.ts +18 -0
- package/dist/lib/dropdown/dropdown.d.ts +29 -0
- package/dist/lib/editor/editor.d.ts +26 -0
- package/dist/lib/empty-state/empty-state.d.ts +9 -0
- package/dist/lib/fab/fab.d.ts +9 -0
- package/dist/lib/field/field.d.ts +14 -0
- package/dist/lib/file-upload/file-upload.d.ts +19 -0
- package/dist/lib/footer/footer.d.ts +6 -0
- package/dist/lib/form-section/form-section.d.ts +15 -0
- package/dist/lib/gauge-arc/gauge-arc.d.ts +8 -0
- package/dist/lib/hud-panel/hud-panel.d.ts +5 -0
- package/dist/lib/icon/icon.d.ts +44 -0
- package/dist/lib/icon-badge/icon-badge.d.ts +14 -0
- package/dist/lib/icon-heading/icon-heading.d.ts +9 -0
- package/dist/lib/icon-text/icon-text.d.ts +12 -0
- package/dist/lib/input/input.d.ts +23 -0
- package/dist/lib/kanban/kanban.d.ts +16 -0
- package/dist/lib/kbd/kbd.d.ts +5 -0
- package/dist/lib/label/label.d.ts +7 -0
- package/dist/lib/loading-overlay/loading-overlay.d.ts +10 -0
- package/dist/lib/menubar/menubar.d.ts +10 -0
- package/dist/lib/metric-card/metric-card.d.ts +9 -0
- package/dist/lib/modal/modal.d.ts +13 -0
- package/dist/lib/native-select/native-select.d.ts +17 -0
- package/dist/lib/navbar/navbar.d.ts +13 -0
- package/dist/lib/navigation-menu/navigation-menu.d.ts +13 -0
- package/dist/lib/otp-input/otp-input.d.ts +23 -0
- package/dist/lib/page-back-link/page-back-link.d.ts +11 -0
- package/dist/lib/page-header/page-header.d.ts +15 -0
- package/dist/lib/pagination/pagination.d.ts +10 -0
- package/dist/lib/pillbox/pillbox.d.ts +15 -0
- package/dist/lib/popover/popover.d.ts +15 -0
- package/dist/lib/profile/profile.d.ts +11 -0
- package/dist/lib/progress/progress.d.ts +12 -0
- package/dist/lib/radio/radio.d.ts +16 -0
- package/dist/lib/ring-gauge/ring-gauge.d.ts +8 -0
- package/dist/lib/scroll-area/scroll-area.d.ts +7 -0
- package/dist/lib/search-palette/search-palette.d.ts +16 -0
- package/dist/lib/select/select.d.ts +26 -0
- package/dist/lib/separator/separator.d.ts +8 -0
- package/dist/lib/sheet/sheet.d.ts +13 -0
- package/dist/lib/sidebar-nav/sidebar-nav.d.ts +46 -0
- package/dist/lib/site-drakkar/site-drakkar.config.d.ts +50 -0
- package/dist/lib/site-drakkar/site-footer.d.ts +18 -0
- package/dist/lib/site-drakkar/site-navbar.d.ts +25 -0
- package/dist/lib/site-drakkar/suite-search-items.d.ts +17 -0
- package/dist/lib/skeleton/skeleton.d.ts +8 -0
- package/dist/lib/slider/slider.d.ts +17 -0
- package/dist/lib/spinner/spinner.d.ts +7 -0
- package/dist/lib/status-metric-row/status-metric-row.d.ts +9 -0
- package/dist/lib/suite-search-palette/suite-search-palette.d.ts +25 -0
- package/dist/lib/switch/switch.d.ts +12 -0
- package/dist/lib/table/table.d.ts +10 -0
- package/dist/lib/tabs/tab-panel.d.ts +12 -0
- package/dist/lib/tabs/tab.d.ts +14 -0
- package/dist/lib/tabs/tabs.d.ts +10 -0
- package/dist/lib/textarea/textarea.d.ts +16 -0
- package/dist/lib/theme-toggle/theme-toggle.d.ts +9 -0
- package/dist/lib/time-picker/time-picker.d.ts +21 -0
- package/dist/lib/timeline/timeline.d.ts +14 -0
- package/dist/lib/toast/toast.d.ts +21 -0
- package/dist/lib/toggle/toggle-group.d.ts +9 -0
- package/dist/lib/toggle/toggle.d.ts +15 -0
- package/dist/lib/tooltip/tooltip.d.ts +20 -0
- package/dist/lib/typography/heading.d.ts +9 -0
- package/dist/lib/typography/text.d.ts +11 -0
- package/dist/lib/uptime-bar/uptime-bar.d.ts +6 -0
- package/dist/lib/verification-code-field/verification-code-field.d.ts +19 -0
- package/dist/lib/whitepaper-cta/whitepaper-cta.d.ts +15 -0
- package/dist/lib/wizard/wizard.d.ts +13 -0
- package/dist/public-api.d.ts +109 -0
- package/dist/tokens/series-presets.d.ts +4 -0
- package/dist/viking-components.css +1837 -0
- package/dist/viking-tokens.json +318 -0
- package/dist/viking-ui-elements.js +1750 -0
- package/dist/viking-ui.css +1 -0
- package/dist/web/badge/viking-badge-wc.d.ts +28 -0
- package/dist/web/button/viking-button-wc.d.ts +28 -0
- package/dist/web/callout/viking-callout-wc.d.ts +27 -0
- package/dist/web/card/viking-card-wc.d.ts +29 -0
- package/dist/web/core/base.d.ts +12 -0
- package/dist/web/core/dom.d.ts +11 -0
- package/dist/web/core/icons-inline.d.ts +7 -0
- package/dist/web/core/styles.d.ts +12 -0
- package/dist/web/core/types.d.ts +10 -0
- package/dist/web/field/viking-field-wc.d.ts +32 -0
- package/dist/web/index.d.ts +15 -0
- package/dist/web/input/viking-input-wc.d.ts +32 -0
- package/dist/web/modal/viking-modal-wc.d.ts +50 -0
- package/dist/web/search-palette/viking-search-palette-wc.d.ts +64 -0
- package/dist/web/select/viking-select-wc.d.ts +48 -0
- package/dist/web/suite-header/viking-suite-header-wc.d.ts +36 -0
- package/dist/web/suite-search-palette/viking-suite-search-palette-wc.d.ts +39 -0
- package/dist/web/theme-toggle/viking-theme-toggle-wc.d.ts +19 -0
- package/dist/web/types.d.ts +40 -0
- package/dist/web-components/index.d.ts +1 -0
- package/dist/web-components.js +1750 -0
- package/dist/widget.js +1182 -0
- package/package.json +89 -30
- package/src/assets/drakkar-favicon.svg +17 -0
- package/src/assets/fonts/inter/InterVariable-Italic.woff2 +0 -0
- package/src/assets/fonts/inter/InterVariable.woff2 +0 -0
- package/src/core/brand/deml-lockup.svg +5 -0
- package/src/core/brand/deml-mark-compact.svg +4 -0
- package/src/core/brand/deml-mark-filled.svg +3 -0
- package/src/core/brand/deml-mark-outline.svg +4 -0
- package/src/core/brand-icons.ts +62 -0
- package/src/core/icons.spec.ts +52 -0
- package/src/core/icons.ts +206 -0
- package/src/core/integration-brand-icons.ts +77 -0
- package/src/core/lucide-paths.generated.ts +130 -0
- package/src/core/types.ts +85 -0
- package/src/core/uid.ts +7 -0
- package/src/elements/button/viking-button.ts +201 -0
- package/src/elements/card/viking-card.ts +60 -0
- package/src/elements/core/dom.ts +33 -0
- package/src/elements/core/styles.ts +28 -0
- package/src/elements/modal/viking-modal.ts +154 -0
- package/src/index.ts +1 -0
- package/src/lib/accordion/accordion.ts +126 -0
- package/src/lib/app-header/app-header.scss +274 -0
- package/src/lib/app-header/app-header.ts +43 -0
- package/src/lib/app-sidebar/app-sidebar.scss +415 -0
- package/src/lib/app-sidebar/app-sidebar.ts +29 -0
- package/src/lib/auth-panel/auth-panel.spec.ts +132 -0
- package/src/lib/auth-panel/auth-panel.ts +228 -0
- package/src/lib/autocomplete/autocomplete.ts +223 -0
- package/src/lib/avatar/avatar.ts +126 -0
- package/src/lib/badge/badge.ts +182 -0
- package/src/lib/bar/bar.ts +31 -0
- package/src/lib/brand/brand.ts +60 -0
- package/src/lib/breadcrumbs/breadcrumbs.ts +81 -0
- package/src/lib/button/button-group.ts +40 -0
- package/src/lib/button/button.scss +96 -0
- package/src/lib/button/button.ts +98 -0
- package/src/lib/calendar/calendar.ts +253 -0
- package/src/lib/callout/callout.ts +211 -0
- package/src/lib/card/card-title.spec.ts +27 -0
- package/src/lib/card/card-title.ts +50 -0
- package/src/lib/card/card.ts +170 -0
- package/src/lib/carousel/carousel.ts +206 -0
- package/src/lib/chart/chart-zoom.spec.ts +65 -0
- package/src/lib/chart/chart-zoom.ts +71 -0
- package/src/lib/chart/chart.ts +1257 -0
- package/src/lib/chart-card-header/chart-card-header.ts +80 -0
- package/src/lib/chart-empty-state/chart-empty-state.ts +146 -0
- package/src/lib/chart-panel/chart-panel.ts +133 -0
- package/src/lib/checkbox/checkbox.ts +139 -0
- package/src/lib/color-picker/color-picker.ts +148 -0
- package/src/lib/command/command.ts +260 -0
- package/src/lib/composer/composer.ts +180 -0
- package/src/lib/confirm-dialog/confirm-dialog.ts +163 -0
- package/src/lib/confirm-dialog/dialog.service.ts +79 -0
- package/src/lib/context/context.ts +75 -0
- package/src/lib/core/brand-icons.ts +62 -0
- package/src/lib/core/cva.ts +33 -0
- package/src/lib/core/icons.ts +206 -0
- package/src/lib/core/integration-brand-icons.ts +77 -0
- package/src/lib/core/lucide-paths.generated.ts +130 -0
- package/src/lib/date-picker/date-picker.ts +139 -0
- package/src/lib/dropdown/dropdown.ts +188 -0
- package/src/lib/editor/editor.ts +170 -0
- package/src/lib/empty-state/empty-state.ts +100 -0
- package/src/lib/fab/fab.ts +76 -0
- package/src/lib/field/field.ts +111 -0
- package/src/lib/file-upload/file-upload.ts +208 -0
- package/src/lib/footer/footer.scss +155 -0
- package/src/lib/footer/footer.ts +28 -0
- package/src/lib/form-section/form-section.ts +200 -0
- package/src/lib/forms.spec.ts +92 -0
- package/src/lib/gauge-arc/gauge-arc.ts +85 -0
- package/src/lib/hud-panel/hud-panel.ts +27 -0
- package/src/lib/icon/icon.ts +284 -0
- package/src/lib/icon-badge/icon-badge.ts +87 -0
- package/src/lib/icon-heading/icon-heading.spec.ts +32 -0
- package/src/lib/icon-heading/icon-heading.ts +38 -0
- package/src/lib/icon-text/icon-text.ts +120 -0
- package/src/lib/input/input.ts +119 -0
- package/src/lib/kanban/kanban.ts +211 -0
- package/src/lib/kbd/kbd.ts +32 -0
- package/src/lib/label/label.ts +39 -0
- package/src/lib/loading-overlay/loading-overlay.ts +80 -0
- package/src/lib/menubar/menubar.ts +77 -0
- package/src/lib/metric-card/metric-card.ts +33 -0
- package/src/lib/modal/modal.ts +207 -0
- package/src/lib/native-select/native-select.ts +124 -0
- package/src/lib/navbar/navbar.ts +124 -0
- package/src/lib/navigation-menu/navigation-menu.ts +116 -0
- package/src/lib/otp-input/otp-input.ts +164 -0
- package/src/lib/page-back-link/page-back-link.ts +74 -0
- package/src/lib/page-header/page-header.ts +70 -0
- package/src/lib/pagination/pagination.ts +157 -0
- package/src/lib/pillbox/pillbox.ts +157 -0
- package/src/lib/popover/popover.ts +92 -0
- package/src/lib/profile/profile.ts +73 -0
- package/src/lib/progress/progress.ts +123 -0
- package/src/lib/radio/radio.ts +132 -0
- package/src/lib/ring-gauge/ring-gauge.ts +75 -0
- package/src/lib/scroll-area/scroll-area.ts +57 -0
- package/src/lib/search-palette/search-palette.scss +288 -0
- package/src/lib/search-palette/search-palette.ts +114 -0
- package/src/lib/select/select.ts +292 -0
- package/src/lib/separator/separator.ts +59 -0
- package/src/lib/sheet/sheet.ts +192 -0
- package/src/lib/sidebar-nav/sidebar-nav.scss +218 -0
- package/src/lib/sidebar-nav/sidebar-nav.ts +158 -0
- package/src/lib/site-drakkar/site-drakkar.config.ts +295 -0
- package/src/lib/site-drakkar/site-footer.ts +129 -0
- package/src/lib/site-drakkar/site-navbar.scss +2 -0
- package/src/lib/site-drakkar/site-navbar.ts +267 -0
- package/src/lib/site-drakkar/suite-search-items.spec.ts +61 -0
- package/src/lib/site-drakkar/suite-search-items.ts +246 -0
- package/src/lib/skeleton/skeleton.ts +51 -0
- package/src/lib/slider/slider.ts +133 -0
- package/src/lib/spinner/spinner.ts +75 -0
- package/src/lib/status-metric-row/status-metric-row.ts +74 -0
- package/src/lib/suite-search-palette/suite-search-palette.ts +95 -0
- package/src/lib/switch/switch.ts +131 -0
- package/src/lib/table/table.ts +137 -0
- package/src/lib/tabs/tab-panel.ts +61 -0
- package/src/lib/tabs/tab.ts +107 -0
- package/src/lib/tabs/tabs.ts +109 -0
- package/src/lib/textarea/textarea.ts +103 -0
- package/src/lib/theme-toggle/theme-toggle.spec.ts +40 -0
- package/src/lib/theme-toggle/theme-toggle.ts +39 -0
- package/src/lib/time-picker/time-picker.ts +197 -0
- package/src/lib/timeline/timeline.ts +152 -0
- package/src/lib/toast/toast.ts +196 -0
- package/src/lib/toggle/toggle-group.ts +60 -0
- package/src/lib/toggle/toggle.ts +101 -0
- package/src/lib/tooltip/tooltip.ts +119 -0
- package/src/lib/typography/heading.ts +52 -0
- package/src/lib/typography/text.ts +51 -0
- package/src/lib/uptime-bar/uptime-bar.ts +55 -0
- package/src/lib/verification-code-field/verification-code-field.ts +149 -0
- package/src/lib/whitepaper-cta/whitepaper-cta.scss +130 -0
- package/src/lib/whitepaper-cta/whitepaper-cta.ts +78 -0
- package/src/lib/wizard/wizard.ts +80 -0
- package/src/public-api.ts +172 -0
- package/src/styles/_buttons.scss +301 -0
- package/src/styles/_component-primitives.scss +183 -0
- package/src/styles/_drakkar-buttons.scss +85 -0
- package/src/styles/_fonts.scss +22 -0
- package/src/styles/_forms.scss +66 -0
- package/src/styles/_input.scss +106 -0
- package/src/styles/_layout-enforcement.scss +166 -0
- package/src/styles/_layout-rhythm.scss +158 -0
- package/src/styles/_legacy-aliases.scss +212 -0
- package/src/styles/_series-colors.scss +24 -0
- package/src/styles/_static-primitives.scss +857 -0
- package/src/styles/_typography.scss +87 -0
- package/src/styles/_variables.scss +527 -0
- package/src/styles/components/a11y.scss +90 -0
- package/src/styles/components/badges.scss +102 -0
- package/src/styles/components/extracted-utilities.scss +459 -0
- package/src/styles/components/footer.scss +155 -0
- package/src/styles/components/icon-heading.scss +47 -0
- package/src/styles/components/icon-inline.scss +78 -0
- package/src/styles/components/layout.scss +59 -0
- package/src/styles/components/utilities.scss +131 -0
- package/src/styles/components/viking-inspired.scss +204 -0
- package/src/styles/components/whitepaper-cta.scss +130 -0
- package/src/styles/components-bundle.scss +9 -0
- package/src/styles/components.scss +175 -0
- package/src/styles/deml-components.scss +10 -0
- package/src/styles/index.scss +8 -0
- package/src/styles/layout-shell.scss +39 -11
- package/src/styles/page-shell.scss +663 -33
- package/src/styles/static-navbar.scss +862 -146
- package/src/styles/surfaces/backend.scss +142 -0
- package/src/styles/surfaces/docs-global.scss +73 -0
- package/src/styles/surfaces/docs-shell.scss +412 -0
- package/src/styles/surfaces/docs-showcase.scss +1051 -0
- package/src/styles/surfaces/marketing-cta.scss +62 -0
- package/src/styles/surfaces/marketing-docs-bento.scss +67 -0
- package/src/styles/surfaces/marketing-global.scss +748 -0
- package/src/styles/surfaces/marketing-landing.scss +1260 -0
- package/src/styles/surfaces/marketing-publication.scss +535 -0
- package/src/styles/surfaces/marketing-theme.scss +14 -0
- package/src/styles/surfaces/swagger-ui.scss +921 -0
- package/src/styles/tokens-export.scss +18 -0
- package/src/styles/tokens.scss +5 -0
- package/src/styles/viking-ui-bundle.scss +20 -2
- package/src/styles/viking-ui.scss +213 -51
- package/src/tokens/series-presets.ts +15 -0
- package/src/tokens/tailwind.preset.js +209 -0
- package/src/tokens/viking-tokens.json +318 -0
- package/src/viking-ui.spec.ts +416 -0
- package/src/web/badge/viking-badge-wc.ts +116 -0
- package/src/web/button/viking-button-wc.ts +165 -0
- package/src/web/callout/viking-callout-wc.ts +105 -0
- package/src/web/card/viking-card-wc.ts +66 -0
- package/src/web/core/base.ts +56 -0
- package/src/web/core/dom.ts +53 -0
- package/src/web/core/icons-inline.ts +44 -0
- package/src/web/core/styles.ts +1138 -0
- package/src/web/core/types.ts +19 -0
- package/src/web/field/viking-field-wc.ts +154 -0
- package/src/web/index.ts +73 -0
- package/src/web/input/viking-input-wc.ts +211 -0
- package/src/web/modal/viking-modal-wc.ts +187 -0
- package/src/web/search-palette/viking-search-palette-wc.ts +494 -0
- package/src/web/select/viking-select-wc.ts +218 -0
- package/src/web/suite-header/viking-suite-header-wc.ts +714 -0
- package/src/web/suite-search-palette/viking-suite-search-palette-wc.ts +234 -0
- package/src/web/theme-toggle/viking-theme-toggle-wc.ts +139 -0
- package/src/web/types.ts +37 -0
- package/src/web/web-components.spec.ts +297 -0
- package/src/web-components/index.ts +1 -0
- package/fesm2022/dataengineeringformachinelearning-viking-ui.mjs +0 -6114
- package/fesm2022/dataengineeringformachinelearning-viking-ui.mjs.map +0 -1
- package/types/dataengineeringformachinelearning-viking-ui.d.ts +0 -1397
- package/viking.manifest.json +0 -238
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
Injectable,
|
|
5
|
+
input,
|
|
6
|
+
signal,
|
|
7
|
+
} from "@angular/core";
|
|
8
|
+
import { VikingIcon } from "../icon/icon";
|
|
9
|
+
import { VikingIconName } from "../../core/icons";
|
|
10
|
+
import { VikingToastInstance, VikingToastOptions } from "../../core/types";
|
|
11
|
+
|
|
12
|
+
const TONE_ICONS: Record<string, VikingIconName> = {
|
|
13
|
+
accent: "info",
|
|
14
|
+
success: "check-circle",
|
|
15
|
+
warning: "alert-triangle",
|
|
16
|
+
danger: "alert-circle",
|
|
17
|
+
muted: "info",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* VikingToastService — imperative toast API.
|
|
22
|
+
* Render a single <viking-toaster> outlet near the app root.
|
|
23
|
+
*/
|
|
24
|
+
@Injectable({ providedIn: "root" })
|
|
25
|
+
export class VikingToastService {
|
|
26
|
+
private nextId = 1;
|
|
27
|
+
readonly toasts = signal<VikingToastInstance[]>([]);
|
|
28
|
+
|
|
29
|
+
readonly show = (options: VikingToastOptions): number => {
|
|
30
|
+
const toast: VikingToastInstance = {
|
|
31
|
+
id: this.nextId++,
|
|
32
|
+
heading: options.heading ?? "",
|
|
33
|
+
text: options.text,
|
|
34
|
+
tone: options.tone ?? "accent",
|
|
35
|
+
duration: options.duration ?? 4500,
|
|
36
|
+
};
|
|
37
|
+
this.toasts.update((list) => [...list, toast]);
|
|
38
|
+
if (toast.duration > 0) {
|
|
39
|
+
setTimeout(() => this.dismiss(toast.id), toast.duration);
|
|
40
|
+
}
|
|
41
|
+
return toast.id;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
readonly dismiss = (id: number): void => {
|
|
45
|
+
this.toasts.update((list) => list.filter((toast) => toast.id !== id));
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* viking-toaster — fixed-position outlet that renders active toasts.
|
|
51
|
+
*/
|
|
52
|
+
@Component({
|
|
53
|
+
selector: "viking-toaster",
|
|
54
|
+
imports: [VikingIcon],
|
|
55
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
56
|
+
host: { "[class.viking-toaster-top]": "position() === 'top-end'" },
|
|
57
|
+
template: `
|
|
58
|
+
@for (toast of service.toasts(); track toast.id) {
|
|
59
|
+
<div
|
|
60
|
+
class="viking-toast"
|
|
61
|
+
[class]="'viking-toast-' + toast.tone"
|
|
62
|
+
role="status"
|
|
63
|
+
>
|
|
64
|
+
<viking-icon
|
|
65
|
+
class="viking-toast-icon"
|
|
66
|
+
[name]="toneIcon(toast.tone)"
|
|
67
|
+
[size]="20"
|
|
68
|
+
/>
|
|
69
|
+
<div class="viking-toast-body">
|
|
70
|
+
@if (toast.heading) {
|
|
71
|
+
<p class="viking-toast-heading">{{ toast.heading }}</p>
|
|
72
|
+
}
|
|
73
|
+
<p class="viking-toast-text">{{ toast.text }}</p>
|
|
74
|
+
</div>
|
|
75
|
+
<button
|
|
76
|
+
type="button"
|
|
77
|
+
class="viking-toast-close"
|
|
78
|
+
aria-label="Dismiss notification"
|
|
79
|
+
(click)="service.dismiss(toast.id)"
|
|
80
|
+
>
|
|
81
|
+
<viking-icon name="x" [size]="16" />
|
|
82
|
+
</button>
|
|
83
|
+
</div>
|
|
84
|
+
}
|
|
85
|
+
`,
|
|
86
|
+
styles: [
|
|
87
|
+
`
|
|
88
|
+
:host {
|
|
89
|
+
position: fixed;
|
|
90
|
+
bottom: var(--viking-space-3);
|
|
91
|
+
right: var(--viking-space-3);
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
gap: var(--viking-space-1);
|
|
95
|
+
z-index: var(--viking-z-toast);
|
|
96
|
+
max-width: min(414px, calc(100vw - var(--viking-space-4)));
|
|
97
|
+
}
|
|
98
|
+
@media (max-width: 767px) {
|
|
99
|
+
:host {
|
|
100
|
+
bottom: var(--viking-space-2);
|
|
101
|
+
right: var(--viking-space-2);
|
|
102
|
+
left: var(--viking-space-2);
|
|
103
|
+
max-width: none;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
:host(.viking-toaster-top) {
|
|
107
|
+
bottom: auto;
|
|
108
|
+
top: var(--viking-space-3);
|
|
109
|
+
}
|
|
110
|
+
.viking-toast {
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: flex-start;
|
|
113
|
+
gap: var(--viking-space-1);
|
|
114
|
+
padding: var(--viking-space-2);
|
|
115
|
+
background: var(--viking-surface);
|
|
116
|
+
border: 1px solid var(--viking-border-strong);
|
|
117
|
+
border-radius: var(--viking-radius);
|
|
118
|
+
box-shadow: var(--viking-shadow-md);
|
|
119
|
+
font-family: var(--viking-font-family);
|
|
120
|
+
animation: viking-toast-in var(--viking-duration) var(--viking-ease-out);
|
|
121
|
+
}
|
|
122
|
+
@keyframes viking-toast-in {
|
|
123
|
+
from {
|
|
124
|
+
transform: translateY(var(--viking-space-1));
|
|
125
|
+
opacity: 0;
|
|
126
|
+
}
|
|
127
|
+
to {
|
|
128
|
+
transform: translateY(0);
|
|
129
|
+
opacity: 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
@media (prefers-reduced-motion: reduce) {
|
|
133
|
+
.viking-toast {
|
|
134
|
+
animation: none;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
.viking-toast-icon {
|
|
138
|
+
margin-top: 2px;
|
|
139
|
+
}
|
|
140
|
+
.viking-toast-accent .viking-toast-icon {
|
|
141
|
+
color: var(--viking-accent);
|
|
142
|
+
}
|
|
143
|
+
.viking-toast-success .viking-toast-icon {
|
|
144
|
+
color: var(--viking-success);
|
|
145
|
+
}
|
|
146
|
+
.viking-toast-warning .viking-toast-icon {
|
|
147
|
+
color: var(--viking-warning);
|
|
148
|
+
}
|
|
149
|
+
.viking-toast-danger .viking-toast-icon {
|
|
150
|
+
color: var(--viking-danger);
|
|
151
|
+
}
|
|
152
|
+
.viking-toast-body {
|
|
153
|
+
flex: 1;
|
|
154
|
+
min-width: 0;
|
|
155
|
+
}
|
|
156
|
+
.viking-toast-heading {
|
|
157
|
+
margin: 0;
|
|
158
|
+
font-size: var(--viking-font-size);
|
|
159
|
+
font-weight: 600;
|
|
160
|
+
color: var(--viking-text);
|
|
161
|
+
}
|
|
162
|
+
.viking-toast-text {
|
|
163
|
+
margin: 0;
|
|
164
|
+
font-size: var(--viking-font-size);
|
|
165
|
+
color: var(--viking-text-muted);
|
|
166
|
+
line-height: 1.45;
|
|
167
|
+
}
|
|
168
|
+
.viking-toast-close {
|
|
169
|
+
display: inline-flex;
|
|
170
|
+
border: none;
|
|
171
|
+
background: transparent;
|
|
172
|
+
color: var(--viking-text-muted);
|
|
173
|
+
cursor: pointer;
|
|
174
|
+
padding: var(--viking-space-half);
|
|
175
|
+
border-radius: var(--viking-radius-pill);
|
|
176
|
+
transition: var(--viking-transition-interactive);
|
|
177
|
+
}
|
|
178
|
+
.viking-toast-close:hover {
|
|
179
|
+
color: var(--viking-text);
|
|
180
|
+
background: var(--viking-accent-soft);
|
|
181
|
+
}
|
|
182
|
+
.viking-toast-close:focus-visible {
|
|
183
|
+
outline: var(--viking-ring-width) solid var(--viking-ring);
|
|
184
|
+
outline-offset: 1px;
|
|
185
|
+
}
|
|
186
|
+
`,
|
|
187
|
+
],
|
|
188
|
+
})
|
|
189
|
+
export class VikingToaster {
|
|
190
|
+
readonly position = input<"bottom-end" | "top-end">("bottom-end");
|
|
191
|
+
|
|
192
|
+
constructor(protected readonly service: VikingToastService) {}
|
|
193
|
+
|
|
194
|
+
protected toneIcon = (tone: string): VikingIconName =>
|
|
195
|
+
TONE_ICONS[tone] ?? "info";
|
|
196
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
InjectionToken,
|
|
5
|
+
model,
|
|
6
|
+
} from "@angular/core";
|
|
7
|
+
|
|
8
|
+
export const VIKING_TOGGLE_GROUP = new InjectionToken<VikingToggleGroup>(
|
|
9
|
+
"VIKING_TOGGLE_GROUP",
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* viking-toggle-group — exclusive or multi toggle cluster.
|
|
14
|
+
*/
|
|
15
|
+
@Component({
|
|
16
|
+
selector: "viking-toggle-group",
|
|
17
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
18
|
+
providers: [{ provide: VIKING_TOGGLE_GROUP, useExisting: VikingToggleGroup }],
|
|
19
|
+
host: {
|
|
20
|
+
role: "group",
|
|
21
|
+
class: "viking-toggle-group",
|
|
22
|
+
"[class.viking-exclusive]": "exclusive()",
|
|
23
|
+
},
|
|
24
|
+
template: `<ng-content />`,
|
|
25
|
+
styles: [
|
|
26
|
+
`
|
|
27
|
+
:host {
|
|
28
|
+
display: inline-flex;
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
gap: 0;
|
|
31
|
+
border: 1px solid var(--viking-border-strong);
|
|
32
|
+
border-radius: var(--viking-radius);
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
box-shadow: var(--viking-shadow-sm);
|
|
35
|
+
}
|
|
36
|
+
:host ::ng-deep viking-toggle:not(:first-child) .viking-toggle {
|
|
37
|
+
border-left: none;
|
|
38
|
+
margin-left: -1px;
|
|
39
|
+
border-radius: 0;
|
|
40
|
+
}
|
|
41
|
+
:host ::ng-deep viking-toggle:first-child .viking-toggle {
|
|
42
|
+
border-top-right-radius: 0;
|
|
43
|
+
border-bottom-right-radius: 0;
|
|
44
|
+
}
|
|
45
|
+
:host ::ng-deep viking-toggle:last-child .viking-toggle {
|
|
46
|
+
border-top-left-radius: 0;
|
|
47
|
+
border-bottom-left-radius: 0;
|
|
48
|
+
}
|
|
49
|
+
:host ::ng-deep viking-toggle .viking-toggle {
|
|
50
|
+
min-width: var(--viking-btn-min-width, 120px);
|
|
51
|
+
border-radius: 0;
|
|
52
|
+
box-shadow: none;
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
],
|
|
56
|
+
})
|
|
57
|
+
export class VikingToggleGroup {
|
|
58
|
+
readonly value = model<string>("");
|
|
59
|
+
readonly exclusive = model(true);
|
|
60
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
Optional,
|
|
5
|
+
input,
|
|
6
|
+
model,
|
|
7
|
+
output,
|
|
8
|
+
} from "@angular/core";
|
|
9
|
+
import { VIKING_TOGGLE_GROUP, VikingToggleGroup } from "./toggle-group";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* viking-toggle — pressed-state button toggle.
|
|
13
|
+
*/
|
|
14
|
+
@Component({
|
|
15
|
+
selector: "viking-toggle",
|
|
16
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
17
|
+
template: `
|
|
18
|
+
<button
|
|
19
|
+
type="button"
|
|
20
|
+
class="viking-toggle"
|
|
21
|
+
[class.viking-pressed]="isPressed()"
|
|
22
|
+
[attr.aria-pressed]="isPressed()"
|
|
23
|
+
[disabled]="disabled()"
|
|
24
|
+
[attr.aria-label]="label() || null"
|
|
25
|
+
(click)="toggle()"
|
|
26
|
+
>
|
|
27
|
+
<ng-content />
|
|
28
|
+
</button>
|
|
29
|
+
`,
|
|
30
|
+
styles: [
|
|
31
|
+
`
|
|
32
|
+
:host {
|
|
33
|
+
display: inline-flex;
|
|
34
|
+
}
|
|
35
|
+
.viking-toggle {
|
|
36
|
+
font-family: var(--viking-font-family);
|
|
37
|
+
font-size: var(--viking-font-size-ui);
|
|
38
|
+
font-weight: 700;
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
gap: var(--viking-space-1);
|
|
43
|
+
min-height: var(--viking-control-height-sm);
|
|
44
|
+
min-width: var(--viking-btn-min-width, 120px);
|
|
45
|
+
padding: 0 var(--viking-space-2);
|
|
46
|
+
border: 1px solid var(--viking-border-strong);
|
|
47
|
+
border-radius: var(--viking-radius);
|
|
48
|
+
background: var(--viking-surface);
|
|
49
|
+
color: var(--viking-text);
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
transition: var(--viking-transition);
|
|
52
|
+
}
|
|
53
|
+
.viking-toggle:hover:not(:disabled) {
|
|
54
|
+
border-color: var(--viking-accent-strong);
|
|
55
|
+
background: var(--viking-accent-soft);
|
|
56
|
+
}
|
|
57
|
+
.viking-toggle:focus-visible {
|
|
58
|
+
outline: var(--viking-ring-width) solid var(--viking-ring);
|
|
59
|
+
outline-offset: var(--viking-ring-offset);
|
|
60
|
+
}
|
|
61
|
+
.viking-toggle.viking-pressed {
|
|
62
|
+
background: var(--viking-accent);
|
|
63
|
+
border-color: var(--viking-accent);
|
|
64
|
+
color: var(--viking-accent-content);
|
|
65
|
+
}
|
|
66
|
+
.viking-toggle:disabled {
|
|
67
|
+
opacity: var(--viking-state-disabled-opacity);
|
|
68
|
+
cursor: not-allowed;
|
|
69
|
+
}
|
|
70
|
+
`,
|
|
71
|
+
],
|
|
72
|
+
})
|
|
73
|
+
export class VikingToggle {
|
|
74
|
+
constructor(@Optional() private readonly group: VikingToggleGroup | null) {}
|
|
75
|
+
|
|
76
|
+
readonly pressed = model(false);
|
|
77
|
+
readonly value = input<string>("");
|
|
78
|
+
readonly disabled = input(false);
|
|
79
|
+
readonly label = input("");
|
|
80
|
+
|
|
81
|
+
readonly toggled = output<boolean>();
|
|
82
|
+
|
|
83
|
+
protected isPressed = (): boolean => {
|
|
84
|
+
if (this.group && this.value()) {
|
|
85
|
+
return this.group.value() === this.value();
|
|
86
|
+
}
|
|
87
|
+
return this.pressed();
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
protected toggle = (): void => {
|
|
91
|
+
if (this.disabled()) return;
|
|
92
|
+
if (this.group && this.value()) {
|
|
93
|
+
this.group.value.set(this.value());
|
|
94
|
+
this.toggled.emit(true);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const next = !this.pressed();
|
|
98
|
+
this.pressed.set(next);
|
|
99
|
+
this.toggled.emit(next);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DOCUMENT,
|
|
3
|
+
Directive,
|
|
4
|
+
ElementRef,
|
|
5
|
+
Inject,
|
|
6
|
+
OnDestroy,
|
|
7
|
+
input,
|
|
8
|
+
} from "@angular/core";
|
|
9
|
+
|
|
10
|
+
let tooltipIdCounter = 0;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* vikingTooltip — attribute directive tooltip.
|
|
14
|
+
* Shows on hover and keyboard focus; positions itself relative to the host.
|
|
15
|
+
*/
|
|
16
|
+
@Directive({
|
|
17
|
+
selector: "[vikingTooltip]",
|
|
18
|
+
host: {
|
|
19
|
+
class: "viking-tooltip-host viking-focus-ring",
|
|
20
|
+
"(mouseenter)": "show()",
|
|
21
|
+
"(mouseleave)": "hide()",
|
|
22
|
+
"(focusin)": "show()",
|
|
23
|
+
"(focusout)": "hide()",
|
|
24
|
+
"(keydown.escape)": "hide()",
|
|
25
|
+
"[attr.aria-describedby]": "visible() ? tooltipId : null",
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
export class VikingTooltip implements OnDestroy {
|
|
29
|
+
constructor(
|
|
30
|
+
private readonly host: ElementRef<HTMLElement>,
|
|
31
|
+
@Inject(DOCUMENT) private readonly document: Document,
|
|
32
|
+
) {}
|
|
33
|
+
|
|
34
|
+
readonly vikingTooltip = input.required<string>();
|
|
35
|
+
readonly tooltipPosition = input<"top" | "bottom" | "left" | "right">("top");
|
|
36
|
+
readonly tooltipKbd = input<string>("");
|
|
37
|
+
|
|
38
|
+
protected readonly tooltipId = `viking-tooltip-${++tooltipIdCounter}`;
|
|
39
|
+
|
|
40
|
+
private element: HTMLElement | null = null;
|
|
41
|
+
|
|
42
|
+
protected visible = (): boolean => this.element !== null;
|
|
43
|
+
|
|
44
|
+
protected show = (): void => {
|
|
45
|
+
if (this.element || !this.vikingTooltip()) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const tip = this.document.createElement("div");
|
|
49
|
+
tip.id = this.tooltipId;
|
|
50
|
+
tip.setAttribute("role", "tooltip");
|
|
51
|
+
tip.className = "viking-tooltip";
|
|
52
|
+
|
|
53
|
+
const text = this.document.createElement("span");
|
|
54
|
+
text.className = "viking-tooltip-text";
|
|
55
|
+
text.textContent = this.vikingTooltip();
|
|
56
|
+
tip.appendChild(text);
|
|
57
|
+
|
|
58
|
+
if (this.tooltipKbd()) {
|
|
59
|
+
const kbd = this.document.createElement("kbd");
|
|
60
|
+
kbd.className = "viking-tooltip-kbd";
|
|
61
|
+
kbd.textContent = this.tooltipKbd();
|
|
62
|
+
tip.appendChild(kbd);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.document.body.appendChild(tip);
|
|
66
|
+
this.position(tip);
|
|
67
|
+
this.element = tip;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
private position = (tip: HTMLElement): void => {
|
|
71
|
+
const anchor = this.host.nativeElement.getBoundingClientRect();
|
|
72
|
+
const rect = tip.getBoundingClientRect();
|
|
73
|
+
const gap =
|
|
74
|
+
parseInt(
|
|
75
|
+
getComputedStyle(this.document.documentElement).getPropertyValue(
|
|
76
|
+
"--viking-space-1",
|
|
77
|
+
),
|
|
78
|
+
10,
|
|
79
|
+
) || 8;
|
|
80
|
+
const edge =
|
|
81
|
+
parseInt(
|
|
82
|
+
getComputedStyle(this.document.documentElement).getPropertyValue(
|
|
83
|
+
"--viking-space-1",
|
|
84
|
+
),
|
|
85
|
+
10,
|
|
86
|
+
) || 8;
|
|
87
|
+
|
|
88
|
+
let left = anchor.left + anchor.width / 2 - rect.width / 2;
|
|
89
|
+
let top = anchor.top - rect.height - gap;
|
|
90
|
+
|
|
91
|
+
switch (this.tooltipPosition()) {
|
|
92
|
+
case "bottom":
|
|
93
|
+
top = anchor.bottom + gap;
|
|
94
|
+
break;
|
|
95
|
+
case "left":
|
|
96
|
+
left = anchor.left - rect.width - gap;
|
|
97
|
+
top = anchor.top + anchor.height / 2 - rect.height / 2;
|
|
98
|
+
break;
|
|
99
|
+
case "right":
|
|
100
|
+
left = anchor.right + gap;
|
|
101
|
+
top = anchor.top + anchor.height / 2 - rect.height / 2;
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
tip.style.left = `${Math.max(edge, Math.min(left, window.innerWidth - rect.width - edge))}px`;
|
|
108
|
+
tip.style.top = `${Math.max(edge, top)}px`;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
protected hide = (): void => {
|
|
112
|
+
this.element?.remove();
|
|
113
|
+
this.element = null;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
ngOnDestroy(): void {
|
|
117
|
+
this.hide();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
computed,
|
|
5
|
+
input,
|
|
6
|
+
} from "@angular/core";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* viking-heading — consistent heading sizes.
|
|
10
|
+
*/
|
|
11
|
+
@Component({
|
|
12
|
+
selector: "viking-heading",
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
host: {
|
|
15
|
+
role: "heading",
|
|
16
|
+
"[attr.aria-level]": "ariaLevel()",
|
|
17
|
+
"[class]": "hostClass()",
|
|
18
|
+
},
|
|
19
|
+
template: `<ng-content />`,
|
|
20
|
+
styles: [
|
|
21
|
+
`
|
|
22
|
+
:host {
|
|
23
|
+
display: block;
|
|
24
|
+
font-family: var(--viking-font-family);
|
|
25
|
+
font-weight: 600;
|
|
26
|
+
color: var(--viking-text);
|
|
27
|
+
letter-spacing: var(--header-letter-spacing, -0.02em);
|
|
28
|
+
font-size: var(--viking-font-size-ui);
|
|
29
|
+
line-height: 1.25;
|
|
30
|
+
}
|
|
31
|
+
:host(.viking-heading-sm) {
|
|
32
|
+
font-size: var(--viking-font-size-sm);
|
|
33
|
+
}
|
|
34
|
+
:host(.viking-heading-lg) {
|
|
35
|
+
font-size: var(--viking-font-size);
|
|
36
|
+
}
|
|
37
|
+
:host(.viking-heading-xl) {
|
|
38
|
+
font-size: var(--viking-font-size-lg);
|
|
39
|
+
font-weight: 700;
|
|
40
|
+
}
|
|
41
|
+
`,
|
|
42
|
+
],
|
|
43
|
+
})
|
|
44
|
+
export class VikingHeading {
|
|
45
|
+
readonly size = input<"sm" | "base" | "lg" | "xl">("base");
|
|
46
|
+
readonly level = input<1 | 2 | 3 | 4>(3);
|
|
47
|
+
|
|
48
|
+
protected readonly ariaLevel = computed(() => this.level());
|
|
49
|
+
protected readonly hostClass = computed(
|
|
50
|
+
() => `viking-heading-${this.size()}`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
computed,
|
|
5
|
+
input,
|
|
6
|
+
} from "@angular/core";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* viking-text — body text with semantic variants.
|
|
10
|
+
*/
|
|
11
|
+
@Component({
|
|
12
|
+
selector: "viking-text",
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
host: { "[class]": "hostClass()" },
|
|
15
|
+
template: `<ng-content />`,
|
|
16
|
+
styles: [
|
|
17
|
+
`
|
|
18
|
+
:host {
|
|
19
|
+
display: block;
|
|
20
|
+
font-family: var(--viking-font-family);
|
|
21
|
+
font-size: var(--viking-font-size);
|
|
22
|
+
line-height: 1.65;
|
|
23
|
+
color: var(--viking-text);
|
|
24
|
+
}
|
|
25
|
+
:host(.viking-text-inline) {
|
|
26
|
+
display: inline;
|
|
27
|
+
}
|
|
28
|
+
:host(.viking-text-muted) {
|
|
29
|
+
color: var(--viking-text-muted);
|
|
30
|
+
}
|
|
31
|
+
:host(.viking-text-strong) {
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
}
|
|
34
|
+
:host(.viking-text-accent) {
|
|
35
|
+
color: var(--viking-accent);
|
|
36
|
+
font-weight: 500;
|
|
37
|
+
}
|
|
38
|
+
`,
|
|
39
|
+
],
|
|
40
|
+
})
|
|
41
|
+
export class VikingText {
|
|
42
|
+
readonly variant = input<"default" | "muted" | "strong" | "accent">(
|
|
43
|
+
"default",
|
|
44
|
+
);
|
|
45
|
+
readonly inline = input<boolean>(false);
|
|
46
|
+
|
|
47
|
+
protected readonly hostClass = computed(() => ({
|
|
48
|
+
[`viking-text-${this.variant()}`]: this.variant() !== "default",
|
|
49
|
+
"viking-text-inline": this.inline(),
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
computed,
|
|
5
|
+
input,
|
|
6
|
+
} from "@angular/core";
|
|
7
|
+
|
|
8
|
+
export type VikingUptimeStatus =
|
|
9
|
+
| "operational"
|
|
10
|
+
| "partial_outage"
|
|
11
|
+
| "major_outage"
|
|
12
|
+
| "no_data";
|
|
13
|
+
|
|
14
|
+
/** viking-uptime-bar — timeline bar for uptime history visualizations. */
|
|
15
|
+
@Component({
|
|
16
|
+
selector: "viking-uptime-bar",
|
|
17
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
18
|
+
host: {
|
|
19
|
+
class: "viking-uptime-bar",
|
|
20
|
+
"[class.viking-uptime-partial]": "status() === 'partial_outage'",
|
|
21
|
+
"[class.viking-uptime-major]": "status() === 'major_outage'",
|
|
22
|
+
"[class.viking-uptime-nodata]": "status() === 'no_data'",
|
|
23
|
+
"[attr.title]": "title()",
|
|
24
|
+
},
|
|
25
|
+
template: "",
|
|
26
|
+
styles: [
|
|
27
|
+
`
|
|
28
|
+
:host {
|
|
29
|
+
display: block;
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 100%;
|
|
32
|
+
border-radius: var(--viking-radius);
|
|
33
|
+
background: var(--viking-success);
|
|
34
|
+
}
|
|
35
|
+
:host(.viking-uptime-partial) {
|
|
36
|
+
height: 70%;
|
|
37
|
+
align-self: flex-end;
|
|
38
|
+
background: var(--viking-warning);
|
|
39
|
+
}
|
|
40
|
+
:host(.viking-uptime-major) {
|
|
41
|
+
height: 40%;
|
|
42
|
+
align-self: flex-end;
|
|
43
|
+
background: var(--viking-danger);
|
|
44
|
+
}
|
|
45
|
+
:host(.viking-uptime-nodata) {
|
|
46
|
+
background: var(--viking-text-muted);
|
|
47
|
+
opacity: 0.35;
|
|
48
|
+
}
|
|
49
|
+
`,
|
|
50
|
+
],
|
|
51
|
+
})
|
|
52
|
+
export class VikingUptimeBar {
|
|
53
|
+
readonly status = input<VikingUptimeStatus>("operational");
|
|
54
|
+
readonly title = input<string>("");
|
|
55
|
+
}
|