@rokkit/app 1.1.14 → 1.1.16
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/app",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
4
4
|
"description": "App-level controls for Rokkit applications - theme management and UI chrome",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"build": "echo 'No build step needed for source-only package'"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@rokkit/actions": "1.1.
|
|
41
|
-
"@rokkit/core": "1.1.
|
|
42
|
-
"@rokkit/states": "1.1.
|
|
43
|
-
"@rokkit/ui": "1.1.
|
|
40
|
+
"@rokkit/actions": "1.1.16",
|
|
41
|
+
"@rokkit/core": "1.1.16",
|
|
42
|
+
"@rokkit/states": "1.1.16",
|
|
43
|
+
"@rokkit/ui": "1.1.16"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"svelte": "^5.0.0"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { vibe } from '@rokkit/states'
|
|
3
|
+
import { Toggle } from '@rokkit/ui'
|
|
4
|
+
import { buildSkinSwitcherOptions } from '../types/skin-switcher.js'
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
skins = undefined,
|
|
8
|
+
labels = {},
|
|
9
|
+
showLabels = false,
|
|
10
|
+
size = 'sm',
|
|
11
|
+
disabled = false,
|
|
12
|
+
class: className = '',
|
|
13
|
+
onchange
|
|
14
|
+
}: {
|
|
15
|
+
skins?: Array<string | { name: string; label?: string; icon?: string }>
|
|
16
|
+
labels?: Record<string, string>
|
|
17
|
+
showLabels?: boolean
|
|
18
|
+
size?: 'sm' | 'md' | 'lg'
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
class?: string
|
|
21
|
+
onchange?: (skin: string) => void
|
|
22
|
+
} = $props()
|
|
23
|
+
|
|
24
|
+
const options = $derived(buildSkinSwitcherOptions(skins ?? vibe.allowedSkins, labels))
|
|
25
|
+
let value = $derived(vibe.skin)
|
|
26
|
+
|
|
27
|
+
function handleChange(newValue: unknown) {
|
|
28
|
+
vibe.skin = newValue as string
|
|
29
|
+
onchange?.(newValue as string)
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<Toggle
|
|
34
|
+
variant="group"
|
|
35
|
+
{options}
|
|
36
|
+
{value}
|
|
37
|
+
onchange={handleChange}
|
|
38
|
+
{showLabels}
|
|
39
|
+
{size}
|
|
40
|
+
{disabled}
|
|
41
|
+
class={className}
|
|
42
|
+
/>
|
package/src/components/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface SkinSwitcherOption {
|
|
2
|
+
value: string
|
|
3
|
+
label: string
|
|
4
|
+
icon?: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function buildSkinSwitcherOptions(
|
|
8
|
+
skins: Array<string | { name: string; label?: string; icon?: string }>,
|
|
9
|
+
labels: Record<string, string> = {}
|
|
10
|
+
): SkinSwitcherOption[] {
|
|
11
|
+
return skins.map((s) => {
|
|
12
|
+
const name = typeof s === 'string' ? s : s.name
|
|
13
|
+
const label = typeof s === 'string' ? (labels[s] ?? s) : (s.label ?? labels[s.name] ?? s.name)
|
|
14
|
+
const icon = typeof s === 'string' ? undefined : s.icon
|
|
15
|
+
return { value: name, label, icon }
|
|
16
|
+
})
|
|
17
|
+
}
|
|
@@ -31,7 +31,7 @@ export const defaultThemeSwitcherIcons: Required<ThemeSwitcherIcons> = {
|
|
|
31
31
|
|
|
32
32
|
export interface ThemeSwitcherOption {
|
|
33
33
|
value: ColorMode
|
|
34
|
-
|
|
34
|
+
label: string
|
|
35
35
|
icon: string
|
|
36
36
|
[key: string]: unknown
|
|
37
37
|
}
|
|
@@ -52,9 +52,9 @@ export function buildThemeSwitcherOptions(
|
|
|
52
52
|
): ThemeSwitcherOption[] {
|
|
53
53
|
const mergedLabels = { ...messages.mode, ...labels }
|
|
54
54
|
const all: ThemeSwitcherOption[] = [
|
|
55
|
-
{ value: 'system',
|
|
56
|
-
{ value: 'light',
|
|
57
|
-
{ value: 'dark',
|
|
55
|
+
{ value: 'system', label: mergedLabels.system, icon: icons.system },
|
|
56
|
+
{ value: 'light', label: mergedLabels.light, icon: icons.light },
|
|
57
|
+
{ value: 'dark', label: mergedLabels.dark, icon: icons.dark }
|
|
58
58
|
]
|
|
59
59
|
return all.filter((o) => modes.includes(o.value))
|
|
60
60
|
}
|