Repository navigation
Expand file tree
/
Copy path_pin-code-input.scss
More file actions
120 lines (102 loc) · 3.5 KB
/
Copy path_pin-code-input.scss
File metadata and controls
120 lines (102 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Segmented verification-code input styled like Carbon text input.
@import "carbon-components/scss/globals/scss/vars";
@import "carbon-components/scss/globals/scss/css--reset";
@import "carbon-components/scss/globals/scss/helper-mixins";
@import "carbon-components/scss/globals/scss/typography";
@import "carbon-components/scss/globals/scss/vendor/@carbon/elements/scss/import-once/import-once";
/// PinCodeInput: a fieldset of single-character segments
/// @access private
/// @group components
@mixin pin-code-input {
// The fieldset takes its segments' width but no more than its container's,
// so they shrink to fit a narrow one. (A fieldset's default minimum is its
// content width.)
.#{$prefix}--pin-code-input .#{$prefix}--pin-code-input__fieldset {
min-inline-size: 0;
max-inline-size: 100%;
border: 0;
margin: 0;
padding: 0;
}
.#{$prefix}--pin-code-input__fields {
position: relative;
}
.#{$prefix}--pin-code-input__segments {
display: flex;
align-items: center;
gap: $carbon--spacing-01;
}
// Segments keep their size where there's room and shrink, down to the
// minimum, in a narrower container rather than overflowing it. One
// character still fits at the minimum.
.#{$prefix}--pin-code-input__field.#{$prefix}--text-input {
@include type-style("body-compact-01");
width: to-rem(40px);
min-width: to-rem(24px);
height: to-rem(40px);
padding: 0;
text-align: center;
}
.#{$prefix}--pin-code-input__field--uppercase {
text-transform: uppercase;
}
// Mask each segment, revealing its character only while it is focused.
.#{$prefix}--pin-code-input__field--masked:not(:focus) {
-webkit-text-security: disc;
text-security: disc;
}
// Read-only: same treatment as text input read-only.
.#{$prefix}--pin-code-input--readonly .#{$prefix}--pin-code-input__field {
background-color: transparent;
border-bottom-color: $text-helper;
}
.#{$prefix}--pin-code-input__field.#{$prefix}--text-input--xs {
width: to-rem(24px);
min-width: to-rem(16px);
height: to-rem(24px);
}
.#{$prefix}--pin-code-input__field.#{$prefix}--text-input--sm {
width: to-rem(32px);
min-width: to-rem(20px);
height: to-rem(32px);
}
.#{$prefix}--pin-code-input__field.#{$prefix}--text-input--xl {
width: to-rem(48px);
min-width: to-rem(28px);
height: to-rem(48px);
}
.#{$prefix}--pin-code-input__icon {
flex-shrink: 0;
margin-inline-start: $carbon--spacing-03;
fill: $support-error;
}
.#{$prefix}--pin-code-input__icon--warning {
fill: $support-warning;
}
// Carbon does not theme the warning icon's inner triangle by default.
.#{$prefix}--pin-code-input__icon--warning path[fill] {
fill: $carbon--black-100;
opacity: 1;
}
// v10 only shows `.bx--form-requirement` for invalid direct siblings.
// Pin code wraps fields, so target the wrapper instead.
.#{$prefix}--pin-code-input__fields[data-invalid]
+ .#{$prefix}--form-requirement,
.#{$prefix}--pin-code-input__fields--invalid + .#{$prefix}--form-requirement {
display: block;
overflow: visible;
max-height: to-rem(200px);
font-weight: 400;
color: $text-error;
}
.#{$prefix}--pin-code-input__fields[data-warn] + .#{$prefix}--form-requirement,
.#{$prefix}--pin-code-input__fields--warning + .#{$prefix}--form-requirement {
display: block;
overflow: visible;
max-height: to-rem(200px);
font-weight: 400;
}
}
@include exports("pin-code-input") {
@include pin-code-input;
}