Skip to content

Commit e47791e

Browse files
committed
feat(demo): improve support for dark color scheme
1 parent f38c0a1 commit e47791e

File tree

4 files changed

+76
-14
lines changed

4 files changed

+76
-14
lines changed

apps/demo/src/app/app.component.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
display: flex;
33
flex-direction: column;
44
height: 100dvh;
5-
background-color: var(--gray-0);
5+
background-color: var(--surface-1);
66

77
h1 {
88
margin: 2rem;
@@ -49,7 +49,7 @@
4949
}
5050

5151
.card {
52-
background-color: white;
52+
background-color: var(--surface-2);
5353
border: var(--border-size-1) solid var(--surface-3);
5454
border-radius: var(--radius-conditional-3);
5555
}

apps/demo/src/app/components/button/button.component.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.c-button {
2-
--tint: black;
3-
--contrast: white;
2+
--tint: var(--surface-inverted-1);
3+
--contrast: var(--text-inverted-1);
44

55
align-items: center;
66
border-radius: var(--radius-2);
@@ -22,7 +22,7 @@
2222
}
2323

2424
&[type='submit'] {
25-
--tint: var(--indigo-7);
25+
--tint: var(--brand);
2626
}
2727

2828
&:hover {
@@ -63,7 +63,7 @@
6363
}
6464

6565
&.c-button--outline {
66-
border: var(--border-size-1) solid var(--surface-3);
66+
border: var(--border-size-1) solid var(--surface-4);
6767
}
6868

6969
&.c-button--loading {

apps/demo/src/app/components/button/button.component.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommonModule } from '@angular/common';
2-
import { ChangeDetectionStrategy, Component, computed, ElementRef, inject, Output, ViewEncapsulation } from '@angular/core';
2+
import { ChangeDetectionStrategy, Component, computed, Output, ViewEncapsulation } from '@angular/core';
33
import { bindAttribute, useAttribute, useBooleanAttribute } from '@bynary/angular-composables/attribute';
44
import { provideBaseClass, useModifier, useModifierGroup } from '@bynary/angular-composables/class';
55
import { useActivate } from '@bynary/angular-composables/observer';
@@ -18,16 +18,12 @@ import { useActivate } from '@bynary/angular-composables/observer';
1818
})
1919
export class ButtonComponent {
2020

21-
readonly element = inject(ElementRef).nativeElement as HTMLElement;
22-
23-
readonly role = useAttribute('role', { defaultValue: 'button' });
2421
readonly type = useAttribute('type', { defaultValue: 'button' });
2522
readonly disabled = useBooleanAttribute('disabled');
2623

2724
readonly loading = useModifier('loading', { applyInitially: false });
2825

2926
readonly appearance = useModifierGroup('solid');
30-
readonly color = useModifierGroup(undefined, { prefix: 'color' });
3127

3228
@Output()
3329
readonly active = useActivate({ click: true, keydown: [ 'Enter' ] });

apps/demo/src/styles.scss

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,70 @@
11
/* You can add global styles to this file, and also import other style files */
2-
@import "open-props/style";
3-
@import "open-props/normalize.min.css";
4-
@import "open-props/media.min.css";
2+
@import 'open-props/style';
3+
@import 'open-props/normalize.min.css';
4+
@import 'open-props/media.min.css';
5+
6+
html {
7+
--brand-light: var(--indigo-6);
8+
9+
--text-1-light: var(--gray-8);
10+
--text-2-light: var(--gray-7);
11+
12+
--surface-1-light: var(--gray-0);
13+
--surface-2-light: var(--gray-1);
14+
--surface-3-light: var(--gray-2);
15+
--surface-4-light: var(--gray-3);
16+
}
17+
18+
html {
19+
--brand-dark: var(--indigo-4);
20+
21+
--text-1-dark: var(--gray-1);
22+
--text-2-dark: var(--gray-3);
23+
24+
--surface-1-dark: var(--gray-12);
25+
--surface-2-dark: var(--gray-11);
26+
--surface-3-dark: var(--gray-10);
27+
--surface-4-dark: var(--gray-9);
28+
}
29+
30+
:root {
31+
--brand: var(--brand-light);
32+
33+
--text-1: var(--text-1-light);
34+
--text-2: var(--text-2-light);
35+
36+
--text-inverted-1: var(--text-1-dark);
37+
--text-inverted-2: var(--text-2-dark);
38+
39+
--surface-1: var(--surface-1-light);
40+
--surface-2: var(--surface-2-light);
41+
--surface-3: var(--surface-3-light);
42+
--surface-4: var(--surface-4-light);
43+
44+
--surface-inverted-1: var(--surface-1-dark);
45+
--surface-inverted-2: var(--surface-2-dark);
46+
--surface-inverted-3: var(--surface-3-dark);
47+
--surface-inverted-4: var(--surface-4-dark);
48+
}
49+
50+
@media (prefers-color-scheme: dark) {
51+
:root {
52+
--brand: var(--brand-dark);
53+
54+
--text-1: var(--text-1-dark);
55+
--text-2: var(--text-2-dark);
56+
57+
--text-inverted-1: var(--text-1-light);
58+
--text-inverted-2: var(--text-2-light);
59+
60+
--surface-1: var(--surface-1-dark);
61+
--surface-2: var(--surface-2-dark);
62+
--surface-3: var(--surface-3-dark);
63+
--surface-4: var(--surface-4-dark);
64+
65+
--surface-inverted-1: var(--surface-1-light);
66+
--surface-inverted-2: var(--surface-2-light);
67+
--surface-inverted-3: var(--surface-3-light);
68+
--surface-inverted-4: var(--surface-4-light);
69+
}
70+
}

0 commit comments

Comments
 (0)