dasar-ui 1.5.0 → 1.9.2
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/CHANGELOG.md +53 -0
- package/README.md +40 -34
- package/docs/_config.yml +3 -0
- package/docs/getting-started.md +89 -0
- package/docs/index.md +9 -0
- package/docs/installation.md +46 -0
- package/package.json +7 -6
- package/projects/dasar-ui/package.json +1 -1
- package/projects/dasar-ui/src/lib/components/dasar-modal/dasar-modal.ts +2 -2
- package/projects/dasar-ui/src/lib/components/dasar-overlay/dasar-overlay.spec.ts +8 -0
- package/projects/dasar-ui/src/lib/components/dasar-overlay/dasar-overlay.ts +2 -2
- package/projects/dasar-ui/src/lib/components/dasar-theme-provider/dasar-theme-provider.spec.ts +89 -0
- package/projects/dasar-ui/src/lib/components/dasar-theme-provider/dasar-theme-provider.ts +23 -0
- package/projects/dasar-ui/src/lib/models/theme.model.ts +64 -0
- package/projects/dasar-ui/src/lib/services/theme.service.spec.ts +65 -0
- package/projects/dasar-ui/src/lib/services/theme.service.ts +70 -0
- package/projects/dasar-ui/src/public-api.ts +1 -0
- package/projects/documentation/src/app/app.html +33 -6
- package/projects/documentation/src/app/app.ts +36 -2
- package/projects/documentation/src/app/components/doc-customize-modal.component.ts +56 -2
- package/projects/documentation/src/app/components/doc-markdown.component.ts +154 -0
- package/projects/documentation/src/app/layouts/doc.layout.ts +23 -3
- package/projects/documentation/src/app/pages/button/button.page.html +1 -1
- package/projects/documentation/src/app/pages/chip/chip.page.html +1 -1
- package/projects/documentation/src/app/pages/getting-started/getting-started.page.ts +21 -0
- package/projects/documentation/src/app/pages/icon/icon.page.html +1 -1
- package/projects/documentation/src/app/pages/installation/installation.page.ts +18 -0
- package/projects/documentation/src/app/pages/introduction/introduction.page.ts +18 -0
- package/projects/documentation/src/app/pages/list/examples/advanced-dynamic/list-advanced-dynamic.example.html +29 -0
- package/projects/documentation/src/app/pages/list/examples/advanced-dynamic/list-advanced-dynamic.example.ts +33 -0
- package/projects/documentation/src/app/pages/list/examples/advanced-theme/list-advanced-theme.example.html +13 -0
- package/projects/documentation/src/app/pages/list/examples/advanced-theme/list-advanced-theme.example.ts +30 -0
- package/projects/documentation/src/app/pages/list/examples/basic/list-basic.example.html +5 -0
- package/projects/documentation/src/app/pages/list/examples/basic/list-basic.example.ts +12 -0
- package/projects/documentation/src/app/pages/list/examples/bordered-divider/list-bordered-divider.example.html +20 -0
- package/projects/documentation/src/app/pages/list/examples/bordered-divider/list-bordered-divider.example.ts +12 -0
- package/projects/documentation/src/app/pages/list/examples/custom-style/list-custom-style.example.html +11 -0
- package/projects/documentation/src/app/pages/list/examples/custom-style/list-custom-style.example.ts +19 -0
- package/projects/documentation/src/app/pages/list/examples/header-footer/list-header-footer.example.html +7 -0
- package/projects/documentation/src/app/pages/list/examples/header-footer/list-header-footer.example.ts +12 -0
- package/projects/documentation/src/app/pages/list/examples/interactive/list-interactive.example.html +20 -0
- package/projects/documentation/src/app/pages/list/examples/interactive/list-interactive.example.ts +22 -0
- package/projects/documentation/src/app/pages/list/examples/prefix-suffix/list-prefix-suffix.example.html +9 -0
- package/projects/documentation/src/app/pages/list/examples/prefix-suffix/list-prefix-suffix.example.ts +16 -0
- package/projects/documentation/src/app/pages/list/examples/size/list-size.example.html +20 -0
- package/projects/documentation/src/app/pages/list/examples/size/list-size.example.ts +12 -0
- package/projects/documentation/src/app/pages/list/list.page.html +95 -0
- package/projects/documentation/src/app/pages/list/list.page.ts +238 -0
- package/projects/documentation/src/app/pages/modal/modal.page.ts +15 -6
- package/projects/documentation/src/app/pages/table/table.page.html +1 -1
- package/projects/documentation/src/app/pages/tabs/tabs.page.ts +7 -0
- package/projects/documentation/src/app/pages/theming/examples/component-config/theming-component-config.example.html +13 -0
- package/projects/documentation/src/app/pages/theming/examples/component-config/theming-component-config.example.ts +20 -0
- package/projects/documentation/src/app/pages/theming/examples/css-override/theming-css-override.example.html +8 -0
- package/projects/documentation/src/app/pages/theming/examples/css-override/theming-css-override.example.scss +4 -0
- package/projects/documentation/src/app/pages/theming/examples/css-override/theming-css-override.example.ts +11 -0
- package/projects/documentation/src/app/pages/theming/examples/custom-tokens/theming-custom-tokens.example.html +13 -0
- package/projects/documentation/src/app/pages/theming/examples/custom-tokens/theming-custom-tokens.example.ts +33 -0
- package/projects/documentation/src/app/pages/theming/examples/global-theme/theming-global-theme.example.html +6 -0
- package/projects/documentation/src/app/pages/theming/examples/global-theme/theming-global-theme.example.ts +20 -0
- package/projects/documentation/src/app/pages/theming/examples/light-dark/theming-light-dark.example.html +15 -0
- package/projects/documentation/src/app/pages/theming/examples/light-dark/theming-light-dark.example.ts +31 -0
- package/projects/documentation/src/app/pages/theming/theming-component-config.page.ts +52 -0
- package/projects/documentation/src/app/pages/theming/theming-css-variables.page.ts +71 -0
- package/projects/documentation/src/app/pages/theming/theming-tokens.page.ts +56 -0
- package/projects/documentation/src/app/pages/theming/theming.data.ts +947 -0
- package/projects/documentation/src/app/pages/theming/theming.page.html +56 -0
- package/projects/documentation/src/app/pages/theming/theming.page.ts +144 -0
- package/projects/documentation/src/app/routes/app.routes.ts +63 -15
- package/projects/documentation/src/app/services/doc-customize.service.ts +12 -0
- package/projects/documentation/src/styles.scss +12 -0
|
@@ -63,3 +63,68 @@ describe('DasarThemeService.themeVariable', () => {
|
|
|
63
63
|
expect(dasarVariables.colors.primary.base).not.toBe('#000000');
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
|
+
|
|
67
|
+
describe('DasarThemeService component tokens', () => {
|
|
68
|
+
let service: DasarThemeService;
|
|
69
|
+
const root = () => document.documentElement;
|
|
70
|
+
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
TestBed.configureTestingModule({});
|
|
73
|
+
service = TestBed.inject(DasarThemeService);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
root().removeAttribute('data-theme');
|
|
78
|
+
[
|
|
79
|
+
'--tabs-gap-normal',
|
|
80
|
+
'--tabs-scroll-gap',
|
|
81
|
+
'--overlay-blur',
|
|
82
|
+
'--overlay-background',
|
|
83
|
+
'--modal-background',
|
|
84
|
+
'--modal-width-md',
|
|
85
|
+
].forEach((cssVar) => root().style.removeProperty(cssVar));
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('injects tabs, overlay and modal tokens on the document root', () => {
|
|
89
|
+
service.setGlobalTheme({
|
|
90
|
+
mode: 'light',
|
|
91
|
+
tokens: {
|
|
92
|
+
light: {
|
|
93
|
+
tabs: { gapNormal: '9px', scrollGap: '7px' },
|
|
94
|
+
overlay: { blur: '7px', background: 'rgba(1, 2, 3, 0.5)' },
|
|
95
|
+
modal: { background: 'red', widthMd: '480px' },
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
expect(root().style.getPropertyValue('--tabs-gap-normal')).toBe('9px');
|
|
101
|
+
expect(root().style.getPropertyValue('--tabs-scroll-gap')).toBe('7px');
|
|
102
|
+
expect(root().style.getPropertyValue('--overlay-blur')).toBe('7px');
|
|
103
|
+
expect(root().style.getPropertyValue('--overlay-background')).toBe('rgba(1, 2, 3, 0.5)');
|
|
104
|
+
expect(root().style.getPropertyValue('--modal-background')).toBe('red');
|
|
105
|
+
expect(root().style.getPropertyValue('--modal-width-md')).toBe('480px');
|
|
106
|
+
expect(root().getAttribute('data-theme')).toBeNull();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('injects dark mode tokens under the dark mode', () => {
|
|
110
|
+
service.setGlobalTheme({
|
|
111
|
+
mode: 'dark',
|
|
112
|
+
tokens: {
|
|
113
|
+
dark: { modal: { background: 'navy' } },
|
|
114
|
+
light: { modal: { background: 'red' } },
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
expect(root().getAttribute('data-theme')).toBe('dark');
|
|
119
|
+
expect(root().style.getPropertyValue('--modal-background')).toBe('navy');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('ignores unknown token keys', () => {
|
|
123
|
+
service.setGlobalTheme({
|
|
124
|
+
mode: 'light',
|
|
125
|
+
tokens: { light: { modal: { notARealToken: 'x' } as any } },
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
expect(root().style.getPropertyValue('--modal-not-a-real-token')).toBe('');
|
|
129
|
+
});
|
|
130
|
+
});
|
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
DasarThemeCommon,
|
|
12
12
|
DasarThemeMenu,
|
|
13
13
|
DasarThemeMode,
|
|
14
|
+
DasarThemeTabs,
|
|
15
|
+
DasarThemeOverlay,
|
|
16
|
+
DasarThemeModal,
|
|
14
17
|
} from '@models/theme.model';
|
|
15
18
|
import {
|
|
16
19
|
DASAR_THEME_PROVIDER,
|
|
@@ -570,6 +573,64 @@ export const listMap: Record<string, string> = {
|
|
|
570
573
|
prefixColor: '--list-prefix-color',
|
|
571
574
|
suffixColor: '--list-suffix-color',
|
|
572
575
|
};
|
|
576
|
+
export const tabsMap: Record<keyof DasarThemeTabs, string> = {
|
|
577
|
+
listPaddingNormal: '--tabs-list-padding-normal',
|
|
578
|
+
listPaddingCompact: '--tabs-list-padding-compact',
|
|
579
|
+
gapNormal: '--tabs-gap-normal',
|
|
580
|
+
gapCompact: '--tabs-gap-compact',
|
|
581
|
+
contentGapNormal: '--tabs-content-gap-normal',
|
|
582
|
+
contentGapCompact: '--tabs-content-gap-compact',
|
|
583
|
+
listRadiusNone: '--tabs-list-radius-none',
|
|
584
|
+
listRadiusXs: '--tabs-list-radius-xs',
|
|
585
|
+
listRadiusSm: '--tabs-list-radius-sm',
|
|
586
|
+
listRadiusMd: '--tabs-list-radius-md',
|
|
587
|
+
listRadiusLg: '--tabs-list-radius-lg',
|
|
588
|
+
listRadiusXl: '--tabs-list-radius-xl',
|
|
589
|
+
listRadiusFull: '--tabs-list-radius-full',
|
|
590
|
+
scrollGap: '--tabs-scroll-gap',
|
|
591
|
+
scrollFade: '--tabs-scroll-fade',
|
|
592
|
+
scrollBtnPaddingX: '--tabs-scroll-btn-padding-x',
|
|
593
|
+
};
|
|
594
|
+
export const overlayMap: Record<keyof DasarThemeOverlay, string> = {
|
|
595
|
+
background: '--overlay-background',
|
|
596
|
+
blur: '--overlay-blur',
|
|
597
|
+
};
|
|
598
|
+
export const modalMap: Record<keyof DasarThemeModal, string> = {
|
|
599
|
+
background: '--modal-background',
|
|
600
|
+
bodyColor: '--modal-body-color',
|
|
601
|
+
titleColor: '--modal-title-color',
|
|
602
|
+
titleFontWeight: '--modal-title-font-weight',
|
|
603
|
+
headerBorder: '--modal-header-border',
|
|
604
|
+
actionsBackground: '--modal-actions-background',
|
|
605
|
+
actionsBorder: '--modal-actions-border',
|
|
606
|
+
actionsGap: '--modal-actions-gap',
|
|
607
|
+
outlineBorder: '--modal-outline-border',
|
|
608
|
+
elevatedBorder: '--modal-elevated-border',
|
|
609
|
+
elevatedShadow: '--modal-elevated-shadow',
|
|
610
|
+
widthSm: '--modal-width-sm',
|
|
611
|
+
widthMd: '--modal-width-md',
|
|
612
|
+
widthLg: '--modal-width-lg',
|
|
613
|
+
fontSizeXs: '--modal-font-size-xs',
|
|
614
|
+
fontSizeSm: '--modal-font-size-sm',
|
|
615
|
+
fontSizeMd: '--modal-font-size-md',
|
|
616
|
+
fontSizeLg: '--modal-font-size-lg',
|
|
617
|
+
fontSizeXl: '--modal-font-size-xl',
|
|
618
|
+
radiusNone: '--modal-radius-none',
|
|
619
|
+
radiusXs: '--modal-radius-xs',
|
|
620
|
+
radiusSm: '--modal-radius-sm',
|
|
621
|
+
radiusMd: '--modal-radius-md',
|
|
622
|
+
radiusLg: '--modal-radius-lg',
|
|
623
|
+
radiusXl: '--modal-radius-xl',
|
|
624
|
+
radiusFull: '--modal-radius-full',
|
|
625
|
+
compactHeaderPadding: '--modal-compact-header-padding',
|
|
626
|
+
compactBodyPadding: '--modal-compact-body-padding',
|
|
627
|
+
compactActionsPadding: '--modal-compact-actions-padding',
|
|
628
|
+
normalHeaderPaddingHorizontal: '--modal-normal-header-padding-horizontal',
|
|
629
|
+
normalHeaderPaddingVertical: '--modal-normal-header-padding-vertical',
|
|
630
|
+
normalBodyPaddingHorizontal: '--modal-normal-body-padding-horizontal',
|
|
631
|
+
normalBodyPaddingVertical: '--modal-normal-body-padding-vertical',
|
|
632
|
+
normalActionsPadding: '--modal-normal-actions-padding',
|
|
633
|
+
};
|
|
573
634
|
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
574
635
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
575
636
|
}
|
|
@@ -667,6 +728,15 @@ export class DasarThemeService {
|
|
|
667
728
|
if (config.tokens?.[config.mode]?.list) {
|
|
668
729
|
this.injectMappedTokens(root, config.tokens?.[config.mode]?.list, listMap);
|
|
669
730
|
}
|
|
731
|
+
if (config.tokens?.[config.mode]?.tabs) {
|
|
732
|
+
this.injectMappedTokens(root, config.tokens?.[config.mode]?.tabs, tabsMap);
|
|
733
|
+
}
|
|
734
|
+
if (config.tokens?.[config.mode]?.overlay) {
|
|
735
|
+
this.injectMappedTokens(root, config.tokens?.[config.mode]?.overlay, overlayMap);
|
|
736
|
+
}
|
|
737
|
+
if (config.tokens?.[config.mode]?.modal) {
|
|
738
|
+
this.injectMappedTokens(root, config.tokens?.[config.mode]?.modal, modalMap);
|
|
739
|
+
}
|
|
670
740
|
this.themeState.next(config);
|
|
671
741
|
}
|
|
672
742
|
|
|
@@ -11,6 +11,7 @@ export * from './lib/components/dasar-calendar/dasar-calendar';
|
|
|
11
11
|
export * from './lib/components/dasar-select/dasar-select';
|
|
12
12
|
export * from './lib/components/dasar-icon/dasar-icon';
|
|
13
13
|
export * from './lib/components/dasar-card/dasar-card';
|
|
14
|
+
export * from './lib/components/dasar-list/dasar-list';
|
|
14
15
|
export * from './lib/components/dasar-chip/dasar-chip';
|
|
15
16
|
export * from './lib/components/dasar-input/dasar-input';
|
|
16
17
|
export * from './lib/components/dasar-modal/dasar-modal';
|
|
@@ -23,18 +23,45 @@
|
|
|
23
23
|
width: '100%',
|
|
24
24
|
}"
|
|
25
25
|
>
|
|
26
|
-
<
|
|
27
|
-
|
|
26
|
+
<div style="display: flex; align-items: center; gap: var(--space-base)">
|
|
27
|
+
<span style="font-weight: 800; font-family: var(--font-hero)">Dasar UI Library</span>
|
|
28
|
+
<dasar-chip variant="secondary" size="xs">v{{ version }}</dasar-chip>
|
|
29
|
+
@if (latestVersion() !== null) {
|
|
30
|
+
<dasar-chip variant="primary" size="xs">latest v{{ latestVersion() }}</dasar-chip>
|
|
31
|
+
}
|
|
32
|
+
</div>
|
|
33
|
+
<div class="docs-navbar-actions">
|
|
34
|
+
<dasar-button appearance="outline" variant="secondary" (click)="customizeOpen.set(true)"
|
|
35
|
+
>Customize</dasar-button
|
|
36
|
+
>
|
|
28
37
|
<dasar-button
|
|
29
38
|
size="md"
|
|
30
39
|
radius="md"
|
|
31
40
|
appearance="outline"
|
|
32
41
|
variant="secondary"
|
|
33
|
-
(click)="
|
|
34
|
-
|
|
42
|
+
(click)="openExternal('https://github.com/pis2co/dasar-ui/blob/main/CHANGELOG.md')"
|
|
43
|
+
aria-label="Open changelog on GitHub"
|
|
44
|
+
>Changelog</dasar-button
|
|
35
45
|
>
|
|
36
|
-
<dasar-button
|
|
37
|
-
|
|
46
|
+
<dasar-button
|
|
47
|
+
appearance="outline"
|
|
48
|
+
variant="secondary"
|
|
49
|
+
icon-only
|
|
50
|
+
(click)="openExternal('https://github.com/pis2co/dasar-ui')"
|
|
51
|
+
aria-label="Open dasar-ui on GitHub"
|
|
52
|
+
><dasar-icon name="brand-github"
|
|
53
|
+
/></dasar-button>
|
|
54
|
+
<dasar-button
|
|
55
|
+
appearance="outline"
|
|
56
|
+
variant="danger"
|
|
57
|
+
icon-only
|
|
58
|
+
(click)="openExternal('https://www.npmjs.com/package/dasar-ui')"
|
|
59
|
+
aria-label="Open dasar-ui on npm"
|
|
60
|
+
><dasar-icon name="brand-npm"
|
|
61
|
+
/></dasar-button>
|
|
62
|
+
|
|
63
|
+
<dasar-button icon-only appearance="solid" (click)="customize.toggleMode()">
|
|
64
|
+
<dasar-icon name="{{ customize.mode() == 'light' ? 'moon' : 'sun' }}" />
|
|
38
65
|
</dasar-button>
|
|
39
66
|
</div>
|
|
40
67
|
</dasar-card>
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
DasarThemeProviderComponent,
|
|
3
|
+
DasarButtonComponent,
|
|
4
|
+
DasarCardComponent,
|
|
5
|
+
DasarChipComponent,
|
|
6
|
+
DasarIconComponent,
|
|
7
|
+
} from 'dasar-ui';
|
|
8
|
+
import { Component, inject, signal, PLATFORM_ID } from '@angular/core';
|
|
9
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
3
10
|
import { RouterOutlet } from '@angular/router';
|
|
4
11
|
import { CommonModule } from '@angular/common';
|
|
5
12
|
import { DocCustomizeService } from './services/doc-customize.service';
|
|
6
13
|
import { DocCustomizeModalComponent } from './components/doc-customize-modal.component';
|
|
7
14
|
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
import packageJson from '../../../../projects/dasar-ui/package.json' with { loader: 'text' };
|
|
17
|
+
|
|
8
18
|
@Component({
|
|
9
19
|
imports: [
|
|
10
20
|
CommonModule,
|
|
@@ -12,6 +22,8 @@ import { DocCustomizeModalComponent } from './components/doc-customize-modal.com
|
|
|
12
22
|
DasarThemeProviderComponent,
|
|
13
23
|
DasarButtonComponent,
|
|
14
24
|
DasarCardComponent,
|
|
25
|
+
DasarChipComponent,
|
|
26
|
+
DasarIconComponent,
|
|
15
27
|
DocCustomizeModalComponent,
|
|
16
28
|
],
|
|
17
29
|
templateUrl: './app.html',
|
|
@@ -20,4 +32,26 @@ import { DocCustomizeModalComponent } from './components/doc-customize-modal.com
|
|
|
20
32
|
export class App {
|
|
21
33
|
protected readonly customize = inject(DocCustomizeService);
|
|
22
34
|
protected readonly customizeOpen = signal(false);
|
|
35
|
+
protected readonly version: string = (typeof packageJson === 'string'
|
|
36
|
+
? (JSON.parse(packageJson) as { version: string })
|
|
37
|
+
: (packageJson as unknown as { version: string })
|
|
38
|
+
).version;
|
|
39
|
+
protected readonly latestVersion = signal<string | null>(null);
|
|
40
|
+
|
|
41
|
+
constructor() {
|
|
42
|
+
if (isPlatformBrowser(inject(PLATFORM_ID))) {
|
|
43
|
+
fetch('https://registry.npmjs.org/dasar-ui/latest')
|
|
44
|
+
.then((res) => (res.ok ? res.json() : null))
|
|
45
|
+
.then((data: { version?: string } | null) => {
|
|
46
|
+
if (data?.version && data.version !== this.version) {
|
|
47
|
+
this.latestVersion.set(data.version);
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
.catch(() => undefined);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected openExternal(url: string) {
|
|
55
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
56
|
+
}
|
|
23
57
|
}
|
|
@@ -113,6 +113,37 @@ const DEFAULT_SENTINEL = '__default__';
|
|
|
113
113
|
></dasar-select>
|
|
114
114
|
</section>
|
|
115
115
|
|
|
116
|
+
<section class="cm-section">
|
|
117
|
+
<h3>List</h3>
|
|
118
|
+
|
|
119
|
+
<dasar-select
|
|
120
|
+
full-width
|
|
121
|
+
label="List size"
|
|
122
|
+
[dropdown-panel-style]="panelStyle"
|
|
123
|
+
[options]="listSizeOptions"
|
|
124
|
+
[ngModel]="draft().listSize ?? sentinel"
|
|
125
|
+
(ngModelChange)="setOption('listSize', $event)"
|
|
126
|
+
></dasar-select>
|
|
127
|
+
|
|
128
|
+
<dasar-select
|
|
129
|
+
full-width
|
|
130
|
+
label="List bordered"
|
|
131
|
+
[dropdown-panel-style]="panelStyle"
|
|
132
|
+
[options]="booleanOptions"
|
|
133
|
+
[ngModel]="booleanSentinel(draft().listBordered)"
|
|
134
|
+
(ngModelChange)="setBooleanOption('listBordered', $event)"
|
|
135
|
+
></dasar-select>
|
|
136
|
+
|
|
137
|
+
<dasar-select
|
|
138
|
+
full-width
|
|
139
|
+
label="List show divider"
|
|
140
|
+
[dropdown-panel-style]="panelStyle"
|
|
141
|
+
[options]="booleanOptions"
|
|
142
|
+
[ngModel]="booleanSentinel(draft().listDivider)"
|
|
143
|
+
(ngModelChange)="setBooleanOption('listDivider', $event)"
|
|
144
|
+
></dasar-select>
|
|
145
|
+
</section>
|
|
146
|
+
|
|
116
147
|
<section class="cm-section">
|
|
117
148
|
<h3>Theme</h3>
|
|
118
149
|
|
|
@@ -147,8 +178,11 @@ const DEFAULT_SENTINEL = '__default__';
|
|
|
147
178
|
></dasar-select>
|
|
148
179
|
</section>
|
|
149
180
|
|
|
150
|
-
<div
|
|
151
|
-
|
|
181
|
+
<div
|
|
182
|
+
action-slot
|
|
183
|
+
style="width: 100%; display: flex; gap: var(--space-base); justify-content: space-between; align-items: center;"
|
|
184
|
+
>
|
|
185
|
+
<dasar-button appearance="outline" variant="danger" (click)="resetDraft()">
|
|
152
186
|
Reset to defaults
|
|
153
187
|
</dasar-button>
|
|
154
188
|
<span class="cm-spacer"></span>
|
|
@@ -270,6 +304,17 @@ export class DocCustomizeModalComponent implements OnChanges {
|
|
|
270
304
|
{ label: 'Normal', value: 'normal' },
|
|
271
305
|
{ label: 'Compact', value: 'compact' },
|
|
272
306
|
];
|
|
307
|
+
readonly listSizeOptions: DasarModalOption[] = [
|
|
308
|
+
{ label: 'Default', value: DEFAULT_SENTINEL },
|
|
309
|
+
{ label: 'Sm', value: 'sm' },
|
|
310
|
+
{ label: 'Md', value: 'md' },
|
|
311
|
+
{ label: 'Lg', value: 'lg' },
|
|
312
|
+
];
|
|
313
|
+
readonly booleanOptions: DasarModalOption[] = [
|
|
314
|
+
{ label: 'Default', value: DEFAULT_SENTINEL },
|
|
315
|
+
{ label: 'On', value: 'true' },
|
|
316
|
+
{ label: 'Off', value: 'false' },
|
|
317
|
+
];
|
|
273
318
|
readonly fontSizeOptions: DasarModalOption[] = [
|
|
274
319
|
{ label: 'Default', value: DEFAULT_SENTINEL },
|
|
275
320
|
{ label: '12px', value: '12px' },
|
|
@@ -299,6 +344,15 @@ export class DocCustomizeModalComponent implements OnChanges {
|
|
|
299
344
|
this.set(key, (value === DEFAULT_SENTINEL ? null : value) as DocCustomizeSettings[K]);
|
|
300
345
|
}
|
|
301
346
|
|
|
347
|
+
setBooleanOption<K extends keyof DocCustomizeSettings>(key: K, value: unknown) {
|
|
348
|
+
const parsed = value === DEFAULT_SENTINEL ? null : String(value) === 'true';
|
|
349
|
+
this.set(key, parsed as DocCustomizeSettings[K]);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
booleanSentinel(value: boolean | null): string {
|
|
353
|
+
return value === null ? DEFAULT_SENTINEL : String(value);
|
|
354
|
+
}
|
|
355
|
+
|
|
302
356
|
resetDraft() {
|
|
303
357
|
this.draft.set({ ...DOC_DEFAULT_SETTINGS });
|
|
304
358
|
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import {
|
|
2
|
+
afterNextRender,
|
|
3
|
+
Component,
|
|
4
|
+
computed,
|
|
5
|
+
ElementRef,
|
|
6
|
+
inject,
|
|
7
|
+
Input,
|
|
8
|
+
PLATFORM_ID,
|
|
9
|
+
signal,
|
|
10
|
+
} from '@angular/core';
|
|
11
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
12
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
13
|
+
import { marked } from 'marked';
|
|
14
|
+
import * as Prism from 'prismjs';
|
|
15
|
+
|
|
16
|
+
import 'prismjs/components/prism-typescript';
|
|
17
|
+
import 'prismjs/components/prism-markup';
|
|
18
|
+
import 'prismjs/components/prism-bash';
|
|
19
|
+
import 'prismjs/components/prism-scss';
|
|
20
|
+
import 'prismjs/components/prism-css';
|
|
21
|
+
|
|
22
|
+
const INTERNAL_DOC_LINKS: Array<[string, string]> = [
|
|
23
|
+
['./installation.md', '/installation'],
|
|
24
|
+
['../README.md', '/introduction'],
|
|
25
|
+
['./README.md', '/introduction'],
|
|
26
|
+
['README.md', '/introduction'],
|
|
27
|
+
['./getting-started.md', '/getting-started'],
|
|
28
|
+
['../docs/getting-started.md', '/getting-started'],
|
|
29
|
+
['../docs/installation.md', '/installation'],
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
@Component({
|
|
33
|
+
selector: 'doc-markdown',
|
|
34
|
+
standalone: true,
|
|
35
|
+
template: `<div class="doc-markdown" [innerHTML]="html()"></div>`,
|
|
36
|
+
styles: [
|
|
37
|
+
`
|
|
38
|
+
.doc-markdown {
|
|
39
|
+
display: block;
|
|
40
|
+
max-width: 860px;
|
|
41
|
+
color: var(--theme-text-primary-color);
|
|
42
|
+
line-height: var(--line-height-normal);
|
|
43
|
+
}
|
|
44
|
+
.doc-markdown h1 {
|
|
45
|
+
font-size: var(--font-size-xl);
|
|
46
|
+
margin: 0 0 var(--space-4);
|
|
47
|
+
}
|
|
48
|
+
.doc-markdown h2 {
|
|
49
|
+
font-size: var(--font-size-lg);
|
|
50
|
+
margin: var(--space-8) 0 var(--space-3);
|
|
51
|
+
}
|
|
52
|
+
.doc-markdown h3 {
|
|
53
|
+
font-size: var(--font-size-base);
|
|
54
|
+
margin: var(--space-6) 0 var(--space-base);
|
|
55
|
+
}
|
|
56
|
+
.doc-markdown p {
|
|
57
|
+
margin: 0 0 var(--space-4);
|
|
58
|
+
}
|
|
59
|
+
.doc-markdown ul,
|
|
60
|
+
.doc-markdown ol {
|
|
61
|
+
margin: 0 0 var(--space-4);
|
|
62
|
+
padding-left: var(--space-6);
|
|
63
|
+
}
|
|
64
|
+
.doc-markdown li {
|
|
65
|
+
margin-bottom: var(--space-base);
|
|
66
|
+
}
|
|
67
|
+
.doc-markdown a {
|
|
68
|
+
color: var(--theme-primary-color);
|
|
69
|
+
}
|
|
70
|
+
.doc-markdown table {
|
|
71
|
+
width: 100%;
|
|
72
|
+
border-collapse: collapse;
|
|
73
|
+
margin: 0 0 var(--space-6);
|
|
74
|
+
font-size: var(--font-size-sm);
|
|
75
|
+
}
|
|
76
|
+
.doc-markdown th,
|
|
77
|
+
.doc-markdown td {
|
|
78
|
+
text-align: left;
|
|
79
|
+
padding: var(--space-base) var(--space-3);
|
|
80
|
+
border-bottom: 1px solid var(--theme-border-subtle-color);
|
|
81
|
+
}
|
|
82
|
+
.doc-markdown th {
|
|
83
|
+
font-weight: var(--font-weight-semibold);
|
|
84
|
+
}
|
|
85
|
+
.doc-markdown code:not(pre code) {
|
|
86
|
+
font-size: var(--font-size-sm);
|
|
87
|
+
padding: 0 var(--space-1);
|
|
88
|
+
border-radius: var(--radius-xs);
|
|
89
|
+
background: var(--theme-bg-hover-color);
|
|
90
|
+
}
|
|
91
|
+
.doc-markdown pre {
|
|
92
|
+
margin: 0 0 var(--space-6);
|
|
93
|
+
padding: var(--space-4);
|
|
94
|
+
border-radius: var(--radius-md);
|
|
95
|
+
overflow: auto;
|
|
96
|
+
}
|
|
97
|
+
.doc-markdown pre code {
|
|
98
|
+
background: transparent;
|
|
99
|
+
padding: 0;
|
|
100
|
+
}
|
|
101
|
+
.doc-markdown blockquote {
|
|
102
|
+
margin: 0 0 var(--space-4);
|
|
103
|
+
padding-left: var(--space-4);
|
|
104
|
+
border-left: 3px solid var(--theme-border-strong-color);
|
|
105
|
+
color: var(--theme-text-secondary-color);
|
|
106
|
+
}
|
|
107
|
+
.doc-markdown img {
|
|
108
|
+
max-width: 100%;
|
|
109
|
+
border-radius: var(--radius-full);
|
|
110
|
+
vertical-align: middle;
|
|
111
|
+
}
|
|
112
|
+
.doc-markdown td img {
|
|
113
|
+
width: 64px;
|
|
114
|
+
height: 64px;
|
|
115
|
+
}
|
|
116
|
+
`,
|
|
117
|
+
],
|
|
118
|
+
})
|
|
119
|
+
export class DocMarkdownComponent {
|
|
120
|
+
@Input({ required: true }) source = '';
|
|
121
|
+
|
|
122
|
+
private platformId = inject(PLATFORM_ID);
|
|
123
|
+
private sanitizer = inject(DomSanitizer);
|
|
124
|
+
private host = inject(ElementRef);
|
|
125
|
+
private rendered = signal(false);
|
|
126
|
+
|
|
127
|
+
protected html = computed(() => {
|
|
128
|
+
const raw = marked.parse(this.source, { async: false }) as unknown as string;
|
|
129
|
+
return this.sanitizer.bypassSecurityTrustHtml(this.rewriteLinks(String(raw)));
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
constructor() {
|
|
133
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
134
|
+
afterNextRender(() => {
|
|
135
|
+
if (!this.rendered()) {
|
|
136
|
+
this.rendered.set(true);
|
|
137
|
+
}
|
|
138
|
+
Prism.highlightAllUnder(this.host.nativeElement);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private rewriteLinks(html: string): string {
|
|
144
|
+
let out = html;
|
|
145
|
+
for (const [from, to] of INTERNAL_DOC_LINKS) {
|
|
146
|
+
out = out.split(`href="${from}"`).join(`href="${to}"`);
|
|
147
|
+
}
|
|
148
|
+
out = out.replace(
|
|
149
|
+
/<a href="(https?:\/\/[^"]+)"/g,
|
|
150
|
+
'<a target="_blank" rel="noopener noreferrer" href="$1"',
|
|
151
|
+
);
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -19,6 +19,7 @@ export interface DocExample {
|
|
|
19
19
|
export interface DocNavItem {
|
|
20
20
|
label: string;
|
|
21
21
|
route: string;
|
|
22
|
+
exact?: boolean;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export interface DocNavGroup {
|
|
@@ -41,7 +42,12 @@ export interface DocNavGroup {
|
|
|
41
42
|
</div>
|
|
42
43
|
<div class="nav-items">
|
|
43
44
|
@for (item of group.items; track item.label) {
|
|
44
|
-
<a
|
|
45
|
+
<a
|
|
46
|
+
[routerLink]="item.route"
|
|
47
|
+
routerLinkActive="active"
|
|
48
|
+
[routerLinkActiveOptions]="{ exact: item.exact ?? false }"
|
|
49
|
+
class="nav-link"
|
|
50
|
+
>
|
|
45
51
|
{{ item.label }}
|
|
46
52
|
</a>
|
|
47
53
|
}
|
|
@@ -122,7 +128,7 @@ export interface DocNavGroup {
|
|
|
122
128
|
margin: 0 auto;
|
|
123
129
|
}
|
|
124
130
|
.docs-header {
|
|
125
|
-
margin-bottom: var(--space-
|
|
131
|
+
margin-bottom: var(--space-base);
|
|
126
132
|
border-bottom: 1px solid var(--theme-border-subtle-color);
|
|
127
133
|
padding-bottom: var(--space-6);
|
|
128
134
|
}
|
|
@@ -191,7 +197,20 @@ export class DocsLayoutComponent {
|
|
|
191
197
|
navigation: DocNavGroup[] = [
|
|
192
198
|
{
|
|
193
199
|
title: 'Getting Started',
|
|
194
|
-
items: [
|
|
200
|
+
items: [
|
|
201
|
+
{ label: 'Introduction', route: '/introduction' },
|
|
202
|
+
{ label: 'Installation', route: '/installation' },
|
|
203
|
+
{ label: 'Getting Started', route: '/getting-started' },
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
title: 'Theming',
|
|
208
|
+
items: [
|
|
209
|
+
{ label: 'Overview', route: '/theming', exact: true },
|
|
210
|
+
{ label: 'Theme Tokens', route: '/theming/tokens' },
|
|
211
|
+
{ label: 'CSS Variables', route: '/theming/css-variables' },
|
|
212
|
+
{ label: 'Component Config', route: '/theming/component-config' },
|
|
213
|
+
],
|
|
195
214
|
},
|
|
196
215
|
{
|
|
197
216
|
title: 'Basic',
|
|
@@ -205,6 +224,7 @@ export class DocsLayoutComponent {
|
|
|
205
224
|
{ label: 'Modal', route: '/components/modal' },
|
|
206
225
|
{ label: 'Menu', route: '/components/menu' },
|
|
207
226
|
{ label: 'Tabs', route: '/components/tabs' },
|
|
227
|
+
{ label: 'List', route: '/components/list' },
|
|
208
228
|
],
|
|
209
229
|
},
|
|
210
230
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<docs-layout
|
|
2
2
|
title="Button"
|
|
3
|
-
description="
|
|
3
|
+
description="A clickable action button with color variants, solid, subtle and outline appearances, five sizes, configurable radius, icon support, and disabled, full-width and fluid layouts."
|
|
4
4
|
[apiData]="apiProps"
|
|
5
5
|
>
|
|
6
6
|
<doc-example-component
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<docs-layout
|
|
2
2
|
title="Chip"
|
|
3
|
-
description="
|
|
3
|
+
description="A compact label for tags, statuses and filters, with color variants, appearances, sizes and radius, plus removable, clickable and disabled states."
|
|
4
4
|
[apiData]="apiProps"
|
|
5
5
|
>
|
|
6
6
|
<doc-example-component
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { DocsLayoutComponent } from '../../layouts/doc.layout';
|
|
3
|
+
import { DocMarkdownComponent } from '../../components/doc-markdown.component';
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import source from '../../../../../../docs/getting-started.md' with { loader: 'text' };
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
imports: [DocsLayoutComponent, DocMarkdownComponent],
|
|
10
|
+
template: `<docs-layout
|
|
11
|
+
title="Getting Started"
|
|
12
|
+
description="Render a component, add the theme provider, and toggle light and dark mode."
|
|
13
|
+
>
|
|
14
|
+
<doc-markdown [source]="source" />
|
|
15
|
+
</docs-layout>`,
|
|
16
|
+
selector: 'app-getting-started-page',
|
|
17
|
+
standalone: true,
|
|
18
|
+
})
|
|
19
|
+
export class GettingStartedDocPage {
|
|
20
|
+
protected source = source;
|
|
21
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<docs-layout
|
|
2
2
|
title="Icon"
|
|
3
|
-
description="
|
|
3
|
+
description="An SVG icon rendered by name from the built-in registry, with adjustable size, color and stroke width."
|
|
4
4
|
[apiData]="apiProps"
|
|
5
5
|
>
|
|
6
6
|
<doc-example-component
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { DocsLayoutComponent } from '../../layouts/doc.layout';
|
|
3
|
+
import { DocMarkdownComponent } from '../../components/doc-markdown.component';
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import source from '../../../../../../docs/installation.md' with { loader: 'text' };
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
imports: [DocsLayoutComponent, DocMarkdownComponent],
|
|
10
|
+
template: `<docs-layout title="Installation" description="Add dasar-ui to an Angular project.">
|
|
11
|
+
<doc-markdown [source]="source" />
|
|
12
|
+
</docs-layout>`,
|
|
13
|
+
selector: 'app-installation-page',
|
|
14
|
+
standalone: true,
|
|
15
|
+
})
|
|
16
|
+
export class InstallationDocPage {
|
|
17
|
+
protected source = source;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { DocsLayoutComponent } from '../../layouts/doc.layout';
|
|
3
|
+
import { DocMarkdownComponent } from '../../components/doc-markdown.component';
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import source from '../../../../../../README.md' with { loader: 'text' };
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
imports: [DocsLayoutComponent, DocMarkdownComponent],
|
|
10
|
+
template: `<docs-layout title="Introduction" description="What dasar-ui is and where to go next.">
|
|
11
|
+
<doc-markdown [source]="source" />
|
|
12
|
+
</docs-layout>`,
|
|
13
|
+
selector: 'app-introduction-page',
|
|
14
|
+
standalone: true,
|
|
15
|
+
})
|
|
16
|
+
export class IntroductionDocPage {
|
|
17
|
+
protected source = source;
|
|
18
|
+
}
|