@clarusjs/ui 0.2.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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/package.json +3 -3
  3. package/src/ui.css +252 -21
package/README.md CHANGED
@@ -3,6 +3,9 @@
3
3
  Thin, accessible styles for the parts in [`@clarusjs/ui-primitives`](https://clarusjs.com/guide/ui-primitives#parts):
4
4
  one stylesheet over their `data-part` names and state attributes, light and dark.
5
5
 
6
+ For components you copy and own (cards, tables, charts, date pickers, blocks…), in plain CSS or Tailwind, see
7
+ [ui.clarusjs.com](https://ui.clarusjs.com).
8
+
6
9
  ```sh
7
10
  pnpm add @clarusjs/ui @clarusjs/ui-primitives
8
11
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clarusjs/ui",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "A styled set for @clarusjs/ui-primitives: design tokens and thin, accessible styles over the parts' data-part and state attributes, light and dark.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -17,7 +17,7 @@
17
17
  "access": "public"
18
18
  },
19
19
  "peerDependencies": {
20
- "@clarusjs/ui-primitives": "^0.2.0"
20
+ "@clarusjs/ui-primitives": "^0.3.1"
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",
@@ -35,7 +35,7 @@
35
35
  "url": "https://github.com/forinda/clarusjs/issues"
36
36
  },
37
37
  "devDependencies": {
38
- "@clarusjs/ui-primitives": "^0.2.0",
38
+ "@clarusjs/ui-primitives": "^0.3.1",
39
39
  "vitest": "^5.1.1"
40
40
  },
41
41
  "scripts": {
package/src/ui.css CHANGED
@@ -7,6 +7,7 @@
7
7
  @layer theme, base, components, utilities; /* Tailwind's order, declared first: components always rank above base. */
8
8
 
9
9
  :root {
10
+ color-scheme: light; /* native controls (select popups, date pickers, scrollbars) match */
10
11
  --ui-font: system-ui, sans-serif;
11
12
  --ui-font-heading: var(--ui-font);
12
13
  --ui-font-mono: ui-monospace, monospace;
@@ -65,6 +66,7 @@
65
66
  }
66
67
  @media (prefers-color-scheme: dark) {
67
68
  :root:not([data-theme='light']) {
69
+ color-scheme: dark;
68
70
  --ui-bg: #121a1b;
69
71
  --ui-fg: #e6eded;
70
72
  --ui-muted: #9aa8a9;
@@ -102,6 +104,7 @@
102
104
  }
103
105
  }
104
106
  :root[data-theme='dark'] {
107
+ color-scheme: dark;
105
108
  --ui-bg: #121a1b;
106
109
  --ui-fg: #e6eded;
107
110
  --ui-muted: #9aa8a9;
@@ -146,6 +149,10 @@
146
149
  outline: 2px solid var(--ui-ring);
147
150
  outline-offset: 2px;
148
151
  }
152
+ /* A combobox's or chip input's box shows its focus: the input inside doesn't draw a second ring (~=: another part's name, not this one's). */
153
+ :where([data-part~='combobox'] [data-part~='input'], [data-part~='chip-input'] [data-part~='input']):focus-visible {
154
+ outline: none;
155
+ }
149
156
  /* end part */
150
157
 
151
158
  /* part: buttons */
@@ -176,8 +183,23 @@
176
183
  box-shadow: var(--ui-shadow);
177
184
  font: calc(var(--ui-font-size) + 1px)/1.5 var(--ui-font);
178
185
  }
186
+ /* The backdrop: a black scrim, dimmed by --ui-backdrop-opacity and blurred by --ui-backdrop-blur (it reads them from
187
+ its dialog). data-backdrop on the dialog picks a variant; set the knobs on :root for a site-wide default. */
179
188
  :where([data-part='dialog'])::backdrop {
180
- background: rgb(0 0 0 / 0.45);
189
+ background: rgb(0 0 0 / var(--ui-backdrop-opacity, 0.45));
190
+ backdrop-filter: blur(var(--ui-backdrop-blur, 0px));
191
+ }
192
+ :where([data-part='dialog'][data-backdrop='light']) {
193
+ --ui-backdrop-opacity: 0.2;
194
+ }
195
+ :where([data-part='dialog'][data-backdrop='dark']) {
196
+ --ui-backdrop-opacity: 0.7;
197
+ }
198
+ :where([data-part='dialog'][data-backdrop='blur']) {
199
+ --ui-backdrop-blur: 6px;
200
+ }
201
+ :where([data-part='dialog'][data-backdrop='none']) {
202
+ --ui-backdrop-opacity: 0;
181
203
  }
182
204
  :where([data-part='title']) {
183
205
  margin: 0 0 var(--ui-space-2);
@@ -563,26 +585,8 @@
563
585
  }
564
586
  /* end part */
565
587
 
566
- /* part: combobox */
567
- /* Combobox: chips in the control, a list below. */
568
- :where([data-part='combobox']) {
569
- display: grid;
570
- gap: var(--ui-space-1);
571
- max-width: 360px;
572
- font: var(--ui-font-size) var(--ui-font);
573
- color: var(--ui-fg);
574
- }
575
- :where([data-part='combobox']) > :where([data-part='control']) {
576
- display: flex;
577
- flex-wrap: wrap;
578
- align-items: center;
579
- gap: var(--ui-space-1);
580
- padding: calc(var(--ui-space) * 0.5) calc(var(--ui-space) * 1.5);
581
- }
582
- :where([data-part='combobox']) > :where([data-part='control']):focus-within {
583
- border-color: var(--ui-ring);
584
- box-shadow: 0 0 0 3px var(--ui-accent-soft);
585
- }
588
+ /* part: chips */
589
+ /* Chips in a control, beside the field you type in (combobox, chip input). */
586
590
  :where([data-part='input']) {
587
591
  flex: 1;
588
592
  min-width: 6ch;
@@ -612,6 +616,28 @@
612
616
  color: var(--ui-muted);
613
617
  cursor: pointer;
614
618
  }
619
+ /* end part */
620
+
621
+ /* part: combobox */
622
+ /* Combobox: chips in the control, a list below. */
623
+ :where([data-part='combobox']) {
624
+ display: grid;
625
+ gap: var(--ui-space-1);
626
+ max-width: 360px;
627
+ font: var(--ui-font-size) var(--ui-font);
628
+ color: var(--ui-fg);
629
+ }
630
+ :where([data-part='combobox']) > :where([data-part='control']) {
631
+ display: flex;
632
+ flex-wrap: wrap;
633
+ align-items: center;
634
+ gap: var(--ui-space-1);
635
+ padding: calc(var(--ui-space) * 0.5) calc(var(--ui-space) * 1.5);
636
+ }
637
+ :where([data-part='combobox']) > :where([data-part='control']):focus-within {
638
+ border-color: var(--ui-ring);
639
+ box-shadow: 0 0 0 3px var(--ui-accent-soft);
640
+ }
615
641
  :where([data-part='listbox']) {
616
642
  margin-top: var(--ui-space-1);
617
643
  padding: var(--ui-space-1);
@@ -654,6 +680,33 @@
654
680
  }
655
681
  /* end part */
656
682
 
683
+ /* part: chip-input */
684
+ /* Chip input: what's typed becomes a chip in the control; a hint below. */
685
+ :where([data-part='chip-input']) {
686
+ display: grid;
687
+ gap: var(--ui-space-1);
688
+ max-width: 360px;
689
+ font: var(--ui-font-size) var(--ui-font);
690
+ color: var(--ui-fg);
691
+ }
692
+ :where([data-part='chip-input']) > :where([data-part='control']) {
693
+ display: flex;
694
+ flex-wrap: wrap;
695
+ align-items: center;
696
+ gap: var(--ui-space-1);
697
+ padding: calc(var(--ui-space) * 0.5) calc(var(--ui-space) * 1.5);
698
+ }
699
+ :where([data-part='chip-input']) > :where([data-part='control']):focus-within {
700
+ border-color: var(--ui-ring);
701
+ box-shadow: 0 0 0 3px var(--ui-accent-soft);
702
+ }
703
+ :where([data-part='hint']) {
704
+ margin: 0;
705
+ color: var(--ui-muted);
706
+ font-size: calc(var(--ui-font-size) - 1px);
707
+ }
708
+ /* end part */
709
+
657
710
  /* part: sidebar */
658
711
  /* Sidebar: inline beside the page on wide screens (hidden when collapsed: its data-state, or data-sidebar on <html>
659
712
  from the remembered choice); on phones a popover panel from the left. */
@@ -811,6 +864,184 @@
811
864
  }
812
865
  /* end part */
813
866
 
867
+ /* part: editor */
868
+ /* @clarusjs/editor's parts, each on its own: the field (a textarea before the editor loads, the editable after: the
869
+ same box), the toolbar and its tools, the count, Send, the attach button, and the suggestion lists by the caret.
870
+ How they sit together (a chat composer's frame, a comment box's buttons) is the page's: see the blocks. */
871
+ /* The box is the field's top-level element (the textarea, then the editor's div), so a page restyles it with a class
872
+ on <editor-field>; the editable inside has the room and the scrolling. */
873
+ :where([data-part='editor']) {
874
+ box-sizing: border-box;
875
+ display: block;
876
+ width: 100%;
877
+ min-width: 0; /* in a grid or flex row, long content wraps instead of widening it */
878
+ border: 1px solid var(--ui-input);
879
+ border-radius: var(--ui-radius);
880
+ background: var(--ui-bg);
881
+ color: var(--ui-fg);
882
+ font-family: var(--ui-font);
883
+ font-size: var(--ui-font-size);
884
+ line-height: 1.5;
885
+ }
886
+ :where(textarea[data-part='editor']):focus-visible,
887
+ :where(div[data-part='editor']):focus-within {
888
+ outline: none;
889
+ border-color: var(--ui-ring);
890
+ box-shadow: 0 0 0 3px var(--ui-accent-soft);
891
+ }
892
+ :where(textarea[data-part='editor'], [data-part='editor'] > [role='textbox']) {
893
+ position: relative;
894
+ box-sizing: border-box;
895
+ width: 100%;
896
+ min-height: calc(var(--ui-space) * 16);
897
+ max-height: 40vh;
898
+ overflow-y: auto;
899
+ margin: 0;
900
+ padding: var(--ui-space-2) var(--ui-space-3);
901
+ color: inherit;
902
+ font-family: inherit;
903
+ font-size: inherit;
904
+ line-height: inherit;
905
+ resize: vertical;
906
+ white-space: pre-wrap;
907
+ overflow-wrap: anywhere;
908
+ }
909
+ :where([data-part='editor'] > [role='textbox']) {
910
+ outline: none; /* the box shows focus */
911
+ }
912
+ :where(textarea[data-part='editor'])::placeholder {
913
+ color: var(--ui-muted);
914
+ }
915
+ :where([data-part='editor'] > [role='textbox'][data-empty])::before {
916
+ content: attr(data-placeholder);
917
+ position: absolute;
918
+ inset: var(--ui-space-2) var(--ui-space-3) auto;
919
+ color: var(--ui-muted);
920
+ pointer-events: none;
921
+ }
922
+ :where([data-part='editor'] > [role='textbox']) :where(p) {
923
+ margin: 0;
924
+ }
925
+ :where([data-part='editor'] > [role='textbox']) :where(code) {
926
+ padding: 0 0.25em;
927
+ border-radius: calc(var(--ui-radius) / 2);
928
+ background: var(--ui-muted-bg);
929
+ font-family: var(--ui-font-mono);
930
+ font-size: calc(var(--ui-font-size) - 1px);
931
+ }
932
+ :where([data-part='editor'] > [role='textbox']) :where(pre) {
933
+ margin: var(--ui-space-1) 0;
934
+ padding: var(--ui-space-2);
935
+ border-radius: calc(var(--ui-radius) / 2);
936
+ background: var(--ui-muted-bg);
937
+ font-family: var(--ui-font-mono);
938
+ font-size: calc(var(--ui-font-size) - 1px);
939
+ white-space: pre-wrap; /* long lines wrap (a pre would set the editor's width) */
940
+ overflow-wrap: anywhere;
941
+ }
942
+ :where([data-part='editor'] > [role='textbox']) :where(pre code) {
943
+ padding: 0;
944
+ background: none;
945
+ }
946
+ :where([data-part='editor'] > [role='textbox']) :where(a) {
947
+ color: var(--ui-accent);
948
+ text-decoration: underline;
949
+ }
950
+ :where([data-mention]) {
951
+ padding: 0 0.2em;
952
+ border-radius: calc(var(--ui-radius) / 2);
953
+ background: var(--ui-accent-soft);
954
+ color: var(--ui-accent-soft-fg);
955
+ font-weight: 600;
956
+ }
957
+ :where([data-part='toolbar']) {
958
+ display: flex;
959
+ flex-wrap: wrap;
960
+ gap: var(--ui-space-1);
961
+ }
962
+ :where([data-part='tool'], [data-part='attach']) {
963
+ min-width: var(--ui-control-sm);
964
+ height: var(--ui-control-sm);
965
+ padding: 0 var(--ui-space-1);
966
+ border: 0;
967
+ border-radius: calc(var(--ui-radius) - 2px);
968
+ background: transparent;
969
+ color: var(--ui-muted);
970
+ font-family: var(--ui-font);
971
+ font-size: var(--ui-font-size);
972
+ font-weight: 600;
973
+ cursor: pointer;
974
+ }
975
+ :where([data-part='tool'], [data-part='attach']):hover {
976
+ background: var(--ui-muted-bg);
977
+ color: var(--ui-fg);
978
+ }
979
+ :where([data-part='tool'])[aria-pressed='true'] {
980
+ background: var(--ui-accent-soft);
981
+ color: var(--ui-accent-soft-fg);
982
+ box-shadow: inset 0 -2px 0 var(--ui-accent); /* not by colour alone */
983
+ }
984
+ :where([data-part='tool']):disabled {
985
+ opacity: 0.4;
986
+ cursor: not-allowed;
987
+ }
988
+ :where([data-part='files'])[hidden] {
989
+ display: none;
990
+ }
991
+ :where([data-part='count']) {
992
+ color: var(--ui-muted);
993
+ font-size: calc(var(--ui-font-size) - 1px);
994
+ font-variant-numeric: tabular-nums;
995
+ }
996
+ :where([data-part='count'])[data-over] {
997
+ color: var(--ui-danger);
998
+ font-weight: 600;
999
+ }
1000
+ :where([data-part='send']) {
1001
+ height: var(--ui-control-sm);
1002
+ padding: 0 var(--ui-space-3);
1003
+ border: 0;
1004
+ border-radius: calc(var(--ui-radius) - 2px);
1005
+ background: var(--ui-accent);
1006
+ color: var(--ui-accent-fg);
1007
+ font-family: var(--ui-font);
1008
+ font-size: var(--ui-font-size);
1009
+ font-weight: 600;
1010
+ cursor: pointer;
1011
+ }
1012
+ :where([data-part='send']):disabled {
1013
+ opacity: 0.55;
1014
+ cursor: not-allowed;
1015
+ }
1016
+ /* No display here: the behaviour shows and hides the list with the hidden attribute. */
1017
+ :where([data-part='suggestions']) {
1018
+ z-index: 50;
1019
+ min-width: 200px;
1020
+ max-width: calc(100vw - var(--ui-space-8));
1021
+ max-height: 240px;
1022
+ overflow-y: auto;
1023
+ margin: 0;
1024
+ padding: var(--ui-space-1);
1025
+ list-style: none;
1026
+ border: 1px solid var(--ui-border);
1027
+ border-radius: var(--ui-radius);
1028
+ background: var(--ui-popover);
1029
+ color: var(--ui-popover-fg);
1030
+ box-shadow: var(--ui-shadow);
1031
+ font-family: var(--ui-font);
1032
+ font-size: var(--ui-font-size);
1033
+ }
1034
+ :where([data-part='suggestion']) {
1035
+ padding: var(--ui-space-1) var(--ui-space-2);
1036
+ border-radius: calc(var(--ui-radius) - 2px);
1037
+ cursor: pointer;
1038
+ }
1039
+ :where([data-part='suggestion'])[aria-selected='true'] {
1040
+ background: var(--ui-accent-soft);
1041
+ color: var(--ui-accent-soft-fg);
1042
+ }
1043
+ /* end part */
1044
+
814
1045
  /* part: motion */
815
1046
  @media (prefers-reduced-motion: reduce) {
816
1047
  :where([data-part]),