@clarusjs/ui 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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/ui.css +178 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clarusjs/ui",
3
- "version": "0.3.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.3.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.3.0",
38
+ "@clarusjs/ui-primitives": "^0.3.1",
39
39
  "vitest": "^5.1.1"
40
40
  },
41
41
  "scripts": {
package/src/ui.css CHANGED
@@ -864,6 +864,184 @@
864
864
  }
865
865
  /* end part */
866
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
+
867
1045
  /* part: motion */
868
1046
  @media (prefers-reduced-motion: reduce) {
869
1047
  :where([data-part]),