Skip to content

Commit 678fde6

Browse files
authored
refactor(themes): add styling support for datetime inputs (#2223)
Related to IgniteUI/igniteui-angular#17270
1 parent f2d7d3c commit 678fde6

5 files changed

Lines changed: 82 additions & 27 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@use 'styles/utilities' as *;
2+
@use '../light/themes' as *;
3+
4+
:host {
5+
@include css-vars-from-theme($base);
6+
7+
color-scheme: dark;
8+
}

src/components/input/themes/light/input.shared.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33

44
:host {
55
@include css-vars-from-theme($base);
6+
7+
color-scheme: light;
68
}

src/components/input/themes/shared/input.common.scss

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ $theme: $base;
3333
}
3434
}
3535

36+
input::-webkit-datetime-edit {
37+
color: inherit;
38+
}
39+
3640
[part~='input']::placeholder {
3741
color: var-get($theme, 'placeholder-color');
3842
}
@@ -45,21 +49,21 @@ $theme: $base;
4549
}
4650

4751
:host(:focus-within),
48-
:host(:not([readonly],[disabled]):hover) {
52+
:host(:not([readonly], [disabled]):hover) {
4953
[part~='input']::placeholder {
5054
color: var-get($theme, 'hover-placeholder-color');
5155
}
5256
}
5357

54-
:host(:not([readonly],[disabled]):hover) {
58+
:host(:not([readonly], [disabled]):hover) {
5559
[part~='filled'] {
5660
[part~='input'] {
5761
color: var-get($theme, 'filled-text-hover-color');
5862
}
5963
}
6064
}
6165

62-
:host(:not([readonly],[disabled]):focus-within) {
66+
:host(:not([readonly], [disabled]):focus-within) {
6367
[part~='filled'] {
6468
[part~='input'] {
6569
color: var-get($theme, 'focused-text-color');
@@ -99,8 +103,8 @@ $theme: $base;
99103
}
100104
}
101105

102-
:host(:not([disabled],[readonly]):state(ig-invalid)),
103-
:host(:not(:disabled,[readonly]):state(ig-invalid)) {
106+
:host(:not([disabled], [readonly]):state(ig-invalid)),
107+
:host(:not(:disabled, [readonly]):state(ig-invalid)) {
104108
::part(helper-text) {
105109
color: var-get($theme, 'error-secondary-color');
106110
}

src/components/input/themes/shared/input.material.scss

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ $fs: rem(16px) !default;
4444
}
4545
}
4646

47-
input:placeholder-shown + [part='notch'] [part='label'],
47+
:is(
48+
input:placeholder-shown,
49+
input[type='date'],
50+
input[type='time'],
51+
input[type='datetime-local'],
52+
input[type='week'],
53+
input[type='month']
54+
) + [part='notch'] [part='label'],
4855
[part~='filled'] + [part='notch'] [part='label'] {
4956
@include type-style('caption');
5057
@extend %label;
@@ -159,7 +166,14 @@ input:placeholder-shown + [part='notch'] [part='label'],
159166

160167
:host([readonly]:not([outlined]):focus-within) {
161168
:not([part~='filled']) {
162-
input:has(:not(:placeholder-shown)) + [part='notch'] [part='label'] {
169+
:is(
170+
input[type='date'],
171+
input[type='time'],
172+
input[type='datetime-local'],
173+
input[type='week'],
174+
input[type='month']
175+
) + [part='notch'] [part='label'],
176+
input:not(:placeholder-shown)+ [part='notch'] [part='label'] {
163177
translate: 0;
164178
font-size: initial;
165179
}
@@ -210,7 +224,14 @@ input:placeholder-shown + [part='notch'] [part='label'],
210224
padding-bottom: rem(6px);
211225
}
212226

213-
input:placeholder-shown + [part='notch'] [part='label'],
227+
:is(
228+
input:placeholder-shown,
229+
input[type='date'],
230+
input[type='time'],
231+
input[type='datetime-local'],
232+
input[type='week'],
233+
input[type='month']
234+
) + [part='notch'] [part='label'],
214235
[part~='filled'] + [part='notch'] [part='label'] {
215236
translate: 0 -73%;
216237
}
@@ -229,14 +250,12 @@ input:placeholder-shown + [part='notch'] [part='label'],
229250
}
230251
}
231252

232-
:host(
233-
:not(
234-
[outlined],
235-
[type='search'],
236-
[aria-haspopup='dialog'],
237-
[role='combobox']
238-
)[readonly]:hover
239-
) {
253+
:host(:not(
254+
[outlined],
255+
[type='search'],
256+
[aria-haspopup='dialog'],
257+
[role='combobox']
258+
)[readonly]:hover) {
240259
[part~='container'] {
241260
background: var-get($theme, 'box-background-focus');
242261
border-bottom-color: var-get($theme, 'idle-bottom-line-color');
@@ -450,6 +469,13 @@ input:placeholder-shown + [part='notch'] [part='label'],
450469
}
451470
}
452471

472+
:is(
473+
input[type='date'],
474+
input[type='time'],
475+
input[type='datetime-local'],
476+
input[type='week'],
477+
input[type='month']
478+
) + [part='notch'],
453479
[part~='filled'] + [part='notch'] {
454480
@extend %floated-styles;
455481

@@ -480,12 +506,10 @@ input:placeholder-shown + [part='notch'] [part='label'],
480506
}
481507
}
482508

483-
:host(
484-
:not(
485-
[aria-haspopup='dialog'],
486-
[role='combobox']
487-
)[outlined][readonly]:focus-within
488-
) {
509+
:host(:not(
510+
[aria-haspopup='dialog'],
511+
[role='combobox']
512+
)[outlined][readonly]:focus-within) {
489513
[part='notch'],
490514
[part='start'],
491515
[part='end'],
@@ -502,13 +526,13 @@ input:placeholder-shown + [part='notch'] [part='label'],
502526
:not(:state(ig-invalid), [type='search'])[readonly][outlined]:focus-within
503527
) {
504528
:not([part~='filled']) {
505-
input:has(:not(:placeholder-shown)) + [part='notch'] [part='label'] {
529+
input:not(:placeholder-shown) + [part='notch'] [part='label'] {
506530
translate: 0;
507531
font-size: initial;
508532
align-self: center;
509533
}
510534

511-
input:has(:not(:placeholder-shown)) + [part='notch'] {
535+
input:not(:placeholder-shown) + [part='notch'] {
512536
border: {
513537
width: $active-border-width;
514538
color: var-get($theme, 'focused-border-color');
@@ -531,6 +555,22 @@ input:placeholder-shown + [part='notch'] [part='label'],
531555
}
532556
}
533557

558+
:host([outlined]:is(
559+
[type='date'],
560+
[type='time'],
561+
[type='datetime-local'],
562+
[type='week'],
563+
[type='month']
564+
)) {
565+
[part='label'] {
566+
transition: none;
567+
}
568+
569+
[part='notch'] {
570+
border-block-start-color: transparent !important;
571+
}
572+
}
573+
534574
:host(:not([type='search'])[outlined]:focus-within) {
535575
[part='start'] {
536576
border: {

src/components/input/themes/themes.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import { styles as bootstrapDark } from './dark/input.bootstrap.css.js';
66
import { styles as fluentDark } from './dark/input.fluent.css.js';
77
import { styles as indigoDark } from './dark/input.indigo.css.js';
88
import { styles as materialDark } from './dark/input.material.css.js';
9+
import { styles as sharedDark } from './dark/input.shared.css.js';
910
// Light Overrides
1011
import { styles as bootstrapLight } from './light/input.bootstrap.css.js';
1112
import { styles as fluentLight } from './light/input.fluent.css.js';
1213
import { styles as indigoLight } from './light/input.indigo.css.js';
1314
import { styles as materialLight } from './light/input.material.css.js';
14-
import { styles as shared } from './light/input.shared.css.js';
15+
import { styles as sharedLight } from './light/input.shared.css.js';
1516
// Shared Styles
1617
import { styles as bootstrap } from './shared/input.bootstrap.css.js';
1718
import { styles as fluent } from './shared/input.fluent.css.js';
@@ -20,7 +21,7 @@ import { styles as material } from './shared/input.material.css.js';
2021

2122
const light = {
2223
shared: css`
23-
${shared}
24+
${sharedLight}
2425
`,
2526
bootstrap: css`
2627
${bootstrap} ${bootstrapLight}
@@ -38,7 +39,7 @@ const light = {
3839

3940
const dark = {
4041
shared: css`
41-
${shared}
42+
${sharedDark}
4243
`,
4344
bootstrap: css`
4445
${bootstrap} ${bootstrapDark}

0 commit comments

Comments
 (0)