@rolemodel/optics 0.3.0 → 0.4.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.
@@ -1,16 +1,34 @@
1
1
  .btn-group {
2
+ --op-btn-group-hover-z-index: 1;
3
+ --op-btn-group-active-z-index: 2;
4
+ --op-btn-group-focus-z-index: 3;
5
+
2
6
  display: inline-flex;
3
7
  align-items: center;
4
8
 
5
9
  .btn,
6
10
  .btn-primary,
7
- .btn-secondary,
8
- .btn-delete {
11
+ .btn-delete,
12
+ .btn-warning {
9
13
  + .btn,
10
14
  + .btn-primary,
11
- + .btn-secondary,
12
- + .btn-delete {
13
- margin-left: 1px;
15
+ + .btn-delete,
16
+ + .btn-warning {
17
+ margin-left: -1px;
18
+ }
19
+
20
+ &:hover {
21
+ z-index: var(--op-btn-group-hover-z-index);
22
+ }
23
+
24
+ &.btn--active {
25
+ z-index: var(--op-btn-group-active-z-index);
26
+ }
27
+
28
+ &:focus,
29
+ &:focus-within,
30
+ &:focus-visible {
31
+ z-index: var(--op-btn-group-focus-z-index);
14
32
  }
15
33
 
16
34
  &:not(:first-child, :last-child) {
@@ -0,0 +1,88 @@
1
+ %confirm-dialog-wrapper-global {
2
+ position: fixed;
3
+ z-index: var(--op-z-index-dialog);
4
+ top: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ left: 0;
8
+ display: flex;
9
+ overflow: hidden;
10
+ align-items: center;
11
+ justify-content: center;
12
+ outline: 0;
13
+ visibility: hidden;
14
+
15
+ .confirm-dialog-wrapper__backdrop {
16
+ position: fixed;
17
+ z-index: var(--op-z-index-dialog-backdrop);
18
+ top: 0;
19
+ right: 0;
20
+ bottom: 0;
21
+ left: 0;
22
+ background: var(--op-color-black);
23
+ opacity: 0;
24
+ transition: var(--op-transition-modal);
25
+ visibility: hidden;
26
+ }
27
+
28
+ &.confirm-dialog-wrapper--active {
29
+ visibility: visible;
30
+
31
+ .confirm-dialog {
32
+ opacity: 1;
33
+ transform: scale(1);
34
+ }
35
+
36
+ .confirm-dialog-wrapper__backdrop {
37
+ opacity: 0.5;
38
+ visibility: visible;
39
+ }
40
+ }
41
+ }
42
+
43
+ %confirm-dialog-global {
44
+ // Public API (allowed to be overridden)
45
+ --_op-confirm-dialog-width: 40rem;
46
+
47
+ z-index: var(--op-z-index-dialog-content);
48
+ width: var(--_op-confirm-dialog-width);
49
+ border-radius: var(--op-radius-medium);
50
+ background-color: var(--op-color-background);
51
+ box-shadow: var(--op-border-all) var(--op-border-color);
52
+ color: var(--op-color-on-background);
53
+ contain: paint;
54
+ font-size: var(--op-font-medium);
55
+ line-height: var(--op-line-height-base);
56
+ opacity: 0;
57
+ transform: scale(0.7);
58
+ transition: var(--op-transition-modal);
59
+
60
+ .confirm-dialog__header,
61
+ .confirm-dialog__body,
62
+ .confirm-dialog__footer {
63
+ padding: var(--op-space-medium);
64
+ }
65
+
66
+ .confirm-dialog__header {
67
+ font-size: var(--op-font-large);
68
+ font-weight: var(--op-font-weight-semi-bold);
69
+ }
70
+
71
+ .confirm-dialog__body {
72
+ box-shadow: var(--op-border-all) var(--op-border-color);
73
+ }
74
+
75
+ .confirm-dialog__footer {
76
+ display: flex;
77
+ align-items: center;
78
+ justify-content: space-between;
79
+ }
80
+ }
81
+
82
+ .confirm-dialog-wrapper {
83
+ @extend %confirm-dialog-wrapper-global;
84
+ }
85
+
86
+ .confirm-dialog {
87
+ @extend %confirm-dialog-global;
88
+ }
@@ -1,85 +1,177 @@
1
- %standard-input {
1
+ %form-control-global {
2
+ // Public API (allowed to be overridden)
3
+ --_op-form-control-height-small: var(--op-input-height-small);
4
+ --_op-form-control-height-medium: var(--op-input-height-medium);
5
+ --_op-form-control-height-large: var(--op-input-height-large);
6
+ --_op-form-control-font-small: var(--op-font-x-small);
7
+ --_op-form-control-font-medium: var(--op-font-small);
8
+ --_op-form-control-font-large: var(--op-font-small);
9
+
10
+ // Private API (don't touch these)
11
+ --__op-form-control-height: var(--_op-form-control-height-large);
12
+ --__op-form-control-font-size: var(--_op-form-control-font-large);
13
+
14
+ min-width: var(--__op-form-control-height);
15
+ height: var(--__op-form-control-height);
16
+
17
+ // Size Modifiers
18
+ &.form-control--small {
19
+ --__op-form-control-height: var(--_op-form-control-height-small);
20
+ --__op-form-control-font-size: var(--_op-form-control-font-small);
21
+ }
22
+
23
+ &.form-control--medium {
24
+ --__op-form-control-height: var(--_op-form-control-height-medium);
25
+ --__op-form-control-font-size: var(--_op-form-control-font-medium);
26
+ }
27
+
28
+ &.form-control--large {
29
+ --__op-form-control-height: var(--_op-form-control-height-large);
30
+ --__op-form-control-font-size: var(--_op-form-control-font-large);
31
+ }
32
+ }
33
+
34
+ %form-control-input-global {
35
+ // Public API (allowed to be overridden)
36
+ --_op-form-control-opacity-disabled: 0.44;
37
+
2
38
  // Private API (don't touch these)
3
- --__op-input-height: var(--op-input-height-large);
39
+ --__op-form-control-border-color: var(--op-color-neutral-plus-four);
4
40
 
5
41
  display: block;
6
42
  width: 100%;
7
- min-width: var(--__op-input-height);
8
- height: var(--__op-input-height);
9
- padding: var(--op-space-small) var(--op-space-medium);
43
+ min-width: var(--__op-form-control-height);
44
+ height: var(--__op-form-control-height);
45
+ padding: var(--op-space-2x-small) var(--op-space-x-small) var(--op-space-2x-small) var(--op-space-small);
10
46
  border: none;
11
- border-radius: var(--op-radius-large);
12
- background-color: var(--op-color-neutral-plus-max);
13
- box-shadow: var(--op-border-all) var(--op-border-color);
14
- color: var(--op-color-neutral-on-plus-max);
47
+ border-radius: var(--op-radius-medium);
48
+ background-color: var(--op-color-neutral-plus-eight);
49
+ box-shadow: var(--op-border-all) var(--__op-form-control-border-color);
50
+ color: var(--op-color-neutral-on-plus-eight);
15
51
  cursor: text;
16
- font-size: var(--op-font-small);
17
- font-weight: var(--op-font-weight-light);
52
+ font-size: var(--__op-form-control-font-size);
18
53
  line-height: var(--op-line-height-base);
19
54
 
20
- &.form-control--read-only {
21
- height: fit-content;
22
- background-color: var(--op-color-neutral-plus-seven);
23
- background-image: none;
55
+ // Hover State
56
+ &:hover:not(:disabled, [readonly]) {
57
+ box-shadow: var(--op-border-all) var(--op-color-primary-plus-three);
58
+ }
59
+
60
+ // Focus State
61
+ &:focus,
62
+ &:focus-within,
63
+ &:focus-visible {
64
+ outline: none;
65
+ }
66
+
67
+ &:focus-visible:not([readonly]) {
68
+ background-color: var(--op-color-primary-plus-seven);
69
+ box-shadow: var(--op-input-focus-primary);
70
+ color: var(--op-color-primary-on-plus-seven);
71
+ }
72
+
73
+ // Borderless State
74
+ &.form-control--no-border {
75
+ background-color: transparent;
24
76
  box-shadow: none;
25
- color: var(--op-color-neutral-on-plus-seven);
26
- cursor: unset;
77
+ color: var(--op-color-primary-on-plus-max);
27
78
 
28
- &[type='color'] {
29
- height: var(--__op-input-height);
79
+ &:focus-visible:not([readonly]) {
80
+ background-color: var(--op-color-primary-plus-seven);
81
+ box-shadow: var(--op-input-focus-primary);
82
+ color: var(--op-color-primary-on-plus-seven);
83
+ }
84
+
85
+ // Borderless + Hover State
86
+ &:hover:not(:disabled, [readonly]) {
87
+ background-color: var(--op-color-primary-plus-eight);
88
+ box-shadow: inset var(--op-border-all) var(--op-color-primary-plus-two);
89
+ color: var(--op-color-primary-on-plus-eight);
30
90
  }
31
91
  }
32
92
  }
33
93
 
94
+ %form-control-inline-global {
95
+ // Public API (allowed to be overridden)
96
+ --_op-form-control-height-small: var(--op-space-medium);
97
+ --_op-form-control-height-medium: var(--op-space-large);
98
+ --_op-form-control-height-large: var(--op-space-x-large);
99
+
100
+ width: var(--__op-form-control-height);
101
+ height: var(--__op-form-control-height);
102
+ align-self: center;
103
+ margin: 0;
104
+ accent-color: var(--op-color-primary-base);
105
+ cursor: pointer;
106
+
107
+ & + label {
108
+ align-self: center;
109
+ }
110
+ }
111
+
34
112
  %dropdown-arrow {
35
113
  padding-right: var(--op-space-3x-large);
36
114
  appearance: none;
37
- background: var(--op-form-dropdown-arrow) center right no-repeat;
38
- background-position-x: calc(100% - ((var(--op-space-3x-large) / 2) - (var(--op-form-dropdown-arrow-width) / 2)));
115
+ background: var(--op-encoded-images-dropdown-arrow) center right no-repeat;
116
+ background-position-x: calc(
117
+ 100% - ((var(--op-space-3x-large) / 2) - (var(--op-encoded-images-dropdown-arrow-width) / 2))
118
+ );
39
119
  cursor: pointer;
40
120
  }
41
121
 
42
122
  .form-label {
43
123
  color: var(--op-color-on-background);
44
- font-size: var(--op-font-small);
124
+ font-size: var(--op-font-x-small);
45
125
  font-weight: var(--op-font-weight-normal);
46
126
  letter-spacing: var(--op-letter-spacing-label);
47
127
  line-height: var(--op-line-height-base);
48
128
  }
49
129
 
50
130
  .form-control {
131
+ @extend %form-control-global;
132
+
51
133
  &:not([type='radio'], [type='checkbox']) {
52
- @extend %standard-input;
134
+ @extend %form-control-input-global;
53
135
  }
54
136
 
55
137
  &[type='color'] {
56
- @extend %dropdown-arrow;
138
+ padding: var(--op-space-2x-small);
139
+
140
+ &::-webkit-color-swatch-wrapper {
141
+ padding: 0;
142
+ }
143
+
144
+ &::-webkit-color-swatch {
145
+ border: none;
146
+ border-radius: var(--op-radius-medium);
147
+ }
57
148
  }
58
149
 
59
150
  &[type='radio'],
60
151
  &[type='checkbox'] {
61
- width: var(--op-space-large);
62
- height: var(--op-space-large);
63
- align-self: center;
64
- margin: 0;
65
- accent-color: var(--op-color-primary-base);
66
- cursor: pointer;
152
+ @extend %form-control-inline-global;
67
153
  }
68
154
 
155
+ // Disabled State
69
156
  &:disabled {
70
157
  cursor: not-allowed;
158
+ opacity: var(--_op-form-control-opacity-disabled);
71
159
  }
72
160
 
73
- &:focus,
74
- &:focus-within,
75
- &:focus-visible,
76
- &:active {
77
- box-shadow: 0 0 0 var(--op-border-width-large) var(--op-color-primary-plus-four), var(--op-input-focus);
78
- outline: none;
161
+ // Readonly State
162
+ &[readonly] {
163
+ padding: 0;
164
+ background: transparent;
165
+ box-shadow: none;
166
+ color: var(--op-color-on-background);
167
+ pointer-events: none;
168
+ user-select: none;
79
169
 
80
- &:hover:not(:disabled) {
81
- box-shadow: 0 0 0 var(--op-border-width-large) var(--op-color-primary-plus-four), var(--op-input-focus);
170
+ /* stylelint-disable selector-no-vendor-prefix */
171
+ &::-webkit-input-placeholder {
172
+ color: var(--op-color-on-background);
82
173
  }
174
+ /* stylelint-enable selector-no-vendor-prefix */
83
175
  }
84
176
  }
85
177
 
@@ -88,21 +180,19 @@ select.form-control:not([multiple], [type='radio'], [type='checkbox']) {
88
180
  }
89
181
 
90
182
  select.form-control[multiple] {
91
- min-height: calc(2 * var(--__op-input-height));
183
+ min-height: calc(2 * var(--__op-form-control-height));
92
184
  }
93
185
 
94
- textarea.form-control {
95
- @extend %standard-input;
96
-
97
- min-width: var(--__op-input-height);
186
+ textarea.form-control:not([type='radio'], [type='checkbox']) {
98
187
  max-width: 100%;
99
- min-height: var(--__op-input-height);
188
+ height: calc(2 * var(--__op-form-control-height));
189
+ min-height: var(--__op-form-control-height);
100
190
  }
101
191
 
102
192
  .form-group--error {
103
193
  /* stylelint-disable no-descending-specificity */
104
194
  .form-control {
105
- box-shadow: var(--op-border-all) var(--op-color-alerts-danger-minus-three);
195
+ box-shadow: var(--op-border-all) var(--op-color-alerts-danger-base);
106
196
 
107
197
  &[type='radio'],
108
198
  &[type='checkbox'] {
@@ -113,16 +203,57 @@ textarea.form-control {
113
203
  font-weight: var(--op-font-weight-bold);
114
204
  }
115
205
  }
206
+
207
+ // Error + Hover State
208
+ &:hover:not(:disabled, [readonly]) {
209
+ background-color: var(--op-color-alerts-danger-plus-seven);
210
+ box-shadow: var(--op-border-all) var(--op-color-alerts-danger-minus-two);
211
+ color: var(--op-color-alerts-danger-on-plus-seven);
212
+ }
213
+
214
+ // Readonly State
215
+ &[readonly] {
216
+ box-shadow: none;
217
+ }
218
+
219
+ // Error + Focus State
220
+ &:focus-visible:not([readonly]) {
221
+ background-color: var(--op-color-alerts-danger-plus-seven);
222
+ box-shadow: var(--op-input-focus-danger);
223
+ color: var(--op-color-alerts-danger-on-plus-seven);
224
+ }
225
+
226
+ // Borderless State
227
+ &.form-control--no-border {
228
+ border-radius: 0;
229
+ box-shadow: var(--op-border-bottom) var(--op-color-alerts-danger-base);
230
+
231
+ // Readonly State
232
+ &[readonly] {
233
+ box-shadow: none;
234
+ }
235
+
236
+ // Borderless + Focus State
237
+ &:focus-visible:not([readonly]) {
238
+ background-color: var(--op-color-alerts-danger-plus-seven);
239
+ box-shadow: var(--op-border-bottom) var(--op-color-alerts-danger-base);
240
+ color: var(--op-color-alerts-danger-on-plus-seven);
241
+ }
242
+
243
+ // Borderless + Hover State
244
+ &:hover:not(:disabled, [readonly]) {
245
+ background-color: var(--op-color-alerts-danger-plus-eight);
246
+ box-shadow: var(--op-border-bottom) var(--op-color-alerts-danger-base);
247
+ color: var(--op-color-alerts-danger-on-plus-eight);
248
+ }
249
+ }
116
250
  }
117
251
  /* stylelint-enable no-descending-specificity */
118
252
  }
119
253
 
120
254
  .form-error {
121
255
  width: fit-content;
122
- padding: var(--op-space-2x-small) var(--op-space-x-small);
123
- border-radius: var(--op-radius-medium);
124
- background: var(--op-color-alerts-danger-plus-seven);
125
- color: var(--op-color-alerts-danger-on-plus-seven);
256
+ color: var(--op-color-alerts-danger-base);
126
257
  font-size: var(--op-font-x-small);
127
258
  }
128
259
 
@@ -3,8 +3,9 @@
3
3
  @import 'button';
4
4
  @import 'button_group';
5
5
  @import 'card';
6
- @import 'flash';
6
+ @import 'confirm-dialog';
7
7
  @import 'form';
8
8
  @import 'icon';
9
+ @import 'modal';
9
10
  @import 'sidebar';
10
11
  @import 'table';
@@ -0,0 +1,156 @@
1
+ %modal-wrapper-global {
2
+ // Public API (allowed to be overridden)
3
+ --_op-modal-backdrop-active-opacity: 0.5;
4
+
5
+ position: fixed;
6
+ z-index: var(--op-z-index-dialog);
7
+ top: 0;
8
+ right: 0;
9
+ bottom: 0;
10
+ left: 0;
11
+ display: flex;
12
+ overflow: hidden;
13
+ align-items: center;
14
+ justify-content: center;
15
+ outline: 0;
16
+ visibility: hidden;
17
+
18
+ .modal-wrapper__backdrop {
19
+ position: fixed;
20
+ z-index: var(--op-z-index-dialog-backdrop);
21
+ top: 0;
22
+ right: 0;
23
+ bottom: 0;
24
+ left: 0;
25
+ background: var(--op-color-black);
26
+ opacity: 0;
27
+ transition: var(--op-transition-modal);
28
+ visibility: hidden;
29
+ }
30
+
31
+ &.modal-wrapper--active {
32
+ visibility: visible;
33
+
34
+ .modal {
35
+ opacity: 1;
36
+ transform: scale(1);
37
+ }
38
+
39
+ .modal-wrapper__backdrop {
40
+ opacity: var(--_op-modal-backdrop-active-opacity);
41
+ visibility: visible;
42
+ }
43
+ }
44
+ }
45
+
46
+ %modal-global {
47
+ // Public API (allowed to be overridden)
48
+ --_op-modal-width: 56.4rem;
49
+ --_op-modal-max-height: 50rem;
50
+
51
+ z-index: var(--op-z-index-dialog-content);
52
+ width: var(--_op-modal-width);
53
+ border-radius: var(--op-radius-medium);
54
+ background-color: var(--op-color-background);
55
+ box-shadow: var(--op-border-all) var(--op-border-color);
56
+ color: var(--op-color-on-background);
57
+ contain: paint;
58
+ font-size: var(--op-font-medium);
59
+ line-height: var(--op-line-height-base);
60
+ opacity: 0;
61
+ transform: scale(0.7);
62
+ transition: var(--op-transition-modal);
63
+
64
+ .modal__header,
65
+ .modal__body,
66
+ .modal__footer {
67
+ padding: var(--op-space-medium);
68
+ }
69
+
70
+ .modal__header {
71
+ display: flex;
72
+ align-items: center;
73
+ justify-content: space-between;
74
+ font-size: var(--op-font-large);
75
+ font-weight: var(--op-font-weight-semi-bold);
76
+ }
77
+
78
+ .modal__body {
79
+ max-height: var(--_op-modal-max-height);
80
+ box-shadow: var(--op-border-all) var(--op-border-color);
81
+ overflow-y: auto;
82
+ }
83
+
84
+ .modal__footer {
85
+ display: flex;
86
+ align-items: center;
87
+ justify-content: flex-end;
88
+ gap: var(--op-space-small);
89
+ }
90
+ }
91
+
92
+ .modal-wrapper {
93
+ @extend %modal-wrapper-global;
94
+ }
95
+
96
+ .modal {
97
+ @extend %modal-global;
98
+ }
99
+
100
+ // Using the Dialog element
101
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog
102
+ @keyframes show-backdrop {
103
+ from {
104
+ opacity: 0;
105
+ }
106
+
107
+ to {
108
+ opacity: var(--_op-modal-backdrop-active-opacity);
109
+ }
110
+ }
111
+
112
+ @keyframes hide-backdrop {
113
+ from {
114
+ opacity: var(--_op-modal-backdrop-active-opacity);
115
+ }
116
+
117
+ to {
118
+ opacity: 0;
119
+ }
120
+ }
121
+
122
+ dialog.modal {
123
+ position: fixed;
124
+ top: 0;
125
+ right: 0;
126
+ bottom: 0;
127
+ left: 0;
128
+ display: block;
129
+ padding: 0;
130
+ border: none;
131
+
132
+ &::backdrop {
133
+ // The Dialog backdrop does not inheret from :root so these need to be duplicated here.
134
+ --op-color-black: hsl(0deg 0% 0%);
135
+ --_op-modal-backdrop-active-opacity: 0.5;
136
+
137
+ animation: show-backdrop 300ms ease-in;
138
+ background: var(--op-color-black);
139
+ opacity: var(--_op-modal-backdrop-active-opacity);
140
+ }
141
+
142
+ &[open] {
143
+ opacity: 1;
144
+ transform: scale(1);
145
+ }
146
+
147
+ &.modal--closing {
148
+ opacity: 0;
149
+ transform: scale(0.7);
150
+
151
+ &::backdrop {
152
+ animation: hide-backdrop 300ms ease-in;
153
+ opacity: 0;
154
+ }
155
+ }
156
+ }