godown 3.10.1 → 3.11.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 (293) hide show
  1. package/README.md +2 -63
  2. package/alert.d.ts.map +1 -1
  3. package/avatar.d.ts.map +1 -1
  4. package/badge.d.ts.map +1 -1
  5. package/breath.d.ts.map +1 -1
  6. package/build/godown+lit.iife.js +14 -14
  7. package/build/godown+lit.iife.js.map +1 -1
  8. package/build/godown+lit.js +14 -14
  9. package/build/godown+lit.js.map +1 -1
  10. package/build/godown+lit.umd.js +14 -14
  11. package/build/godown+lit.umd.js.map +1 -1
  12. package/build/godown.iife.js +9 -9
  13. package/build/godown.js +7 -7
  14. package/build/godown.js.map +1 -1
  15. package/build/godown.umd.js +10 -10
  16. package/build/godown.umd.js.map +1 -1
  17. package/button.d.ts.map +1 -1
  18. package/card.d.ts.map +1 -1
  19. package/carousel.d.ts.map +1 -1
  20. package/chip.d.ts +2 -0
  21. package/chip.d.ts.map +1 -0
  22. package/chip.js +2 -0
  23. package/chip.js.map +1 -0
  24. package/custom-elements.json +1 -1
  25. package/details.d.ts.map +1 -1
  26. package/dialog.d.ts.map +1 -1
  27. package/divider.d.ts.map +1 -1
  28. package/dragbox.d.ts.map +1 -1
  29. package/flex.d.ts.map +1 -1
  30. package/form.d.ts.map +1 -1
  31. package/grid.d.ts.map +1 -1
  32. package/heading.d.ts.map +1 -1
  33. package/index.d.ts +1 -0
  34. package/index.d.ts.map +1 -1
  35. package/index.js +1 -1
  36. package/input.d.ts.map +1 -1
  37. package/internal/direction.d.ts.map +1 -1
  38. package/internal/direction.js.map +1 -1
  39. package/internal/global-style.d.ts +8 -9
  40. package/internal/global-style.d.ts.map +1 -1
  41. package/internal/global-style.js +1 -1
  42. package/internal/global-style.js.map +1 -1
  43. package/internal/icons/caret-down.d.ts +4 -0
  44. package/internal/icons/caret-down.d.ts.map +1 -0
  45. package/internal/icons/caret-down.js +2 -0
  46. package/internal/icons/caret-down.js.map +1 -0
  47. package/internal/icons/caret-left.d.ts +4 -0
  48. package/internal/icons/caret-left.d.ts.map +1 -0
  49. package/internal/icons/caret-left.js +2 -0
  50. package/internal/icons/caret-left.js.map +1 -0
  51. package/internal/icons/caret-right.d.ts +4 -0
  52. package/internal/icons/caret-right.d.ts.map +1 -0
  53. package/internal/icons/caret-right.js +2 -0
  54. package/internal/icons/caret-right.js.map +1 -0
  55. package/internal/icons/eye-slash.d.ts +4 -0
  56. package/internal/icons/eye-slash.d.ts.map +1 -0
  57. package/internal/icons/eye-slash.js +2 -0
  58. package/internal/icons/eye-slash.js.map +1 -0
  59. package/internal/ring.d.ts +19 -0
  60. package/internal/ring.d.ts.map +1 -0
  61. package/internal/ring.js +2 -0
  62. package/internal/ring.js.map +1 -0
  63. package/internal/super-input.d.ts +2 -2
  64. package/internal/super-input.d.ts.map +1 -1
  65. package/internal/super-input.js +1 -1
  66. package/internal/super-input.js.map +1 -1
  67. package/internal/super-openable.d.ts.map +1 -1
  68. package/internal/super-openable.js.map +1 -1
  69. package/layout.d.ts.map +1 -1
  70. package/link.d.ts.map +1 -1
  71. package/package.json +3 -5
  72. package/progress.d.ts.map +1 -1
  73. package/range.d.ts.map +1 -1
  74. package/rotate.d.ts.map +1 -1
  75. package/router.d.ts.map +1 -1
  76. package/select.d.ts.map +1 -1
  77. package/skeleton.d.ts.map +1 -1
  78. package/split.d.ts.map +1 -1
  79. package/src/chip.ts +1 -0
  80. package/src/index.ts +1 -0
  81. package/src/internal/global-style.ts +40 -37
  82. package/src/internal/icons/caret-down.ts +7 -0
  83. package/src/internal/icons/caret-left.ts +7 -0
  84. package/src/internal/icons/caret-right.ts +7 -0
  85. package/src/internal/icons/eye-slash.ts +7 -0
  86. package/src/internal/ring.ts +57 -0
  87. package/src/internal/super-input.ts +9 -70
  88. package/src/web-components/alert/component.ts +16 -195
  89. package/src/web-components/badge/component.ts +7 -96
  90. package/src/web-components/breath/component.ts +8 -8
  91. package/src/web-components/button/component.ts +9 -139
  92. package/src/web-components/card/component.ts +11 -6
  93. package/src/web-components/carousel/component.ts +6 -6
  94. package/src/web-components/chip/component.ts +115 -0
  95. package/src/web-components/chip/definition.ts +11 -0
  96. package/src/web-components/details/component.ts +1 -1
  97. package/src/web-components/divider/component.ts +2 -17
  98. package/src/web-components/heading/component.ts +12 -16
  99. package/src/web-components/input/component.ts +87 -39
  100. package/src/web-components/link/component.ts +53 -3
  101. package/src/web-components/progress/component.ts +2 -1
  102. package/src/web-components/range/component.ts +19 -25
  103. package/src/web-components/rotate/component.ts +2 -2
  104. package/src/web-components/select/component.ts +14 -18
  105. package/src/web-components/select/definition.ts +1 -1
  106. package/src/web-components/skeleton/component.ts +13 -57
  107. package/src/web-components/split/component.ts +16 -14
  108. package/src/web-components/switch/component.ts +4 -7
  109. package/src/web-components/tabs/component.ts +11 -8
  110. package/src/web-components/text/component.ts +2 -2
  111. package/switch.d.ts.map +1 -1
  112. package/tabs.d.ts.map +1 -1
  113. package/text.d.ts.map +1 -1
  114. package/time.d.ts.map +1 -1
  115. package/tooltip.d.ts.map +1 -1
  116. package/typewriter.d.ts.map +1 -1
  117. package/vscode.html-custom-data.json +1 -1
  118. package/web-components/alert/component.d.ts +5 -32
  119. package/web-components/alert/component.d.ts.map +1 -1
  120. package/web-components/alert/component.js +1 -1
  121. package/web-components/alert/component.js.map +1 -1
  122. package/web-components/alert/definition.d.ts.map +1 -1
  123. package/web-components/alert/definition.js.map +1 -1
  124. package/web-components/avatar/component.d.ts.map +1 -1
  125. package/web-components/avatar/component.js.map +1 -1
  126. package/web-components/avatar/definition.d.ts.map +1 -1
  127. package/web-components/avatar/definition.js.map +1 -1
  128. package/web-components/badge/component.d.ts +4 -21
  129. package/web-components/badge/component.d.ts.map +1 -1
  130. package/web-components/badge/component.js +1 -1
  131. package/web-components/badge/component.js.map +1 -1
  132. package/web-components/badge/definition.d.ts.map +1 -1
  133. package/web-components/badge/definition.js.map +1 -1
  134. package/web-components/breath/component.d.ts.map +1 -1
  135. package/web-components/breath/component.js +1 -1
  136. package/web-components/breath/component.js.map +1 -1
  137. package/web-components/breath/definition.d.ts.map +1 -1
  138. package/web-components/breath/definition.js.map +1 -1
  139. package/web-components/button/component.d.ts +0 -18
  140. package/web-components/button/component.d.ts.map +1 -1
  141. package/web-components/button/component.js +1 -1
  142. package/web-components/button/component.js.map +1 -1
  143. package/web-components/button/definition.d.ts.map +1 -1
  144. package/web-components/button/definition.js.map +1 -1
  145. package/web-components/card/component.d.ts +3 -0
  146. package/web-components/card/component.d.ts.map +1 -1
  147. package/web-components/card/component.js +1 -1
  148. package/web-components/card/component.js.map +1 -1
  149. package/web-components/card/definition.d.ts.map +1 -1
  150. package/web-components/card/definition.js.map +1 -1
  151. package/web-components/carousel/component.d.ts.map +1 -1
  152. package/web-components/carousel/component.js +1 -1
  153. package/web-components/carousel/component.js.map +1 -1
  154. package/web-components/carousel/definition.d.ts.map +1 -1
  155. package/web-components/carousel/definition.js.map +1 -1
  156. package/web-components/chip/component.d.ts +31 -0
  157. package/web-components/chip/component.d.ts.map +1 -0
  158. package/web-components/chip/component.js +2 -0
  159. package/web-components/chip/component.js.map +1 -0
  160. package/web-components/chip/definition.d.ts +8 -0
  161. package/web-components/chip/definition.d.ts.map +1 -0
  162. package/web-components/chip/definition.js +2 -0
  163. package/web-components/chip/definition.js.map +1 -0
  164. package/web-components/details/component.d.ts.map +1 -1
  165. package/web-components/details/component.js +1 -1
  166. package/web-components/details/component.js.map +1 -1
  167. package/web-components/details/definition.d.ts.map +1 -1
  168. package/web-components/details/definition.js.map +1 -1
  169. package/web-components/dialog/component.d.ts.map +1 -1
  170. package/web-components/dialog/component.js.map +1 -1
  171. package/web-components/dialog/definition.d.ts.map +1 -1
  172. package/web-components/dialog/definition.js.map +1 -1
  173. package/web-components/divider/component.d.ts.map +1 -1
  174. package/web-components/divider/component.js +1 -1
  175. package/web-components/divider/component.js.map +1 -1
  176. package/web-components/divider/definition.d.ts.map +1 -1
  177. package/web-components/divider/definition.js.map +1 -1
  178. package/web-components/dragbox/component.d.ts.map +1 -1
  179. package/web-components/dragbox/component.js.map +1 -1
  180. package/web-components/dragbox/definition.d.ts.map +1 -1
  181. package/web-components/dragbox/definition.js.map +1 -1
  182. package/web-components/flex/component.d.ts.map +1 -1
  183. package/web-components/flex/component.js.map +1 -1
  184. package/web-components/flex/definition.d.ts.map +1 -1
  185. package/web-components/flex/definition.js.map +1 -1
  186. package/web-components/form/component.d.ts.map +1 -1
  187. package/web-components/form/component.js.map +1 -1
  188. package/web-components/form/definition.d.ts.map +1 -1
  189. package/web-components/form/definition.js.map +1 -1
  190. package/web-components/grid/component.d.ts.map +1 -1
  191. package/web-components/grid/component.js.map +1 -1
  192. package/web-components/grid/definition.d.ts.map +1 -1
  193. package/web-components/grid/definition.js.map +1 -1
  194. package/web-components/heading/component.d.ts +2 -2
  195. package/web-components/heading/component.d.ts.map +1 -1
  196. package/web-components/heading/component.js +1 -1
  197. package/web-components/heading/component.js.map +1 -1
  198. package/web-components/heading/definition.d.ts.map +1 -1
  199. package/web-components/heading/definition.js.map +1 -1
  200. package/web-components/input/component.d.ts +3 -3
  201. package/web-components/input/component.d.ts.map +1 -1
  202. package/web-components/input/component.js +1 -1
  203. package/web-components/input/component.js.map +1 -1
  204. package/web-components/input/definition.d.ts.map +1 -1
  205. package/web-components/input/definition.js.map +1 -1
  206. package/web-components/layout/component.d.ts.map +1 -1
  207. package/web-components/layout/component.js.map +1 -1
  208. package/web-components/layout/definition.d.ts.map +1 -1
  209. package/web-components/layout/definition.js.map +1 -1
  210. package/web-components/link/component.d.ts +13 -2
  211. package/web-components/link/component.d.ts.map +1 -1
  212. package/web-components/link/component.js +1 -1
  213. package/web-components/link/component.js.map +1 -1
  214. package/web-components/link/definition.d.ts.map +1 -1
  215. package/web-components/link/definition.js.map +1 -1
  216. package/web-components/progress/component.d.ts.map +1 -1
  217. package/web-components/progress/component.js +1 -1
  218. package/web-components/progress/component.js.map +1 -1
  219. package/web-components/progress/definition.d.ts.map +1 -1
  220. package/web-components/progress/definition.js.map +1 -1
  221. package/web-components/range/component.d.ts.map +1 -1
  222. package/web-components/range/component.js +1 -1
  223. package/web-components/range/component.js.map +1 -1
  224. package/web-components/range/definition.d.ts.map +1 -1
  225. package/web-components/range/definition.js.map +1 -1
  226. package/web-components/rotate/component.d.ts.map +1 -1
  227. package/web-components/rotate/component.js +1 -1
  228. package/web-components/rotate/component.js.map +1 -1
  229. package/web-components/rotate/definition.d.ts.map +1 -1
  230. package/web-components/rotate/definition.js.map +1 -1
  231. package/web-components/router/component.d.ts.map +1 -1
  232. package/web-components/router/component.js.map +1 -1
  233. package/web-components/router/definition.d.ts.map +1 -1
  234. package/web-components/router/definition.js.map +1 -1
  235. package/web-components/select/component.d.ts +2 -1
  236. package/web-components/select/component.d.ts.map +1 -1
  237. package/web-components/select/component.js +1 -1
  238. package/web-components/select/component.js.map +1 -1
  239. package/web-components/select/definition.d.ts +1 -1
  240. package/web-components/select/definition.d.ts.map +1 -1
  241. package/web-components/select/definition.js.map +1 -1
  242. package/web-components/skeleton/component.d.ts +0 -9
  243. package/web-components/skeleton/component.d.ts.map +1 -1
  244. package/web-components/skeleton/component.js +1 -1
  245. package/web-components/skeleton/component.js.map +1 -1
  246. package/web-components/skeleton/definition.d.ts.map +1 -1
  247. package/web-components/skeleton/definition.js.map +1 -1
  248. package/web-components/split/component.d.ts +1 -1
  249. package/web-components/split/component.d.ts.map +1 -1
  250. package/web-components/split/component.js +1 -1
  251. package/web-components/split/component.js.map +1 -1
  252. package/web-components/split/definition.d.ts.map +1 -1
  253. package/web-components/split/definition.js.map +1 -1
  254. package/web-components/switch/component.d.ts.map +1 -1
  255. package/web-components/switch/component.js +1 -1
  256. package/web-components/switch/component.js.map +1 -1
  257. package/web-components/switch/definition.d.ts.map +1 -1
  258. package/web-components/switch/definition.js.map +1 -1
  259. package/web-components/tabs/component.d.ts +3 -3
  260. package/web-components/tabs/component.d.ts.map +1 -1
  261. package/web-components/tabs/component.js +1 -1
  262. package/web-components/tabs/component.js.map +1 -1
  263. package/web-components/tabs/definition.d.ts.map +1 -1
  264. package/web-components/tabs/definition.js.map +1 -1
  265. package/web-components/text/component.d.ts +1 -1
  266. package/web-components/text/component.d.ts.map +1 -1
  267. package/web-components/text/component.js +1 -1
  268. package/web-components/text/component.js.map +1 -1
  269. package/web-components/text/definition.d.ts.map +1 -1
  270. package/web-components/text/definition.js.map +1 -1
  271. package/web-components/time/component.d.ts.map +1 -1
  272. package/web-components/time/component.js.map +1 -1
  273. package/web-components/time/definition.d.ts.map +1 -1
  274. package/web-components/time/definition.js.map +1 -1
  275. package/web-components/tooltip/component.d.ts.map +1 -1
  276. package/web-components/tooltip/component.js.map +1 -1
  277. package/web-components/tooltip/definition.d.ts.map +1 -1
  278. package/web-components/tooltip/definition.js.map +1 -1
  279. package/web-components/typewriter/component.d.ts.map +1 -1
  280. package/web-components/typewriter/component.js.map +1 -1
  281. package/web-components/typewriter/definition.d.ts.map +1 -1
  282. package/web-components/typewriter/definition.js.map +1 -1
  283. package/web-types.json +1 -1
  284. package/internal/outline.d.ts +0 -19
  285. package/internal/outline.d.ts.map +0 -1
  286. package/internal/outline.js +0 -2
  287. package/internal/outline.js.map +0 -1
  288. package/internal/super-anchor.d.ts +0 -18
  289. package/internal/super-anchor.d.ts.map +0 -1
  290. package/internal/super-anchor.js +0 -2
  291. package/internal/super-anchor.js.map +0 -1
  292. package/src/internal/outline.ts +0 -58
  293. package/src/internal/super-anchor.ts +0 -60
@@ -1,4 +1,4 @@
1
- import { attr, godown, htmlSlot, joinRules, part, StyleController, styles } from "@godown/element";
1
+ import { attr, godown, htmlSlot, queryPart, styles } from "@godown/element";
2
2
  import { type TemplateResult, css, html } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
@@ -7,92 +7,11 @@ import { GlobalStyle, cssGlobalVars, scopePrefix } from "../../internal/global-s
7
7
  const protoName = "button";
8
8
  const cssScope = scopePrefix(protoName);
9
9
 
10
- const whiteFont = cssGlobalVars.white;
11
- const blackFont = cssGlobalVars.black;
12
-
13
- type Colors =
14
- | "none"
15
- | "teal"
16
- | "blue"
17
- | "green"
18
- | "red"
19
- | "purple"
20
- | "orange"
21
- | "yellow"
22
- | "pink"
23
- | "gray"
24
- | "white"
25
- | "black";
26
-
27
- const colorDetails = {
28
- black: [
29
- whiteFont, // color
30
- cssGlobalVars._colors.darkgray[7], // background
31
- cssGlobalVars._colors.darkgray[5], // gradients
32
- ],
33
- gray: [
34
- whiteFont, // color
35
- cssGlobalVars._colors.darkgray[1], // background
36
- cssGlobalVars._colors.lightgray[8], // gradients
37
- ],
38
- white: [
39
- blackFont, // color
40
- cssGlobalVars._colors.lightgray[3], // background
41
- cssGlobalVars._colors.lightgray[0], // gradients
42
- ],
43
- blue: [
44
- whiteFont, // color
45
- cssGlobalVars._colors.blue[6], // background
46
- cssGlobalVars._colors.blue[4], // gradients
47
- ],
48
- green: [
49
- whiteFont, // color
50
- cssGlobalVars._colors.green[6], // background
51
- cssGlobalVars._colors.green[4], // gradients
52
- ],
53
- red: [
54
- whiteFont, // color
55
- cssGlobalVars._colors.red[6], // background
56
- cssGlobalVars._colors.red[4], // gradients
57
- ],
58
- orange: [
59
- whiteFont, // color
60
- cssGlobalVars._colors.orange[6], // background
61
- cssGlobalVars._colors.orange[4], // gradients
62
- ],
63
- pink: [
64
- whiteFont, // color
65
- cssGlobalVars._colors.pink[6], // background
66
- cssGlobalVars._colors.pink[4], // gradients
67
- ],
68
- purple: [
69
- whiteFont, // color
70
- cssGlobalVars._colors.purple[6], // background
71
- cssGlobalVars._colors.purple[4], // gradients
72
- ],
73
- yellow: [
74
- blackFont, // color
75
- cssGlobalVars._colors.yellow[6], // background
76
- cssGlobalVars._colors.yellow[4], // gradients
77
- ],
78
- teal: [
79
- whiteFont, // color
80
- cssGlobalVars._colors.teal[6], // background
81
- cssGlobalVars._colors.teal[4], // gradients
82
- ],
83
- };
84
-
85
10
  /**
86
11
  * {@linkcode Button} renders a button.
87
12
  *
88
13
  * Create modal animation upon clicking.
89
14
  *
90
- * Available colors (background): none, black, gray, white, blue, green, red, orange, pink, purple, yellow, teal.
91
- *
92
- * Default color is `black`.
93
- *
94
- * Set the color to `none` to prevent applying styles.
95
- *
96
15
  * @slot - The content of the button.
97
16
  * @category input
98
17
  */
@@ -112,13 +31,6 @@ const colorDetails = {
112
31
  filter: brightness(0.85);
113
32
  }
114
33
 
115
- :host([ghost]) {
116
- ${cssScope}--modal-background: var(${cssScope}--ghost-color);
117
- box-shadow: inset 0px 0px 0px var(${cssScope}--ghost-width) var(${cssScope}--ghost-color);
118
- color: var(${cssScope}--ghost-color);
119
- background: transparent;
120
- }
121
-
122
34
  :host([plain]) {
123
35
  ${cssScope}--gradients: unset;
124
36
  ${cssScope}--focus-scale: unset;
@@ -126,21 +38,14 @@ const colorDetails = {
126
38
  `,
127
39
  css`
128
40
  :host {
129
- ${cssScope}--padding-x: .8em;
130
- ${cssScope}--padding-y: calc(var(${cssScope}--padding-x) / 4);
131
- ${cssScope}--padding: var(${cssScope}--padding-y) var(${cssScope}--padding-x);
132
- ${cssScope}--modal-animation-duration: 1s;
133
- ${cssScope}--ghost-width: .08em;
41
+ ${cssScope}--modal-animation-duration: 1.5s;
134
42
  ${cssScope}--focus-scale: .97;
135
43
  ${cssScope}--deg: 45deg;
136
- ${cssScope}--ghost-color:var(${cssScope}--background);
137
- color: var(${cssScope}--color, inherit);
138
- background: linear-gradient(
139
- var(${cssScope}--deg),
140
- var(${cssScope}--background),
141
- var(${cssScope}--gradients, var(${cssScope}--background))
142
- );
143
- padding: var(${cssScope}--padding);
44
+ color: var(${cssGlobalVars.primaryForeground});
45
+ background: var(${cssGlobalVars.primaryBackground});
46
+ padding: 0.25em 0.75em;
47
+ border-width: var(${cssGlobalVars.ringWidth});
48
+ border-style: none;
144
49
  width: fit-content;
145
50
  display: block;
146
51
  overflow: hidden;
@@ -155,10 +60,7 @@ const colorDetails = {
155
60
 
156
61
  [part="root"] {
157
62
  position: relative;
158
- transition: none;
159
63
  user-select: none;
160
- border-radius: inherit;
161
- transition-duration: inherit;
162
64
  }
163
65
 
164
66
  i {
@@ -190,21 +92,6 @@ const colorDetails = {
190
92
  `,
191
93
  )
192
94
  class Button extends GlobalStyle {
193
- private __colorSC = new StyleController(this, () => {
194
- const color = this.nextColor();
195
- if (color in colorDetails) {
196
- const [fg, bg, gd] = colorDetails[color];
197
- return joinRules({
198
- ":host": [
199
- [`${cssScope}--color`, `var(${fg})`],
200
- [`${cssScope}--background`, `var(${bg})`],
201
- [`${cssScope}--gradients`, `var(${gd})`],
202
- ],
203
- });
204
- }
205
- return null;
206
- });
207
-
208
95
  /**
209
96
  * If true, remove gradient, modal animation, focus scale.
210
97
  */
@@ -217,13 +104,6 @@ class Button extends GlobalStyle {
217
104
  @property({ type: Boolean, reflect: true })
218
105
  disabled = false;
219
106
 
220
- /**
221
- * Whether this element should be rendered as a "ghost" button.
222
- * A ghost button is a button with a transparent background and a border.
223
- */
224
- @property({ type: Boolean, reflect: true })
225
- ghost = false;
226
-
227
107
  /**
228
108
  * Whether this element is active or not.
229
109
  */
@@ -236,21 +116,15 @@ class Button extends GlobalStyle {
236
116
  @property({ type: Boolean, reflect: true })
237
117
  round = false;
238
118
 
239
- /**
240
- * The primary color.
241
- */
242
- @property({ reflect: true })
243
- color: Colors = "black";
244
-
245
119
  /**
246
120
  * Content text.
247
121
  */
248
122
  @property()
249
123
  content: string;
250
124
 
251
- @part("modal-root")
125
+ @queryPart("modal-root")
252
126
  protected _modalRoot: HTMLElement;
253
- @part("root")
127
+ @queryPart("root")
254
128
  protected _root: HTMLElement;
255
129
 
256
130
  protected render(): TemplateResult<1> {
@@ -307,10 +181,6 @@ class Button extends GlobalStyle {
307
181
  this._modalRoot.appendChild(modal);
308
182
  modal.addEventListener("animationend", () => modal.remove(), { once: true });
309
183
  }
310
-
311
- nextColor(): Colors {
312
- return this.color;
313
- }
314
184
  }
315
185
 
316
186
  export default Button;
@@ -1,9 +1,10 @@
1
- import { attr, godown, htmlSlot, styles } from "@godown/element";
1
+ import { attr, godown, htmlSlot, StyleController, styles } from "@godown/element";
2
2
  import { type TemplateResult, css, html } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
5
5
  import { GlobalStyle, cssGlobalVars, scopePrefix } from "../../internal/global-style.js";
6
6
  import type Layout from "../layout/component.js";
7
+ import { RingBuilder, type RingType } from "../../internal/ring.js";
7
8
 
8
9
  const protoName = "card";
9
10
  const cssScope = scopePrefix(protoName);
@@ -22,9 +23,8 @@ const cssScope = scopePrefix(protoName);
22
23
  @godown(protoName)
23
24
  @styles(css`
24
25
  :host {
25
- ${cssScope}--border-width: .075em;
26
- ${cssScope}--border-color: var(${cssGlobalVars.passive});
27
26
  ${cssScope}--padding: .75em;
27
+ background: var(${cssGlobalVars.background});
28
28
  display: block;
29
29
  flex-shrink: 0;
30
30
  }
@@ -35,9 +35,6 @@ const cssScope = scopePrefix(protoName);
35
35
  }
36
36
 
37
37
  [part="root"] {
38
- border-color: var(${cssScope}--border-color);
39
- border-style: solid;
40
- border-width: var(${cssScope}--border-width);
41
38
  border-radius: inherit;
42
39
  }
43
40
 
@@ -50,6 +47,14 @@ const cssScope = scopePrefix(protoName);
50
47
  }
51
48
  `)
52
49
  class Card extends GlobalStyle {
50
+ constructor() {
51
+ super();
52
+ new StyleController(this, () => new RingBuilder({ type: this.ringType }).css);
53
+ }
54
+
55
+ @property({ attribute: "ring-type" })
56
+ ringType: RingType = "border";
57
+
53
58
  /**
54
59
  * Whether to display the header.
55
60
  */
@@ -1,6 +1,6 @@
1
- import { attr, godown, htmlSlot, part, styles } from "@godown/element";
2
- import iconChevronLeft from "@godown/f7-icon/icons/chevron-left.js";
3
- import iconChevronRight from "@godown/f7-icon/icons/chevron-right.js";
1
+ import { attr, godown, htmlSlot, queryPart, styles } from "@godown/element";
2
+ import iconCaretLeft from "../../internal/icons/caret-left.js";
3
+ import iconCaretRight from "../../internal/icons/caret-right.js";
4
4
  import { type TemplateResult, css, html } from "lit";
5
5
  import { property } from "lit/decorators.js";
6
6
 
@@ -80,7 +80,7 @@ class Carousel extends GlobalStyle {
80
80
  @property({ type: Number })
81
81
  autoChange = 0;
82
82
 
83
- @part("move-root")
83
+ @queryPart("move-root")
84
84
  protected _moveRoot: HTMLElement;
85
85
 
86
86
  intervalID: number;
@@ -101,14 +101,14 @@ class Carousel extends GlobalStyle {
101
101
  part="prev"
102
102
  @click="${this.prev}"
103
103
  >
104
- ${iconChevronLeft()}
104
+ ${iconCaretLeft()}
105
105
  </i>
106
106
  <div part="move-root">${htmlSlot()}</div>
107
107
  <i
108
108
  part="next"
109
109
  @click="${this.next}"
110
110
  >
111
- ${iconChevronRight()}
111
+ ${iconCaretRight()}
112
112
  </i>
113
113
  </div>
114
114
  `;
@@ -0,0 +1,115 @@
1
+ import { attr, godown, htmlSlot, styles } from "@godown/element";
2
+ import { type TemplateResult, css, html } from "lit";
3
+ import { property } from "lit/decorators.js";
4
+
5
+ import { GlobalStyle, cssGlobalVars, scopePrefix } from "../../internal/global-style.js";
6
+ import type { DirectionCorner } from "../../internal/direction.js";
7
+
8
+ const protoName = "chip";
9
+ const cssScope = scopePrefix(protoName);
10
+
11
+ /**
12
+ * {@linkcode Chip} renders a chip.
13
+ *
14
+ * @slot - Chip content.
15
+ * @category display
16
+ */
17
+ @godown(protoName)
18
+ @styles(css`
19
+ :host {
20
+ ${cssScope}--offset: 0%;
21
+ ${cssScope}--offset-x: var(${cssScope}--offset);
22
+ ${cssScope}--offset-y: var(${cssScope}--offset);
23
+ }
24
+
25
+ :host,
26
+ :host([contents]) [part="root"] {
27
+ display: inline-block;
28
+ }
29
+
30
+ [part="root"] {
31
+ position: relative;
32
+ }
33
+
34
+ [part="chip"] {
35
+ position: absolute;
36
+ font-size: 75%;
37
+ padding: 0 0.5em;
38
+ user-select: none;
39
+ border-radius: calc(infinity * 1px);
40
+ transform: translate(-50%, -50%);
41
+ color: var(${cssGlobalVars.primaryForeground});
42
+ background: var(${cssGlobalVars.primaryBackground});
43
+ }
44
+
45
+ [part="chip"]:empty {
46
+ width: 0.5em;
47
+ height: 0.5em;
48
+ font-size: 100%;
49
+ padding: 0;
50
+ border-radius: 50%;
51
+ }
52
+
53
+ [position^="top"] [part="chip"] {
54
+ top: calc(0% + var(${cssScope}--offset-y));
55
+ }
56
+
57
+ [position$="right"] [part="chip"] {
58
+ left: calc(100% - var(${cssScope}--offset-x));
59
+ }
60
+
61
+ [position^="bottom"] [part="chip"] {
62
+ top: calc(100% - var(${cssScope}--offset-y));
63
+ }
64
+
65
+ [position$="left"] [part="chip"] {
66
+ left: calc(0% + var(${cssScope}--offset-x));
67
+ }
68
+ `)
69
+ class Chip extends GlobalStyle {
70
+ /**
71
+ * The position of the chip relative to its parent element.
72
+ * Possible values are `"top-left"`, `"top-right"`, `"bottom-left"`, and `"bottom-right"`.
73
+ */
74
+ @property()
75
+ position: DirectionCorner = "top-right";
76
+
77
+ @property({ type: Number })
78
+ value = 0;
79
+
80
+ /**
81
+ * If `true`, render a dot chip.
82
+ */
83
+ @property({ type: Boolean })
84
+ dot = false;
85
+
86
+ /**
87
+ * The maximum value that can be displayed in the chip
88
+ * Values greater than this will be displayed as `max+` by default.
89
+ */
90
+ @property({ type: Number })
91
+ max = 99;
92
+
93
+ formatValue(value: number): string {
94
+ return value > this.max ? this.max + "+" : value + "";
95
+ }
96
+
97
+ render(): TemplateResult<1> {
98
+ return html`
99
+ <div
100
+ part="root"
101
+ ${attr(this.observedRecord)}
102
+ >
103
+ ${htmlSlot()}
104
+ ${this.value || this.dot
105
+ ? html`
106
+ <div part="chip">${this.dot ? "" : this.formatValue(this.value)}</div>
107
+ `
108
+ : ""}
109
+ </div>
110
+ `;
111
+ }
112
+ }
113
+
114
+ export default Chip;
115
+ export { Chip };
@@ -0,0 +1,11 @@
1
+ import Chip from "./component.js";
2
+
3
+ Chip.define();
4
+
5
+ export default Chip;
6
+
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ "godown-chip": Chip;
10
+ }
11
+ }
@@ -1,5 +1,5 @@
1
1
  import { attr, godown, htmlSlot, styles } from "@godown/element";
2
- import svgCaretDown from "@godown/f7-icon/icons/chevron-down.js";
2
+ import svgCaretDown from "../../internal/icons/caret-down.js";
3
3
  import { type TemplateResult, css, html } from "lit";
4
4
  import { property } from "lit/decorators.js";
5
5
 
@@ -1,4 +1,4 @@
1
- import { attr, godown, styles } from "@godown/element";
1
+ import { godown, styles } from "@godown/element";
2
2
  import { type TemplateResult, css, html } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
@@ -25,18 +25,6 @@ const protoName = "divider";
25
25
  width: 0.05em;
26
26
  height: 100%;
27
27
  }
28
-
29
- :host([contents]) [part="root"] {
30
- width: 100%;
31
- height: 0.05em;
32
- margin: auto;
33
- display: block;
34
- background: currentColor;
35
- }
36
-
37
- [part="root"] {
38
- display: contents;
39
- }
40
28
  `)
41
29
  class Divider extends GlobalStyle {
42
30
  /**
@@ -47,10 +35,7 @@ class Divider extends GlobalStyle {
47
35
 
48
36
  protected render(): TemplateResult<1> {
49
37
  return html`
50
- <div
51
- part="root"
52
- ${attr(this.observedRecord)}
53
- ></div>
38
+ <div part="root"></div>
54
39
  `;
55
40
  }
56
41
  }
@@ -1,8 +1,8 @@
1
- import { attr, godown, htmlSlot, styles } from "@godown/element";
1
+ import { godown, htmlSlot, styles, tokenList } from "@godown/element";
2
2
  import { type TemplateResult, css, html, nothing } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
5
- import { GlobalStyle } from "../../internal/global-style.js";
5
+ import Link from "../link/component.js";
6
6
 
7
7
  const protoName = "heading";
8
8
 
@@ -21,22 +21,19 @@ const protoName = "heading";
21
21
  text-align: start;
22
22
  }
23
23
 
24
- [part="anchor"] {
24
+ [part~="anchor"] {
25
25
  position: absolute;
26
26
  text-align: center;
27
27
  min-width: 1.25em;
28
28
  right: 100%;
29
29
  }
30
30
 
31
- [side="left"] [part="anchor"] {
31
+ [part~="left"][part~="anchor"] {
32
32
  right: 100%;
33
33
  }
34
- [side="right"] [part="anchor"] {
35
- left: 100%;
36
- }
37
34
 
38
- a {
39
- color: inherit;
35
+ [part~="right"][part~="anchor"] {
36
+ left: 100%;
40
37
  }
41
38
 
42
39
  h1,
@@ -45,13 +42,12 @@ const protoName = "heading";
45
42
  h4,
46
43
  h5,
47
44
  h6 {
48
- direction: ltr;
45
+ width: fit-content;
49
46
  font-size: revert;
50
47
  position: relative;
51
- width: fit-content;
52
48
  }
53
49
  `)
54
- class Heading extends GlobalStyle {
50
+ class Heading extends Link {
55
51
  /**
56
52
  * The heading level.
57
53
  */
@@ -73,17 +69,17 @@ class Heading extends GlobalStyle {
73
69
  side: "left" | "right" = "left";
74
70
 
75
71
  protected render(): TemplateResult<1> {
72
+ const hrefValue = this.href || (this.id ? "#" + this.id : undefined);
76
73
  return html`
77
74
  <a
78
75
  part="root"
79
- href="${this.id ? "#" + this.id : nothing}"
80
- ${attr(this.observedRecord)}
76
+ href="${hrefValue || nothing}"
81
77
  >
82
78
  ${this.wrapHeading(
83
79
  htmlSlot(),
84
- this.id
80
+ hrefValue
85
81
  ? html`
86
- <i part="anchor">${this.anchor}</i>
82
+ <i part="${tokenList("anchor", this.side)}">${this.anchor}</i>
87
83
  `
88
84
  : "",
89
85
  )}