@rimelight/ui 0.0.24 → 0.0.26

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 (65) hide show
  1. package/package.json +7 -3
  2. package/src/components/Head.astro +199 -156
  3. package/src/components/ThemeToggle.astro +2 -2
  4. package/src/components/astro/RLAAccordion.astro +22 -0
  5. package/src/components/astro/RLAButton.astro +104 -118
  6. package/src/components/astro/RLAFooter.astro +17 -43
  7. package/src/components/astro/RLAHeader.astro +21 -80
  8. package/src/components/astro/RLAIcon.astro +14 -39
  9. package/src/components/astro/RLALogo.astro +14 -48
  10. package/src/components/astro/RLAPlaceholder.astro +11 -35
  11. package/src/components/astro/RLAQuote.astro +15 -0
  12. package/src/components/astro/RLAScrollToTop.astro +171 -221
  13. package/src/components/astro/RLASection.astro +210 -0
  14. package/src/components/vue/RLVButton.vue +166 -139
  15. package/src/components/vue/RLVFooter.vue +17 -54
  16. package/src/components/vue/RLVHeader.vue +22 -105
  17. package/src/components/vue/RLVIcon.vue +14 -45
  18. package/src/components/vue/RLVLogo.vue +11 -58
  19. package/src/components/vue/RLVPlaceholder.vue +14 -35
  20. package/src/components/vue/RLVScrollToTop.vue +18 -89
  21. package/src/components/vue/RLVSection.vue +166 -0
  22. package/src/composables/index.ts +0 -1
  23. package/src/env.d.ts +5 -0
  24. package/src/integrations/ui.ts +2 -6
  25. package/src/plugins/index.ts +5 -2
  26. package/src/plugins/starlightAddons/index.ts +3 -64
  27. package/src/plugins/starlightDocsApi/components/ApiEmits.astro +46 -0
  28. package/src/plugins/starlightDocsApi/components/ApiProps.astro +47 -0
  29. package/src/plugins/starlightDocsApi/components/ApiSlots.astro +50 -0
  30. package/src/plugins/starlightDocsApi/components/ApiTheme.astro +27 -0
  31. package/src/plugins/starlightDocsApi/extract-vue.ts +286 -0
  32. package/src/plugins/starlightDocsApi/index.ts +265 -0
  33. package/src/plugins/starlightDocsApi/types.ts +40 -0
  34. package/src/plugins/starlightDocsApi/utils.ts +45 -0
  35. package/src/themes/button.theme.ts +29 -14
  36. package/src/themes/footer.theme.ts +4 -6
  37. package/src/themes/header.theme.ts +4 -28
  38. package/src/themes/icon.theme.ts +4 -2
  39. package/src/themes/index.ts +15 -20
  40. package/src/themes/logo.theme.ts +4 -2
  41. package/src/themes/placeholder.theme.ts +4 -6
  42. package/src/themes/scroll-to-top.theme.ts +4 -6
  43. package/src/themes/section.theme.ts +187 -0
  44. package/src/types/componentVariant.ts +14 -0
  45. package/src/types/index.ts +1 -0
  46. package/src/utils/defineTheme.ts +11 -0
  47. package/src/utils/index.ts +3 -0
  48. package/src/utils/resolveClasses.ts +21 -0
  49. package/src/utils/useUi.ts +19 -0
  50. package/src/composables/useUi.ts +0 -27
  51. package/src/plugins/starlightAddons/Sidebar.astro +0 -89
  52. package/src/plugins/starlightAddons/data.ts +0 -39
  53. package/src/plugins/starlightAddons/libs/config.ts +0 -107
  54. package/src/plugins/starlightAddons/libs/content.ts +0 -20
  55. package/src/plugins/starlightAddons/libs/i18n.ts +0 -51
  56. package/src/plugins/starlightAddons/libs/locals.ts +0 -12
  57. package/src/plugins/starlightAddons/libs/pathname.ts +0 -22
  58. package/src/plugins/starlightAddons/libs/plugin.ts +0 -9
  59. package/src/plugins/starlightAddons/libs/sidebar.ts +0 -183
  60. package/src/plugins/starlightAddons/libs/vite.ts +0 -46
  61. package/src/plugins/starlightAddons/locals.d.ts +0 -14
  62. package/src/plugins/starlightAddons/middleware.ts +0 -132
  63. package/src/plugins/starlightAddons/overrides/Sidebar.astro +0 -8
  64. package/src/plugins/starlightAddons/schema.ts +0 -13
  65. package/src/plugins/starlightAddons/virtual.d.ts +0 -13
@@ -0,0 +1,166 @@
1
+ <script setup lang="ts">
2
+ import { computed, useSlots } from "vue"
3
+ import { scv } from "css-variants"
4
+ import { useUi, resolveClasses } from "../../utils"
5
+ import type { ComponentVariants, ComponentSlots } from "../../types"
6
+ import sectionTheme from "../../themes/section.theme"
7
+ import type { RLVButtonProps } from "./RLVButton.vue"
8
+ import RLVIcon from "./RLVIcon.vue"
9
+ import RLVButton from "./RLVButton.vue"
10
+
11
+ const section = scv(sectionTheme)
12
+ type SectionVariants = ComponentVariants<typeof sectionTheme>
13
+
14
+ export interface RLVSectionProps {
15
+ as?: any
16
+ variant?: SectionVariants["variant"]
17
+ headline?: string
18
+ icon?: string
19
+ title?: string
20
+ description?: string
21
+ links?: RLVButtonProps[]
22
+ orientation?: SectionVariants["orientation"]
23
+ reverse?: boolean
24
+ ctaVariant?: SectionVariants["ctaVariant"]
25
+ ui?: ComponentSlots<typeof sectionTheme>
26
+ class?: any
27
+ }
28
+
29
+ const {
30
+ as = "div",
31
+ variant = "default",
32
+ orientation = "vertical",
33
+ reverse = false,
34
+ ctaVariant = "solid",
35
+ ui: uiProp,
36
+ class: className,
37
+ headline,
38
+ title,
39
+ description,
40
+ links
41
+ } = defineProps<RLVSectionProps>()
42
+
43
+ const slots = useSlots()
44
+
45
+ const resolvedClasses = computed(() =>
46
+ resolveClasses(
47
+ section,
48
+ {
49
+ variant,
50
+ orientation,
51
+ reverse,
52
+ ...(variant === "cta" && { ctaVariant }),
53
+ headline: !!(slots.headline || headline),
54
+ title: !!(slots.title || title),
55
+ description: !!(slots.description || description),
56
+ body: !!slots.body
57
+ },
58
+ useUi("section", uiProp),
59
+ className
60
+ )
61
+ )
62
+ </script>
63
+
64
+ <template>
65
+ <component
66
+ :is="as"
67
+ data-slot="root"
68
+ :data-orientation="orientation"
69
+ :class="[resolvedClasses.root]"
70
+ v-bind="$attrs"
71
+ >
72
+ <slot v-if="$slots.background" name="background">
73
+ <div :class="resolvedClasses.background" data-slot="background">
74
+ <slot name="background" />
75
+ </div>
76
+ </slot>
77
+
78
+ <slot name="top" />
79
+
80
+ <div data-slot="container" :class="resolvedClasses.container">
81
+ <div
82
+ v-if="
83
+ $slots.header ||
84
+ icon ||
85
+ headline ||
86
+ title ||
87
+ description ||
88
+ $slots.body ||
89
+ $slots.footer ||
90
+ $slots.links ||
91
+ links?.length
92
+ "
93
+ data-slot="wrapper"
94
+ :class="resolvedClasses.wrapper"
95
+ >
96
+ <div
97
+ v-if="$slots.header || icon || headline || title || description"
98
+ data-slot="header"
99
+ :class="resolvedClasses.header"
100
+ >
101
+ <slot name="header">
102
+ <div v-if="icon || $slots.leading" data-slot="leading" :class="resolvedClasses.leading">
103
+ <slot name="leading" :ui="resolvedClasses">
104
+ <RLVIcon
105
+ v-if="icon"
106
+ :name="icon"
107
+ size="md"
108
+ :ui="{ root: resolvedClasses.leadingIcon }"
109
+ />
110
+ </slot>
111
+ </div>
112
+
113
+ <div v-if="headline" data-slot="headline" :class="resolvedClasses.headline">
114
+ <slot name="headline">
115
+ {{ headline }}
116
+ </slot>
117
+ </div>
118
+
119
+ <component
120
+ :is="variant === 'hero' ? 'h1' : 'h2'"
121
+ v-if="title"
122
+ data-slot="title"
123
+ :class="resolvedClasses.title"
124
+ >
125
+ <slot name="title">
126
+ {{ title }}
127
+ </slot>
128
+ </component>
129
+
130
+ <div v-if="description" data-slot="description" :class="resolvedClasses.description">
131
+ <slot name="description">
132
+ {{ description }}
133
+ </slot>
134
+ </div>
135
+ </slot>
136
+ </div>
137
+
138
+ <div v-if="$slots.body" data-slot="body" :class="resolvedClasses.body">
139
+ <slot name="body" />
140
+ </div>
141
+
142
+ <div
143
+ v-if="$slots.footer || $slots.links || links?.length"
144
+ data-slot="footer"
145
+ :class="resolvedClasses.footer"
146
+ >
147
+ <slot name="footer">
148
+ <div
149
+ v-if="links?.length || $slots.links"
150
+ data-slot="links"
151
+ :class="resolvedClasses.links"
152
+ >
153
+ <RLVButton v-for="(link, index) in links" :key="index" size="lg" v-bind="link" />
154
+ <slot name="links" />
155
+ </div>
156
+ </slot>
157
+ </div>
158
+ </div>
159
+
160
+ <slot v-if="$slots.default" />
161
+ <div v-else-if="orientation === 'horizontal'" class="hidden lg:block" />
162
+ </div>
163
+
164
+ <slot name="bottom" />
165
+ </component>
166
+ </template>
@@ -1,2 +1 @@
1
- export { useUi } from "./useUi"
2
1
  export { useScrollToTop } from "./useScrollToTop"
package/src/env.d.ts CHANGED
@@ -22,6 +22,11 @@ declare module "virtual:rimelight-starlight-addons-config" {
22
22
  export default config
23
23
  }
24
24
 
25
+ declare module "virtual:rimelight-ui-docs-meta" {
26
+ const meta: Record<string, unknown>
27
+ export default meta
28
+ }
29
+
25
30
  declare module "turndown" {
26
31
  class TurndownService {
27
32
  constructor(options?: Record<string, unknown>)
@@ -5,16 +5,12 @@ import uiPlugin from "@nuxt/ui/vite"
5
5
  import defu from "defu"
6
6
  import tailwindcss from "@tailwindcss/vite"
7
7
  import { defaultUIConfig } from "../themes"
8
+ import type { ComponentTheme } from "../utils/defineTheme"
8
9
 
9
10
  /**
10
11
  * Shape of the `ui` config that can be passed to the integration.
11
12
  */
12
- export type UIConfigOverrides = {
13
- "button"?: Partial<(typeof defaultUIConfig)["button"]>
14
- "header"?: Partial<(typeof defaultUIConfig)["header"]>
15
- "scroll-to-top"?: Partial<(typeof defaultUIConfig)["scroll-to-top"]>
16
- "logo"?: Partial<(typeof defaultUIConfig)["logo"]>
17
- }
13
+ export type UIConfigOverrides = Record<string, Partial<ComponentTheme>>
18
14
 
19
15
  export interface UIOptions {
20
16
  /**
@@ -1,2 +1,5 @@
1
- export { default as starlightAddons } from "../plugins/starlightAddons"
2
- export type { StarlightAddonsConfig } from "../plugins/starlightAddons"
1
+ export { default as starlightAddons } from "./starlightAddons"
2
+ export type { StarlightAddonsConfig } from "./starlightAddons"
3
+
4
+ export { default as starlightDocsApi } from "./starlightDocsApi"
5
+ export type { StarlightDocsApiConfig } from "./starlightDocsApi"
@@ -1,34 +1,13 @@
1
- /// <reference path="./locals.d.ts" />
2
- import type { StarlightPlugin, StarlightUserConfig } from "@astrojs/starlight/types"
1
+ import type { StarlightPlugin } from "@astrojs/starlight/types"
3
2
  import virtual from "vite-plugin-virtual"
4
3
  import path from "node:path"
5
4
  import { fileURLToPath } from "node:url"
6
- import { z } from "astro/zod"
7
-
8
- import {
9
- StarlightSidebarTopicsConfigSchema,
10
- StarlightSidebarTopicsOptionsSchema,
11
- type StarlightSidebarTopicsUserConfig,
12
- type StarlightSidebarTopicsUserOptions
13
- } from "./libs/config"
14
- import { throwPluginError } from "./libs/plugin"
15
- import { vitePluginStarlightSidebarTopics } from "./libs/vite"
16
-
17
- export type {
18
- StarlightSidebarTopicsConfig,
19
- StarlightSidebarTopicsUserConfig,
20
- StarlightSidebarTopicsOptions,
21
- StarlightSidebarTopicsUserOptions
22
- } from "./libs/config"
23
5
 
24
6
  const __dirname = path.dirname(fileURLToPath(import.meta.url))
25
7
 
26
8
  export interface StarlightAddonsConfig {
27
9
  copy?: boolean
28
10
  share?: boolean
29
- // Merged config for Topics
30
- topics?: StarlightSidebarTopicsUserConfig
31
- topicOptions?: StarlightSidebarTopicsUserOptions
32
11
  }
33
12
 
34
13
  export default function starlightAddons(userConfig?: StarlightAddonsConfig): StarlightPlugin {
@@ -40,48 +19,10 @@ export default function starlightAddons(userConfig?: StarlightAddonsConfig): Sta
40
19
 
41
20
  const addonConfig = { ...defaultAddonConfig, ...userConfig }
42
21
 
43
- // 2. Validate Sidebar Topics configurations if they exist
44
- const parsedTopics = StarlightSidebarTopicsConfigSchema.safeParse(addonConfig.topics || [])
45
- if (!parsedTopics.success) {
46
- throwPluginError(
47
- `Invalid topics config: ${parsedTopics.error.issues.map((i) => i.message).join("\n")}`
48
- )
49
- }
50
-
51
- const parsedOptions = StarlightSidebarTopicsOptionsSchema.safeParse(addonConfig.topicOptions)
52
- if (!parsedOptions.success) {
53
- throwPluginError(`Invalid topic options: ${z.prettifyError(parsedOptions.error)}`)
54
- }
55
-
56
- const topicsData = parsedTopics.data
57
- const optionsData = parsedOptions.data
58
-
59
22
  return {
60
23
  name: "rimelight-ui-starlight-addons",
61
24
  hooks: {
62
- "config:setup"({ addIntegration, updateConfig, logger, command, config: starlightConfig }) {
63
- // --- Sidebar Topics Logic ---
64
- if ((command === "dev" || command === "build") && topicsData.length > 0) {
65
- if (starlightConfig.sidebar) {
66
- throwPluginError(
67
- "Sidebar detected. To use topics, move your sidebar items into the topics config."
68
- )
69
- }
70
-
71
- const topicSidebar: StarlightUserConfig["sidebar"] = topicsData.map((topic, index) => {
72
- return "items" in topic
73
- ? { label: String(index), items: topic.items }
74
- : { label: String(index), items: [] }
75
- })
76
-
77
- updateConfig({
78
- sidebar: topicSidebar,
79
- components: {
80
- Sidebar: `starlight-sidebar-topics/overrides/Sidebar.astro`
81
- }
82
- })
83
- }
84
-
25
+ "config:setup"({ addIntegration, updateConfig, logger }) {
85
26
  // --- Addons Logic ---
86
27
  if (!addonConfig.copy && !addonConfig.share) {
87
28
  logger.warn("StarlightAddons: No features enabled.")
@@ -104,9 +45,7 @@ export default function starlightAddons(userConfig?: StarlightAddonsConfig): Sta
104
45
  plugins: [
105
46
  virtual({
106
47
  "virtual:rimelight-starlight-addons-config": `export default ${JSON.stringify(addonConfig)}`
107
- }),
108
- // Pass the validated topic data to the vite plugin
109
- vitePluginStarlightSidebarTopics(topicsData, optionsData)
48
+ })
110
49
  ]
111
50
  }
112
51
  } as Record<string, unknown>)
@@ -0,0 +1,46 @@
1
+ ---
2
+ import type { ComponentMetaMap, EmitMeta } from "../types"
3
+ import meta from "virtual:rimelight-ui-docs-meta"
4
+
5
+ interface Props {
6
+ component: string
7
+ }
8
+
9
+ const { component } = Astro.props
10
+
11
+ const allMeta = meta as unknown as ComponentMetaMap
12
+ const compMeta = allMeta[component]
13
+
14
+ const emits = compMeta?.emits ?? []
15
+ ---
16
+
17
+ {emits.length === 0 ? (
18
+ <p class="text-sm italic text-gray-500">No events emitted by this component.</p>
19
+ ) : (
20
+ <div class="overflow-x-auto">
21
+ <table class="w-full text-sm border-collapse">
22
+ <thead>
23
+ <tr class="border-b border-gray-200 dark:border-gray-700">
24
+ <th class="text-left py-2 px-3 font-semibold">Event</th>
25
+ <th class="text-left py-2 px-3 font-semibold">Payload</th>
26
+ </tr>
27
+ </thead>
28
+ <tbody>
29
+ {emits.map((emit: EmitMeta) => (
30
+ <tr class="border-b border-gray-100 dark:border-gray-800">
31
+ <td class="py-2 px-3">
32
+ <code class="text-sm bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded">
33
+ {emit.name}
34
+ </code>
35
+ </td>
36
+ <td class="py-2 px-3">
37
+ <code class="text-xs bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded font-mono">
38
+ {emit.type}
39
+ </code>
40
+ </td>
41
+ </tr>
42
+ ))}
43
+ </tbody>
44
+ </table>
45
+ </div>
46
+ )}
@@ -0,0 +1,47 @@
1
+ ---
2
+ import type { ComponentMetaMap, PropMeta } from "../types"
3
+ import { filterProps } from "../utils"
4
+ import meta from "virtual:rimelight-ui-docs-meta"
5
+
6
+ interface Props {
7
+ component: string
8
+ hide?: string[]
9
+ show?: string[]
10
+ }
11
+
12
+ const { component, hide = ["class"], show } = Astro.props
13
+
14
+ const allMeta = meta as unknown as ComponentMetaMap
15
+ const compMeta = allMeta[component]
16
+
17
+ const filterOpts: { hide?: string[]; show?: string[] } = { hide }
18
+ if (show !== undefined) filterOpts.show = show
19
+ const props = filterProps(compMeta?.props ?? [], filterOpts)
20
+ ---
21
+
22
+ {props.length > 0 ? (
23
+ <table>
24
+ <thead>
25
+ <tr>
26
+ <th>Name</th>
27
+ <th>Type</th>
28
+ <th>Required</th>
29
+ <th>Default</th>
30
+ <th>Description</th>
31
+ </tr>
32
+ </thead>
33
+ <tbody>
34
+ {props.map((prop: PropMeta) => (
35
+ <tr>
36
+ <td><code>{prop.name}</code></td>
37
+ <td><code>{prop.type}</code></td>
38
+ <td>{prop.required ? "Yes" : "No"}</td>
39
+ <td>{prop.default !== undefined ? <code>{prop.default}</code> : "—"}</td>
40
+ <td>{prop.description || "—"}</td>
41
+ </tr>
42
+ ))}
43
+ </tbody>
44
+ </table>
45
+ ) : (
46
+ <p>No props to display.</p>
47
+ )}
@@ -0,0 +1,50 @@
1
+ ---
2
+ import type { ComponentMetaMap, SlotMeta } from "../types"
3
+ import meta from "virtual:rimelight-ui-docs-meta"
4
+
5
+ interface Props {
6
+ component: string
7
+ }
8
+
9
+ const { component } = Astro.props
10
+
11
+ const allMeta = meta as unknown as ComponentMetaMap
12
+ const compMeta = allMeta[component]
13
+
14
+ const slots = compMeta?.slots ?? []
15
+ ---
16
+
17
+ {slots.length === 0 ? (
18
+ <p class="text-sm italic text-gray-500">No slots to display.</p>
19
+ ) : (
20
+ <div class="overflow-x-auto">
21
+ <table class="w-full text-sm border-collapse">
22
+ <thead>
23
+ <tr class="border-b border-gray-200 dark:border-gray-700">
24
+ <th class="text-left py-2 px-3 font-semibold">Slot</th>
25
+ <th class="text-left py-2 px-3 font-semibold">Type</th>
26
+ </tr>
27
+ </thead>
28
+ <tbody>
29
+ {slots.map((slot: SlotMeta) => (
30
+ <tr class="border-b border-gray-100 dark:border-gray-800">
31
+ <td class="py-2 px-3">
32
+ <code class="text-sm bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded">
33
+ {slot.name}
34
+ </code>
35
+ </td>
36
+ <td class="py-2 px-3">
37
+ {Object.keys(slot.bindings).length > 0 ? (
38
+ <code class="text-xs bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded font-mono">
39
+ {Object.values(slot.bindings)[0]}
40
+ </code>
41
+ ) : (
42
+ <span class="text-gray-400">-</span>
43
+ )}
44
+ </td>
45
+ </tr>
46
+ ))}
47
+ </tbody>
48
+ </table>
49
+ </div>
50
+ )}
@@ -0,0 +1,27 @@
1
+ ---
2
+ import type { ComponentMetaMap } from "../types"
3
+ import { generateThemeCode } from "../utils"
4
+ import meta from "virtual:rimelight-ui-docs-meta"
5
+
6
+ interface Props {
7
+ component: string
8
+ }
9
+
10
+ const { component } = Astro.props
11
+
12
+ const allMeta = meta as unknown as ComponentMetaMap
13
+ const compMeta = allMeta[component]
14
+
15
+ const theme = compMeta?.theme ?? null
16
+ const themeCode = theme ? generateThemeCode(component, theme) : null
17
+ ---
18
+
19
+ {themeCode ? (
20
+ <div class="expressive-code">
21
+ <figure class="frame">
22
+ <pre class="language-ts overflow-x-auto"><code class="language-ts">{themeCode}</code></pre>
23
+ </figure>
24
+ </div>
25
+ ) : (
26
+ <p class="text-sm italic text-gray-500">No theme data available.</p>
27
+ )}