kmcom-nuxt-layers 2.2.5 → 2.2.8

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 (218) hide show
  1. package/docs/FEEDS.md +197 -0
  2. package/docs/LAYERS-FIXES.md +101 -0
  3. package/docs/MIGRATION.md +627 -0
  4. package/docs/feed-layer.md +374 -0
  5. package/docs/patch-picture-provider-type.md +52 -0
  6. package/docs/shaderGuide.md +2071 -0
  7. package/docs/types-architecture.md +234 -0
  8. package/layers/animations/app/components/Motion/CountUp.vue +1 -1
  9. package/layers/animations/app/components/Motion/Magnetic.vue +1 -1
  10. package/layers/animations/app/components/Motion/Marquee.vue +3 -2
  11. package/layers/animations/app/components/Motion/MarqueeText.vue +3 -2
  12. package/layers/animations/app/components/Motion/Tilt.vue +1 -1
  13. package/layers/animations/app/composables/useCountUp.ts +4 -1
  14. package/layers/animations/app/composables/useMagneticElement.ts +2 -4
  15. package/layers/animations/app/composables/useMarqueeCopies.ts +4 -4
  16. package/layers/animations/app/composables/useTiltEffect.ts +1 -1
  17. package/layers/animations/app/types/animations.ts +8 -0
  18. package/layers/animations/app/types/index.ts +1 -0
  19. package/layers/animations/package.json +4 -1
  20. package/layers/canvas/app/components/ShaderCanvas.vue +4 -4
  21. package/layers/canvas/app/composables/useRendererCapabilities.ts +19 -15
  22. package/layers/canvas/app/types/index.ts +1 -0
  23. package/layers/canvas/package.json +2 -1
  24. package/layers/canvas/tsconfig.json +2 -1
  25. package/layers/content/app/components/Blog/Card.vue +5 -5
  26. package/layers/content/app/components/Gallery/AmbientImage.vue +3 -3
  27. package/layers/content/app/components/Gallery/Card.vue +3 -3
  28. package/layers/content/app/components/Gallery/Lightbox.vue +5 -1
  29. package/layers/content/app/components/NuxtContent/Detail.vue +5 -1
  30. package/layers/content/app/components/NuxtContent/Surround.vue +5 -3
  31. package/layers/content/app/components/NuxtContent/Toc.vue +1 -1
  32. package/layers/content/app/components/Portfolio/Card.vue +5 -5
  33. package/layers/content/app/components/content/Figure.vue +3 -3
  34. package/layers/content/app/composables/useBlogPosts.ts +2 -2
  35. package/layers/content/app/composables/useCollectionItem.ts +1 -3
  36. package/layers/content/app/composables/useGalleryItems.ts +2 -2
  37. package/layers/content/app/types/index.ts +1 -0
  38. package/layers/content/package.json +2 -1
  39. package/layers/core/app/composables/useCache.ts +0 -1
  40. package/layers/core/app/composables/useErrorLog.ts +9 -11
  41. package/layers/core/app/plugins/error-handler.ts +36 -36
  42. package/layers/core/app/plugins/feature-detection.client.ts +15 -15
  43. package/layers/core/app/plugins/init.ts +121 -129
  44. package/layers/core/app/plugins/loading.client.ts +27 -27
  45. package/layers/core/app/plugins/scroll-guard.client.ts +26 -26
  46. package/layers/core/app/utils/helpers.ts +14 -12
  47. package/layers/core/nuxt.config.ts +1 -0
  48. package/layers/feeds/app/plugins/feed-head.ts +62 -63
  49. package/layers/feeds/package.json +2 -1
  50. package/layers/feeds/server/routes/feed/discovery.get.ts +1 -2
  51. package/layers/feeds/server/utils/content-adapter.ts +3 -2
  52. package/layers/forms/app/components/Form/Field.vue +4 -4
  53. package/layers/forms/app/types/index.ts +1 -0
  54. package/layers/forms/package.json +2 -1
  55. package/layers/forms/server/api/contact.post.ts +1 -1
  56. package/layers/layout/app/components/Layout/Grid/Item.vue +33 -19
  57. package/layers/layout/app/components/Layout/Page/Container.vue +11 -11
  58. package/layers/layout/app/components/Layout/Page/Header.vue +1 -1
  59. package/layers/layout/app/components/Layout/Page/index.vue +1 -1
  60. package/layers/layout/app/components/Layout/Section/Gallery.vue +6 -1
  61. package/layers/layout/app/components/Layout/Section/Title.vue +1 -1
  62. package/layers/layout/app/types/index.ts +1 -0
  63. package/layers/layout/package.json +2 -1
  64. package/layers/mailer/app/types/index.ts +1 -0
  65. package/layers/mailer/app/types/mailer.ts +25 -0
  66. package/layers/mailer/package.json +2 -1
  67. package/layers/motion/package.json +2 -1
  68. package/layers/navigation/app/components/Links/Group.vue +1 -0
  69. package/layers/navigation/app/components/Links/Named.vue +2 -0
  70. package/layers/navigation/app/types/index.ts +1 -0
  71. package/layers/navigation/package.json +4 -1
  72. package/layers/page-transitions/app/plugins/page-transitions.client.ts +9 -9
  73. package/layers/page-transitions/package.json +4 -1
  74. package/layers/routing/app/plugins/feature-flags.client.ts +9 -9
  75. package/layers/routing/app/types/app-config.d.ts +3 -1
  76. package/layers/routing/app/types/index.ts +1 -0
  77. package/layers/routing/package.json +2 -1
  78. package/layers/scripts/app/composables/useGtm.ts +1 -1
  79. package/layers/scripts/app/types/index.ts +1 -0
  80. package/layers/scripts/app/types/scripts.ts +14 -0
  81. package/layers/scripts/package.json +2 -1
  82. package/layers/scroll/app/components/Motion/ScrollScene.vue +3 -1
  83. package/layers/scroll/app/composables/useScrollSteps.ts +2 -9
  84. package/layers/scroll/app/composables/useSectionProgress.ts +2 -1
  85. package/layers/scroll/app/plugins/locomotive-scroll.client.ts +54 -61
  86. package/layers/scroll/app/types/index.ts +1 -0
  87. package/layers/scroll/app/types/scroll.ts +32 -0
  88. package/layers/scroll/package.json +3 -0
  89. package/layers/seo/package.json +2 -1
  90. package/layers/shader/app/components/Material/Fresnel.client.vue +1 -1
  91. package/layers/shader/app/components/Material/Image.client.vue +1 -1
  92. package/layers/shader/app/components/Material/Node.client.vue +7 -7
  93. package/layers/shader/app/components/Material/Noise.client.vue +1 -1
  94. package/layers/shader/app/components/Node/Color.client.vue +17 -20
  95. package/layers/shader/app/components/Node/Noise.client.vue +31 -34
  96. package/layers/shader/app/components/Pipeline/Aurora.client.vue +4 -8
  97. package/layers/shader/app/components/Pipeline/BilinearGradient.client.vue +8 -11
  98. package/layers/shader/app/components/Pipeline/BillowNoise.client.vue +4 -8
  99. package/layers/shader/app/components/Pipeline/BrightnessContrast.client.vue +6 -2
  100. package/layers/shader/app/components/Pipeline/CellularNoise.client.vue +4 -8
  101. package/layers/shader/app/components/Pipeline/Checkerboard.client.vue +4 -8
  102. package/layers/shader/app/components/Pipeline/Circle.client.vue +5 -8
  103. package/layers/shader/app/components/Pipeline/Clouds.client.vue +4 -8
  104. package/layers/shader/app/components/Pipeline/ColorBurnBlend.client.vue +2 -19
  105. package/layers/shader/app/components/Pipeline/ColorDodgeBlend.client.vue +2 -19
  106. package/layers/shader/app/components/Pipeline/ColourRamp.client.vue +5 -9
  107. package/layers/shader/app/components/Pipeline/ConicGradient.client.vue +5 -8
  108. package/layers/shader/app/components/Pipeline/Cross.client.vue +4 -8
  109. package/layers/shader/app/components/Pipeline/CurlNoise.client.vue +3 -7
  110. package/layers/shader/app/components/Pipeline/DarkenBlend.client.vue +2 -19
  111. package/layers/shader/app/components/Pipeline/DayNightCycle.client.vue +5 -8
  112. package/layers/shader/app/components/Pipeline/DiagonalGradient.client.vue +5 -8
  113. package/layers/shader/app/components/Pipeline/DiamondGradient.client.vue +5 -8
  114. package/layers/shader/app/components/Pipeline/DifferenceBlend.client.vue +2 -19
  115. package/layers/shader/app/components/Pipeline/DomainWarpedNoise.client.vue +4 -8
  116. package/layers/shader/app/components/Pipeline/Dots.client.vue +4 -8
  117. package/layers/shader/app/components/Pipeline/DuoTone.client.vue +5 -9
  118. package/layers/shader/app/components/Pipeline/ExclusionBlend.client.vue +3 -23
  119. package/layers/shader/app/components/Pipeline/ExponentialFog.client.vue +4 -7
  120. package/layers/shader/app/components/Pipeline/FilmBurn.client.vue +4 -7
  121. package/layers/shader/app/components/Pipeline/Flame.client.vue +4 -8
  122. package/layers/shader/app/components/Pipeline/FocalGradient.client.vue +5 -8
  123. package/layers/shader/app/components/Pipeline/GodRays.client.vue +4 -7
  124. package/layers/shader/app/components/Pipeline/GradientNoise.client.vue +4 -8
  125. package/layers/shader/app/components/Pipeline/Grid.client.vue +4 -8
  126. package/layers/shader/app/components/Pipeline/Halation.client.vue +3 -7
  127. package/layers/shader/app/components/Pipeline/HardLightBlend.client.vue +2 -19
  128. package/layers/shader/app/components/Pipeline/Haze.client.vue +4 -7
  129. package/layers/shader/app/components/Pipeline/Hexagon.client.vue +4 -8
  130. package/layers/shader/app/components/Pipeline/LensFlare.client.vue +4 -7
  131. package/layers/shader/app/components/Pipeline/LightenBlend.client.vue +2 -19
  132. package/layers/shader/app/components/Pipeline/LinearGradient4.client.vue +2 -2
  133. package/layers/shader/app/components/Pipeline/Marble.client.vue +4 -8
  134. package/layers/shader/app/components/Pipeline/MonochromeTint.client.vue +3 -7
  135. package/layers/shader/app/components/Pipeline/MultiplyBlend.client.vue +2 -19
  136. package/layers/shader/app/components/Pipeline/NoisyGradient.client.vue +4 -8
  137. package/layers/shader/app/components/Pipeline/NoisyGradientBlend.client.vue +4 -8
  138. package/layers/shader/app/components/Pipeline/OverlayBlend.client.vue +2 -19
  139. package/layers/shader/app/components/Pipeline/Polygon.client.vue +4 -8
  140. package/layers/shader/app/components/Pipeline/RaymarchTunnel.client.vue +4 -7
  141. package/layers/shader/app/components/Pipeline/Rectangle.client.vue +4 -8
  142. package/layers/shader/app/components/Pipeline/RidgedNoise.client.vue +4 -8
  143. package/layers/shader/app/components/Pipeline/Ring.client.vue +4 -8
  144. package/layers/shader/app/components/Pipeline/ScreenBlend.client.vue +2 -19
  145. package/layers/shader/app/components/Pipeline/SkyAtmosphere.client.vue +6 -9
  146. package/layers/shader/app/components/Pipeline/SoftLightBlend.client.vue +2 -19
  147. package/layers/shader/app/components/Pipeline/SplitTone.client.vue +4 -8
  148. package/layers/shader/app/components/Pipeline/Star.client.vue +4 -8
  149. package/layers/shader/app/components/Pipeline/Stripes.client.vue +4 -8
  150. package/layers/shader/app/components/Pipeline/Tint.client.vue +4 -7
  151. package/layers/shader/app/components/Pipeline/Triangle.client.vue +4 -8
  152. package/layers/shader/app/components/Pipeline/ValueNoise.client.vue +4 -8
  153. package/layers/shader/app/components/Pipeline/VoronoiEdges.client.vue +4 -8
  154. package/layers/shader/app/components/Pipeline/Water.client.vue +5 -8
  155. package/layers/shader/app/components/Pipeline/WaveBendLayer.client.vue +4 -7
  156. package/layers/shader/app/components/Pipeline/WaveColourLayer.client.vue +3 -7
  157. package/layers/shader/app/components/Pipeline/Wood.client.vue +4 -8
  158. package/layers/shader/app/components/Preset/Aurora.client.vue +15 -21
  159. package/layers/shader/app/components/Preset/Flow.client.vue +2 -1
  160. package/layers/shader/app/components/Preset/GradientMesh.client.vue +2 -1
  161. package/layers/shader/app/components/Preset/Nebula.client.vue +2 -1
  162. package/layers/shader/app/components/Preset/Ocean.client.vue +2 -1
  163. package/layers/shader/app/components/Preset/ThemeAurora.client.vue +30 -90
  164. package/layers/shader/app/components/Preset/ThemeBubble.client.vue +30 -91
  165. package/layers/shader/app/components/Preset/ThemeFlow.client.vue +30 -90
  166. package/layers/shader/app/components/Preset/ThemeGradient.client.vue +30 -91
  167. package/layers/shader/app/components/Preset/ThemeLavaLamp.client.vue +30 -90
  168. package/layers/shader/app/components/Preset/ThemePlasma.client.vue +30 -90
  169. package/layers/shader/app/components/Preset/ThemeWave.client.vue +30 -90
  170. package/layers/shader/app/components/Shader/Background.client.vue +4 -4
  171. package/layers/shader/app/components/Shader/Host.client.vue +31 -33
  172. package/layers/shader/app/components/Shader/Runtime.client.vue +15 -23
  173. package/layers/shader/app/composables/useAmbientMaterials.ts +53 -51
  174. package/layers/shader/app/composables/useShaderMixBlend.ts +26 -0
  175. package/layers/shader/app/composables/useThemePreset.ts +75 -0
  176. package/layers/shader/app/plugins/shader.client.ts +21 -21
  177. package/layers/shader/app/shaders/common/noise.ts +2 -7
  178. package/layers/shader/app/shaders/types.ts +6 -6
  179. package/layers/shader/app/types/tsl.ts +7 -25
  180. package/layers/shader/app/types/uniforms.ts +2 -1
  181. package/layers/shader/app/utils/tsl/color.ts +7 -1
  182. package/layers/shader/package.json +2 -1
  183. package/layers/theme/app/components/ThemePicker/Colors.vue +1 -3
  184. package/layers/theme/app/plugins/theme.client.ts +54 -51
  185. package/layers/theme/app/types/app-config.d.ts +4 -2
  186. package/layers/theme/app/types/index.ts +1 -0
  187. package/layers/theme/app/types/theme.ts +3 -18
  188. package/layers/theme/package.json +2 -1
  189. package/layers/theme/server/plugins/theme-fouc.ts +1 -1
  190. package/layers/transitions/package.json +4 -1
  191. package/layers/typography/app/components/Typography/CodeBlock.vue +2 -2
  192. package/layers/typography/app/components/Typography/Headline.vue +2 -2
  193. package/layers/typography/app/components/Typography/HeadlineScreen.vue +1 -1
  194. package/layers/typography/app/components/Typography/QuoteBlock.vue +4 -1
  195. package/layers/typography/app/components/Typography/TextStroke.vue +2 -0
  196. package/layers/typography/app/components/Typography/index.vue +36 -27
  197. package/layers/typography/app/composables/typography.ts +27 -21
  198. package/layers/typography/app/types/colors.ts +9 -29
  199. package/layers/typography/app/types/index.ts +2 -0
  200. package/layers/typography/package.json +4 -1
  201. package/layers/ui/package.json +2 -1
  202. package/layers/visual/app/app.config.ts +5 -2
  203. package/layers/visual/app/components/Accent/Blob.vue +20 -20
  204. package/layers/visual/app/components/Accent/Scene.vue +2 -2
  205. package/layers/visual/app/components/Base/Modal.vue +2 -2
  206. package/layers/visual/app/components/Gradient/Background.vue +2 -2
  207. package/layers/visual/app/components/Gradient/Text.vue +2 -2
  208. package/layers/visual/app/components/Media/Picture.vue +3 -1
  209. package/layers/visual/app/components/Progress/Bar.vue +6 -6
  210. package/layers/visual/app/components/Tint/Overlay.vue +14 -14
  211. package/layers/visual/app/composables/accent.ts +10 -8
  212. package/layers/visual/app/composables/gradient.ts +2 -3
  213. package/layers/visual/app/composables/tint.ts +7 -7
  214. package/layers/visual/app/types/index.ts +6 -0
  215. package/layers/visual/app/types/media.ts +4 -2
  216. package/layers/visual/app/types/tint.ts +2 -1
  217. package/layers/visual/package.json +4 -1
  218. package/package.json +5 -2
@@ -3,30 +3,30 @@ import { checkWebGPUSupport } from '#layers/canvas/app/composables/useRendererCa
3
3
  export default defineNuxtPlugin({
4
4
  name: 'shader:shader',
5
5
  async setup() {
6
- const config = useAppConfig()
7
- const shaderConfig = (config.shader || {}) as {
8
- preferWebGPU?: boolean
9
- }
6
+ const config = useAppConfig()
7
+ const shaderConfig = (config.shader || {}) as {
8
+ preferWebGPU?: boolean
9
+ }
10
10
 
11
- // Check WebGPU support
12
- const hasWebGPU = await checkWebGPUSupport()
13
- const useWebGPU = shaderConfig.preferWebGPU && hasWebGPU
11
+ // Check WebGPU support
12
+ const hasWebGPU = await checkWebGPUSupport()
13
+ const useWebGPU = shaderConfig.preferWebGPU && hasWebGPU
14
14
 
15
- // Log renderer info in development
16
- if (import.meta.dev) {
17
- console.log('[Shader Layer] Initialized')
18
- console.log(`[Shader Layer] WebGPU supported: ${hasWebGPU}`)
19
- console.log(`[Shader Layer] Using: ${useWebGPU ? 'WebGPU' : 'WebGL'}`)
20
- }
15
+ // Log renderer info in development
16
+ if (import.meta.dev) {
17
+ console.log('[Shader Layer] Initialized')
18
+ console.log(`[Shader Layer] WebGPU supported: ${hasWebGPU}`)
19
+ console.log(`[Shader Layer] Using: ${useWebGPU ? 'WebGPU' : 'WebGL'}`)
20
+ }
21
21
 
22
- return {
23
- provide: {
24
- shader: {
25
- hasWebGPU,
26
- useWebGPU,
27
- config: shaderConfig,
22
+ return {
23
+ provide: {
24
+ shader: {
25
+ hasWebGPU,
26
+ useWebGPU,
27
+ config: shaderConfig,
28
+ },
28
29
  },
29
- },
30
- }
30
+ }
31
31
  },
32
32
  })
@@ -26,6 +26,7 @@ import {
26
26
  vec4,
27
27
  } from 'three/tsl'
28
28
 
29
+ import type { FBMOptions } from '../../types/tsl'
29
30
  import type { TSLNode } from '../types'
30
31
  import {
31
32
  fade,
@@ -204,13 +205,7 @@ export function gradientNoise3D(p: TSLNode): TSLNode {
204
205
  // FBM (Fractal Brownian Motion)
205
206
  // ============================================
206
207
 
207
- export type FBMOptions = {
208
- octaves?: number
209
- lacunarity?: number
210
- gain?: number
211
- amplitude?: number
212
- frequency?: number
213
- }
208
+ export type { FBMOptions }
214
209
 
215
210
  /**
216
211
  * 2D Fractal Brownian Motion
@@ -7,15 +7,15 @@
7
7
  // This provides flexibility while maintaining code readability
8
8
 
9
9
  import type { UniformNode } from 'three/webgpu'
10
+ import type { Vector3 } from 'three'
10
11
 
11
- export type TSLNode = any
12
+ export type { TSLNode } from '../types/tsl'
12
13
 
13
- /**
14
- * Float uniform with full TSL operator support.
15
- * `ReturnType<typeof uniform>` collapses to `UniformNode<unknown, unknown>`,
16
- * which has no operator methods — use this concrete type instead.
17
- */
14
+ /** Float uniform: `uniform(someNumber)` */
18
15
  export type FloatUniform = UniformNode<'float', number>
19
16
 
17
+ /** Vec3 uniform: `uniform(new Vector3(...))` */
18
+ export type Vec3Uniform = UniformNode<'vec3', Vector3>
19
+
20
20
  // Re-export common Three types
21
21
  export type { Color, Texture, Vector2, Vector3, Vector4 } from 'three'
@@ -1,23 +1,11 @@
1
- /**
2
- * TSL Node types
3
- * Using generic types for flexibility across Three.js versions
4
- */
1
+ import type { Node } from 'three/webgpu'
5
2
 
6
- export type TSLNode = any
7
-
8
- export type TSLFloat = any
9
-
10
- export type TSLVec2 = any
11
-
12
- export type TSLVec3 = any
13
-
14
- export type TSLVec4 = any
15
-
16
- export type TSLColor = any
17
-
18
- export type TSLMat3 = any
19
-
20
- export type TSLMat4 = any
3
+ export type TSLNode = Node
4
+ export type TSLVec3 = Node<'vec3'>
5
+ export type TSLVec4 = Node<'vec4'>
6
+ export type TSLColor = Node<'color'>
7
+ export type TSLMat3 = Node<'mat3'>
8
+ export type TSLMat4 = Node<'mat4'>
21
9
 
22
10
  export type GradientStop = {
23
11
  position: number
@@ -31,9 +19,3 @@ export type FBMOptions = {
31
19
  amplitude?: number
32
20
  frequency?: number
33
21
  }
34
-
35
- export type VoronoiResult = {
36
- distance: TSLFloat
37
- cellCenter: TSLVec2
38
- edgeDistance: TSLFloat
39
- }
@@ -1,4 +1,5 @@
1
1
  import type { Color, Matrix3, Matrix4, Texture, Vector2, Vector3, Vector4 } from 'three'
2
+ import type { TSLNode } from './tsl'
2
3
 
3
4
  export type UniformPrimitive = number | boolean | string
4
5
  export type UniformVector = Vector2 | Vector3 | Vector4
@@ -17,5 +18,5 @@ export type UniformValues = Record<string, UniformValue>
17
18
 
18
19
  export type UniformsState<T extends UniformValues> = {
19
20
  values: T
20
- nodes: Record<keyof T, import('./tsl').TSLNode>
21
+ nodes: Record<keyof T, TSLNode>
21
22
  }
@@ -1,8 +1,14 @@
1
- import { abs, clamp, float, Fn, max, min, mix, mod, vec3 } from 'three/tsl'
1
+ import { Color, Vector3 } from 'three'
2
+ import { abs, clamp, float, Fn, max, min, mix, mod, uniform, vec3 } from 'three/tsl'
2
3
 
3
4
  import type { GradientStop, TSLNode } from '../../types'
4
5
  import { circularDistance } from './math'
5
6
 
7
+ export function hexToVec3Uniform(hex: string) {
8
+ const c = new Color(hex)
9
+ return uniform(new Vector3(c.r, c.g, c.b))
10
+ }
11
+
6
12
  /**
7
13
  * Linear gradient with multiple color stops
8
14
  */
@@ -6,7 +6,8 @@
6
6
  "scripts": {
7
7
  "dev": "nuxi dev",
8
8
  "dev:playground": "PLAYGROUND_LAYERS=core,canvas,shader pnpm -F playground dev",
9
- "typecheck": "vue-tsc --noEmit -p ../../tsconfig.typecheck.json"
9
+ "typecheck": "vue-tsc --noEmit -p ../../tsconfig.typecheck.json",
10
+ "lint": "eslint ."
10
11
  },
11
12
  "dependencies": {
12
13
  "@vueuse/core": "catalog:"
@@ -1,10 +1,8 @@
1
1
  <script setup lang="ts">
2
- import type { AccentColor } from '#layers/theme/app/types/theme'
3
-
4
2
  const appConfig = useAppConfig()
5
3
  const { activeAccent, setAccent } = useAccentColor()
6
4
 
7
- const accents = computed(() => ((appConfig as any).themeLayer?.accents as AccentColor[]) ?? [])
5
+ const accents = computed(() => appConfig.themeLayer?.accents ?? [])
8
6
  </script>
9
7
 
10
8
  <template>
@@ -3,56 +3,59 @@ import type { AccentColor, PreferenceOverride } from '#layers/theme/app/types/th
3
3
  export default defineNuxtPlugin({
4
4
  name: 'theme:theme',
5
5
  setup() {
6
- const { setAccent, activeAccent } = useAccentColor()
7
- const { setContrastOverride, effectiveHighContrast } = useThemeContrast()
8
- const { setMotionOverride, effectiveReducedMotion } = useThemeMotion()
9
- const { setTransparencyOverride, effectiveReducedTransparency } = useThemeTransparency()
10
-
11
- // Restore persisted preferences. useState defaults were serialized from the
12
- // server, so hydration matches. We update to the stored values here, after
13
- // hydration completes, to avoid any mismatch.
14
- const storedAccent = localStorage.getItem('theme-colour')
15
- if (storedAccent) setAccent(storedAccent as AccentColor)
16
-
17
- const storedContrast = localStorage.getItem('theme-contrast')
18
- if (storedContrast) setContrastOverride(storedContrast as PreferenceOverride)
19
-
20
- const storedMotion = localStorage.getItem('theme-motion')
21
- if (storedMotion) setMotionOverride(storedMotion as PreferenceOverride)
22
-
23
- const storedTransparency = localStorage.getItem('theme-transparency')
24
- if (storedTransparency) setTransparencyOverride(storedTransparency as PreferenceOverride)
25
-
26
- watch(
27
- activeAccent,
28
- (color) => {
29
- document.documentElement.setAttribute('data-theme-colour', color)
30
- },
31
- { immediate: true }
32
- )
33
-
34
- watch(
35
- effectiveHighContrast,
36
- (high) => {
37
- document.documentElement.setAttribute('data-theme-contrast', high ? 'high' : 'standard')
38
- },
39
- { immediate: true }
40
- )
41
-
42
- watch(
43
- effectiveReducedMotion,
44
- (reduced) => {
45
- document.documentElement.setAttribute('data-theme-motion', reduced ? 'reduced' : 'full')
46
- },
47
- { immediate: true }
48
- )
49
-
50
- watch(
51
- effectiveReducedTransparency,
52
- (reduced) => {
53
- document.documentElement.setAttribute('data-theme-transparency', reduced ? 'reduced' : 'full')
54
- },
55
- { immediate: true }
56
- )
6
+ const { setAccent, activeAccent } = useAccentColor()
7
+ const { setContrastOverride, effectiveHighContrast } = useThemeContrast()
8
+ const { setMotionOverride, effectiveReducedMotion } = useThemeMotion()
9
+ const { setTransparencyOverride, effectiveReducedTransparency } = useThemeTransparency()
10
+
11
+ // Restore persisted preferences. useState defaults were serialized from the
12
+ // server, so hydration matches. We update to the stored values here, after
13
+ // hydration completes, to avoid any mismatch.
14
+ const storedAccent = localStorage.getItem('theme-colour')
15
+ if (storedAccent) setAccent(storedAccent as AccentColor)
16
+
17
+ const storedContrast = localStorage.getItem('theme-contrast')
18
+ if (storedContrast) setContrastOverride(storedContrast as PreferenceOverride)
19
+
20
+ const storedMotion = localStorage.getItem('theme-motion')
21
+ if (storedMotion) setMotionOverride(storedMotion as PreferenceOverride)
22
+
23
+ const storedTransparency = localStorage.getItem('theme-transparency')
24
+ if (storedTransparency) setTransparencyOverride(storedTransparency as PreferenceOverride)
25
+
26
+ watch(
27
+ activeAccent,
28
+ (color) => {
29
+ document.documentElement.setAttribute('data-theme-colour', color)
30
+ },
31
+ { immediate: true }
32
+ )
33
+
34
+ watch(
35
+ effectiveHighContrast,
36
+ (high) => {
37
+ document.documentElement.setAttribute('data-theme-contrast', high ? 'high' : 'standard')
38
+ },
39
+ { immediate: true }
40
+ )
41
+
42
+ watch(
43
+ effectiveReducedMotion,
44
+ (reduced) => {
45
+ document.documentElement.setAttribute('data-theme-motion', reduced ? 'reduced' : 'full')
46
+ },
47
+ { immediate: true }
48
+ )
49
+
50
+ watch(
51
+ effectiveReducedTransparency,
52
+ (reduced) => {
53
+ document.documentElement.setAttribute(
54
+ 'data-theme-transparency',
55
+ reduced ? 'reduced' : 'full'
56
+ )
57
+ },
58
+ { immediate: true }
59
+ )
57
60
  },
58
61
  })
@@ -1,8 +1,10 @@
1
+ import type { AccentColor } from './theme'
2
+
1
3
  declare module '@nuxt/schema' {
2
4
  interface AppConfigInput {
3
5
  themeLayer?: {
4
- accents?: Array<import('./theme').AccentColor>
5
- defaultAccent?: import('./theme').AccentColor
6
+ accents?: AccentColor[]
7
+ defaultAccent?: AccentColor
6
8
  }
7
9
  }
8
10
  }
@@ -0,0 +1 @@
1
+ export type * from './theme'
@@ -5,24 +5,9 @@
5
5
  * and the theme preferences interface.
6
6
  */
7
7
 
8
- export type AccentColor =
9
- | 'red'
10
- | 'orange'
11
- | 'amber'
12
- | 'yellow'
13
- | 'lime'
14
- | 'green'
15
- | 'emerald'
16
- | 'teal'
17
- | 'cyan'
18
- | 'sky'
19
- | 'blue'
20
- | 'indigo'
21
- | 'violet'
22
- | 'purple'
23
- | 'fuchsia'
24
- | 'pink'
25
- | 'rose'
8
+ import type { AccentColor } from '#types'
9
+
10
+ export type { AccentColor }
26
11
 
27
12
  export type PreferenceOverride = 'system' | 'on' | 'off'
28
13
 
@@ -9,6 +9,7 @@
9
9
  "dev:prepare": "nuxt prepare .playground",
10
10
  "build": "nuxt build .playground",
11
11
  "generate": "nuxt generate .playground",
12
- "preview": "nuxt preview .playground"
12
+ "preview": "nuxt preview .playground",
13
+ "lint": "eslint ."
13
14
  }
14
15
  }
@@ -150,7 +150,7 @@ const initScript = `(function(){
150
150
  export default defineNitroPlugin((nitroApp) => {
151
151
  nitroApp.hooks.hook('render:html', (html) => {
152
152
  html.head.unshift(
153
- `<style id="theme-accent-css">${accentCSS}</style>` + `<script>${initScript}</script>`
153
+ `<style id="theme-accent-css">${accentCSS}</style><script>${initScript}</script>`
154
154
  )
155
155
  })
156
156
  })
@@ -2,5 +2,8 @@
2
2
  "name": "kmcom-layer-transitions",
3
3
  "version": "0.0.1",
4
4
  "type": "module",
5
- "main": "./nuxt.config.ts"
5
+ "main": "./nuxt.config.ts",
6
+ "scripts": {
7
+ "lint": "eslint ."
8
+ }
6
9
  }
@@ -6,9 +6,9 @@
6
6
  defineOptions({ inheritAttrs: false })
7
7
 
8
8
  const {
9
- language,
9
+ language = undefined,
10
10
  color = 'default',
11
- size,
11
+ size = undefined,
12
12
  class: classProp = '',
13
13
  } = defineProps<{
14
14
  language?: string
@@ -24,8 +24,8 @@
24
24
  tracking = 'tracking-tight',
25
25
  align = 'left',
26
26
  transform = 'none',
27
- color,
28
- size,
27
+ color = undefined,
28
+ size = undefined,
29
29
  class: classProp = '',
30
30
  } = defineProps<{
31
31
  level?: 1 | 2 | 3 | 4 | 5 | 6
@@ -25,7 +25,7 @@
25
25
  tracking = 'tracking-tight',
26
26
  align = 'left',
27
27
  transform = 'none',
28
- color,
28
+ color = undefined,
29
29
  class: classProp = '',
30
30
  } = defineProps<{
31
31
  level?: 1 | 2 | 3 | 4 | 5 | 6
@@ -5,7 +5,10 @@
5
5
 
6
6
  defineOptions({ inheritAttrs: false })
7
7
 
8
- const { color, size } = defineProps<{ color?: UiColors; size?: FontSize }>()
8
+ const { color = undefined, size = undefined } = defineProps<{
9
+ color?: UiColors
10
+ size?: FontSize
11
+ }>()
9
12
  const colorClass = useColor(color, 'text')
10
13
  </script>
11
14
 
@@ -1,4 +1,6 @@
1
1
  <script lang="ts" setup>
2
+ defineOptions({ inheritAttrs: false })
3
+
2
4
  const {
3
5
  strokeWidth = 1.5,
4
6
  strokeColor = 'currentColor',
@@ -14,33 +14,42 @@
14
14
  TypographyTag,
15
15
  } from '../../types/typography'
16
16
 
17
- const props = withDefaults(
18
- defineProps<{
19
- tag?: TypographyTag
20
- weight?: FontWeight
21
- width?: FontWidth
22
- slant?: FontSlant
23
- leading?: FontLeading
24
- tracking?: FontTracking
25
- align?: TextAlign
26
- transform?: TextTransform
27
- color?: UiColors
28
- size?: FontSize
29
- }>(),
30
- {
31
- tag: 'p',
32
- weight: 'font-normal',
33
- width: 'font-stretch-normal',
34
- slant: 'normal',
35
- leading: 'leading-normal',
36
- tracking: 'tracking-normal',
37
- align: 'left',
38
- transform: 'none',
39
- size: 'base',
40
- }
41
- )
42
- const { classes } = useTypography(props)
43
- const colorClass = useColor(props.color, 'text')
17
+ defineOptions({ inheritAttrs: false })
18
+
19
+ const {
20
+ tag = 'p',
21
+ weight = 'font-normal',
22
+ width = 'font-stretch-normal',
23
+ slant = 'normal',
24
+ leading = 'leading-normal',
25
+ tracking = 'tracking-normal',
26
+ align = 'left',
27
+ transform = 'none',
28
+ color = undefined,
29
+ size = 'base',
30
+ } = defineProps<{
31
+ tag?: TypographyTag
32
+ weight?: FontWeight
33
+ width?: FontWidth
34
+ slant?: FontSlant
35
+ leading?: FontLeading
36
+ tracking?: FontTracking
37
+ align?: TextAlign
38
+ transform?: TextTransform
39
+ color?: UiColors
40
+ size?: FontSize
41
+ }>()
42
+ const { classes } = useTypography(() => ({
43
+ weight,
44
+ width,
45
+ slant,
46
+ leading,
47
+ tracking,
48
+ align,
49
+ transform,
50
+ size,
51
+ }))
52
+ const colorClass = useColor(color, 'text')
44
53
  </script>
45
54
 
46
55
  <template>
@@ -1,3 +1,6 @@
1
+ import type { MaybeRefOrGetter } from 'vue'
2
+ import { toValue } from 'vue'
3
+
1
4
  import type {
2
5
  FontLeading,
3
6
  FontSize,
@@ -35,50 +38,53 @@ function getSizeClass(size: FontSize | undefined): string {
35
38
  return typeof size === 'number' ? `text-[${size}]` : `text-${size}`
36
39
  }
37
40
 
38
- export function useTypography(props: {
39
- weight?: FontWeight
40
- slant?: FontSlant
41
- width?: FontWidth
42
- leading?: FontLeading
43
- tracking?: FontTracking
44
- align?: TextAlign
45
- transform?: TextTransform
46
- size?: FontSize
47
- }) {
48
- const classes = computed(() =>
49
- [
50
- normalizeAxis(props.weight, {
41
+ export function useTypography(
42
+ props: MaybeRefOrGetter<{
43
+ weight?: FontWeight
44
+ slant?: FontSlant
45
+ width?: FontWidth
46
+ leading?: FontLeading
47
+ tracking?: FontTracking
48
+ align?: TextAlign
49
+ transform?: TextTransform
50
+ size?: FontSize
51
+ }>
52
+ ) {
53
+ const classes = computed(() => {
54
+ const p = toValue(props)
55
+ return [
56
+ normalizeAxis(p.weight, {
51
57
  prefix: 'font',
52
58
  fallback: 'font-normal',
53
59
  }),
54
60
 
55
- normalizeAxis(props.width, {
61
+ normalizeAxis(p.width, {
56
62
  numericFormatter: (v) => `font-stretch-[${v}%]`,
57
63
  }),
58
64
 
59
- normalizeAxis(props.slant, {
65
+ normalizeAxis(p.slant, {
60
66
  fallback: 'not-italic',
61
67
  }),
62
68
 
63
- normalizeAxis(props.leading, {
69
+ normalizeAxis(p.leading, {
64
70
  prefix: 'leading',
65
71
  fallback: 'leading-normal',
66
72
  }),
67
73
 
68
- normalizeAxis(props.tracking, {
74
+ normalizeAxis(p.tracking, {
69
75
  prefix: 'tracking',
70
76
  fallback: 'tracking-normal',
71
77
  }),
72
78
 
73
- getSizeClass(props.size),
79
+ getSizeClass(p.size),
74
80
 
75
- props.align ? `text-${props.align}` : '',
81
+ p.align ? `text-${p.align}` : '',
76
82
 
77
- props.transform && props.transform !== 'none' ? props.transform : '',
83
+ p.transform && p.transform !== 'none' ? p.transform : '',
78
84
  ]
79
85
  .filter(Boolean)
80
86
  .join(' ')
81
- )
87
+ })
82
88
 
83
89
  return { classes }
84
90
  }
@@ -1,29 +1,9 @@
1
- /***************************************************************
2
- UI Primitives - Semantic Color Types
3
-
4
- `UiSemanticColor` defines neutral or semantic colors for general UI elements.
5
- `UiStatusColor` defines status-related colors (info, success, warning, error).
6
- `UiCustomColors` defines custom design colors like accent or secondary.
7
- `UiBaseColor` defines fundamental colors (black, white).
8
- `UiColors` is the union of all color types and can be applied to text, backgrounds, borders, or other UI elements.
9
- `ColorUsage` defines the intended usage of a color in a component.
10
- ***************************************************************/
11
-
12
- export type ColorUsage = 'text' | 'bg' | 'border'
13
-
14
- export type UiSemanticColor = 'dimmed' | 'muted' | 'toned' | 'default' | 'highlighted' | 'inverted'
15
-
16
- export type UiStatusColor = 'info' | 'success' | 'warning' | 'error'
17
-
18
- export type UiDefaultNuxtUiColors = 'primary' | 'neutral'
19
-
20
- export type UiCustomColors = 'secondary' | 'accent'
21
-
22
- export type UiBaseColor = 'black' | 'white'
23
-
24
- export type UiColors =
25
- | UiSemanticColor
26
- | UiStatusColor
27
- | UiDefaultNuxtUiColors
28
- | UiCustomColors
29
- | UiBaseColor
1
+ export type {
2
+ ColorUsage,
3
+ UiSemanticColor,
4
+ UiStatusColor,
5
+ UiDefaultNuxtUiColors,
6
+ UiCustomColors,
7
+ UiBaseColor,
8
+ UiColors,
9
+ } from '#types'
@@ -0,0 +1,2 @@
1
+ export type * from './colors'
2
+ export type * from './typography'
@@ -2,5 +2,8 @@
2
2
  "name": "kmcom-layer-typography",
3
3
  "version": "0.0.1",
4
4
  "type": "module",
5
- "main": "./nuxt.config.ts"
5
+ "main": "./nuxt.config.ts",
6
+ "scripts": {
7
+ "lint": "eslint ."
8
+ }
6
9
  }
@@ -10,6 +10,7 @@
10
10
  "dev:prepare": "nuxt prepare .playground",
11
11
  "build": "UI_STANDALONE=true nuxi build",
12
12
  "generate": "UI_STANDALONE=true nuxi generate",
13
- "preview": "nuxt preview .playground"
13
+ "preview": "nuxt preview .playground",
14
+ "lint": "eslint ."
14
15
  }
15
16
  }