@rolemodel/optics 0.3.1 → 0.4.1

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.
Files changed (37) hide show
  1. package/.babelrc.json +14 -0
  2. package/.github/pull_request_template.md +1 -0
  3. package/.github/workflows/publish-storybook.yml +1 -1
  4. package/.prettierignore +2 -0
  5. package/README.md +10 -14
  6. package/dist/css/optics.css +961 -446
  7. package/dist/css/optics.css.map +1 -1
  8. package/dist/scss/addons/tom-select.scss +1 -4
  9. package/dist/scss/components/alert.scss +56 -38
  10. package/dist/scss/components/avatar.scss +96 -0
  11. package/dist/scss/components/badge.scss +8 -3
  12. package/dist/scss/components/button.scss +168 -97
  13. package/dist/scss/components/button_group.scss +23 -5
  14. package/dist/scss/components/confirm-dialog.scss +88 -0
  15. package/dist/scss/components/divider.scss +59 -0
  16. package/dist/scss/components/form.scss +180 -49
  17. package/dist/scss/components/index.scss +6 -1
  18. package/dist/scss/components/modal.scss +156 -0
  19. package/dist/scss/components/pagination.scss +28 -0
  20. package/dist/scss/components/sidebar.scss +83 -159
  21. package/dist/scss/components/table.scss +22 -17
  22. package/dist/scss/components/tooltip.scss +136 -0
  23. package/dist/scss/core/tokens/base_tokens.scss +10 -5
  24. package/dist/scss/recipes/16six-sidebar.scss +32 -61
  25. package/dist/scss/recipes/domains-sidebar.scss +24 -44
  26. package/dist/tokens/tokens.json +9 -8
  27. package/package.json +30 -24
  28. package/.storybook/ModeSwitcher.jsx +0 -98
  29. package/.storybook/documentation.scss +0 -93
  30. package/.storybook/main.js +0 -11
  31. package/.storybook/manager.js +0 -22
  32. package/.storybook/preview.js +0 -12
  33. package/.storybook/rolemodelTheme.js +0 -10
  34. package/dist/scss/addons/rails-modal-and-panel/index.scss +0 -2
  35. package/dist/scss/addons/rails-modal-and-panel/modal.scss +0 -111
  36. package/dist/scss/components/flash.scss +0 -58
  37. /package/dist/scss/addons/{rails-modal-and-panel/panel.scss → panel.scss} +0 -0
@@ -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
 
@@ -1,10 +1,15 @@
1
1
  @import 'alert';
2
+ @import 'avatar';
2
3
  @import 'badge';
3
4
  @import 'button';
4
5
  @import 'button_group';
5
6
  @import 'card';
6
- @import 'flash';
7
+ @import 'confirm-dialog';
8
+ @import 'divider';
7
9
  @import 'form';
8
10
  @import 'icon';
11
+ @import 'modal';
12
+ @import 'pagination';
9
13
  @import 'sidebar';
10
14
  @import 'table';
15
+ @import 'tooltip';
@@ -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
+ }
@@ -0,0 +1,28 @@
1
+ %pagination-global {
2
+ display: flex;
3
+ align-items: center;
4
+ gap: 0;
5
+
6
+ // Showing Dropdown
7
+ .form-group {
8
+ align-items: center;
9
+
10
+ .form-label {
11
+ grid-column: 1;
12
+ }
13
+
14
+ .form-control {
15
+ grid-column: 2;
16
+ }
17
+ }
18
+
19
+ // ... Gap
20
+ .pagination__divider {
21
+ height: 100%;
22
+ padding: 0 var(--op-space-x-small);
23
+ }
24
+ }
25
+
26
+ .pagination {
27
+ @extend %pagination-global;
28
+ }