@adaptive-sm/astro-ui 0.2.1 → 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 (94) hide show
  1. package/README.md +7 -7
  2. package/lib/badge/Badge.astro +27 -0
  3. package/lib/badge/classesBadge.ts +67 -0
  4. package/lib/button/Button.astro +17 -27
  5. package/lib/button/buttonCva.ts +4 -2
  6. package/lib/button/buttonIconCva.ts +2 -2
  7. package/lib/button/classesButtonClickAnimation.ts +1 -1
  8. package/lib/button/classesButtonClickAnimationPush.ts +1 -1
  9. package/lib/button/classesButtonClickAnimationSquish.ts +1 -1
  10. package/lib/card/CardWrapper.astro +6 -5
  11. package/lib/card/classesBorderWrapper.ts +1 -0
  12. package/lib/card/classesCardWrapper.ts +21 -9
  13. package/lib/card/classesShadow.ts +5 -0
  14. package/lib/details/Details.astro +13 -8
  15. package/lib/dev/TailwindIndicator.astro +2 -2
  16. package/lib/form/Fieldset.astro +8 -5
  17. package/lib/generate_demo_list/DemoList.astro +3 -3
  18. package/lib/generate_demo_list/generateDemoList.ts +2 -2
  19. package/lib/generate_image_list/generateImageList.ts +3 -3
  20. package/lib/grid/FeatureGridSection.astro +28 -35
  21. package/lib/grid/classesGridCols.ts +27 -2
  22. package/lib/header/PageHeader.astro +25 -0
  23. package/lib/header/SectionHeader.astro +37 -0
  24. package/lib/icon/Icon.astro +26 -0
  25. package/lib/icons/iconApple.ts +1 -0
  26. package/lib/icons/iconGithub.ts +4 -0
  27. package/lib/icons/iconGoogle.ts +4 -0
  28. package/lib/icons/iconGooglePlay.ts +2 -0
  29. package/lib/icons/iconLinkedin.ts +2 -0
  30. package/lib/icons/iconNpm.ts +2 -0
  31. package/lib/icons/iconTelegram.ts +2 -0
  32. package/lib/icons/iconTrello.ts +2 -0
  33. package/lib/icons/iconXcom.ts +1 -0
  34. package/lib/img/Img.astro +10 -5
  35. package/lib/img/TypedImg.astro +11 -10
  36. package/lib/img/TypedImgB2.astro +25 -0
  37. package/lib/layouts/MarkdownPageWrapper.astro +19 -0
  38. package/lib/layouts/MinimalLayout.astro +23 -16
  39. package/lib/layouts/parts/ThemeToggle.astro +9 -9
  40. package/lib/link/LinkButton.astro +18 -19
  41. package/lib/link/LinkText.astro +10 -7
  42. package/lib/link/classesTextLink.ts +1 -1
  43. package/lib/list/BlackBulletPoint.astro +1 -1
  44. package/lib/list/BlackBulletPoints.astro +7 -7
  45. package/lib/list/CheckPoint.astro +3 -3
  46. package/lib/list/CheckPoints.astro +3 -3
  47. package/lib/list/NumberedList.astro +1 -1
  48. package/lib/list/Ps.astro +8 -5
  49. package/lib/list/TextOrLink.astro +3 -9
  50. package/lib/md/MarkdownDiv.astro +18 -0
  51. package/lib/modal/Modal.astro +28 -12
  52. package/lib/modal/ModalButton.astro +35 -12
  53. package/lib/page/PageCentered.astro +5 -3
  54. package/lib/page/PageCenteredCard.astro +7 -5
  55. package/lib/page/classesPageCentered.ts +1 -1
  56. package/lib/popover/Popover1.astro +4 -4
  57. package/lib/select/Select.astro +14 -10
  58. package/lib/table/Table.astro +2 -2
  59. package/lib/table/TableD.astro +2 -2
  60. package/lib/table/TableM.astro +2 -2
  61. package/lib/table/TableMEntry.astro +2 -2
  62. package/lib/table/tableVisibilityClasses.ts +3 -3
  63. package/lib/utils/HasId.ts +3 -0
  64. package/lib/utils/HasSubtitle.ts +4 -0
  65. package/lib/utils/HasTitle.ts +4 -0
  66. package/lib/utils/MayHaveButtonVariant.ts +5 -0
  67. package/lib/utils/MayHaveClass.ts +3 -0
  68. package/lib/utils/MayHaveIcon.ts +4 -0
  69. package/lib/utils/MayHaveId.ts +3 -0
  70. package/lib/utils/MayHaveInnerClass.ts +3 -0
  71. package/lib/utils/MayHaveSubtitle.ts +4 -0
  72. package/lib/utils/MayHaveTitle.ts +4 -0
  73. package/package.json +13 -12
  74. package/lib/icon/Icon1.astro +0 -21
  75. package/lib/layouts/MarkdownWrapper.astro +0 -17
  76. package/lib/utils/bun/BunCmd.ts +0 -7
  77. package/lib/utils/bun/cryAndTryAgainLater.ts +0 -6
  78. package/lib/utils/bun/logBunCmd.ts +0 -1
  79. package/lib/utils/bun/runCmdAsync.ts +0 -44
  80. package/lib/utils/bun/runCmdLocally.ts +0 -13
  81. package/lib/utils/obj/objectKeys.ts +0 -21
  82. package/lib/utils/ran/generateId12.ts +0 -7
  83. package/lib/utils/ran/generateId3.ts +0 -7
  84. package/lib/utils/ran/generateId4.ts +0 -7
  85. package/lib/utils/ran/generateId5.ts +0 -7
  86. package/lib/utils/ran/generateId6.ts +0 -7
  87. package/lib/utils/ran/generateId7.ts +0 -7
  88. package/lib/utils/ran/generateReadableId.ts +0 -35
  89. package/lib/utils/ran/urlAlphabet32.ts +0 -8
  90. /package/lib/{layouts/parts → md}/markdown.css +0 -0
  91. /package/lib/utils/{ui/classArr.ts → classArr.ts} +0 -0
  92. /package/lib/utils/{ui/classMerge.ts → classMerge.ts} +0 -0
  93. /package/lib/utils/{ui/isDevEnv.ts → isDevEnv.ts} +0 -0
  94. /package/lib/utils/{ui/tailwindBreakpoint.ts → tailwindBreakpoint.ts} +0 -0
@@ -1,9 +1,9 @@
1
1
  ---
2
+ import Button from "~ui/button/Button.astro"
3
+ import { buttonVariant, type ButtonSize, type ButtonVariant } from "~ui/button/buttonCva"
4
+ import { classesTextHeader } from "~ui/text/classesTextHeader"
5
+ import { classMerge } from "~ui/utils/classMerge"
2
6
  import "./Modal.module.css"
3
- import { classesTextHeader } from "~/text/classesTextHeader"
4
- import { classMerge } from "~/utils/ui/classMerge"
5
- import { buttonVariant } from "~/button/buttonCva"
6
- import Button from "~/button/Button.astro"
7
7
 
8
8
  /**
9
9
  * https://github.com/markteekman/accessible-astro-components/blob/main/Modal.astro
@@ -13,16 +13,25 @@ interface Props {
13
13
  title: string
14
14
  titleClass?: string
15
15
  closeText?: string
16
+
17
+ close?: {
18
+ text?: string
19
+ variant?: ButtonVariant
20
+ size?: ButtonSize
21
+ class?: string
22
+ icon?: string
23
+ iconClass?: string
24
+ }
25
+
16
26
  class?: string
17
27
  classContentArea?: string
18
28
  }
19
29
 
20
- const props = Astro.props
21
- const triggerId = props.triggerId
22
- const title = props.title
23
- const titleClass = props.titleClass
24
- const closeText = props.closeText ?? "Close"
25
- const classContentArea = props.classContentArea
30
+ const p = Astro.props
31
+ const triggerId = p.triggerId
32
+ const title = p.title
33
+ const titleClass = p.titleClass
34
+ const classContentArea = p.classContentArea
26
35
  const closeId = `${triggerId}-close`
27
36
  ---
28
37
 
@@ -33,7 +42,7 @@ const closeId = `${triggerId}-close`
33
42
  "max-w-5xl",
34
43
  "bg-white dark:bg-gray-900 text-black dark:text-white", // bg
35
44
  "border-1 border-black p-4 rounded-xl", // border
36
- props.class,
45
+ p.class,
37
46
  )}
38
47
  aria-labelledby={triggerId}
39
48
  >
@@ -43,7 +52,14 @@ const closeId = `${triggerId}-close`
43
52
  {title}
44
53
  </h2>
45
54
  <slot>Modal description</slot>
46
- <Button id={closeId} variant={buttonVariant.outline} class="modal-close w-full">{closeText}</Button>
55
+ <Button
56
+ id={closeId}
57
+ icon={p.close?.icon}
58
+ iconClass={p.close?.iconClass}
59
+ size={p.close?.size}
60
+ variant={p.close?.variant ?? buttonVariant.outline}
61
+ class={classMerge("modal-close w-full", p.close?.class)}>{p.close?.text ?? "Close"}</Button
62
+ >
47
63
  </div>
48
64
  </div>
49
65
  </dialog>
@@ -1,10 +1,9 @@
1
1
  ---
2
- import { generateId5 } from "~/utils/ran/generateId5"
3
- import type { ButtonSize, ButtonVariant } from "~/button/buttonCva"
2
+ import Button from "~ui/button/Button.astro"
3
+ import type { ButtonSize, ButtonVariant } from "~ui/button/buttonCva"
4
+ import { classesTextGray } from "~ui/text/classesTextGray"
5
+ import { classArr } from "~ui/utils/classArr"
4
6
  import Modal from "./Modal.astro"
5
- import { classesTextGray } from "~/text/classesTextGray"
6
- import { classArr } from "~/utils/ui/classArr"
7
- import Button from "~/button/Button.astro"
8
7
 
9
8
  interface Props {
10
9
  button: {
@@ -17,25 +16,49 @@ interface Props {
17
16
  iconClass?: string
18
17
  class?: string
19
18
  }
19
+ close?: {
20
+ text?: string
21
+ variant?: ButtonVariant
22
+ size?: ButtonSize
23
+ class?: string
24
+ icon?: string
25
+ iconClass?: string
26
+ }
20
27
  id?: string
21
28
  title?: string
29
+ titleClass?: string
22
30
  class?: string
23
31
  classContentArea?: string
24
32
  }
25
- const props = Astro.props
26
- const id = props.id ?? `modal-id-${generateId5()}`
27
- const button = props.button
28
- const title = props.title ?? "Dialog Title"
29
- const classContentArea = props.classContentArea
33
+ const p = Astro.props
34
+
35
+ /**
36
+ * Generates a random alphanumeric string ID
37
+ *
38
+ * Uses Math.random() converted to base-36 to create a string of letters and numbers.
39
+ * The substring(2, 11) removes the "0." prefix and takes 9 characters for a good balance
40
+ * of uniqueness and brevity (approximately 10^36 possible combinations).
41
+ *
42
+ * @returns {string} A 9-character random alphanumeric string
43
+ */
44
+ function generateRandomId(): string {
45
+ return Math.random().toString(36).substring(2, 11)
46
+ }
47
+
48
+ const id = p.id ?? `modal-id-${generateRandomId()}`
49
+ const button = p.button
50
+ const title = p.title ?? "Dialog Title"
51
+ const classContentArea = p.classContentArea
30
52
  ---
31
53
 
32
54
  <Button id={id} {...button} />
33
55
  <Modal
34
56
  triggerId={id}
35
57
  title={title}
36
- titleClass={classArr(classesTextGray, "text-xl", "mb-2")}
37
- class={props.class}
58
+ titleClass={classArr(classesTextGray, "text-xl", "mb-2", p.titleClass)}
59
+ class={p.class}
38
60
  classContentArea={classContentArea}
61
+ close={p.close}
39
62
  >
40
63
  <slot />
41
64
  </Modal>
@@ -1,14 +1,16 @@
1
1
  ---
2
- import { classMerge } from "~/utils/ui/classMerge"
2
+ import { classMerge } from "~ui/utils/classMerge"
3
3
  import { classesPageCentered } from "./classesPageCentered"
4
+ import type { HTMLAttributes } from "astro/types"
4
5
 
5
6
  interface Props {
6
- id?:string
7
+ id?: string
7
8
  class?: string
9
+ restProps?: HTMLAttributes<"div">
8
10
  }
9
11
  const p = Astro.props
10
12
  ---
11
13
 
12
- <div id={p.id} class={classMerge(classesPageCentered, p.class)}>
14
+ <div id={p.id} class={classMerge(classesPageCentered, p.class)} {...p.restProps}>
13
15
  <slot />
14
16
  </div>
@@ -1,17 +1,19 @@
1
1
  ---
2
- import { classMerge } from "~/utils/ui/classMerge"
2
+ import type { HTMLAttributes } from "astro/types"
3
+ import { classesCardWrapperPage } from "~ui/card/classesCardWrapper"
4
+ import { classMerge } from "~ui/utils/classMerge"
3
5
  import PageCentered from "./PageCentered.astro"
4
- import { classesCardWrapperPage } from "~/card/classesCardWrapper"
5
6
 
6
7
  interface Props {
7
8
  class?: string
8
9
  classInner?: string
10
+ restProps?: HTMLAttributes<"div">
9
11
  }
10
- const props = Astro.props
12
+ const p = Astro.props
11
13
  ---
12
14
 
13
- <PageCentered class={props.class}>
14
- <div class={classMerge(classesCardWrapperPage, props.classInner)}>
15
+ <PageCentered class={p.class} restProps={p.restProps}>
16
+ <div class={classMerge(classesCardWrapperPage, p.classInner)}>
15
17
  <slot />
16
18
  </div>
17
19
  </PageCentered>
@@ -1,4 +1,4 @@
1
- import { classArr } from "~/utils/ui/classArr"
1
+ import { classArr } from "~ui/utils/classArr"
2
2
 
3
3
  export const classesPageCentered = classArr(
4
4
  "flex flex-col justify-center items-center my-auto", // align center
@@ -1,7 +1,7 @@
1
1
  ---
2
- import Icon1 from "~/icon/Icon1.astro"
3
- import { buttonVariant, type ButtonVariant, buttonCva2 } from "~/button/buttonCva"
4
- import { classArr } from "~/utils/ui/classArr"
2
+ import Icon from "~ui/icon/Icon.astro"
3
+ import { buttonVariant, type ButtonVariant, buttonCva2 } from "~ui/button/buttonCva"
4
+ import { classArr } from "~ui/utils/classArr"
5
5
  import { setupPopoverListeners } from "./setupPopoverListeners"
6
6
 
7
7
  interface Props {
@@ -23,7 +23,7 @@ const summaryClasses = buttonCva2(variant, null, "flex flex-wrap gap-2 text-xl f
23
23
  )}
24
24
  >
25
25
  <summary class={summaryClasses}>
26
- <Icon1 path={icon} />
26
+ <Icon path={icon} />
27
27
  {title}
28
28
  </summary>
29
29
  <div
@@ -1,18 +1,21 @@
1
1
  ---
2
- import { classArr } from "~/utils/ui/classArr"
2
+ import type { HTMLAttributes } from "astro/types"
3
+ import { classArr } from "~ui/utils/classArr"
4
+ import type { MayHaveClass } from "~ui/utils/MayHaveClass"
5
+ import type { MayHaveId } from "~ui/utils/MayHaveId"
3
6
 
4
7
  type ValueDisplayFn = (value: string) => string
5
8
 
6
- type NativeSingleSelectProps = {
9
+ export interface Props extends MayHaveId, MayHaveClass {
7
10
  initialValue: string
8
11
  options: string[]
9
12
  optionClass?: string
10
13
  valueDisplay?: ValueDisplayFn
11
14
  id?: string
12
15
  class?: string
16
+ restProps?: HTMLAttributes<"select">
13
17
  }
14
-
15
- const props = Astro.props as NativeSingleSelectProps
18
+ const p = Astro.props
16
19
 
17
20
  const getDisplayValue = (itemValue: string, valueDisplay?: ValueDisplayFn) => {
18
21
  if (!valueDisplay) return itemValue
@@ -23,7 +26,7 @@ const getDisplayValue = (itemValue: string, valueDisplay?: ValueDisplayFn) => {
23
26
  ---
24
27
 
25
28
  <select
26
- id={props.id}
29
+ id={p.id}
27
30
  class={classArr(
28
31
  "block w-full p-2.5",
29
32
  "text-gray-900 dark:text-white text-sm",
@@ -31,14 +34,15 @@ const getDisplayValue = (itemValue: string, valueDisplay?: ValueDisplayFn) => {
31
34
  "bg-gray-50 dark:bg-gray-700",
32
35
  "rounded-lg border border-gray-300 dark:border-gray-600",
33
36
  "focus:ring-blue-500 focus:border-blue-500 dark:focus:border-blue-500 dark:focus:ring-blue-500",
34
- props.class,
37
+ p.class,
35
38
  )}
36
- value={props.initialValue}
39
+ value={p.initialValue}
40
+ {...p.restProps}
37
41
  >
38
42
  {
39
- props.options.map((option: string) => (
40
- <option value={option} class={props.optionClass}>
41
- {getDisplayValue(option, props.valueDisplay)}
43
+ p.options.map((option: string) => (
44
+ <option value={option} class={p.optionClass} selected={option === p.initialValue}>
45
+ {getDisplayValue(option, p.valueDisplay)}
42
46
  </option>
43
47
  ))
44
48
  }
@@ -2,8 +2,8 @@
2
2
  import type { DesktopTableClassses } from "./DesktopTableClassses"
3
3
  import type { MobileTableClassses } from "./MobileTableClassses"
4
4
  import { tableVisibilityClasses } from "./tableVisibilityClasses"
5
- import { classMerge } from "~/utils/ui/classMerge"
6
- import { type TailwindBreakpoint, tailwindBreakpoint } from "~/utils/ui/tailwindBreakpoint"
5
+ import { classMerge } from "~ui/utils/classMerge"
6
+ import { type TailwindBreakpoint, tailwindBreakpoint } from "~ui/utils/tailwindBreakpoint"
7
7
  import type { TableColumnDef } from "./TableColumnDef"
8
8
  import TableD from "./TableD.astro"
9
9
  import TableM from "./TableM.astro"
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  import { type DesktopTableClassses } from "./DesktopTableClassses"
3
3
  import { sharedTableRowClasses } from "./sharedTableRowClasses"
4
- // import { t4table } from "~/ui_tables/table3/t4table"
5
- import { classMerge } from "~/utils/ui/classMerge"
4
+ // import { t4table } from "~ui/ui_tables/table3/t4table"
5
+ import { classMerge } from "~ui/utils/classMerge"
6
6
  import { type TableColumnDef } from "./TableColumnDef"
7
7
 
8
8
  interface Props {
@@ -1,8 +1,8 @@
1
1
  ---
2
- import { classMerge } from "~/utils/ui/classMerge"
2
+ import { classMerge } from "~ui/utils/classMerge"
3
3
  import { type TableColumnDef } from "./TableColumnDef"
4
4
  import TableMEntry from "./TableMEntry.astro"
5
- import type { MobileTableClassses } from "~/table/MobileTableClassses"
5
+ import type { MobileTableClassses } from "~ui/table/MobileTableClassses"
6
6
 
7
7
  interface Props {
8
8
  rows: string[]
@@ -1,7 +1,7 @@
1
1
  ---
2
- import { classMerge } from "~/utils/ui/classMerge"
2
+ import { classMerge } from "~ui/utils/classMerge"
3
3
  import { type TableColumnDef } from "./TableColumnDef"
4
- import type { MobileTableClassses } from "~/table/MobileTableClassses"
4
+ import type { MobileTableClassses } from "~ui/table/MobileTableClassses"
5
5
 
6
6
  interface Props {
7
7
  row: string
@@ -1,6 +1,6 @@
1
- import { classMerge } from "~/utils/ui/classMerge"
2
- import type { TailwindBreakpoint } from "~/utils/ui/tailwindBreakpoint"
3
- import { tailwindBreakpoint } from "~/utils/ui/tailwindBreakpoint"
1
+ import { classMerge } from "~ui/utils/classMerge"
2
+ import type { TailwindBreakpoint } from "~ui/utils/tailwindBreakpoint"
3
+ import { tailwindBreakpoint } from "~ui/utils/tailwindBreakpoint"
4
4
 
5
5
  function tableDesktopclass(b: TailwindBreakpoint) {
6
6
  const tb = tailwindBreakpoint
@@ -0,0 +1,3 @@
1
+ export interface HasId {
2
+ id: string
3
+ }
@@ -0,0 +1,4 @@
1
+ export interface HasSubtitle {
2
+ subtitle: string
3
+ subtitleClass?: string
4
+ }
@@ -0,0 +1,4 @@
1
+ export interface HasTitle {
2
+ title: string
3
+ titleClass?: string
4
+ }
@@ -0,0 +1,5 @@
1
+ import type { ButtonVariant } from "~ui/button/buttonCva"
2
+
3
+ export interface MayHaveButtonVariant {
4
+ variant?: ButtonVariant
5
+ }
@@ -0,0 +1,3 @@
1
+ export interface MayHaveClass {
2
+ class?: string
3
+ }
@@ -0,0 +1,4 @@
1
+ export interface MayHaveIcon {
2
+ icon?: string
3
+ iconClass?: string
4
+ }
@@ -0,0 +1,3 @@
1
+ export interface MayHaveId {
2
+ id?: string
3
+ }
@@ -0,0 +1,3 @@
1
+ export interface MayHaveInnerClass {
2
+ innerClass?: string
3
+ }
@@ -0,0 +1,4 @@
1
+ export interface MayHaveSubtitle {
2
+ subtitle?: string
3
+ subtitleClass?: string
4
+ }
@@ -0,0 +1,4 @@
1
+ export interface MayHaveTitle {
2
+ title?: string
3
+ titleClass?: string
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptive-sm/astro-ui",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "scripts": {
5
5
  "astro": "astro",
6
6
  "dev": "nice -5 astro dev",
@@ -10,7 +10,7 @@
10
10
  "upload": "bun run wrangler pages deploy ./dist --project-name=adaptive-astro-ui --commit-dirty",
11
11
  "tag": "git branch -f deployed",
12
12
  "release": "bash ./ops/release.sh",
13
- "generateDemoList": "bun run ./lib/generate_demo_list/generateDemoList.ts",
13
+ "generateDemoList": "bun run ./src/demos/generateDemoList.cli.ts",
14
14
  "generateImageList": "bun run ./src/pages/images/generateImageList.cli.ts",
15
15
  "generateAiRulesLib": "bash ./lib/generate_ai_rules/generate_agent_rules_1_lib.bash",
16
16
  "update": "nice -15 bun x npm-check-updates -u && bun i",
@@ -19,24 +19,25 @@
19
19
  "reset": "rm -rf ./node_modules"
20
20
  },
21
21
  "devDependencies": {
22
- "@astrojs/check": "^0.9.4",
23
- "@biomejs/biome": "^2.2.4",
22
+ "@adaptive-sm/utils": "^0.5.0",
23
+ "@astrojs/check": "^0.9.5",
24
+ "@biomejs/biome": "^2.3.6",
24
25
  "@mdi/js": "^7.4.47",
25
- "@tailwindcss/vite": "^4.1.13",
26
+ "@tailwindcss/vite": "^4.1.17",
26
27
  "@types/bun": "latest",
27
- "astro": "^5.13.9",
28
- "dayjs": "^1.11.18",
28
+ "astro": "^5.15.9",
29
+ "dayjs": "^1.11.19",
29
30
  "image-size": "^2.0.2",
30
31
  "prettier": "^3.6.2",
31
32
  "prettier-plugin-astro": "^0.14.1",
32
33
  "rehype-autolink-headings": "^7.1.0",
33
34
  "rehype-slug": "^6.0.0",
34
35
  "remark-toc": "^9.0.0",
35
- "rollup-plugin-visualizer": "^6.0.3",
36
- "tailwind-merge": "^3.3.1",
37
- "tailwindcss": "^4.1.13",
38
- "typescript": "^5.9.2",
39
- "wrangler": "^4.38.0"
36
+ "rollup-plugin-visualizer": "^6.0.5",
37
+ "tailwind-merge": "^3.4.0",
38
+ "tailwindcss": "^4.1.17",
39
+ "typescript": "^5.9.3",
40
+ "wrangler": "^4.49.0"
40
41
  },
41
42
  "prettier": {
42
43
  "semi": false,
@@ -1,21 +0,0 @@
1
- ---
2
- import { classMerge } from "~/utils/ui/classMerge"
3
-
4
- interface Props {
5
- path: string
6
- class?: string
7
- title?: string
8
- ariaHidden?: boolean
9
- }
10
- const props = Astro.props
11
- const ariaHidden = props.ariaHidden ?? !props.title
12
- // TODO: maybe re-add title={title}
13
- ---
14
-
15
- <svg
16
- viewBox={"0 0 24 24"}
17
- aria-hidden={ariaHidden}
18
- class={classMerge("size-6 flex-shrink-0 align-middle dark:fill-white", props.class)}
19
- >
20
- <path d={props.path}></path>
21
- </svg>
@@ -1,17 +0,0 @@
1
- ---
2
- import PageCenteredCard from "~/page/PageCenteredCard.astro"
3
- import { classMerge } from "~/utils/ui/classMerge"
4
- import { classArr } from "~/utils/ui/classArr"
5
-
6
- import "./parts/markdown.css"
7
-
8
- interface Props {
9
- class?: string
10
- }
11
-
12
- const p = Astro.props
13
- ---
14
-
15
- <PageCenteredCard class={classMerge("max-w-5xl my-12", p.class)} classInner={classArr("markdown-body", p.class)}>
16
- <slot />
17
- </PageCenteredCard>
@@ -1,7 +0,0 @@
1
- export type BunCmd = {
2
- cmd: string[]
3
- success: boolean
4
- exitCode: number
5
- lines: string[]
6
- ms: number
7
- }
@@ -1,6 +0,0 @@
1
- import process from "node:process"
2
-
3
- export function cryAndTryAgainLater<T>(t: T): T {
4
- process.exit(1)
5
- return t
6
- }
@@ -1 +0,0 @@
1
- export const logBunCmd = true
@@ -1,44 +0,0 @@
1
- import console from "node:console"
2
- import type { BunCmd } from "./BunCmd"
3
- import { logBunCmd } from "./logBunCmd"
4
-
5
- export async function runCmdAsync(cmd: string[]): Promise<BunCmd> {
6
- const startedAt = performance.now()
7
- if (logBunCmd) {
8
- console.log({ cmd })
9
- }
10
- const process = Bun.spawn(cmd, {
11
- stdout: "pipe",
12
- stderr: "pipe",
13
- })
14
- const exitCode = await process.exited
15
- const output = await Bun.readableStreamToText(process.stdout)
16
- const error = await Bun.readableStreamToText(process.stderr)
17
- const outputLines = output.split("\n").filter((s) => s.length > 0)
18
- const errorLines = error.split("\n").filter((s) => s.length > 0)
19
- const lines = [...outputLines, ...errorLines]
20
- const endedAt = performance.now()
21
- const ms = Math.round(endedAt - startedAt)
22
- const r: BunCmd = {
23
- cmd,
24
- success: exitCode === 0,
25
- exitCode,
26
- lines,
27
- ms,
28
- }
29
- if (logBunCmd) {
30
- if (lines.length < 8) {
31
- console.log(r)
32
- } else {
33
- const l: Omit<BunCmd, "lines"> = {
34
- cmd,
35
- success: exitCode === 0,
36
- exitCode,
37
- ms,
38
- }
39
- console.log(l)
40
- console.log(JSON.stringify(lines, null, 2))
41
- }
42
- }
43
- return r
44
- }
@@ -1,13 +0,0 @@
1
- import type { BunCmd } from "./BunCmd"
2
- import { cryAndTryAgainLater } from "./cryAndTryAgainLater"
3
- import { runCmdAsync } from "./runCmdAsync"
4
-
5
- export async function runCmdLocally(cmd: string | string[]): Promise<BunCmd> {
6
- return runCmdAsync(["sh", "-c", Array.isArray(cmd) ? cmd.join(" ") : cmd])
7
- }
8
-
9
- export async function runCmdLocallyAndExitOnError(cmd: string | string[]): Promise<BunCmd> {
10
- const got = await runCmdLocally(cmd)
11
- if (!got.success) return cryAndTryAgainLater(got)
12
- return got
13
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Like Object.keys, but unsound in exchange for more convenience.
3
- *
4
- * Casts the result of Object.keys to the known keys of an object type,
5
- * even though JavaScript objects may contain additional keys.
6
- *
7
- * Only use this function when you know/control the provenance of the object
8
- * you're iterating, and can verify it contains exactly the keys declared
9
- * to the type system.
10
- *
11
- * Example:
12
- * ```
13
- * const o = {x: "ok", y: 10}
14
- * o["z"] = "UNTRACKED_KEY"
15
- * const safeKeys = Object.keys(o)
16
- * const unsafeKeys = objectKeys(o)
17
- * ```
18
- * => const safeKeys: string[]
19
- * => const unsafeKeys: ("x" | "y")[] // Missing "z"
20
- */
21
- export const objectKeys = Object.keys as <T>(obj: T) => Array<keyof T>
@@ -1,7 +0,0 @@
1
- import { generateReadableId } from "~/utils/ran/generateReadableId"
2
-
3
- const gen = generateReadableId(12)
4
-
5
- export function generateId12(): string {
6
- return gen()
7
- }
@@ -1,7 +0,0 @@
1
- import { generateReadableId } from "~/utils/ran/generateReadableId"
2
-
3
- const gen = generateReadableId(3)
4
-
5
- export function generateId3(): string {
6
- return gen()
7
- }
@@ -1,7 +0,0 @@
1
- import { generateReadableId } from "~/utils/ran/generateReadableId"
2
-
3
- const gen = generateReadableId(4)
4
-
5
- export function generateId4(): string {
6
- return gen()
7
- }
@@ -1,7 +0,0 @@
1
- import { generateReadableId } from "./generateReadableId"
2
-
3
- const gen = generateReadableId(5)
4
-
5
- export function generateId5(): string {
6
- return gen()
7
- }
@@ -1,7 +0,0 @@
1
- import { generateReadableId } from "~/utils/ran/generateReadableId"
2
-
3
- const gen = generateReadableId(6)
4
-
5
- export function generateId6(): string {
6
- return gen()
7
- }
@@ -1,7 +0,0 @@
1
- import { generateReadableId } from "~/utils/ran/generateReadableId"
2
-
3
- const gen = generateReadableId(7)
4
-
5
- export function generateId7(): string {
6
- return gen()
7
- }