@allxsmith/bestax-bulma 5.42.1 → 5.43.0

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.
@@ -0,0 +1,175 @@
1
+ // Bestax Extras - PinInput Styles
2
+ // A row of boxes for a short code, drawn under the one input that holds it.
3
+ // Each box is a Bulma `.input`, the way DateRangeInput's field is, so the
4
+ // boxes take Bulma's input colors, sizes, rounded corners, focus ring, dark
5
+ // mode and `--bulma-input-*` theme variables as they are, and this partial
6
+ // only lays them out. The input lies over the row with its text, caret and
7
+ // selection transparent, so a click or a tap lands on it and the boxes show
8
+ // what it holds.
9
+
10
+ @use 'bulma/sass/utilities/initial-variables' as iv;
11
+ @use 'bulma/sass/utilities/css-variables' as cv;
12
+
13
+ // In em, so it follows the size of the boxes.
14
+ $pin-input-gap: 0.5em !default;
15
+ // A Bulma control's height, in the box's own size, so a box is square.
16
+ $pin-input-box-width: cv.getVar('control-height') !default;
17
+ $pin-input-caret-width: max(1px, 0.0625em) !default;
18
+ $pin-input-caret-height: 1.25em !default;
19
+ // The box's text color, so the caret follows a color, dark mode and a theme.
20
+ $pin-input-caret-color: currentColor !default;
21
+ $pin-input-caret-blink-duration: 1s !default;
22
+
23
+ .#{iv.$class-prefix}pin-input {
24
+ @include cv.register-vars(
25
+ (
26
+ 'pin-input-gap': #{$pin-input-gap},
27
+ 'pin-input-box-width': #{$pin-input-box-width},
28
+ 'pin-input-caret-width': #{$pin-input-caret-width},
29
+ 'pin-input-caret-height': #{$pin-input-caret-height},
30
+ 'pin-input-caret-color': #{$pin-input-caret-color},
31
+ 'pin-input-caret-blink-duration': #{$pin-input-caret-blink-duration},
32
+ )
33
+ );
34
+ }
35
+
36
+ // The row is as wide as its boxes, so the input over it covers them and
37
+ // nothing more, and no wider than its container: in a narrow one the boxes
38
+ // give up some width rather than overflow.
39
+ .#{iv.$class-prefix}pin-input {
40
+ display: inline-flex;
41
+ max-width: 100%;
42
+ position: relative;
43
+ vertical-align: top;
44
+ }
45
+
46
+ // Three classes, because Bulma's `.input` sets the width and its
47
+ // `.input.is-rounded` the side padding, and these have to win whichever
48
+ // stylesheet loads first. The character sits in the middle either way.
49
+ .#{iv.$class-prefix}pin-input
50
+ > .#{iv.$class-prefix}input.#{iv.$class-prefix}pin-input-box {
51
+ flex: 0 1 auto;
52
+ font-variant-numeric: tabular-nums;
53
+ justify-content: center;
54
+ min-width: 0;
55
+ padding-left: 0;
56
+ padding-right: 0;
57
+ width: cv.getVar('pin-input-box-width');
58
+ }
59
+
60
+ .#{iv.$class-prefix}pin-input-box + .#{iv.$class-prefix}pin-input-box {
61
+ margin-inline-start: cv.getVar('pin-input-gap');
62
+ }
63
+
64
+ // A div takes no `disabled`, so a disabled box is marked by class and drawn
65
+ // the way Bulma draws a disabled input.
66
+ .#{iv.$class-prefix}pin-input-box.#{iv.$class-prefix}is-disabled {
67
+ background-color: cv.getVar('input-disabled-background-color');
68
+ border-color: cv.getVar('input-disabled-border-color');
69
+ box-shadow: none;
70
+ color: cv.getVar('input-disabled-color');
71
+ }
72
+
73
+ // The caret, in the empty box at the input's caret. The box lays out its
74
+ // content in a centered row, so the caret sits in the middle.
75
+ .#{iv.$class-prefix}pin-input-box.#{iv.$class-prefix}has-caret::after {
76
+ animation: #{iv.$class-prefix}pin-input-caret-blink
77
+ cv.getVar('pin-input-caret-blink-duration') step-end infinite;
78
+ background-color: cv.getVar('pin-input-caret-color');
79
+ content: '';
80
+ height: cv.getVar('pin-input-caret-height');
81
+ width: cv.getVar('pin-input-caret-width');
82
+ }
83
+
84
+ @keyframes #{iv.$class-prefix}pin-input-caret-blink {
85
+ 50% {
86
+ opacity: 0;
87
+ }
88
+ }
89
+
90
+ // The input that holds the code, over the whole row. Its text is squeezed
91
+ // to the row's start, so a click anywhere on the row puts the caret at the
92
+ // end of the code, and the arrow keys move it from there. Its font is never
93
+ // under 16px, since iOS zooms the page into a field with smaller text when
94
+ // it takes focus.
95
+ .#{iv.$class-prefix}pin-input-field {
96
+ appearance: none;
97
+ background: transparent;
98
+ border: 0;
99
+ box-shadow: none;
100
+ caret-color: transparent;
101
+ color: transparent;
102
+ cursor: text;
103
+ font-family: monospace;
104
+ font-size: max(1em, 16px);
105
+ height: 100%;
106
+ left: 0;
107
+ letter-spacing: -0.5em;
108
+ line-height: 1;
109
+ margin: 0;
110
+ outline: 0;
111
+ padding: 0;
112
+ position: absolute;
113
+ top: 0;
114
+ width: 100%;
115
+ z-index: 1;
116
+
117
+ &::selection {
118
+ background-color: transparent;
119
+ color: transparent;
120
+ }
121
+
122
+ &::placeholder {
123
+ color: transparent;
124
+ }
125
+
126
+ &:disabled {
127
+ cursor: not-allowed;
128
+ }
129
+ }
130
+
131
+ // Autofill paints a fill and text of its own on the input. The boxes show
132
+ // the code, so the input hides instead. One rule each, since a browser
133
+ // drops a whole rule over a selector it doesn't know.
134
+ .#{iv.$class-prefix}pin-input-field:-webkit-autofill {
135
+ opacity: 0;
136
+ }
137
+
138
+ .#{iv.$class-prefix}pin-input-field:autofill {
139
+ opacity: 0;
140
+ }
141
+
142
+ @media (prefers-reduced-motion: reduce) {
143
+ .#{iv.$class-prefix}pin-input-box.#{iv.$class-prefix}has-caret::after {
144
+ animation: none;
145
+ }
146
+ }
147
+
148
+ @media (forced-colors: active) {
149
+ // Forced colors would paint the input's transparent text and caret in the
150
+ // text color, over the boxes, so it keeps its own.
151
+ .#{iv.$class-prefix}pin-input-field {
152
+ forced-color-adjust: none;
153
+ }
154
+
155
+ // Forced colors drops Bulma's focus ring, which is a shadow, so the box
156
+ // at the caret, and each selected one, gets an outline in the system's
157
+ // Highlight color. Three classes, to outrank Bulma's `.input.is-focused`
158
+ // border whichever stylesheet loads first.
159
+ .#{iv.$class-prefix}pin-input
160
+ > .#{iv.$class-prefix}pin-input-box.#{iv.$class-prefix}is-focused {
161
+ border-color: Highlight;
162
+ outline: 2px solid Highlight;
163
+ }
164
+
165
+ // The caret is a fill, which forced colors would make the background.
166
+ .#{iv.$class-prefix}pin-input-box.#{iv.$class-prefix}has-caret::after {
167
+ background-color: CanvasText;
168
+ forced-color-adjust: none;
169
+ }
170
+
171
+ .#{iv.$class-prefix}pin-input-box.#{iv.$class-prefix}is-disabled {
172
+ border-color: GrayText;
173
+ color: GrayText;
174
+ }
175
+ }