godown 3.0.0-canary.0 → 3.0.0-canary.10

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 (431) hide show
  1. package/README.md +37 -8
  2. package/components/alert.d.ts +5 -3
  3. package/components/alert.d.ts.map +1 -1
  4. package/components/alert.js +24 -14
  5. package/components/alert.js.map +1 -1
  6. package/components/avatar.d.ts +5 -1
  7. package/components/avatar.d.ts.map +1 -1
  8. package/components/avatar.js +7 -3
  9. package/components/avatar.js.map +1 -1
  10. package/components/breath.d.ts +2 -1
  11. package/components/breath.d.ts.map +1 -1
  12. package/components/breath.js +5 -4
  13. package/components/breath.js.map +1 -1
  14. package/components/button.d.ts +16 -9
  15. package/components/button.d.ts.map +1 -1
  16. package/components/button.js +22 -20
  17. package/components/button.js.map +1 -1
  18. package/components/card.d.ts +1 -2
  19. package/components/card.d.ts.map +1 -1
  20. package/components/card.js +5 -11
  21. package/components/card.js.map +1 -1
  22. package/components/carousel.d.ts +6 -5
  23. package/components/carousel.d.ts.map +1 -1
  24. package/components/carousel.js +3 -2
  25. package/components/carousel.js.map +1 -1
  26. package/components/details.d.ts +5 -2
  27. package/components/details.d.ts.map +1 -1
  28. package/components/details.js +5 -2
  29. package/components/details.js.map +1 -1
  30. package/components/dialog.d.ts +8 -4
  31. package/components/dialog.d.ts.map +1 -1
  32. package/components/dialog.js +17 -12
  33. package/components/dialog.js.map +1 -1
  34. package/components/divider.d.ts +1 -1
  35. package/components/divider.js +1 -1
  36. package/components/divider.js.map +1 -1
  37. package/components/dragbox.d.ts +7 -7
  38. package/components/dragbox.d.ts.map +1 -1
  39. package/components/dragbox.js +1 -1
  40. package/components/dragbox.js.map +1 -1
  41. package/components/flex.d.ts +2 -1
  42. package/components/flex.d.ts.map +1 -1
  43. package/components/flex.js +8 -0
  44. package/components/flex.js.map +1 -1
  45. package/components/form.d.ts +0 -2
  46. package/components/form.d.ts.map +1 -1
  47. package/components/form.js +0 -2
  48. package/components/form.js.map +1 -1
  49. package/components/grid.d.ts +8 -3
  50. package/components/grid.d.ts.map +1 -1
  51. package/components/grid.js +1 -0
  52. package/components/grid.js.map +1 -1
  53. package/components/input.d.ts +2 -3
  54. package/components/input.d.ts.map +1 -1
  55. package/components/input.js +3 -6
  56. package/components/input.js.map +1 -1
  57. package/components/layout.d.ts +3 -6
  58. package/components/layout.d.ts.map +1 -1
  59. package/components/layout.js +21 -10
  60. package/components/layout.js.map +1 -1
  61. package/components/link.d.ts +3 -1
  62. package/components/link.d.ts.map +1 -1
  63. package/components/link.js +3 -1
  64. package/components/link.js.map +1 -1
  65. package/components/progress.d.ts +2 -11
  66. package/components/progress.d.ts.map +1 -1
  67. package/components/progress.js +6 -15
  68. package/components/progress.js.map +1 -1
  69. package/components/range.d.ts +43 -17
  70. package/components/range.d.ts.map +1 -1
  71. package/components/range.js +132 -58
  72. package/components/range.js.map +1 -1
  73. package/components/rotate.d.ts +1 -1
  74. package/components/rotate.d.ts.map +1 -1
  75. package/components/rotate.js +1 -1
  76. package/components/rotate.js.map +1 -1
  77. package/components/router.d.ts +6 -8
  78. package/components/router.d.ts.map +1 -1
  79. package/components/router.js +10 -10
  80. package/components/router.js.map +1 -1
  81. package/components/select.d.ts +4 -8
  82. package/components/select.d.ts.map +1 -1
  83. package/components/select.js +42 -41
  84. package/components/select.js.map +1 -1
  85. package/components/skeleton.d.ts.map +1 -1
  86. package/components/skeleton.js +3 -4
  87. package/components/skeleton.js.map +1 -1
  88. package/components/split.d.ts +18 -1
  89. package/components/split.d.ts.map +1 -1
  90. package/components/split.js +52 -19
  91. package/components/split.js.map +1 -1
  92. package/components/switch.d.ts +4 -4
  93. package/components/switch.d.ts.map +1 -1
  94. package/components/switch.js +6 -6
  95. package/components/switch.js.map +1 -1
  96. package/components/text.js +3 -3
  97. package/components/text.js.map +1 -1
  98. package/components/time.d.ts +4 -20
  99. package/components/time.d.ts.map +1 -1
  100. package/components/time.js +5 -66
  101. package/components/time.js.map +1 -1
  102. package/components/tooltip.d.ts +11 -1
  103. package/components/tooltip.d.ts.map +1 -1
  104. package/components/tooltip.js +23 -5
  105. package/components/tooltip.js.map +1 -1
  106. package/components/typewriter.d.ts +2 -2
  107. package/components/typewriter.d.ts.map +1 -1
  108. package/components/typewriter.js +2 -2
  109. package/components/typewriter.js.map +1 -1
  110. package/core/global-style.d.ts.map +1 -1
  111. package/core/global-style.js +8 -1
  112. package/core/global-style.js.map +1 -1
  113. package/core/super-anchor.js +1 -1
  114. package/core/super-anchor.js.map +1 -1
  115. package/core/super-input.d.ts +2 -3
  116. package/core/super-input.d.ts.map +1 -1
  117. package/core/super-input.js +3 -6
  118. package/core/super-input.js.map +1 -1
  119. package/core/super-openable.js.map +1 -1
  120. package/custom-elements.json +1 -1
  121. package/dev/alert.d.ts +8 -0
  122. package/dev/alert.d.ts.map +1 -0
  123. package/dev/alert.js +4 -0
  124. package/dev/alert.js.map +1 -0
  125. package/dev/avatar.d.ts +8 -0
  126. package/dev/avatar.d.ts.map +1 -0
  127. package/dev/avatar.js +4 -0
  128. package/dev/avatar.js.map +1 -0
  129. package/dev/breath.d.ts +9 -0
  130. package/dev/breath.d.ts.map +1 -0
  131. package/dev/breath.js +5 -0
  132. package/dev/breath.js.map +1 -0
  133. package/dev/button.d.ts +8 -0
  134. package/dev/button.d.ts.map +1 -0
  135. package/dev/button.js +4 -0
  136. package/dev/button.js.map +1 -0
  137. package/dev/card.d.ts +8 -0
  138. package/dev/card.d.ts.map +1 -0
  139. package/dev/card.js +4 -0
  140. package/dev/card.js.map +1 -0
  141. package/dev/carousel.d.ts +8 -0
  142. package/dev/carousel.d.ts.map +1 -0
  143. package/dev/carousel.js +4 -0
  144. package/dev/carousel.js.map +1 -0
  145. package/dev/components/alert.d.ts +52 -0
  146. package/dev/components/alert.d.ts.map +1 -0
  147. package/dev/components/alert.js +245 -0
  148. package/dev/components/alert.js.map +1 -0
  149. package/dev/components/avatar.d.ts +30 -0
  150. package/dev/components/avatar.d.ts.map +1 -0
  151. package/dev/components/avatar.js +92 -0
  152. package/dev/components/avatar.js.map +1 -0
  153. package/dev/components/breath.d.ts +35 -0
  154. package/dev/components/breath.d.ts.map +1 -0
  155. package/dev/components/breath.js +135 -0
  156. package/dev/components/breath.js.map +1 -0
  157. package/dev/components/button.d.ts +52 -0
  158. package/dev/components/button.d.ts.map +1 -0
  159. package/dev/components/button.js +260 -0
  160. package/dev/components/button.js.map +1 -0
  161. package/dev/components/card.d.ts +19 -0
  162. package/dev/components/card.d.ts.map +1 -0
  163. package/dev/components/card.js +81 -0
  164. package/dev/components/card.js.map +1 -0
  165. package/dev/components/carousel.d.ts +41 -0
  166. package/dev/components/carousel.d.ts.map +1 -0
  167. package/dev/components/carousel.js +157 -0
  168. package/dev/components/carousel.js.map +1 -0
  169. package/dev/components/details.d.ts +23 -0
  170. package/dev/components/details.d.ts.map +1 -0
  171. package/dev/components/details.js +118 -0
  172. package/dev/components/details.js.map +1 -0
  173. package/dev/components/dialog.d.ts +37 -0
  174. package/dev/components/dialog.d.ts.map +1 -0
  175. package/dev/components/dialog.js +159 -0
  176. package/dev/components/dialog.js.map +1 -0
  177. package/dev/components/divider.d.ts +17 -0
  178. package/dev/components/divider.d.ts.map +1 -0
  179. package/dev/components/divider.js +46 -0
  180. package/dev/components/divider.js.map +1 -0
  181. package/dev/components/dragbox.d.ts +40 -0
  182. package/dev/components/dragbox.d.ts.map +1 -0
  183. package/dev/components/dragbox.js +117 -0
  184. package/dev/components/dragbox.js.map +1 -0
  185. package/dev/components/flex.d.ts +32 -0
  186. package/dev/components/flex.d.ts.map +1 -0
  187. package/dev/components/flex.js +60 -0
  188. package/dev/components/flex.js.map +1 -0
  189. package/dev/components/form.d.ts +22 -0
  190. package/dev/components/form.d.ts.map +1 -0
  191. package/dev/components/form.js +77 -0
  192. package/dev/components/form.js.map +1 -0
  193. package/dev/components/grid.d.ts +36 -0
  194. package/dev/components/grid.d.ts.map +1 -0
  195. package/dev/components/grid.js +54 -0
  196. package/dev/components/grid.js.map +1 -0
  197. package/dev/components/input.d.ts +19 -0
  198. package/dev/components/input.d.ts.map +1 -0
  199. package/dev/components/input.js +70 -0
  200. package/dev/components/input.js.map +1 -0
  201. package/dev/components/layout.d.ts +26 -0
  202. package/dev/components/layout.d.ts.map +1 -0
  203. package/dev/components/layout.js +82 -0
  204. package/dev/components/layout.js.map +1 -0
  205. package/dev/components/link.d.ts +22 -0
  206. package/dev/components/link.d.ts.map +1 -0
  207. package/dev/components/link.js +42 -0
  208. package/dev/components/link.js.map +1 -0
  209. package/dev/components/progress.d.ts +21 -0
  210. package/dev/components/progress.d.ts.map +1 -0
  211. package/dev/components/progress.js +99 -0
  212. package/dev/components/progress.js.map +1 -0
  213. package/dev/components/range.d.ts +86 -0
  214. package/dev/components/range.d.ts.map +1 -0
  215. package/dev/components/range.js +364 -0
  216. package/dev/components/range.js.map +1 -0
  217. package/dev/components/rotate.d.ts +26 -0
  218. package/dev/components/rotate.d.ts.map +1 -0
  219. package/dev/components/rotate.js +86 -0
  220. package/dev/components/rotate.js.map +1 -0
  221. package/dev/components/router.d.ts +119 -0
  222. package/dev/components/router.d.ts.map +1 -0
  223. package/dev/components/router.js +248 -0
  224. package/dev/components/router.js.map +1 -0
  225. package/dev/components/select.d.ts +46 -0
  226. package/dev/components/select.d.ts.map +1 -0
  227. package/dev/components/select.js +245 -0
  228. package/dev/components/select.js.map +1 -0
  229. package/dev/components/skeleton.d.ts +26 -0
  230. package/dev/components/skeleton.d.ts.map +1 -0
  231. package/dev/components/skeleton.js +118 -0
  232. package/dev/components/skeleton.js.map +1 -0
  233. package/dev/components/split.d.ts +49 -0
  234. package/dev/components/split.d.ts.map +1 -0
  235. package/dev/components/split.js +206 -0
  236. package/dev/components/split.js.map +1 -0
  237. package/dev/components/switch.d.ts +39 -0
  238. package/dev/components/switch.d.ts.map +1 -0
  239. package/dev/components/switch.js +182 -0
  240. package/dev/components/switch.js.map +1 -0
  241. package/dev/components/text.d.ts +19 -0
  242. package/dev/components/text.d.ts.map +1 -0
  243. package/dev/components/text.js +93 -0
  244. package/dev/components/text.js.map +1 -0
  245. package/dev/components/time.d.ts +37 -0
  246. package/dev/components/time.d.ts.map +1 -0
  247. package/dev/components/time.js +75 -0
  248. package/dev/components/time.js.map +1 -0
  249. package/dev/components/tooltip.d.ts +48 -0
  250. package/dev/components/tooltip.d.ts.map +1 -0
  251. package/dev/components/tooltip.js +137 -0
  252. package/dev/components/tooltip.js.map +1 -0
  253. package/dev/components/typewriter.d.ts +55 -0
  254. package/dev/components/typewriter.d.ts.map +1 -0
  255. package/dev/components/typewriter.js +155 -0
  256. package/dev/components/typewriter.js.map +1 -0
  257. package/dev/core/global-style.d.ts +21 -0
  258. package/dev/core/global-style.d.ts.map +1 -0
  259. package/dev/core/global-style.js +76 -0
  260. package/dev/core/global-style.js.map +1 -0
  261. package/dev/core/super-anchor.d.ts +15 -0
  262. package/dev/core/super-anchor.d.ts.map +1 -0
  263. package/dev/core/super-anchor.js +58 -0
  264. package/dev/core/super-anchor.js.map +1 -0
  265. package/dev/core/super-input.d.ts +38 -0
  266. package/dev/core/super-input.d.ts.map +1 -0
  267. package/dev/core/super-input.js +182 -0
  268. package/dev/core/super-input.js.map +1 -0
  269. package/dev/core/super-openable.d.ts +19 -0
  270. package/dev/core/super-openable.d.ts.map +1 -0
  271. package/dev/core/super-openable.js +36 -0
  272. package/dev/core/super-openable.js.map +1 -0
  273. package/dev/details.d.ts +8 -0
  274. package/dev/details.d.ts.map +1 -0
  275. package/dev/details.js +4 -0
  276. package/dev/details.js.map +1 -0
  277. package/dev/dialog.d.ts +8 -0
  278. package/dev/dialog.d.ts.map +1 -0
  279. package/dev/dialog.js +4 -0
  280. package/dev/dialog.js.map +1 -0
  281. package/dev/divider.d.ts +8 -0
  282. package/dev/divider.d.ts.map +1 -0
  283. package/dev/divider.js +4 -0
  284. package/dev/divider.js.map +1 -0
  285. package/dev/dragbox.d.ts +8 -0
  286. package/dev/dragbox.d.ts.map +1 -0
  287. package/dev/dragbox.js +4 -0
  288. package/dev/dragbox.js.map +1 -0
  289. package/dev/flex.d.ts +8 -0
  290. package/dev/flex.d.ts.map +1 -0
  291. package/dev/flex.js +4 -0
  292. package/dev/flex.js.map +1 -0
  293. package/dev/form.d.ts +8 -0
  294. package/dev/form.d.ts.map +1 -0
  295. package/dev/form.js +4 -0
  296. package/dev/form.js.map +1 -0
  297. package/dev/grid.d.ts +8 -0
  298. package/dev/grid.d.ts.map +1 -0
  299. package/dev/grid.js +4 -0
  300. package/dev/grid.js.map +1 -0
  301. package/dev/index.d.ts +29 -0
  302. package/dev/index.d.ts.map +1 -0
  303. package/dev/index.js +29 -0
  304. package/dev/index.js.map +1 -0
  305. package/dev/input.d.ts +9 -0
  306. package/dev/input.d.ts.map +1 -0
  307. package/dev/input.js +5 -0
  308. package/dev/input.js.map +1 -0
  309. package/dev/layout.d.ts +9 -0
  310. package/dev/layout.d.ts.map +1 -0
  311. package/dev/layout.js +5 -0
  312. package/dev/layout.js.map +1 -0
  313. package/dev/link.d.ts +9 -0
  314. package/dev/link.d.ts.map +1 -0
  315. package/dev/link.js +5 -0
  316. package/dev/link.js.map +1 -0
  317. package/dev/progress.d.ts +9 -0
  318. package/dev/progress.d.ts.map +1 -0
  319. package/dev/progress.js +5 -0
  320. package/dev/progress.js.map +1 -0
  321. package/dev/range.d.ts +9 -0
  322. package/dev/range.d.ts.map +1 -0
  323. package/dev/range.js +5 -0
  324. package/dev/range.js.map +1 -0
  325. package/dev/rotate.d.ts +9 -0
  326. package/dev/rotate.d.ts.map +1 -0
  327. package/dev/rotate.js +5 -0
  328. package/dev/rotate.js.map +1 -0
  329. package/dev/router.d.ts +9 -0
  330. package/dev/router.d.ts.map +1 -0
  331. package/dev/router.js +5 -0
  332. package/dev/router.js.map +1 -0
  333. package/dev/select.d.ts +9 -0
  334. package/dev/select.d.ts.map +1 -0
  335. package/dev/select.js +5 -0
  336. package/dev/select.js.map +1 -0
  337. package/dev/skeleton.d.ts +9 -0
  338. package/dev/skeleton.d.ts.map +1 -0
  339. package/dev/skeleton.js +5 -0
  340. package/dev/skeleton.js.map +1 -0
  341. package/dev/split.d.ts +9 -0
  342. package/dev/split.d.ts.map +1 -0
  343. package/dev/split.js +5 -0
  344. package/dev/split.js.map +1 -0
  345. package/dev/switch.d.ts +9 -0
  346. package/dev/switch.d.ts.map +1 -0
  347. package/dev/switch.js +5 -0
  348. package/dev/switch.js.map +1 -0
  349. package/dev/text.d.ts +9 -0
  350. package/dev/text.d.ts.map +1 -0
  351. package/dev/text.js +5 -0
  352. package/dev/text.js.map +1 -0
  353. package/dev/time.d.ts +9 -0
  354. package/dev/time.d.ts.map +1 -0
  355. package/dev/time.js +5 -0
  356. package/dev/time.js.map +1 -0
  357. package/dev/tooltip.d.ts +9 -0
  358. package/dev/tooltip.d.ts.map +1 -0
  359. package/dev/tooltip.js +5 -0
  360. package/dev/tooltip.js.map +1 -0
  361. package/dev/typewriter.d.ts +8 -0
  362. package/dev/typewriter.d.ts.map +1 -0
  363. package/dev/typewriter.js +4 -0
  364. package/dev/typewriter.js.map +1 -0
  365. package/index.js +13 -13
  366. package/package.json +10 -8
  367. package/range.d.ts +1 -1
  368. package/range.d.ts.map +1 -1
  369. package/src/alert.ts +11 -0
  370. package/src/avatar.ts +11 -0
  371. package/src/breath.ts +13 -0
  372. package/src/button.ts +11 -0
  373. package/src/card.ts +11 -0
  374. package/src/carousel.ts +11 -0
  375. package/src/components/alert.ts +282 -0
  376. package/src/components/avatar.ts +95 -0
  377. package/src/components/breath.ts +153 -0
  378. package/src/components/button.ts +286 -0
  379. package/src/components/card.ts +80 -0
  380. package/src/components/carousel.ts +169 -0
  381. package/src/components/details.ts +116 -0
  382. package/src/components/dialog.ts +165 -0
  383. package/src/components/divider.ts +44 -0
  384. package/src/components/dragbox.ts +127 -0
  385. package/src/components/flex.ts +70 -0
  386. package/src/components/form.ts +82 -0
  387. package/src/components/grid.ts +75 -0
  388. package/src/components/input.ts +72 -0
  389. package/src/components/layout.ts +82 -0
  390. package/src/components/link.ts +38 -0
  391. package/src/components/progress.ts +95 -0
  392. package/src/components/range.ts +404 -0
  393. package/src/components/rotate.ts +92 -0
  394. package/src/components/router.ts +273 -0
  395. package/src/components/select.ts +268 -0
  396. package/src/components/skeleton.ts +118 -0
  397. package/src/components/split.ts +221 -0
  398. package/src/components/switch.ts +180 -0
  399. package/src/components/text.ts +95 -0
  400. package/src/components/time.ts +81 -0
  401. package/src/components/tooltip.ts +138 -0
  402. package/src/components/typewriter.ts +154 -0
  403. package/src/core/global-style.ts +86 -0
  404. package/src/core/super-anchor.ts +52 -0
  405. package/src/core/super-input.ts +230 -0
  406. package/src/core/super-openable.ts +51 -0
  407. package/src/details.ts +11 -0
  408. package/src/dialog.ts +11 -0
  409. package/src/divider.ts +11 -0
  410. package/src/dragbox.ts +11 -0
  411. package/src/flex.ts +11 -0
  412. package/src/form.ts +11 -0
  413. package/src/grid.ts +11 -0
  414. package/src/index.ts +28 -0
  415. package/src/input.ts +13 -0
  416. package/src/layout.ts +12 -0
  417. package/src/link.ts +13 -0
  418. package/src/progress.ts +12 -0
  419. package/src/range.ts +13 -0
  420. package/src/rotate.ts +13 -0
  421. package/src/router.ts +12 -0
  422. package/src/select.ts +13 -0
  423. package/src/skeleton.ts +13 -0
  424. package/src/split.ts +13 -0
  425. package/src/switch.ts +13 -0
  426. package/src/text.ts +13 -0
  427. package/src/time.ts +13 -0
  428. package/src/tooltip.ts +13 -0
  429. package/src/typewriter.ts +11 -0
  430. package/vscode.html-custom-data.json +1 -1
  431. package/web-types.json +1 -1
@@ -0,0 +1,153 @@
1
+ import { godown } from "@godown/element/decorators/godown.js";
2
+ import { styles } from "@godown/element/decorators/styles.js";
3
+ import { htmlStyle } from "@godown/element/directives/html-style.js";
4
+ import { css, html } from "lit";
5
+ import { property } from "lit/decorators.js";
6
+
7
+ import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
8
+
9
+ const defineName = "breath";
10
+ const cssScope = scopePrefix(defineName);
11
+
12
+ /**
13
+ * {@linkcode Breath} render the text with a breathing effect.
14
+ *
15
+ * Dynamically generate a breathing effect based on the length of the split text.
16
+ *
17
+ * If there is not enough CSS variable, overrun elements will use the.
18
+ *
19
+ * godown was a css library in its earliest days,
20
+ * and this is the component version of its first effect.
21
+ *
22
+ * Inspired by Vercel home page (2023).
23
+ *
24
+ * @slot - Breathing parts.
25
+ * @category effect
26
+ */
27
+ @godown(defineName)
28
+ @styles(
29
+ css`
30
+ :host {
31
+ ${cssScope}--deg: 60deg;
32
+ ${cssScope}--1-1: var(${cssGlobalVars._colors.red[5]});
33
+ ${cssScope}--1-2: var(${cssGlobalVars._colors.yellow[5]});
34
+ ${cssScope}--2-1: var(${cssGlobalVars._colors.green[5]});
35
+ ${cssScope}--2-2: var(${cssGlobalVars._colors.purple[5]});
36
+ ${cssScope}--3-1: var(${cssGlobalVars._colors.blue[5]});
37
+ ${cssScope}--3-2: var(${cssGlobalVars._colors.pink[5]});
38
+ ${cssScope}--1: linear-gradient(var(${cssScope}--deg), var(${cssScope}--1-1), var(${cssScope}--1-2));
39
+ ${cssScope}--2: linear-gradient(var(${cssScope}--deg), var(${cssScope}--2-1), var(${cssScope}--2-2));
40
+ ${cssScope}--3: linear-gradient(var(${cssScope}--deg), var(${cssScope}--3-1), var(${cssScope}--3-2));
41
+ }
42
+ `,
43
+ css`
44
+ :host {
45
+ display: flex;
46
+ margin: auto;
47
+ width: -moz-fit-content;
48
+ width: fit-content;
49
+ font-size: 2em;
50
+ align-items: center;
51
+ direction: ltr;
52
+ }
53
+
54
+ ::selection {
55
+ background: none;
56
+ }
57
+
58
+ .rel {
59
+ position: relative;
60
+ font-weight: 800;
61
+ font-size: inherit;
62
+ letter-spacing: -0.05em;
63
+ }
64
+ `,
65
+ css`
66
+ .nocolor,
67
+ .colorful {
68
+ padding: 0 0.05em;
69
+ box-sizing: border-box;
70
+ display: inline-block;
71
+ animation-iteration-count: infinite;
72
+ -webkit-text-fill-color: transparent;
73
+ -webkit-background-clip: text !important;
74
+ background-clip: text !important;
75
+ }
76
+ .colorful {
77
+ opacity: 0;
78
+ animation-name: colorfulN;
79
+ }
80
+ .nocolor {
81
+ position: absolute;
82
+ top: 0;
83
+ background: var(${cssGlobalVars.clipBackground});
84
+ }
85
+ `,
86
+ )
87
+ class Breath extends GlobalStyle {
88
+ /**
89
+ * Strings or array of strings,
90
+ * if array, divided each element into chunks,
91
+ * otherwise split strings by whitespace.
92
+ */
93
+ @property()
94
+ text: string | string[];
95
+
96
+ /**
97
+ * Effect duration, ending in s or ms.
98
+ */
99
+ @property()
100
+ duration: string;
101
+
102
+ protected render() {
103
+ const texts = this.getTexts();
104
+ return [
105
+ texts.map(this.renderText),
106
+ htmlStyle(this.computeStyle(texts.length)),
107
+ ];
108
+ }
109
+
110
+ protected renderText(text: string) {
111
+ return html`<span class="rel">
112
+ <span class="nocolor">${text}</span>
113
+ <span class="colorful">${text}</span>
114
+ </span>`;
115
+ }
116
+
117
+ protected getTexts(): string[] {
118
+ return Array.isArray(this.text) ? this.text : (this.text || this.textContent).split(/\s+/).filter((x) => x);
119
+ }
120
+
121
+ protected computeStyle(len: number) {
122
+ const gap = 100 / 2 / len;
123
+ const duration = this.parseDuration() || len * 2 + 2;
124
+
125
+ return (
126
+ `.colorful{animation-duration:${duration}s;}`
127
+ + `@keyframes colorfulN{0%,${gap * 3}%{opacity:0;}${gap}%,${gap * 2}%{opacity:1;}}`
128
+ + (() => {
129
+ let style1 = "";
130
+ for (let number = 1; number <= len; number++) {
131
+ const delay = -duration / len * (len - number + 1);
132
+ const defaultNumber = ((number - 1) % 3) + 1;
133
+ style1 +=
134
+ `.rel:nth-child(${number}) .colorful{animation-delay:${delay}s;background:var(${cssScope}--${number},var(${cssScope}--${defaultNumber}));}`;
135
+ }
136
+ return style1;
137
+ })()
138
+ );
139
+ }
140
+
141
+ protected parseDuration() {
142
+ const { duration } = this;
143
+ if (duration) {
144
+ if (duration.endsWith("s")) {
145
+ return parseFloat(duration.slice(0, -1));
146
+ } else if (duration.endsWith("ms")) {
147
+ return parseFloat(duration.slice(0, -2)) / 1000;
148
+ }
149
+ }
150
+ }
151
+ }
152
+
153
+ export default Breath;
@@ -0,0 +1,286 @@
1
+ import { godown } from "@godown/element/decorators/godown.js";
2
+ import { part } from "@godown/element/decorators/part.js";
3
+ import { styles } from "@godown/element/decorators/styles.js";
4
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
+ import { htmlStyle } from "@godown/element/directives/html-style.js";
6
+ import { constructCSSObject, toVar } from "@godown/element/tools/css.js";
7
+ import { css, html } from "lit";
8
+ import { property } from "lit/decorators.js";
9
+
10
+ import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
11
+
12
+ const protoName = "button";
13
+ const cssScope = scopePrefix(protoName);
14
+
15
+ const whiteFont = cssGlobalVars.white;
16
+ const blackFont = cssGlobalVars.black;
17
+
18
+ const colors = constructCSSObject(
19
+ ["color", "background", "gradients"].map((k) => `${cssScope}--${k}`),
20
+ {
21
+ black: [
22
+ whiteFont, // color
23
+ cssGlobalVars._colors.darkgray[7], // background
24
+ cssGlobalVars._colors.darkgray[5], // gradients
25
+ ],
26
+ gray: [
27
+ whiteFont, // color
28
+ cssGlobalVars._colors.darkgray[1], // background
29
+ cssGlobalVars._colors.lightgray[8], // gradients
30
+ ],
31
+ white: [
32
+ blackFont, // color
33
+ cssGlobalVars._colors.lightgray[3], // background
34
+ cssGlobalVars._colors.lightgray[0], // gradients
35
+ ],
36
+ blue: [
37
+ whiteFont, // color
38
+ cssGlobalVars._colors.blue[6], // background
39
+ cssGlobalVars._colors.blue[4], // gradients
40
+ ],
41
+ green: [
42
+ whiteFont, // color
43
+ cssGlobalVars._colors.green[6], // background
44
+ cssGlobalVars._colors.green[4], // gradients
45
+ ],
46
+ red: [
47
+ whiteFont, // color
48
+ cssGlobalVars._colors.red[6], // background
49
+ cssGlobalVars._colors.red[4], // gradients
50
+ ],
51
+ orange: [
52
+ whiteFont, // color
53
+ cssGlobalVars._colors.orange[6], // background
54
+ cssGlobalVars._colors.orange[4], // gradients
55
+ ],
56
+ pink: [
57
+ whiteFont, // color
58
+ cssGlobalVars._colors.pink[6], // background
59
+ cssGlobalVars._colors.pink[4], // gradients
60
+ ],
61
+ purple: [
62
+ whiteFont, // color
63
+ cssGlobalVars._colors.purple[6], // background
64
+ cssGlobalVars._colors.purple[4], // gradients
65
+ ],
66
+ yellow: [
67
+ blackFont, // color
68
+ cssGlobalVars._colors.yellow[6], // background
69
+ cssGlobalVars._colors.yellow[4], // gradients
70
+ ],
71
+ teal: [
72
+ whiteFont, // color
73
+ cssGlobalVars._colors.teal[6], // background
74
+ cssGlobalVars._colors.teal[4], // gradients
75
+ ],
76
+ },
77
+ () => `:host`,
78
+ (prop) => toVar(prop),
79
+ );
80
+
81
+ /**
82
+ * {@linkcode Button} renders a button.
83
+ *
84
+ * Create modal animation upon clicking.
85
+ *
86
+ * Available colors (background): none, black, gray, white, blue, green, red, orange, pink, purple, yellow, teal.
87
+ *
88
+ * Default color is `black`.
89
+ *
90
+ * Set the color to `none` to prevent applying styles.
91
+ *
92
+ * @category input
93
+ */
94
+ @godown(protoName)
95
+ @styles(
96
+ css`
97
+ :host(:not([disabled]):active) {
98
+ transform: scale(var(${cssScope}--focus-scale));
99
+ }
100
+
101
+ :host([round]) {
102
+ ${cssScope}--padding-x: .75em;
103
+ border-radius: calc(infinity * 1px);
104
+ }
105
+
106
+ :host([disabled]) {
107
+ cursor: not-allowed;
108
+ filter: brightness(0.85);
109
+ }
110
+
111
+ :host([ghost]) {
112
+ ${cssScope}--modal-background: var(${cssScope}--ghost-color);
113
+ box-shadow:inset 0px 0px 0px var(${cssScope}--ghost-width) var(${cssScope}--ghost-color);
114
+ color: var(${cssScope}--ghost-color);
115
+ background: transparent;
116
+ }
117
+ `,
118
+ css`
119
+ :host {
120
+ ${cssScope}--padding-x: .5em;
121
+ ${cssScope}--padding-y: .15em;
122
+ ${cssScope}--padding: var(${cssScope}--padding-y) var(${cssScope}--padding-x);
123
+ ${cssScope}--modal-animation-duration: 1s;
124
+ ${cssScope}--ghost-width: .08em;
125
+ ${cssScope}--focus-scale: .97;
126
+ ${cssScope}--deg: 45deg;
127
+ ${cssScope}--ghost-color:var(${cssScope}--background);
128
+ color: var(${cssScope}--color, inherit);
129
+ background: linear-gradient(
130
+ var(${cssScope}--deg),
131
+ var(${cssScope}--background),
132
+ var(${cssScope}--gradients, var(${cssScope}--background))
133
+ );
134
+ border-radius: 0.3em;
135
+ width: -moz-fit-content;
136
+ width: fit-content;
137
+ transition: 0.1s;
138
+ display: block;
139
+ overflow: hidden;
140
+ text-align: center;
141
+ padding: 0 !important;
142
+ cursor: pointer;
143
+ }
144
+
145
+ [part=root] {
146
+ width: 100%;
147
+ height: 100%;
148
+ overflow: hidden;
149
+ position: relative;
150
+ transition: none;
151
+ user-select: none;
152
+ border-radius: inherit;
153
+ transition-duration: inherit;
154
+ }
155
+
156
+ [part=content] {
157
+ padding: var(${cssScope}--padding);
158
+ }
159
+
160
+ i {
161
+ position: absolute;
162
+ inset: 0;
163
+ opacity: 0;
164
+ width: 100%;
165
+ height: 100%;
166
+ border-radius: 50%;
167
+ visibility: visible;
168
+ pointer-events: none;
169
+ transform-origin: 0 0;
170
+ background: var(${cssScope}--modal-background, currentColor);
171
+ animation-duration: var(${cssScope}--modal-animation-duration);
172
+ }
173
+
174
+ @keyframes kf {
175
+ 0% {
176
+ transform: scale(0) translate(-50%, -50%);
177
+ opacity: var(${cssScope}--modal-opacity, 0.1);
178
+ }
179
+ 80% {
180
+ transform: scale(1) translate(-50%, -50%);
181
+ }
182
+ to {
183
+ opacity: 0;
184
+ }
185
+ }
186
+ `,
187
+ )
188
+ class Button extends GlobalStyle {
189
+ /**
190
+ * Whether to disable this element.
191
+ */
192
+ @property({ type: Boolean, reflect: true })
193
+ disabled: boolean;
194
+
195
+ /**
196
+ * Display ghost.
197
+ */
198
+ @property({ type: Boolean, reflect: true })
199
+ ghost: boolean;
200
+
201
+ /**
202
+ * Whether this element is active or not.
203
+ */
204
+ @property({ type: Boolean, reflect: true })
205
+ active: boolean;
206
+
207
+ /**
208
+ * Display rounded.
209
+ */
210
+ @property({ type: Boolean, reflect: true })
211
+ round: boolean;
212
+
213
+ /**
214
+ * The primary color.
215
+ */
216
+ @property({ reflect: true })
217
+ color: "none" | keyof typeof colors = "black";
218
+
219
+ /**
220
+ * Content text.
221
+ */
222
+ @property()
223
+ content: string;
224
+
225
+ @part("modal-root")
226
+ protected _modalRoot: HTMLElement;
227
+ @part("root")
228
+ protected _root: HTMLElement;
229
+
230
+ protected render() {
231
+ const color = this.nextColor();
232
+ return html`<div part="root">
233
+ <span part="modal-root"></span>
234
+ <div part="content">
235
+ ${[this.content || htmlSlot(), htmlStyle(colors[color])]}
236
+ </div>
237
+ </div>`;
238
+ }
239
+
240
+ focus() {
241
+ if (this.disabled) {
242
+ return;
243
+ }
244
+ this.active = true;
245
+ super.focus();
246
+ }
247
+
248
+ blur() {
249
+ this.active = false;
250
+ super.blur();
251
+ }
252
+
253
+ firstUpdated() {
254
+ this.events.add(this, "click", this._handelClick, true);
255
+ }
256
+
257
+ protected _handelClick(e: MouseEvent) {
258
+ if (this.disabled) {
259
+ e.stopPropagation();
260
+ e.preventDefault();
261
+ return;
262
+ }
263
+ this._handleModal(e);
264
+ }
265
+
266
+ protected _handleModal(e: MouseEvent) {
267
+ const modal = document.createElement("i");
268
+ const rect = this.getBoundingClientRect();
269
+ const h = rect.height;
270
+ const w = rect.width;
271
+ const size = `${Math.sqrt(h * h + w * w) * 2}px`;
272
+ modal.style.height = size;
273
+ modal.style.width = size;
274
+ modal.style.left = `${e.clientX - rect.left}px`;
275
+ modal.style.top = `${e.clientY - rect.y}px`;
276
+ modal.style.animationName = "kf";
277
+ this._modalRoot.appendChild(modal);
278
+ modal.addEventListener("animationend", () => modal.remove(), { once: true });
279
+ }
280
+
281
+ nextColor() {
282
+ return this.color;
283
+ }
284
+ }
285
+
286
+ export default Button;
@@ -0,0 +1,80 @@
1
+ import { godown } from "@godown/element/decorators/godown.js";
2
+ import { styles } from "@godown/element/decorators/styles.js";
3
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
4
+ import { css } from "lit";
5
+ import { property } from "lit/decorators.js";
6
+
7
+ import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
8
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
+ import type Layout from "../layout.js";
10
+
11
+ const protoName = "card";
12
+ const cssScope = scopePrefix(protoName);
13
+
14
+ /**
15
+ * {@linkcode Card} renders a card.
16
+ *
17
+ * This may be similar to {@linkcode Layout},
18
+ * but it needs to be specified to enable header and footer.
19
+ *
20
+ * @slot - The main content of the card.
21
+ * @slot header - The header of the card.
22
+ * @slot footer - The footer of the card.
23
+ * @category display
24
+ */
25
+ @godown(protoName)
26
+ @styles(
27
+ css`
28
+ :host {
29
+ ${cssScope}--background: var(${cssGlobalVars.background});
30
+ ${cssScope}--border-width: .0375em;
31
+ ${cssScope}--border-color: transparent;
32
+ ${cssScope}--border-background: var(${cssGlobalVars.passive});
33
+ ${cssScope}--padding: .75em;
34
+ color: var(${cssGlobalVars.foreground});
35
+ background: var(${cssScope}--background);
36
+ border-width: var(${cssScope}--border-width);
37
+ display: block;
38
+ flex-shrink: 0;
39
+ position: relative;
40
+ overflow: hidden;
41
+ box-sizing: border-box;
42
+ }
43
+
44
+ slot {
45
+ display: block;
46
+ padding: var(${cssScope}--padding);
47
+ }
48
+
49
+ :host,
50
+ slot {
51
+ border-color: var(${cssScope}--border-background);
52
+ border-style: solid;
53
+ }
54
+
55
+ [name=footer]{
56
+ border-top-width: var(${cssScope}--border-width);
57
+ }
58
+
59
+ [name=header]{
60
+ border-bottom-width: var(${cssScope}--border-width);
61
+ }
62
+ `,
63
+ )
64
+ class Card extends GlobalStyle {
65
+ @property({ type: Boolean })
66
+ footer = false;
67
+
68
+ @property({ type: Boolean })
69
+ header = false;
70
+
71
+ protected render() {
72
+ return [
73
+ this.header ? htmlSlot("header") : "",
74
+ htmlSlot(),
75
+ this.footer ? htmlSlot("footer") : "",
76
+ ];
77
+ }
78
+ }
79
+
80
+ export default Card;
@@ -0,0 +1,169 @@
1
+ import { godown } from "@godown/element/decorators/godown.js";
2
+ import { part } from "@godown/element/decorators/part.js";
3
+ import { styles } from "@godown/element/decorators/styles.js";
4
+ import { htmlSlot } from "@godown/element/directives/html-slot.js";
5
+ import { htmlStyle } from "@godown/element/directives/html-style.js";
6
+ import iconChevronLeft from "@godown/f7-icon/icons/chevron-left.js";
7
+ import iconChevronRight from "@godown/f7-icon/icons/chevron-right.js";
8
+ import { css, html } from "lit";
9
+ import { property } from "lit/decorators.js";
10
+
11
+ import { GlobalStyle } from "../core/global-style.js";
12
+
13
+ const protoName = "carousel";
14
+
15
+ /**
16
+ * {@linkcode Carousel} make the content display as a carousel.
17
+ *
18
+ * When this component is `firstUpdated`,
19
+ * clone the first and last element and make the matching element visible when switching index.
20
+ *
21
+ * Child elements should maintain the same size.
22
+ *
23
+ * If no width, it will be the width of the first element.
24
+ *
25
+ * @slot - Carousel items, should maintain the same size.
26
+ * @category display
27
+ */
28
+ @godown(protoName)
29
+ @styles(
30
+ css`
31
+ :host {
32
+ display: block;
33
+ transition: .3s;
34
+ }
35
+
36
+ [part=root] {
37
+ overflow: hidden;
38
+ }
39
+
40
+ [part=root],
41
+ [part=move-root] {
42
+ height: 100%;
43
+ width: 100%;
44
+ display: flex;
45
+ position: relative;
46
+ transition: inherit;
47
+ }
48
+
49
+ [part=prev],
50
+ [part=next] {
51
+ height: 100%;
52
+ width: 1.5em;
53
+ z-index: 1;
54
+ position: absolute;
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: center;
58
+ user-select: none;
59
+ }
60
+
61
+ [part=prev] {
62
+ left: 0;
63
+ }
64
+
65
+ [part=next] {
66
+ right: 0;
67
+ }
68
+
69
+ slot::slotted(*) {
70
+ flex-shrink: 0 !important;
71
+ }
72
+ `,
73
+ )
74
+ class Carousel extends GlobalStyle {
75
+ /**
76
+ * The index of the element is displayed for the first time.
77
+ */
78
+ @property({ type: Number })
79
+ index = 0;
80
+
81
+ /**
82
+ * If autoChange > 0, the rotation will be automated.
83
+ */
84
+ @property({ type: Number })
85
+ autoChange = 0;
86
+
87
+ /**
88
+ * Element width.
89
+ */
90
+ @property()
91
+ width: string;
92
+
93
+ @part("move-root")
94
+ protected _moveRoot: HTMLElement;
95
+
96
+ protected intervalID: number;
97
+
98
+ private _cloneFirst: HTMLElement | undefined;
99
+
100
+ private _cloneLast: HTMLElement | undefined;
101
+
102
+ protected render() {
103
+ return [
104
+ html`<div part="root">
105
+ <i part="prev" @click="${this.prev}">${iconChevronLeft()}</i>
106
+ <div part="move-root" style="transform:${`translateX(-${this.index + 1}00%)`}">${htmlSlot()}</div>
107
+ <i part="next" @click="${this.next}">${iconChevronRight()}</i>
108
+ </div>`,
109
+ htmlStyle(`:host{width:${this.width};}`),
110
+ ];
111
+ }
112
+
113
+ protected async firstUpdated() {
114
+ await this.updateComplete;
115
+
116
+ if (this.children.length) {
117
+ this.width ||= `${(this.firstElementChild as HTMLElement).offsetWidth}px`;
118
+
119
+ this._cloneFirst?.remove();
120
+ this._cloneLast?.remove();
121
+ this._cloneLast = this.firstElementChild.cloneNode(true) as HTMLElement;
122
+ this._cloneFirst = this.lastElementChild.cloneNode(true) as HTMLElement;
123
+ this.appendChild(this._cloneLast);
124
+ this.insertBefore(this._cloneFirst, this.firstElementChild);
125
+ this.show(this.index);
126
+ }
127
+ if (this.autoChange) {
128
+ this.intervalID = window.setInterval(() => {
129
+ this.next();
130
+ }, this.autoChange);
131
+ }
132
+ }
133
+
134
+ disconnectedCallback() {
135
+ clearInterval(this.intervalID);
136
+ }
137
+
138
+ show(i: number) {
139
+ this.index = i;
140
+ }
141
+
142
+ next() {
143
+ if (this.index === this.childElementCount - 3) {
144
+ this._doTranslateX("0", true);
145
+ this.show(0);
146
+ } else {
147
+ this.show(this.index + 1);
148
+ }
149
+ }
150
+
151
+ prev() {
152
+ if (this.index === 0) {
153
+ this._doTranslateX(`-${this.childElementCount - 1}00%`, true);
154
+ this.show(this.children.length - 3);
155
+ } else {
156
+ this.show(this.index - 1);
157
+ }
158
+ }
159
+
160
+ protected _doTranslateX(xValue: string, noTransition?: boolean) {
161
+ this._moveRoot.style.transform = `translateX(${xValue})`;
162
+ if (noTransition) {
163
+ this._moveRoot.style.transition = `none`;
164
+ }
165
+ this._moveRoot.getBoundingClientRect();
166
+ }
167
+ }
168
+
169
+ export default Carousel;