@adaptive-sm/astro-ui 0.1.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 (86) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +183 -0
  3. package/lib/button/Button.astro +58 -0
  4. package/lib/button/buttonCva.ts +196 -0
  5. package/lib/button/buttonIconCva.ts +52 -0
  6. package/lib/button/classesButtonClickAnimation.ts +8 -0
  7. package/lib/button/classesButtonClickAnimationPush.ts +6 -0
  8. package/lib/button/classesButtonClickAnimationSquish.ts +6 -0
  9. package/lib/button/classesButtonDisabled.ts +1 -0
  10. package/lib/card/CardWrapper.astro +15 -0
  11. package/lib/card/classesCardWrapper.ts +16 -0
  12. package/lib/details/Details.astro +57 -0
  13. package/lib/dev/TailwindIndicator.astro +28 -0
  14. package/lib/form/Fieldset.astro +21 -0
  15. package/lib/form/classesFieldset.ts +1 -0
  16. package/lib/generate_ai_rules/generate_agent_rules.bash +9 -0
  17. package/lib/generate_ai_rules/generate_agent_rules_1_lib.bash +33 -0
  18. package/lib/generate_ai_rules/generate_agent_rules_2_copy.bash +14 -0
  19. package/lib/generate_ai_rules/generate_agent_rules_3_combine.bash +31 -0
  20. package/lib/generate_demo_list/DemoList.astro +31 -0
  21. package/lib/generate_demo_list/DemoListType.ts +1 -0
  22. package/lib/generate_demo_list/generateDemoList.ts +55 -0
  23. package/lib/generate_image_list/generateImageList.ts +101 -0
  24. package/lib/grid/classesGridCols.ts +86 -0
  25. package/lib/icon/Icon1.astro +21 -0
  26. package/lib/img/ImageType.ts +6 -0
  27. package/lib/img/Img.astro +27 -0
  28. package/lib/img/TypedImg.astro +26 -0
  29. package/lib/img/classInvertDiagram.ts +1 -0
  30. package/lib/img/classesImgZoomInOnHover.ts +1 -0
  31. package/lib/layouts/MarkdownWrapper.astro +17 -0
  32. package/lib/layouts/MinimalLayout.astro +67 -0
  33. package/lib/layouts/parts/ThemeToggle.astro +137 -0
  34. package/lib/layouts/parts/astroElementId.ts +7 -0
  35. package/lib/layouts/parts/markdown.css +93 -0
  36. package/lib/link/LinkButton.astro +48 -0
  37. package/lib/link/LinkText.astro +23 -0
  38. package/lib/link/classesTextLink.ts +13 -0
  39. package/lib/list/BlackBulletPoint.astro +16 -0
  40. package/lib/list/BlackBulletPoints.astro +23 -0
  41. package/lib/list/CheckPoint.astro +20 -0
  42. package/lib/list/CheckPoints.astro +23 -0
  43. package/lib/list/NumberedList.astro +14 -0
  44. package/lib/list/Ps.astro +12 -0
  45. package/lib/list/TextOrLink.astro +19 -0
  46. package/lib/modal/Modal.astro +54 -0
  47. package/lib/modal/Modal.module.css +19 -0
  48. package/lib/modal/ModalButton.astro +41 -0
  49. package/lib/modal/modal.ts +137 -0
  50. package/lib/page/PageCentered.astro +14 -0
  51. package/lib/page/PageCenteredCard.astro +17 -0
  52. package/lib/page/classesBg.ts +27 -0
  53. package/lib/page/classesPageCentered.ts +6 -0
  54. package/lib/popover/Popover1.astro +45 -0
  55. package/lib/popover/setupPopoverListeners.ts +22 -0
  56. package/lib/select/Select.astro +45 -0
  57. package/lib/table/DesktopTableClassses.ts +6 -0
  58. package/lib/table/MobileTableClassses.ts +7 -0
  59. package/lib/table/Table.astro +41 -0
  60. package/lib/table/TableColumnDef.ts +10 -0
  61. package/lib/table/TableD.astro +55 -0
  62. package/lib/table/TableM.astro +22 -0
  63. package/lib/table/TableMEntry.astro +27 -0
  64. package/lib/table/sharedTableRowClasses.ts +1 -0
  65. package/lib/table/tableVisibilityClasses.ts +28 -0
  66. package/lib/text/classesTextGray.ts +1 -0
  67. package/lib/text/classesTextHeader.ts +1 -0
  68. package/lib/utils/bun/BunCmd.ts +7 -0
  69. package/lib/utils/bun/cryAndTryAgainLater.ts +6 -0
  70. package/lib/utils/bun/logBunCmd.ts +1 -0
  71. package/lib/utils/bun/runCmdAsync.ts +44 -0
  72. package/lib/utils/bun/runCmdLocally.ts +13 -0
  73. package/lib/utils/obj/objectKeys.ts +21 -0
  74. package/lib/utils/ran/generateId12.ts +7 -0
  75. package/lib/utils/ran/generateId3.ts +7 -0
  76. package/lib/utils/ran/generateId4.ts +7 -0
  77. package/lib/utils/ran/generateId5.ts +7 -0
  78. package/lib/utils/ran/generateId6.ts +7 -0
  79. package/lib/utils/ran/generateId7.ts +7 -0
  80. package/lib/utils/ran/generateReadableId.ts +35 -0
  81. package/lib/utils/ran/urlAlphabet32.ts +8 -0
  82. package/lib/utils/ui/classArr.ts +3 -0
  83. package/lib/utils/ui/classMerge.ts +10 -0
  84. package/lib/utils/ui/isDevEnv.ts +7 -0
  85. package/lib/utils/ui/tailwindBreakpoint.ts +83 -0
  86. package/package.json +56 -0
@@ -0,0 +1,7 @@
1
+ import { generateReadableId } from "~/utils/ran/generateReadableId"
2
+
3
+ const gen = generateReadableId(6)
4
+
5
+ export function generateId6(): string {
6
+ return gen()
7
+ }
@@ -0,0 +1,7 @@
1
+ import { generateReadableId } from "~/utils/ran/generateReadableId"
2
+
3
+ const gen = generateReadableId(7)
4
+
5
+ export function generateId7(): string {
6
+ return gen()
7
+ }
@@ -0,0 +1,35 @@
1
+ import { urlAlphabet32 } from "./urlAlphabet32"
2
+
3
+ /**
4
+ * * works in browser
5
+ * * completely random, not sequential as a feature
6
+ * * 32 chars: url friendly, readable, not disambiguate
7
+ * * variable length
8
+ * * uses secure crypto/web-crypto/node:crypto api
9
+ * * generates in batches of 4 for better perf
10
+ * @param len - character amount
11
+ */
12
+ export function generateReadableId(len: number = 16): () => string {
13
+ const arr = new Uint16Array(Math.ceil(len / 4))
14
+ return () => {
15
+ crypto.getRandomValues(arr)
16
+ let r = ""
17
+ for (const a of arr) {
18
+ const n1 = (a >> 9) % 32
19
+ r += urlAlphabet32[n1]!
20
+ if (r.length >= len) return r
21
+
22
+ const n2 = (a >> 6) % 32
23
+ r += urlAlphabet32[n2]!
24
+
25
+ if (r.length >= len) return r
26
+ const n3 = (a >> 3) % 32
27
+ r += urlAlphabet32[n3]!
28
+
29
+ if (r.length >= len) return r
30
+ const n4 = a % 32
31
+ r += urlAlphabet32[n4]!
32
+ }
33
+ return r
34
+ }
35
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * - calculate strength - https://zelark.github.io/nano-id-cc/
3
+ * - remove 0, O, i, l for better readability and no disambiguity
4
+ * - 32 length = 10 (numbers) - 1 (no zero) + 26 (alphabet) - 3 (i,l,o)
5
+ * - ignores casing
6
+ * - Crockford's Base32 - https://www.crockford.com/base32.html
7
+ */
8
+ export const urlAlphabet32 = "123456789abcdefghjkmnpqrstuvwxyz"
@@ -0,0 +1,3 @@
1
+ export function classArr(...list: (false | null | undefined | string | 0)[]): string {
2
+ return list.filter(Boolean).join(" ")
3
+ }
@@ -0,0 +1,10 @@
1
+ import { type ClassValue, clsx } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ /**
5
+ * https://github.com/dcastil/tailwind-merge
6
+ * @param inputs
7
+ */
8
+ export function classMerge(...inputs: ClassValue[]) {
9
+ return twMerge(clsx(inputs))
10
+ }
@@ -0,0 +1,7 @@
1
+ export function isDevEnv() {
2
+ return import.meta.env.DEV
3
+ }
4
+
5
+ export function isProdEnv() {
6
+ return !isDevEnv()
7
+ }
@@ -0,0 +1,83 @@
1
+ export type TailwindBreakpoint = keyof typeof tailwindBreakpoint
2
+
3
+ /**
4
+ * https://tailwindcss.com/docs/responsive-design
5
+ */
6
+ export const tailwindBreakpoint = {
7
+ // sm - 640px = 40rem
8
+ sm: "sm",
9
+
10
+ // md - 768px = 48rem
11
+ md: "md",
12
+
13
+ // lg - 1024px = 64rem
14
+ lg: "lg",
15
+
16
+ // xl - 1280px = 80rem
17
+ xl: "xl",
18
+
19
+ // 2xl - 2560px = 160rem
20
+ "2xl": "2xl",
21
+
22
+ // 3xl - 3840px = 240rem
23
+ "3xl": "3xl",
24
+ } as const
25
+
26
+ export const tailwindBreakpointW = {
27
+ sm: "40rem",
28
+ md: "48rem",
29
+ lg: "64rem",
30
+ xl: "80rem",
31
+ "2xl": "160rem",
32
+ "3xl": "240rem",
33
+ } as const satisfies Record<TailwindBreakpoint, string>
34
+
35
+ export const tailwindBreakpointWidthClass = {
36
+ sm: "xl",
37
+ md: "3xl",
38
+ lg: "5xl",
39
+ xl: "7xl",
40
+ "2xl": "",
41
+ "3xl": "",
42
+ } as const satisfies Record<TailwindBreakpoint, string>
43
+
44
+ /**
45
+ * assume: 1 column = 200px
46
+ * xs ~= 400-500
47
+ * sm - 640px = 40rem -> 4 columns
48
+ * md - 768px = 48rem -> 5 columns
49
+ * lg - 1024px = 64rem -> 6 columns
50
+ * xl - 1280px = 80rem -> 7 columns
51
+ * https://tailwindcss.com/docs/responsive-design
52
+ * @param columns - amount of columns
53
+ * @param sm - amount of columns fit inside tailwind xs/sm (640px)
54
+ * @param columnsStepSize - amount of columns fit inside an increase in tailwind breakpoint (around 200px)
55
+ */
56
+ export function tableColumnAmountToTailwindBreakpoint(
57
+ columns: number,
58
+ sm = 3,
59
+ columnsStepSize = 1,
60
+ ): TailwindBreakpoint {
61
+ const v = columns - sm
62
+ if (v === columnsStepSize) return tailwindBreakpoint.md
63
+ if (v === columnsStepSize * 2) return tailwindBreakpoint.lg
64
+ if (v >= columnsStepSize * 3) return tailwindBreakpoint.xl
65
+ return tailwindBreakpoint.sm
66
+ }
67
+
68
+ // max-w-3xs - 16rem - 256px
69
+ // max-w-2xs - 18rem - 288px
70
+ // max-w-xs - 20rem - 320px
71
+ // max-w-sm - 24rem - 384px
72
+ // max-w-md - 28rem - 448px
73
+ // max-w-lg - 32rem - 512px
74
+ // max-w-xl - 36rem - 576px
75
+ // max-w-2xl - 42rem - 672px
76
+ // max-w-3xl - 48rem - 768px
77
+ // max-w-4xl - 56rem - 896px
78
+ // max-w-5xl - 64rem - 1024px
79
+ // max-w-6xl - 72rem - 1152px
80
+ // max-w-7xl - 80rem - 1280px
81
+ // max-w-min
82
+ // max-w-max
83
+ // max-w-fit
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@adaptive-sm/astro-ui",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": false,
6
+ "scripts": {
7
+ "astro": "astro",
8
+ "dev": "nice -5 astro dev",
9
+ "check": "clear && nice -15 astro check --minimumSeverity error",
10
+ "build": "nice -15 astro build",
11
+ "deploy": "bun run build && bun run upload && bun run tag",
12
+ "upload": "bun run wrangler pages deploy ./dist --project-name=adaptive-astro-ui --commit-dirty",
13
+ "tag": "git branch -f deployed",
14
+ "generateDemoList": "bun run ./src/pages/demos/generateDemoList.cli.ts",
15
+ "generateImageList": "bun run ./src/pages/images/generateImageList.cli.ts",
16
+ "generateAiRulesLib": "bash ./lib/generate_ai_rules/generate_agent_rules_1_lib.bash",
17
+ "update": "nice -15 bun x npm-check-updates -u && bun i",
18
+ "update:commit": "bun x npm-check-updates -u && bun i && git add package.json && bun run tsc && git commit -m \"update dependencies\" && git push",
19
+ "clean": "rm -rf ./dist",
20
+ "reset": "rm -rf ./node_modules"
21
+ },
22
+ "devDependencies": {
23
+ "@astrojs/check": "^0.9.4",
24
+ "@biomejs/biome": "^2.2.4",
25
+ "@mdi/js": "^7.4.47",
26
+ "@tailwindcss/vite": "^4.1.13",
27
+ "@types/bun": "latest",
28
+ "astro": "^5.13.9",
29
+ "dayjs": "^1.11.18",
30
+ "image-size": "^2.0.2",
31
+ "prettier": "^3.6.2",
32
+ "prettier-plugin-astro": "^0.14.1",
33
+ "rehype-autolink-headings": "^7.1.0",
34
+ "rehype-slug": "^6.0.0",
35
+ "remark-toc": "^9.0.0",
36
+ "rollup-plugin-visualizer": "^6.0.3",
37
+ "tailwind-merge": "^3.3.1",
38
+ "tailwindcss": "^4.1.13",
39
+ "typescript": "^5.9.2",
40
+ "wrangler": "^4.38.0"
41
+ },
42
+ "prettier": {
43
+ "semi": false,
44
+ "printWidth": 120,
45
+ "trailingComma": "all",
46
+ "plugins": [
47
+ "prettier-plugin-astro"
48
+ ]
49
+ },
50
+ "files": [
51
+ "lib"
52
+ ],
53
+ "exports": {
54
+ "./*": "./lib/*"
55
+ }
56
+ }