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.
- package/docs/FEEDS.md +197 -0
- package/docs/LAYERS-FIXES.md +101 -0
- package/docs/MIGRATION.md +627 -0
- package/docs/feed-layer.md +374 -0
- package/docs/patch-picture-provider-type.md +52 -0
- package/docs/shaderGuide.md +2071 -0
- package/docs/types-architecture.md +234 -0
- package/layers/animations/app/components/Motion/CountUp.vue +1 -1
- package/layers/animations/app/components/Motion/Magnetic.vue +1 -1
- package/layers/animations/app/components/Motion/Marquee.vue +3 -2
- package/layers/animations/app/components/Motion/MarqueeText.vue +3 -2
- package/layers/animations/app/components/Motion/Tilt.vue +1 -1
- package/layers/animations/app/composables/useCountUp.ts +4 -1
- package/layers/animations/app/composables/useMagneticElement.ts +2 -4
- package/layers/animations/app/composables/useMarqueeCopies.ts +4 -4
- package/layers/animations/app/composables/useTiltEffect.ts +1 -1
- package/layers/animations/app/types/animations.ts +8 -0
- package/layers/animations/app/types/index.ts +1 -0
- package/layers/animations/package.json +4 -1
- package/layers/canvas/app/components/ShaderCanvas.vue +4 -4
- package/layers/canvas/app/composables/useRendererCapabilities.ts +19 -15
- package/layers/canvas/app/types/index.ts +1 -0
- package/layers/canvas/package.json +2 -1
- package/layers/canvas/tsconfig.json +2 -1
- package/layers/content/app/components/Blog/Card.vue +5 -5
- package/layers/content/app/components/Gallery/AmbientImage.vue +3 -3
- package/layers/content/app/components/Gallery/Card.vue +3 -3
- package/layers/content/app/components/Gallery/Lightbox.vue +5 -1
- package/layers/content/app/components/NuxtContent/Detail.vue +5 -1
- package/layers/content/app/components/NuxtContent/Surround.vue +5 -3
- package/layers/content/app/components/NuxtContent/Toc.vue +1 -1
- package/layers/content/app/components/Portfolio/Card.vue +5 -5
- package/layers/content/app/components/content/Figure.vue +3 -3
- package/layers/content/app/composables/useBlogPosts.ts +2 -2
- package/layers/content/app/composables/useCollectionItem.ts +1 -3
- package/layers/content/app/composables/useGalleryItems.ts +2 -2
- package/layers/content/app/types/index.ts +1 -0
- package/layers/content/package.json +2 -1
- package/layers/core/app/composables/useCache.ts +0 -1
- package/layers/core/app/composables/useErrorLog.ts +9 -11
- package/layers/core/app/plugins/error-handler.ts +36 -36
- package/layers/core/app/plugins/feature-detection.client.ts +15 -15
- package/layers/core/app/plugins/init.ts +121 -129
- package/layers/core/app/plugins/loading.client.ts +27 -27
- package/layers/core/app/plugins/scroll-guard.client.ts +26 -26
- package/layers/core/app/utils/helpers.ts +14 -12
- package/layers/core/nuxt.config.ts +1 -0
- package/layers/feeds/app/plugins/feed-head.ts +62 -63
- package/layers/feeds/package.json +2 -1
- package/layers/feeds/server/routes/feed/discovery.get.ts +1 -2
- package/layers/feeds/server/utils/content-adapter.ts +3 -2
- package/layers/forms/app/components/Form/Field.vue +4 -4
- package/layers/forms/app/types/index.ts +1 -0
- package/layers/forms/package.json +2 -1
- package/layers/forms/server/api/contact.post.ts +1 -1
- package/layers/layout/app/components/Layout/Grid/Item.vue +33 -19
- package/layers/layout/app/components/Layout/Page/Container.vue +11 -11
- package/layers/layout/app/components/Layout/Page/Header.vue +1 -1
- package/layers/layout/app/components/Layout/Page/index.vue +1 -1
- package/layers/layout/app/components/Layout/Section/Gallery.vue +6 -1
- package/layers/layout/app/components/Layout/Section/Title.vue +1 -1
- package/layers/layout/app/types/index.ts +1 -0
- package/layers/layout/package.json +2 -1
- package/layers/mailer/app/types/index.ts +1 -0
- package/layers/mailer/app/types/mailer.ts +25 -0
- package/layers/mailer/package.json +2 -1
- package/layers/motion/package.json +2 -1
- package/layers/navigation/app/components/Links/Group.vue +1 -0
- package/layers/navigation/app/components/Links/Named.vue +2 -0
- package/layers/navigation/app/types/index.ts +1 -0
- package/layers/navigation/package.json +4 -1
- package/layers/page-transitions/app/plugins/page-transitions.client.ts +9 -9
- package/layers/page-transitions/package.json +4 -1
- package/layers/routing/app/plugins/feature-flags.client.ts +9 -9
- package/layers/routing/app/types/app-config.d.ts +3 -1
- package/layers/routing/app/types/index.ts +1 -0
- package/layers/routing/package.json +2 -1
- package/layers/scripts/app/composables/useGtm.ts +1 -1
- package/layers/scripts/app/types/index.ts +1 -0
- package/layers/scripts/app/types/scripts.ts +14 -0
- package/layers/scripts/package.json +2 -1
- package/layers/scroll/app/components/Motion/ScrollScene.vue +3 -1
- package/layers/scroll/app/composables/useScrollSteps.ts +2 -9
- package/layers/scroll/app/composables/useSectionProgress.ts +2 -1
- package/layers/scroll/app/plugins/locomotive-scroll.client.ts +54 -61
- package/layers/scroll/app/types/index.ts +1 -0
- package/layers/scroll/app/types/scroll.ts +32 -0
- package/layers/scroll/package.json +3 -0
- package/layers/seo/package.json +2 -1
- package/layers/shader/app/components/Material/Fresnel.client.vue +1 -1
- package/layers/shader/app/components/Material/Image.client.vue +1 -1
- package/layers/shader/app/components/Material/Node.client.vue +7 -7
- package/layers/shader/app/components/Material/Noise.client.vue +1 -1
- package/layers/shader/app/components/Node/Color.client.vue +17 -20
- package/layers/shader/app/components/Node/Noise.client.vue +31 -34
- package/layers/shader/app/components/Pipeline/Aurora.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/BilinearGradient.client.vue +8 -11
- package/layers/shader/app/components/Pipeline/BillowNoise.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/BrightnessContrast.client.vue +6 -2
- package/layers/shader/app/components/Pipeline/CellularNoise.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/Checkerboard.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/Circle.client.vue +5 -8
- package/layers/shader/app/components/Pipeline/Clouds.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/ColorBurnBlend.client.vue +2 -19
- package/layers/shader/app/components/Pipeline/ColorDodgeBlend.client.vue +2 -19
- package/layers/shader/app/components/Pipeline/ColourRamp.client.vue +5 -9
- package/layers/shader/app/components/Pipeline/ConicGradient.client.vue +5 -8
- package/layers/shader/app/components/Pipeline/Cross.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/CurlNoise.client.vue +3 -7
- package/layers/shader/app/components/Pipeline/DarkenBlend.client.vue +2 -19
- package/layers/shader/app/components/Pipeline/DayNightCycle.client.vue +5 -8
- package/layers/shader/app/components/Pipeline/DiagonalGradient.client.vue +5 -8
- package/layers/shader/app/components/Pipeline/DiamondGradient.client.vue +5 -8
- package/layers/shader/app/components/Pipeline/DifferenceBlend.client.vue +2 -19
- package/layers/shader/app/components/Pipeline/DomainWarpedNoise.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/Dots.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/DuoTone.client.vue +5 -9
- package/layers/shader/app/components/Pipeline/ExclusionBlend.client.vue +3 -23
- package/layers/shader/app/components/Pipeline/ExponentialFog.client.vue +4 -7
- package/layers/shader/app/components/Pipeline/FilmBurn.client.vue +4 -7
- package/layers/shader/app/components/Pipeline/Flame.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/FocalGradient.client.vue +5 -8
- package/layers/shader/app/components/Pipeline/GodRays.client.vue +4 -7
- package/layers/shader/app/components/Pipeline/GradientNoise.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/Grid.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/Halation.client.vue +3 -7
- package/layers/shader/app/components/Pipeline/HardLightBlend.client.vue +2 -19
- package/layers/shader/app/components/Pipeline/Haze.client.vue +4 -7
- package/layers/shader/app/components/Pipeline/Hexagon.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/LensFlare.client.vue +4 -7
- package/layers/shader/app/components/Pipeline/LightenBlend.client.vue +2 -19
- package/layers/shader/app/components/Pipeline/LinearGradient4.client.vue +2 -2
- package/layers/shader/app/components/Pipeline/Marble.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/MonochromeTint.client.vue +3 -7
- package/layers/shader/app/components/Pipeline/MultiplyBlend.client.vue +2 -19
- package/layers/shader/app/components/Pipeline/NoisyGradient.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/NoisyGradientBlend.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/OverlayBlend.client.vue +2 -19
- package/layers/shader/app/components/Pipeline/Polygon.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/RaymarchTunnel.client.vue +4 -7
- package/layers/shader/app/components/Pipeline/Rectangle.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/RidgedNoise.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/Ring.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/ScreenBlend.client.vue +2 -19
- package/layers/shader/app/components/Pipeline/SkyAtmosphere.client.vue +6 -9
- package/layers/shader/app/components/Pipeline/SoftLightBlend.client.vue +2 -19
- package/layers/shader/app/components/Pipeline/SplitTone.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/Star.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/Stripes.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/Tint.client.vue +4 -7
- package/layers/shader/app/components/Pipeline/Triangle.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/ValueNoise.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/VoronoiEdges.client.vue +4 -8
- package/layers/shader/app/components/Pipeline/Water.client.vue +5 -8
- package/layers/shader/app/components/Pipeline/WaveBendLayer.client.vue +4 -7
- package/layers/shader/app/components/Pipeline/WaveColourLayer.client.vue +3 -7
- package/layers/shader/app/components/Pipeline/Wood.client.vue +4 -8
- package/layers/shader/app/components/Preset/Aurora.client.vue +15 -21
- package/layers/shader/app/components/Preset/Flow.client.vue +2 -1
- package/layers/shader/app/components/Preset/GradientMesh.client.vue +2 -1
- package/layers/shader/app/components/Preset/Nebula.client.vue +2 -1
- package/layers/shader/app/components/Preset/Ocean.client.vue +2 -1
- package/layers/shader/app/components/Preset/ThemeAurora.client.vue +30 -90
- package/layers/shader/app/components/Preset/ThemeBubble.client.vue +30 -91
- package/layers/shader/app/components/Preset/ThemeFlow.client.vue +30 -90
- package/layers/shader/app/components/Preset/ThemeGradient.client.vue +30 -91
- package/layers/shader/app/components/Preset/ThemeLavaLamp.client.vue +30 -90
- package/layers/shader/app/components/Preset/ThemePlasma.client.vue +30 -90
- package/layers/shader/app/components/Preset/ThemeWave.client.vue +30 -90
- package/layers/shader/app/components/Shader/Background.client.vue +4 -4
- package/layers/shader/app/components/Shader/Host.client.vue +31 -33
- package/layers/shader/app/components/Shader/Runtime.client.vue +15 -23
- package/layers/shader/app/composables/useAmbientMaterials.ts +53 -51
- package/layers/shader/app/composables/useShaderMixBlend.ts +26 -0
- package/layers/shader/app/composables/useThemePreset.ts +75 -0
- package/layers/shader/app/plugins/shader.client.ts +21 -21
- package/layers/shader/app/shaders/common/noise.ts +2 -7
- package/layers/shader/app/shaders/types.ts +6 -6
- package/layers/shader/app/types/tsl.ts +7 -25
- package/layers/shader/app/types/uniforms.ts +2 -1
- package/layers/shader/app/utils/tsl/color.ts +7 -1
- package/layers/shader/package.json +2 -1
- package/layers/theme/app/components/ThemePicker/Colors.vue +1 -3
- package/layers/theme/app/plugins/theme.client.ts +54 -51
- package/layers/theme/app/types/app-config.d.ts +4 -2
- package/layers/theme/app/types/index.ts +1 -0
- package/layers/theme/app/types/theme.ts +3 -18
- package/layers/theme/package.json +2 -1
- package/layers/theme/server/plugins/theme-fouc.ts +1 -1
- package/layers/transitions/package.json +4 -1
- package/layers/typography/app/components/Typography/CodeBlock.vue +2 -2
- package/layers/typography/app/components/Typography/Headline.vue +2 -2
- package/layers/typography/app/components/Typography/HeadlineScreen.vue +1 -1
- package/layers/typography/app/components/Typography/QuoteBlock.vue +4 -1
- package/layers/typography/app/components/Typography/TextStroke.vue +2 -0
- package/layers/typography/app/components/Typography/index.vue +36 -27
- package/layers/typography/app/composables/typography.ts +27 -21
- package/layers/typography/app/types/colors.ts +9 -29
- package/layers/typography/app/types/index.ts +2 -0
- package/layers/typography/package.json +4 -1
- package/layers/ui/package.json +2 -1
- package/layers/visual/app/app.config.ts +5 -2
- package/layers/visual/app/components/Accent/Blob.vue +20 -20
- package/layers/visual/app/components/Accent/Scene.vue +2 -2
- package/layers/visual/app/components/Base/Modal.vue +2 -2
- package/layers/visual/app/components/Gradient/Background.vue +2 -2
- package/layers/visual/app/components/Gradient/Text.vue +2 -2
- package/layers/visual/app/components/Media/Picture.vue +3 -1
- package/layers/visual/app/components/Progress/Bar.vue +6 -6
- package/layers/visual/app/components/Tint/Overlay.vue +14 -14
- package/layers/visual/app/composables/accent.ts +10 -8
- package/layers/visual/app/composables/gradient.ts +2 -3
- package/layers/visual/app/composables/tint.ts +7 -7
- package/layers/visual/app/types/index.ts +6 -0
- package/layers/visual/app/types/media.ts +4 -2
- package/layers/visual/app/types/tint.ts +2 -1
- package/layers/visual/package.json +4 -1
- 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const config = useAppConfig()
|
|
7
|
+
const shaderConfig = (config.shader || {}) as {
|
|
8
|
+
preferWebGPU?: boolean
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
// Check WebGPU support
|
|
12
|
+
const hasWebGPU = await checkWebGPUSupport()
|
|
13
|
+
const useWebGPU = shaderConfig.preferWebGPU && hasWebGPU
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
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 =
|
|
7
|
-
|
|
8
|
-
export type
|
|
9
|
-
|
|
10
|
-
export type
|
|
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,
|
|
21
|
+
nodes: Record<keyof T, TSLNode>
|
|
21
22
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
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(() =>
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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?:
|
|
5
|
-
defaultAccent?:
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
|
@@ -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
|
|
153
|
+
`<style id="theme-accent-css">${accentCSS}</style><script>${initScript}</script>`
|
|
154
154
|
)
|
|
155
155
|
})
|
|
156
156
|
})
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
defineOptions({ inheritAttrs: false })
|
|
7
7
|
|
|
8
|
-
const { color, size } = defineProps<{
|
|
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
|
|
|
@@ -14,33 +14,42 @@
|
|
|
14
14
|
TypographyTag,
|
|
15
15
|
} from '../../types/typography'
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
)
|
|
42
|
-
const { classes } = useTypography(
|
|
43
|
-
|
|
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(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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(
|
|
61
|
+
normalizeAxis(p.width, {
|
|
56
62
|
numericFormatter: (v) => `font-stretch-[${v}%]`,
|
|
57
63
|
}),
|
|
58
64
|
|
|
59
|
-
normalizeAxis(
|
|
65
|
+
normalizeAxis(p.slant, {
|
|
60
66
|
fallback: 'not-italic',
|
|
61
67
|
}),
|
|
62
68
|
|
|
63
|
-
normalizeAxis(
|
|
69
|
+
normalizeAxis(p.leading, {
|
|
64
70
|
prefix: 'leading',
|
|
65
71
|
fallback: 'leading-normal',
|
|
66
72
|
}),
|
|
67
73
|
|
|
68
|
-
normalizeAxis(
|
|
74
|
+
normalizeAxis(p.tracking, {
|
|
69
75
|
prefix: 'tracking',
|
|
70
76
|
fallback: 'tracking-normal',
|
|
71
77
|
}),
|
|
72
78
|
|
|
73
|
-
getSizeClass(
|
|
79
|
+
getSizeClass(p.size),
|
|
74
80
|
|
|
75
|
-
|
|
81
|
+
p.align ? `text-${p.align}` : '',
|
|
76
82
|
|
|
77
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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'
|
package/layers/ui/package.json
CHANGED