elbe-ui 0.2.5 → 0.2.11

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 (49) hide show
  1. package/dist/index.js +2 -2
  2. package/dist/ui/color_theme.d.ts +5 -0
  3. package/dist/ui/components/badge.d.ts +25 -0
  4. package/dist/ui/components/box.d.ts +1027 -0
  5. package/dist/ui/components/button.d.ts +23 -0
  6. package/dist/ui/components/card.d.ts +14 -0
  7. package/dist/ui/components/dialog.d.ts +8 -0
  8. package/dist/ui/components/flex.d.ts +11 -0
  9. package/dist/ui/components/icon_button.d.ts +19 -0
  10. package/dist/ui/components/input/checkbox.d.ts +6 -0
  11. package/dist/ui/components/input/input_field.d.ts +22 -0
  12. package/dist/ui/components/input/range.d.ts +8 -0
  13. package/dist/ui/components/input/select.d.ts +10 -0
  14. package/dist/ui/components/input/text_area.d.ts +10 -0
  15. package/dist/ui/components/padded.d.ts +25 -0
  16. package/dist/ui/components/text.d.ts +33 -0
  17. package/dist/ui/components/toggle_button.d.ts +12 -0
  18. package/dist/ui/components/util.d.ts +3 -0
  19. package/dist/ui/util/confirm_dialog.d.ts +10 -0
  20. package/dist/ui/util/error_view.d.ts +1 -0
  21. package/dist/ui/util/toast.d.ts +5 -0
  22. package/dist/ui/util/util.d.ts +3 -0
  23. package/package.json +6 -3
  24. package/src/index.ts +24 -0
  25. package/src/ui/color_theme.ts +24 -0
  26. package/src/ui/components/badge.tsx +78 -0
  27. package/src/ui/components/box.tsx +49 -0
  28. package/src/ui/components/button.tsx +61 -0
  29. package/src/ui/components/card.tsx +45 -0
  30. package/src/ui/components/dialog.tsx +51 -0
  31. package/src/ui/components/flex.tsx +64 -0
  32. package/src/ui/components/icon_button.tsx +57 -0
  33. package/src/ui/components/input/checkbox.tsx +32 -0
  34. package/src/ui/components/input/input_field.tsx +57 -0
  35. package/src/ui/components/input/range.tsx +37 -0
  36. package/src/ui/components/input/select.tsx +29 -0
  37. package/src/ui/components/input/text_area.tsx +45 -0
  38. package/src/ui/components/padded.tsx +62 -0
  39. package/src/ui/components/text.tsx +78 -0
  40. package/src/ui/components/toggle_button.tsx +51 -0
  41. package/src/ui/components/util.tsx +3 -0
  42. package/src/ui/util/confirm_dialog.ts +53 -0
  43. package/src/ui/util/error_view.tsx +16 -0
  44. package/src/ui/util/toast.ts +14 -0
  45. package/src/ui/util/util.ts +4 -0
  46. package/style/color_style.scss +148 -0
  47. package/style/components.scss +574 -0
  48. package/style/root.scss +50 -0
  49. package/style/type_style.scss +22 -0
@@ -0,0 +1,148 @@
1
+ @function contrast($colorA, $colorB) {
2
+ $yiqA: calc(
3
+ ((red($colorA) * 299) + (green($colorA) * 587) + (blue($colorA) * 114)) /
4
+ 1000
5
+ );
6
+ $yiqB: calc(
7
+ ((red($colorB) * 299) + (green($colorB) * 587) + (blue($colorB) * 114)) /
8
+ 1000
9
+ );
10
+ @return abs($yiqA - $yiqB);
11
+ }
12
+
13
+ @function mg($map, $value) {
14
+ @return map-get($map, $value);
15
+ }
16
+
17
+ @function ifn($a, $b) {
18
+ @return if($a ==null, $b, $a);
19
+ }
20
+
21
+ @function inter($colorA, $colorB: #888888, $weight: 50%) {
22
+ @return mix($colorA, $colorB, $weight);
23
+ }
24
+
25
+ @mixin colored($back, $front, $border) {
26
+ color: $front;
27
+ background-color: $back;
28
+ border-color: $border;
29
+ }
30
+
31
+ @mixin blinking($length: 1s) {
32
+ animation: blinker $length linear infinite;
33
+ }
34
+
35
+ @keyframes blinker {
36
+ 50% {
37
+ opacity: 0;
38
+ }
39
+ }
40
+
41
+ // SHOW WHEN THE STYLES ARE NOT BEING USED WITHIN A MODE
42
+ @each $style, $s_colors in $c-styles {
43
+ .#{$style} {
44
+ @include blinking();
45
+ @include colored(rgb(255, 55, 0), white, transparent);
46
+ }
47
+ }
48
+
49
+ //COLORS
50
+
51
+ @each $mode, $m_colors in $c-modes {
52
+ .#{$mode} {
53
+ $mode_back: mg($m_colors, back);
54
+ $mode_front: mg($m_colors, front);
55
+ $mode_border: mg($m_colors, border);
56
+ @include colored($mode_back, $mode_front, $mode_border);
57
+
58
+ .plain {
59
+ @include colored(transparent, $mode_front, $mode_border);
60
+ }
61
+
62
+ .plain-opaque {
63
+ @include colored($mode_back, $mode_front, $mode_border);
64
+ }
65
+
66
+ & {
67
+ --c-mode: #{$mode};
68
+ }
69
+
70
+ @each $style, $s_colors in $c-styles {
71
+ $back: mg($s_colors, back);
72
+ $border: ifn(mg($s_colors, border), $back);
73
+
74
+ $effectiveBack: ifn(
75
+ if(mg($s_colors, back) == transparent, $mode_back, mg($s_colors, back)),
76
+ $mode_back
77
+ );
78
+ $front: ifn(
79
+ mg($s_colors, front),
80
+ if(contrast($mode_front, $effectiveBack) > 128, $mode_front, $mode_back)
81
+ );
82
+
83
+ & {
84
+ --c-#{$style}: #{$back};
85
+ }
86
+
87
+ .#{$style} {
88
+ animation: none;
89
+
90
+ @include colored($back, $front, $border);
91
+
92
+ &.minor {
93
+ $mback: inter(mg($s_colors, back), mg($m_colors, back), 25%);
94
+ $mfront: mg($s_colors, back);
95
+ $mborder: ifn(mg($s_colors, border), $mfront);
96
+
97
+ @include colored($mback, $mfront, $mborder);
98
+
99
+ &.hovered {
100
+ $hback: inter($mback, $mfront, 90%);
101
+ @include colored($hback, $mfront, $mborder);
102
+ }
103
+
104
+ &.pressed {
105
+ $pback: inter($mback, $mfront, 75%);
106
+ @include colored($pback, $mfront, $mborder);
107
+ }
108
+
109
+ &.disabled {
110
+ $disback: grayscale($mback);
111
+ $disfront: grayscale($mfront);
112
+ $disborder: if($mborder ==null, null, grayscale($mborder));
113
+
114
+ @include colored($disback, $disfront, $disborder);
115
+ }
116
+ }
117
+
118
+ &.hovered {
119
+ $hback: inter($back, $front, 95%);
120
+ $hborder: if(
121
+ $border ==transparent,
122
+ transparent,
123
+ inter($border, $front, 95%)
124
+ );
125
+ @include colored($hback, $front, $hborder);
126
+ }
127
+
128
+ &.pressed {
129
+ $pback: inter($back, $front, 85%);
130
+ $pborder: if(
131
+ $border ==transparent,
132
+ transparent,
133
+ inter($border, $front, 85%)
134
+ );
135
+ @include colored($pback, $front, $pborder);
136
+ }
137
+
138
+ &.disabled {
139
+ @include colored(
140
+ grayscale($back),
141
+ grayscale($front),
142
+ grayscale($back)
143
+ );
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
@@ -0,0 +1,574 @@
1
+ #hide-site {
2
+ position: fixed;
3
+ left: 0px;
4
+ right: 0px;
5
+ top: 0px;
6
+ bottom: 0px;
7
+ background-color: white;
8
+ z-index: 99; /* Higher than anything else in the document */
9
+ }
10
+
11
+ .margin-none {
12
+ margin: 0;
13
+ }
14
+
15
+ .padded {
16
+ padding: 1rem;
17
+ }
18
+
19
+ .padding-none {
20
+ padding: 0rem;
21
+ }
22
+
23
+ .padded_v {
24
+ padding-top: 1rem;
25
+ padding-bottom: 1rem;
26
+ }
27
+
28
+ .padded_h {
29
+ padding-left: 1rem;
30
+ padding-right: 1rem;
31
+ }
32
+
33
+ .margined {
34
+ margin: 1rem;
35
+ }
36
+
37
+ .margined_v {
38
+ margin-top: 1rem;
39
+ margin-bottom: 1rem;
40
+ }
41
+
42
+ .margined_h {
43
+ margin-left: 1rem;
44
+ margin-right: 1rem;
45
+ }
46
+
47
+ .box {
48
+ @extend .padded;
49
+
50
+ @extend .text-m;
51
+
52
+ @extend .primary;
53
+
54
+ &.primary {
55
+ @extend .primary;
56
+ }
57
+
58
+ &.secondary {
59
+ @extend .secondary;
60
+ }
61
+
62
+ &.inverse {
63
+ @extend .inverse;
64
+ }
65
+ }
66
+
67
+ .flex {
68
+ display: flex;
69
+ flex-direction: column;
70
+ }
71
+
72
+ .card {
73
+ @extend .box;
74
+ border-width: 2px;
75
+ border-style: solid;
76
+ border-radius: $g-radius;
77
+ //overflow: hidden;
78
+ }
79
+
80
+ .row {
81
+ display: flex;
82
+ flex-direction: row;
83
+ align-items: center;
84
+ gap: 1rem;
85
+
86
+ &.wrap {
87
+ flex-wrap: wrap;
88
+ }
89
+ }
90
+
91
+ .if-wide {
92
+ @media (max-width: 700px) {
93
+ & {
94
+ display: none;
95
+ }
96
+ }
97
+ }
98
+
99
+ .if-narrow {
100
+ @media (min-width: 700px) {
101
+ & {
102
+ display: none;
103
+ }
104
+ }
105
+ }
106
+
107
+ .row-resp,
108
+ .row-resp-rev {
109
+ display: flex;
110
+ flex-direction: row;
111
+ justify-content: center;
112
+ align-items: start;
113
+ gap: 1rem;
114
+
115
+ @media (max-width: 700px) {
116
+ & {
117
+ flex-direction: column;
118
+ justify-content: start;
119
+ align-items: stretch;
120
+ }
121
+
122
+ &.row-resp-rev {
123
+ flex-direction: column-reverse;
124
+ }
125
+ }
126
+ }
127
+
128
+ .column {
129
+ display: flex;
130
+ flex-direction: column;
131
+ align-items: center;
132
+ gap: 1rem;
133
+ }
134
+
135
+ // ================ GAP ================
136
+
137
+ .gap-none {
138
+ gap: 0;
139
+ }
140
+
141
+ .gap-quarter {
142
+ gap: 0.25rem;
143
+ }
144
+
145
+ .gap-half {
146
+ gap: 0.5rem;
147
+ }
148
+
149
+ .gap {
150
+ gap: 1rem;
151
+ }
152
+
153
+ @for $i from 0 through 6 {
154
+ .gap-#{$i} {
155
+ gap: #{$i}rem;
156
+ }
157
+ }
158
+
159
+ $cross_modes: (stretch, start, end, center);
160
+
161
+ @each $name in $cross_modes {
162
+ .cross-#{$name} {
163
+ align-items: $name;
164
+ }
165
+ }
166
+
167
+ $main_modes: (stretch, start, end, center, space-between);
168
+
169
+ @each $name in $main_modes {
170
+ .main-#{$name} {
171
+ justify-content: $name;
172
+ }
173
+ }
174
+
175
+ .column.cross-stretch-fill {
176
+ align-items: stretch;
177
+ width: 100%;
178
+ }
179
+
180
+ @for $i from 1 through 12 {
181
+ .flex-#{$i} {
182
+ @extend .flex;
183
+ flex: $i;
184
+ }
185
+ }
186
+
187
+ .i {
188
+ font-style: italic;
189
+ }
190
+ b,
191
+ .b {
192
+ font-weight: bold;
193
+ }
194
+
195
+ .u {
196
+ text-decoration: underline;
197
+ }
198
+
199
+ .ni {
200
+ font-style: normal;
201
+ }
202
+
203
+ .nb {
204
+ font-weight: normal;
205
+ }
206
+
207
+ .nu {
208
+ text-decoration: none;
209
+ }
210
+
211
+ .striked {
212
+ text-decoration: line-through;
213
+ }
214
+
215
+ .code {
216
+ font-family: monospace;
217
+ }
218
+
219
+ .header {
220
+ @extend .box;
221
+ @extend .row;
222
+ width: 100%;
223
+ position: fixed;
224
+ left: 0;
225
+ top: 0;
226
+ display: flex;
227
+ border-width: 20px;
228
+ border-style: solid;
229
+ border-width: 0 0 2px 0;
230
+ //border-width: 0 0 2px 0;
231
+ background-color: transparent;
232
+ backdrop-filter: blur(10px);
233
+ -webkit-backdrop-filter: blur(10px);
234
+ z-index: 20;
235
+ // place border inside the element:
236
+ box-sizing: border-box;
237
+ height: 4rem;
238
+ }
239
+
240
+ .centered {
241
+ display: flex;
242
+ align-items: center;
243
+ justify-content: center;
244
+ }
245
+
246
+ .sharp {
247
+ border-radius: 0;
248
+ }
249
+
250
+ .rounded {
251
+ border-radius: $g-radius;
252
+ }
253
+
254
+ .round {
255
+ border-radius: 50%;
256
+ }
257
+
258
+ img.round,
259
+ img.rounded {
260
+ object-fit: cover;
261
+ }
262
+
263
+ .base-limited {
264
+ @extend .box;
265
+ max-width: 700px;
266
+ width: 100%;
267
+ margin: 0 auto;
268
+ }
269
+
270
+ .scrollbars-none {
271
+ scrollbar-width: none;
272
+ -ms-overflow-style: none;
273
+ &::-webkit-scrollbar {
274
+ display: none;
275
+ }
276
+ }
277
+
278
+ .pointer {
279
+ cursor: pointer;
280
+ }
281
+
282
+ button {
283
+ @extend .card;
284
+ @extend .accent;
285
+ @extend .row;
286
+ @extend .text-m;
287
+ @extend .b;
288
+ justify-content: center;
289
+ padding: 0.25rem 0.75rem;
290
+ gap: 0.5rem;
291
+ min-height: 3rem;
292
+ cursor: pointer;
293
+
294
+ &:hover:not(&:disabled, .disabled) {
295
+ @extend .hovered;
296
+ }
297
+
298
+ &:active:not(&:disabled, .disabled) {
299
+ @extend .pressed;
300
+ }
301
+
302
+ &:disabled,
303
+ &.disabled {
304
+ @extend .disabled;
305
+ cursor: not-allowed;
306
+
307
+ &.action {
308
+ opacity: 0.7;
309
+ filter: grayscale(1);
310
+ }
311
+ }
312
+
313
+ & > .lucide {
314
+ & + div {
315
+ text-align: center;
316
+ flex: 1;
317
+ text-align: center;
318
+ }
319
+ }
320
+
321
+ &.text-left {
322
+ text-align: left;
323
+ div {
324
+ margin-left: 0.25rem;
325
+ text-align: left;
326
+ }
327
+ }
328
+ }
329
+
330
+ input[type="text"],
331
+ input[type="number"],
332
+ input[type="password"],
333
+ input[type="email"],
334
+ input[type="date"],
335
+ input[type="time"] {
336
+ @extend .card;
337
+ padding: 0 0.75rem;
338
+ height: 3rem;
339
+ min-width: 12rem;
340
+ width: 100%;
341
+ }
342
+
343
+ select {
344
+ @extend .card;
345
+ padding: 0 0.75rem;
346
+ height: 3rem;
347
+ min-width: 12rem;
348
+ width: 100%;
349
+ }
350
+
351
+ textarea {
352
+ @extend .card;
353
+ height: 6rem;
354
+ padding: 0.6rem 0.75rem;
355
+ resize: vertical;
356
+ min-height: 3rem;
357
+ min-width: 12rem;
358
+ width: 100%;
359
+ }
360
+
361
+ .text-centered {
362
+ text-align: center;
363
+ }
364
+
365
+ .text-left {
366
+ text-align: left;
367
+ }
368
+
369
+ body:has(dialog[open=""]) {
370
+ overflow: hidden;
371
+ }
372
+
373
+ dialog {
374
+ @extend .column;
375
+ @extend .cross-center;
376
+ @extend .main-center;
377
+
378
+ z-index: 100;
379
+
380
+ position: fixed;
381
+ top: 0;
382
+ left: 0;
383
+ width: 100vw;
384
+ height: 100vh;
385
+
386
+ border: none;
387
+
388
+ pointer-events: none;
389
+
390
+ background-color: transparent;
391
+
392
+ transition: background-color 0.3s ease-in-out;
393
+ transition: backdrop-filter 0.3s ease-in-out;
394
+
395
+ & > * {
396
+ display: none;
397
+ }
398
+
399
+ &[open=""] {
400
+ background-color: rgba(0, 0, 0, 0.2);
401
+ backdrop-filter: blur(5px);
402
+ pointer-events: all;
403
+ & > * {
404
+ display: unset;
405
+ }
406
+ }
407
+ }
408
+
409
+ .raised {
410
+ box-shadow: 0 0.1rem 1rem #00000033;
411
+ }
412
+
413
+ .icon {
414
+ aspect-ratio: 1;
415
+ border-radius: 25%;
416
+ object-fit: cover;
417
+ }
418
+
419
+ .toast {
420
+ @extend .card;
421
+ @extend .inverse;
422
+ @extend .b;
423
+ @extend .raised;
424
+ position: fixed;
425
+ bottom: 1rem;
426
+ right: 1rem;
427
+ z-index: 200;
428
+ left: 50%;
429
+ width: min(40rem, 90%);
430
+ transform: translateX(-50%);
431
+ }
432
+
433
+ .borderless {
434
+ border: none;
435
+ }
436
+
437
+ input[type="range"] {
438
+ -webkit-appearance: none;
439
+ appearance: none;
440
+ background: transparent;
441
+ cursor: pointer;
442
+ width: 15rem;
443
+
444
+ &::-webkit-slider-runnable-track,
445
+ &::-moz-range-track {
446
+ @extend .secondary;
447
+ border-radius: 100px;
448
+ border: none;
449
+ height: 0.5rem;
450
+ }
451
+
452
+ &::-webkit-slider-thumb,
453
+ &::-moz-range-thumb {
454
+ @extend .accent;
455
+ border: none;
456
+ -webkit-appearance: none; /* Override default look */
457
+ appearance: none;
458
+ margin-top: -12px;
459
+ border-radius: 100px;
460
+ height: 1.2rem;
461
+ width: 1.2rem;
462
+ }
463
+ }
464
+
465
+ // ============ CHECKBOXES ============
466
+
467
+ input[type="checkbox"] {
468
+ -webkit-appearance: none;
469
+ appearance: none;
470
+ margin: 0;
471
+
472
+ font: inherit;
473
+ color: black;
474
+ //margin: 0.6rem 0.6rem;
475
+ width: 1.8rem;
476
+ height: 1.8rem;
477
+ border: 0.16em solid black;
478
+ border-radius: 25%;
479
+ transform: translateY(-0.075em);
480
+
481
+ display: grid;
482
+ place-content: center;
483
+ outline: none;
484
+ }
485
+
486
+ input[type="checkbox"]::before {
487
+ content: "";
488
+ width: 0.95rem;
489
+ height: 0.75rem;
490
+ clip-path: polygon(10% 41%, 37% 75%, 91% 0, 100% 13%, 38% 100%, 0 55%);
491
+ // check tick clip path outlined:
492
+ transform: scale(0);
493
+ transform-origin: center;
494
+ transition: 0.2s transform ease-in-out;
495
+ background-color: black;
496
+ //box-shadow: inset 1em 1em green;
497
+ }
498
+
499
+ input[type="checkbox"]:checked {
500
+ @extend .loud;
501
+ @extend .minor;
502
+ border-color: $c-accent !important;
503
+ &::before {
504
+ transform: scale(1);
505
+ background-color: $c-accent;
506
+ }
507
+ }
508
+
509
+ input[type="checkbox"]:focus {
510
+ outline: max(2px, 0.15em) solid blue;
511
+ outline-offset: 0;
512
+ }
513
+
514
+ input[type="checkbox"]:disabled {
515
+ //--form-control-color: var(--form-control-disabled);
516
+
517
+ color: gray;
518
+ cursor: not-allowed;
519
+ }
520
+
521
+ .code {
522
+ @extend .card;
523
+ @extend .secondary;
524
+ padding: 0.4rem 0.5rem;
525
+ font-family: monospace;
526
+ white-space: pre-wrap;
527
+ }
528
+
529
+ .rotate-box {
530
+ @extend .rotate;
531
+ display: flex;
532
+ align-items: center;
533
+ justify-content: center;
534
+ }
535
+
536
+ .rotate {
537
+ animation: rotation 1.5s infinite linear;
538
+ }
539
+
540
+ @keyframes rotation {
541
+ from {
542
+ transform: rotate(0deg);
543
+ }
544
+
545
+ to {
546
+ transform: rotate(359deg);
547
+ }
548
+ }
549
+
550
+ [data-tooltip]:hover:after {
551
+ opacity: 1;
552
+ transition: all 0.1s ease 0.8s;
553
+ visibility: visible;
554
+ }
555
+
556
+ [data-tooltip]:after {
557
+ @extend .inverse;
558
+ content: attr(data-tooltip);
559
+ position: absolute;
560
+ bottom: -1.6em;
561
+ left: 50%;
562
+ transform: translateX(-50%);
563
+ white-space: nowrap;
564
+ box-shadow: 0 0.125rem 0.5rem 0.2rem #00000022;
565
+ padding: 0.25em 0.5em;
566
+ border-radius: 0.25em;
567
+ opacity: 0;
568
+ z-index: 999;
569
+ visibility: hidden;
570
+ pointer-events: none;
571
+ }
572
+ [data-tooltip] {
573
+ position: relative;
574
+ }