@baklavue/mcp 1.0.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.
- package/README.md +72 -0
- package/dist/data/component-categories.d.ts +7 -0
- package/dist/data/component-categories.js +48 -0
- package/dist/data/loaders.d.ts +22 -0
- package/dist/data/loaders.js +346 -0
- package/dist/docs/components/accordion.md +601 -0
- package/dist/docs/components/alert.md +233 -0
- package/dist/docs/components/badge.md +100 -0
- package/dist/docs/components/banner.md +231 -0
- package/dist/docs/components/button.md +324 -0
- package/dist/docs/components/checkbox.md +343 -0
- package/dist/docs/components/chip.md +199 -0
- package/dist/docs/components/datepicker.md +243 -0
- package/dist/docs/components/dialog.md +224 -0
- package/dist/docs/components/drawer.md +188 -0
- package/dist/docs/components/dropdown.md +291 -0
- package/dist/docs/components/file-upload.md +248 -0
- package/dist/docs/components/icon.md +142 -0
- package/dist/docs/components/image.md +161 -0
- package/dist/docs/components/index.md +151 -0
- package/dist/docs/components/input.md +407 -0
- package/dist/docs/components/link.md +249 -0
- package/dist/docs/components/notification.md +179 -0
- package/dist/docs/components/pagination.md +168 -0
- package/dist/docs/components/radio.md +221 -0
- package/dist/docs/components/scroll-to-top.md +90 -0
- package/dist/docs/components/select.md +239 -0
- package/dist/docs/components/skeleton.md +79 -0
- package/dist/docs/components/spinner.md +93 -0
- package/dist/docs/components/split-button.md +165 -0
- package/dist/docs/components/stepper.md +337 -0
- package/dist/docs/components/switch.md +144 -0
- package/dist/docs/components/tab.md +140 -0
- package/dist/docs/components/table.md +362 -0
- package/dist/docs/components/tag.md +243 -0
- package/dist/docs/components/textarea.md +190 -0
- package/dist/docs/components/tooltip.md +155 -0
- package/dist/docs/composables/alert.md +87 -0
- package/dist/docs/composables/asyncState.md +74 -0
- package/dist/docs/composables/base64.md +72 -0
- package/dist/docs/composables/breakpoints.md +129 -0
- package/dist/docs/composables/clipboard.md +108 -0
- package/dist/docs/composables/colorScheme.md +110 -0
- package/dist/docs/composables/confirmDialog.md +105 -0
- package/dist/docs/composables/containerScroll.md +89 -0
- package/dist/docs/composables/cookie.md +137 -0
- package/dist/docs/composables/debounce.md +69 -0
- package/dist/docs/composables/disclosure.md +69 -0
- package/dist/docs/composables/elementSize.md +84 -0
- package/dist/docs/composables/fetch.md +257 -0
- package/dist/docs/composables/fieldArray.md +104 -0
- package/dist/docs/composables/file.md +343 -0
- package/dist/docs/composables/focusTrap.md +87 -0
- package/dist/docs/composables/formPersistence.md +69 -0
- package/dist/docs/composables/formState.md +71 -0
- package/dist/docs/composables/formValidation.md +355 -0
- package/dist/docs/composables/format.md +107 -0
- package/dist/docs/composables/id.md +54 -0
- package/dist/docs/composables/index.md +112 -0
- package/dist/docs/composables/infiniteQuery.md +104 -0
- package/dist/docs/composables/intersectionObserver.md +64 -0
- package/dist/docs/composables/lazyQuery.md +68 -0
- package/dist/docs/composables/loading.md +91 -0
- package/dist/docs/composables/mutation.md +83 -0
- package/dist/docs/composables/notification.md +169 -0
- package/dist/docs/composables/pagination.md +109 -0
- package/dist/docs/composables/polling.md +76 -0
- package/dist/docs/composables/previous.md +58 -0
- package/dist/docs/composables/query.md +248 -0
- package/dist/docs/composables/raf.md +78 -0
- package/dist/docs/composables/scrollLock.md +46 -0
- package/dist/docs/composables/scrollToError.md +291 -0
- package/dist/docs/composables/scrollVisibility.md +60 -0
- package/dist/docs/composables/share.md +78 -0
- package/dist/docs/composables/slug.md +58 -0
- package/dist/docs/composables/stepper.md +117 -0
- package/dist/docs/composables/stepperForm.md +74 -0
- package/dist/docs/composables/sticky.md +91 -0
- package/dist/docs/composables/storage.md +193 -0
- package/dist/docs/composables/theme.md +252 -0
- package/dist/docs/composables/themePreset.md +62 -0
- package/dist/docs/composables/throttle.md +76 -0
- package/dist/docs/composables/timer.md +78 -0
- package/dist/docs/composables/toggle.md +55 -0
- package/dist/docs/guide/contributing.md +364 -0
- package/dist/docs/guide/design-tokens.md +29 -0
- package/dist/docs/guide/getting-started.md +181 -0
- package/dist/docs/guide/installation.md +287 -0
- package/dist/docs/guide/localization.md +132 -0
- package/dist/docs/guide/mcp.md +141 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +177 -0
- package/package.json +48 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# useSticky
|
|
2
|
+
|
|
3
|
+
A composable to detect when a sticky element is "stuck" at the top of the viewport. Uses scroll position and `getBoundingClientRect`. The target should have `position: sticky` and `top: 0` (or similar).
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<header
|
|
10
|
+
ref="header"
|
|
11
|
+
class="sticky top-0 transition-shadow"
|
|
12
|
+
:class="{ 'shadow-md': isSticky }"
|
|
13
|
+
>
|
|
14
|
+
Header
|
|
15
|
+
</header>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup>
|
|
19
|
+
import { ref } from "vue";
|
|
20
|
+
import { useSticky } from "@baklavue/composables";
|
|
21
|
+
|
|
22
|
+
const header = ref<HTMLElement | null>(null);
|
|
23
|
+
const { isSticky } = useSticky(header);
|
|
24
|
+
</script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## With Custom Scroll Container
|
|
28
|
+
|
|
29
|
+
```vue
|
|
30
|
+
<template>
|
|
31
|
+
<div ref="scrollContainer" class="overflow-auto h-64">
|
|
32
|
+
<div ref="stickyHeader" class="sticky top-0">Sticky header</div>
|
|
33
|
+
<div>Content</div>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script setup>
|
|
38
|
+
import { ref } from "vue";
|
|
39
|
+
import { useSticky } from "@baklavue/composables";
|
|
40
|
+
|
|
41
|
+
const stickyHeader = ref<HTMLElement | null>(null);
|
|
42
|
+
const scrollContainer = ref<HTMLElement | null>(null);
|
|
43
|
+
const { isSticky } = useSticky(stickyHeader, {
|
|
44
|
+
scrollTarget: scrollContainer,
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Options
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<script setup>
|
|
53
|
+
import { useSticky } from "@baklavue/composables";
|
|
54
|
+
|
|
55
|
+
const header = ref<HTMLElement | null>(null);
|
|
56
|
+
const { isSticky } = useSticky(header, {
|
|
57
|
+
threshold: 0,
|
|
58
|
+
scrollTarget: undefined,
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
| Option | Type | Default | Description |
|
|
64
|
+
| --- | --- | --- | --- |
|
|
65
|
+
| `threshold` | `number` | `0` | Pixels. `isSticky` is true when element top is at or above this |
|
|
66
|
+
| `scrollTarget` | `Ref<Element \| null \| undefined>` | `undefined` | Scroll container. Default: window |
|
|
67
|
+
|
|
68
|
+
## API
|
|
69
|
+
|
|
70
|
+
### Parameters
|
|
71
|
+
|
|
72
|
+
- `target` — `Ref<Element | null | undefined>` — Ref to the sticky element
|
|
73
|
+
- `options` — Optional `UseStickyOptions`
|
|
74
|
+
|
|
75
|
+
### Return Value
|
|
76
|
+
|
|
77
|
+
| Property | Type | Description |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| `isSticky` | `Ref<boolean>` | `true` when element is stuck |
|
|
80
|
+
|
|
81
|
+
## TypeScript Support
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import {
|
|
85
|
+
useSticky,
|
|
86
|
+
type UseStickyOptions,
|
|
87
|
+
} from "@baklavue/composables";
|
|
88
|
+
|
|
89
|
+
const header = ref<HTMLElement | null>(null);
|
|
90
|
+
const { isSticky } = useSticky(header, { threshold: 0 });
|
|
91
|
+
```
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# useLocalStorage / useSessionStorage
|
|
2
|
+
|
|
3
|
+
Reactive sync with `localStorage` and `sessionStorage`. Persist user preferences like theme, table page size, or form drafts across sessions (localStorage) or within the current tab (sessionStorage).
|
|
4
|
+
|
|
5
|
+
## useLocalStorage
|
|
6
|
+
|
|
7
|
+
Persists across browser sessions. Use for theme, page size, sidebar state, etc.
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<template>
|
|
11
|
+
<BvSelect v-model="pageSize" :options="pageSizeOptions" />
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup>
|
|
15
|
+
import { BvSelect } from "@baklavue/ui";
|
|
16
|
+
import { useLocalStorage } from "@baklavue/composables";
|
|
17
|
+
|
|
18
|
+
const pageSize = useLocalStorage("table-page-size", 10);
|
|
19
|
+
const pageSizeOptions = [
|
|
20
|
+
{ value: 10, text: "10" },
|
|
21
|
+
{ value: 25, text: "25" },
|
|
22
|
+
{ value: 50, text: "50" },
|
|
23
|
+
];
|
|
24
|
+
</script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## useSessionStorage
|
|
28
|
+
|
|
29
|
+
Persists only for the current tab/session. Use for form drafts, temporary filters, etc.
|
|
30
|
+
|
|
31
|
+
```vue
|
|
32
|
+
<script setup>
|
|
33
|
+
import { useSessionStorage } from "@baklavue/composables";
|
|
34
|
+
|
|
35
|
+
const draft = useSessionStorage("form-draft", null);
|
|
36
|
+
</script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## With useBaklavaTheme
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<script setup>
|
|
43
|
+
import { useBaklavaTheme, useLocalStorage } from "@baklavue/composables";
|
|
44
|
+
|
|
45
|
+
const themePreset = useLocalStorage("theme-preset", "vue");
|
|
46
|
+
const { applyTheme } = useBaklavaTheme();
|
|
47
|
+
|
|
48
|
+
watch(themePreset, (preset) => applyTheme({ preset }), { immediate: true });
|
|
49
|
+
</script>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## With usePagination
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<script setup>
|
|
56
|
+
import { usePagination, useLocalStorage } from "@baklavue/composables";
|
|
57
|
+
|
|
58
|
+
const savedPageSize = useLocalStorage("pagination-page-size", 10);
|
|
59
|
+
const { currentPage, pageSize, totalItems, slice } = usePagination({
|
|
60
|
+
pageSize: savedPageSize.value,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
watch(pageSize, (size) => (savedPageSize.value = size));
|
|
64
|
+
</script>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Options
|
|
68
|
+
|
|
69
|
+
`useLocalStorage` and `useSessionStorage` accept an optional third parameter.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
interface UseStorageOptions<T> {
|
|
73
|
+
/** Merge default with stored value when both are objects. Default: false */
|
|
74
|
+
mergeDefaults?: boolean | ((storageValue: T, defaults: T) => T);
|
|
75
|
+
/** Listen to storage events for cross-tab sync. Default: true for localStorage, false for sessionStorage */
|
|
76
|
+
listenToStorageChanges?: boolean;
|
|
77
|
+
/** Custom serializer. Default: JSON */
|
|
78
|
+
serializer?: { read: (raw: string) => T; write: (value: T) => string };
|
|
79
|
+
/** Error callback. Default: silent */
|
|
80
|
+
onError?: (error: unknown) => void;
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### mergeDefaults
|
|
85
|
+
|
|
86
|
+
When you add new properties to your default object, existing stored values won't have them. Enable `mergeDefaults: true` for a shallow merge:
|
|
87
|
+
|
|
88
|
+
```vue
|
|
89
|
+
<script setup>
|
|
90
|
+
import { useLocalStorage } from "@baklavue/composables";
|
|
91
|
+
|
|
92
|
+
// If storage has { theme: "vue" } but default adds compact, merged result includes both
|
|
93
|
+
const prefs = useLocalStorage("prefs", { theme: "vue", compact: false }, {
|
|
94
|
+
mergeDefaults: true,
|
|
95
|
+
});
|
|
96
|
+
</script>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Or pass a custom merge function for deep merge:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { useLocalStorage } from "@baklavue/composables";
|
|
103
|
+
|
|
104
|
+
const prefs = useLocalStorage("prefs", defaultPrefs, {
|
|
105
|
+
mergeDefaults: (stored, defaults) => ({ ...defaults, ...stored }),
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### listenToStorageChanges
|
|
110
|
+
|
|
111
|
+
Changes in other tabs update the ref automatically. Enabled by default for `useLocalStorage`; disabled for `useSessionStorage` (sessionStorage is tab-scoped).
|
|
112
|
+
|
|
113
|
+
### Custom serializer
|
|
114
|
+
|
|
115
|
+
Store `Map`, `Set`, `Date`, or custom formats:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { useLocalStorage } from "@baklavue/composables";
|
|
119
|
+
|
|
120
|
+
const count = useLocalStorage("count", 0, {
|
|
121
|
+
serializer: {
|
|
122
|
+
read: (v) => parseFloat(v) || 0,
|
|
123
|
+
write: (v) => String(v),
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const lastVisit = useLocalStorage("last-visit", new Date(), {
|
|
128
|
+
serializer: {
|
|
129
|
+
read: (v) => new Date(v),
|
|
130
|
+
write: (v) => v.toISOString(),
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### onError
|
|
136
|
+
|
|
137
|
+
Handle quota exceeded or parse errors:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
const prefs = useLocalStorage("prefs", {}, {
|
|
141
|
+
onError: (e) => console.error("Storage error:", e),
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## API
|
|
146
|
+
|
|
147
|
+
### useLocalStorage
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
useLocalStorage<T>(key: string, defaultValue: T): Ref<T>
|
|
151
|
+
useLocalStorage<T>(key: string, defaultValue: T, options: UseStorageOptions<T>): Ref<T>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
| Parameter | Type | Description |
|
|
155
|
+
| --- | --- | --- |
|
|
156
|
+
| `key` | `string` | Storage key |
|
|
157
|
+
| `defaultValue` | `T` | Default when key is missing or on SSR |
|
|
158
|
+
| `options` | `UseStorageOptions<T>` | Optional: mergeDefaults, listenToStorageChanges, serializer, onError |
|
|
159
|
+
|
|
160
|
+
### useSessionStorage
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
useSessionStorage<T>(key: string, defaultValue: T): Ref<T>
|
|
164
|
+
useSessionStorage<T>(key: string, defaultValue: T, options: UseStorageOptions<T>): Ref<T>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
| Parameter | Type | Description |
|
|
168
|
+
| --- | --- | --- |
|
|
169
|
+
| `key` | `string` | Storage key |
|
|
170
|
+
| `defaultValue` | `T` | Default when key is missing or on SSR |
|
|
171
|
+
| `options` | `UseStorageOptions<T>` | Optional: mergeDefaults, listenToStorageChanges, serializer, onError |
|
|
172
|
+
|
|
173
|
+
### Notes
|
|
174
|
+
|
|
175
|
+
- Values are JSON-serialized by default. Primitives, objects, and arrays are supported.
|
|
176
|
+
- On SSR, returns `defaultValue` (storage is not available).
|
|
177
|
+
- Changes to the ref are written to storage (with `{ deep: true }` for objects).
|
|
178
|
+
- Cross-tab sync is enabled for `useLocalStorage` by default.
|
|
179
|
+
|
|
180
|
+
## TypeScript Support
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { useLocalStorage, useSessionStorage, type UseStorageOptions } from "@baklavue/composables";
|
|
184
|
+
|
|
185
|
+
const pageSize = useLocalStorage<number>("page-size", 10);
|
|
186
|
+
const prefs = useLocalStorage("prefs", { theme: "vue", compact: false });
|
|
187
|
+
const draft = useSessionStorage<string | null>("draft", null);
|
|
188
|
+
|
|
189
|
+
// With options
|
|
190
|
+
const prefsWithMerge = useLocalStorage("prefs", { theme: "vue", compact: false }, {
|
|
191
|
+
mergeDefaults: true,
|
|
192
|
+
});
|
|
193
|
+
```
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# useBaklavaTheme
|
|
2
|
+
|
|
3
|
+
A composable for overwriting Baklava design system tokens. Use the Vue preset, pass your own preset object, or override specific colors, border radius, size/spacing, typography, and z-index.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
### Vue Preset
|
|
8
|
+
|
|
9
|
+
Apply Vue.js brand colors (Mint #41B883, Police Blue #34495E) to Baklava components:
|
|
10
|
+
|
|
11
|
+
```vue
|
|
12
|
+
<script setup>
|
|
13
|
+
import { useBaklavaTheme } from "@baklavue/composables";
|
|
14
|
+
|
|
15
|
+
useBaklavaTheme().applyTheme({ preset: "vue" });
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<BvButton variant="primary">Primary Button</BvButton>
|
|
20
|
+
</template>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Custom Preset
|
|
24
|
+
|
|
25
|
+
Pass your own preset object mapping CSS variable names to values:
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<script setup>
|
|
29
|
+
import { useBaklavaTheme } from "@baklavue/composables";
|
|
30
|
+
|
|
31
|
+
useBaklavaTheme().applyTheme({
|
|
32
|
+
preset: {
|
|
33
|
+
"--bl-color-primary": "#ea4c89",
|
|
34
|
+
"--bl-color-primary-highlight": "#d6427a",
|
|
35
|
+
"--bl-color-primary-contrast": "#fce8ee",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Custom Colors
|
|
42
|
+
|
|
43
|
+
Override specific Baklava color tokens:
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<script setup>
|
|
47
|
+
import { useBaklavaTheme } from "@baklavue/composables";
|
|
48
|
+
|
|
49
|
+
useBaklavaTheme().applyTheme({
|
|
50
|
+
colors: {
|
|
51
|
+
primary: "#41B883",
|
|
52
|
+
primaryHighlight: "#3aa876",
|
|
53
|
+
primaryContrast: "#e7f9ef",
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Border Radius
|
|
60
|
+
|
|
61
|
+
Override border radius tokens:
|
|
62
|
+
|
|
63
|
+
```vue
|
|
64
|
+
<script setup>
|
|
65
|
+
import { useBaklavaTheme } from "@baklavue/composables";
|
|
66
|
+
|
|
67
|
+
useBaklavaTheme().applyTheme({
|
|
68
|
+
borderRadius: {
|
|
69
|
+
s: "0.5rem",
|
|
70
|
+
m: "0.75rem",
|
|
71
|
+
l: "1rem",
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
</script>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Size & Spacing
|
|
78
|
+
|
|
79
|
+
Override size and spacing tokens:
|
|
80
|
+
|
|
81
|
+
```vue
|
|
82
|
+
<script setup>
|
|
83
|
+
import { useBaklavaTheme } from "@baklavue/composables";
|
|
84
|
+
|
|
85
|
+
useBaklavaTheme().applyTheme({
|
|
86
|
+
size: {
|
|
87
|
+
s: "0.875rem",
|
|
88
|
+
m: "1rem",
|
|
89
|
+
l: "1.25rem",
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
</script>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Typography
|
|
96
|
+
|
|
97
|
+
Override typography tokens:
|
|
98
|
+
|
|
99
|
+
```vue
|
|
100
|
+
<script setup>
|
|
101
|
+
import { useBaklavaTheme } from "@baklavue/composables";
|
|
102
|
+
|
|
103
|
+
useBaklavaTheme().applyTheme({
|
|
104
|
+
typography: {
|
|
105
|
+
fontFamily: "'Inter', sans-serif",
|
|
106
|
+
fontSize: { s: "0.75rem", m: "0.875rem", l: "1rem" },
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
</script>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### With VitePress or App Setup
|
|
113
|
+
|
|
114
|
+
Call `applyTheme` when your app mounts (e.g. in `main.ts` or VitePress `enhanceApp`):
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { createApp } from "vue";
|
|
118
|
+
import App from "./App.vue";
|
|
119
|
+
import { useBaklavaTheme } from "@baklavue/composables";
|
|
120
|
+
|
|
121
|
+
const app = createApp(App);
|
|
122
|
+
useBaklavaTheme().applyTheme({ preset: "vue" });
|
|
123
|
+
app.mount("#app");
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## API
|
|
127
|
+
|
|
128
|
+
### applyTheme
|
|
129
|
+
|
|
130
|
+
Applies theme overrides by injecting CSS variables into the document.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
applyTheme(options?: ApplyThemeOptions): void
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### ApplyThemeOptions
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
interface ApplyThemeOptions {
|
|
140
|
+
preset?: "vue" | "default" | BaklavaThemePresetRecord;
|
|
141
|
+
colors?: Partial<BaklavaThemeColors>;
|
|
142
|
+
borderRadius?: Partial<BaklavaThemeBorderRadius>;
|
|
143
|
+
size?: Partial<BaklavaThemeSize>;
|
|
144
|
+
typography?: Partial<BaklavaThemeTypography>;
|
|
145
|
+
zIndex?: Partial<BaklavaThemeZIndex>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Custom preset: map of CSS variable names to values
|
|
149
|
+
type BaklavaThemePresetRecord = Record<string, string>;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### BaklavaThemeColors
|
|
153
|
+
|
|
154
|
+
Custom color keys map to Baklava's `--bl-color-*` CSS variables:
|
|
155
|
+
|
|
156
|
+
| Key | Baklava Variable |
|
|
157
|
+
| ------------------------------------------------------ | ------------------------------ |
|
|
158
|
+
| `primary` | `--bl-color-primary` |
|
|
159
|
+
| `primaryHighlight` | `--bl-color-primary-highlight` |
|
|
160
|
+
| `primaryContrast` | `--bl-color-primary-contrast` |
|
|
161
|
+
| `success`, `successHighlight`, `successContrast` | `--bl-color-success-*` |
|
|
162
|
+
| `danger`, `warning`, `info` | `--bl-color-{semantic}-*` |
|
|
163
|
+
| `neutralDarkest`, `neutralDarker`, `neutralDark`, etc. | `--bl-color-neutral-*` |
|
|
164
|
+
|
|
165
|
+
### BaklavaThemeBorderRadius
|
|
166
|
+
|
|
167
|
+
| Key | Baklava Variable |
|
|
168
|
+
| -------- | --------------------------- |
|
|
169
|
+
| `xs` | `--bl-border-radius-xs` |
|
|
170
|
+
| `s` | `--bl-border-radius-s` |
|
|
171
|
+
| `m` | `--bl-border-radius-m` |
|
|
172
|
+
| `l` | `--bl-border-radius-l` |
|
|
173
|
+
| `pill` | `--bl-border-radius-pill` |
|
|
174
|
+
| `circle` | `--bl-border-radius-circle` |
|
|
175
|
+
|
|
176
|
+
### BaklavaThemeSize
|
|
177
|
+
|
|
178
|
+
| Key | Baklava Variable |
|
|
179
|
+
| ----------- | --------------------------------------- |
|
|
180
|
+
| `4xs`–`6xl` | `--bl-size-4xs` through `--bl-size-6xl` |
|
|
181
|
+
|
|
182
|
+
### BaklavaThemeTypography
|
|
183
|
+
|
|
184
|
+
| Key | Baklava Variable |
|
|
185
|
+
| ------------ | ------------------------ |
|
|
186
|
+
| `fontFamily` | `--bl-font-family` |
|
|
187
|
+
| `fontSize` | `--bl-font-size-{key}` |
|
|
188
|
+
| `fontWeight` | `--bl-font-weight-{key}` |
|
|
189
|
+
|
|
190
|
+
### BaklavaThemeZIndex
|
|
191
|
+
|
|
192
|
+
| Key | Baklava Variable |
|
|
193
|
+
| -------------- | ------------------------- |
|
|
194
|
+
| `deep` | `--bl-index-deep` |
|
|
195
|
+
| `base` | `--bl-index-base` |
|
|
196
|
+
| `popover` | `--bl-index-popover` |
|
|
197
|
+
| `tooltip` | `--bl-index-tooltip` |
|
|
198
|
+
| `sticky` | `--bl-index-sticky` |
|
|
199
|
+
| `overlay` | `--bl-index-overlay` |
|
|
200
|
+
| `dialog` | `--bl-index-dialog` |
|
|
201
|
+
| `notification` | `--bl-index-notification` |
|
|
202
|
+
|
|
203
|
+
## Vue Preset Colors
|
|
204
|
+
|
|
205
|
+
The `vue` preset applies:
|
|
206
|
+
|
|
207
|
+
- **Primary**: #41B883 (Vue Mint)
|
|
208
|
+
- **Primary Highlight**: #3aa876 (darker mint)
|
|
209
|
+
- **Primary Contrast**: #e7f9ef (light mint background)
|
|
210
|
+
- **Success**: Same as primary (Vue green)
|
|
211
|
+
- **Neutral Darker**: #34495E (Police Blue)
|
|
212
|
+
- **Neutral Darkest**: #2c3e50
|
|
213
|
+
|
|
214
|
+
## Design Tokens Reference
|
|
215
|
+
|
|
216
|
+
For a full reference of all Baklava design tokens with live preview examples, see [Design Tokens](/guide/design-tokens).
|
|
217
|
+
|
|
218
|
+
## TypeScript Support
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
import {
|
|
222
|
+
useBaklavaTheme,
|
|
223
|
+
type ApplyThemeOptions,
|
|
224
|
+
type BaklavaThemeBorderRadius,
|
|
225
|
+
type BaklavaThemeColors,
|
|
226
|
+
type BaklavaThemePreset,
|
|
227
|
+
type BaklavaThemePresetRecord,
|
|
228
|
+
type BaklavaThemeSize,
|
|
229
|
+
type BaklavaThemeTypography,
|
|
230
|
+
type BaklavaThemeZIndex,
|
|
231
|
+
} from "@baklavue/composables";
|
|
232
|
+
|
|
233
|
+
const { applyTheme } = useBaklavaTheme();
|
|
234
|
+
|
|
235
|
+
// Built-in preset
|
|
236
|
+
applyTheme({ preset: "vue" });
|
|
237
|
+
|
|
238
|
+
// Custom preset
|
|
239
|
+
applyTheme({
|
|
240
|
+
preset: {
|
|
241
|
+
"--bl-color-primary": "#ea4c89",
|
|
242
|
+
"--bl-color-primary-highlight": "#d6427a",
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// Full customization
|
|
247
|
+
applyTheme({
|
|
248
|
+
colors: { primary: "#41B883" },
|
|
249
|
+
borderRadius: { m: "0.5rem" },
|
|
250
|
+
size: { m: "1rem" },
|
|
251
|
+
});
|
|
252
|
+
```
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# useThemePreset
|
|
2
|
+
|
|
3
|
+
A composable to persist and apply Baklava theme preset across sessions. Combines `useBaklavaTheme` and `useLocalStorage`. Re-applies theme when preset changes.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<BvSelect v-model="preset" :options="presetOptions" />
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import { BvSelect } from "@baklavue/ui";
|
|
14
|
+
import { useThemePreset } from "@baklavue/composables";
|
|
15
|
+
|
|
16
|
+
const { preset, setPreset, applyTheme } = useThemePreset();
|
|
17
|
+
|
|
18
|
+
const presetOptions = [
|
|
19
|
+
{ value: "vue", text: "Vue" },
|
|
20
|
+
{ value: "default", text: "Default" },
|
|
21
|
+
];
|
|
22
|
+
</script>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Options
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<script setup>
|
|
29
|
+
import { useThemePreset } from "@baklavue/composables";
|
|
30
|
+
|
|
31
|
+
const { preset, setPreset, applyTheme } = useThemePreset({
|
|
32
|
+
storageKey: "theme-preset",
|
|
33
|
+
defaultPreset: "vue",
|
|
34
|
+
});
|
|
35
|
+
</script>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
| Option | Type | Default | Description |
|
|
39
|
+
| --- | --- | --- | --- |
|
|
40
|
+
| `storageKey` | `string` | `"theme-preset"` | localStorage key |
|
|
41
|
+
| `defaultPreset` | `"vue" \| "default"` | `"vue"` | Default when no stored value exists |
|
|
42
|
+
|
|
43
|
+
## API
|
|
44
|
+
|
|
45
|
+
### Return Value
|
|
46
|
+
|
|
47
|
+
| Property | Type | Description |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `preset` | `Ref<BaklavaThemePreset>` | Current preset (persisted) |
|
|
50
|
+
| `setPreset` | `(value: BaklavaThemePreset) => void` | Set preset and re-apply |
|
|
51
|
+
| `applyTheme` | `() => void` | Manually re-apply current preset |
|
|
52
|
+
|
|
53
|
+
## TypeScript Support
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import {
|
|
57
|
+
useThemePreset,
|
|
58
|
+
type UseThemePresetOptions,
|
|
59
|
+
} from "@baklavue/composables";
|
|
60
|
+
|
|
61
|
+
const { preset, setPreset } = useThemePreset({ defaultPreset: "default" });
|
|
62
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# useThrottleFn / useThrottledRef
|
|
2
|
+
|
|
3
|
+
Throttle function execution or ref value. Useful for scroll, resize, and mousemove handlers.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
### useThrottleFn
|
|
8
|
+
|
|
9
|
+
Returns a throttled version of a function. The function is called at most once per specified interval.
|
|
10
|
+
|
|
11
|
+
```vue
|
|
12
|
+
<script setup>
|
|
13
|
+
import { onMounted, onUnmounted } from "vue";
|
|
14
|
+
import { useThrottleFn } from "@baklavue/composables";
|
|
15
|
+
|
|
16
|
+
const throttledScroll = useThrottleFn(() => {
|
|
17
|
+
updateScrollPosition();
|
|
18
|
+
}, 100);
|
|
19
|
+
|
|
20
|
+
onMounted(() => {
|
|
21
|
+
window.addEventListener("scroll", throttledScroll);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
onUnmounted(() => {
|
|
25
|
+
window.removeEventListener("scroll", throttledScroll);
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### useThrottledRef
|
|
31
|
+
|
|
32
|
+
Returns a ref that updates at most once per specified interval.
|
|
33
|
+
|
|
34
|
+
```vue
|
|
35
|
+
<script setup>
|
|
36
|
+
import { ref, onMounted } from "vue";
|
|
37
|
+
import { useThrottledRef } from "@baklavue/composables";
|
|
38
|
+
|
|
39
|
+
const scrollY = ref(0);
|
|
40
|
+
const throttledScrollY = useThrottledRef(scrollY, 100);
|
|
41
|
+
|
|
42
|
+
onMounted(() => {
|
|
43
|
+
window.addEventListener("scroll", () => {
|
|
44
|
+
scrollY.value = window.scrollY;
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
### useThrottleFn
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
useThrottleFn<T>(
|
|
56
|
+
fn: T,
|
|
57
|
+
delay?: number,
|
|
58
|
+
options?: { leading?: boolean; trailing?: boolean }
|
|
59
|
+
): (...args: Parameters<T>) => void
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- `fn` — Function to throttle
|
|
63
|
+
- `delay` — Minimum interval in milliseconds. Default: 200
|
|
64
|
+
- `options.leading` — Call on leading edge. Default: true
|
|
65
|
+
- `options.trailing` — Call on trailing edge. Default: true
|
|
66
|
+
- Returns a throttled function
|
|
67
|
+
|
|
68
|
+
### useThrottledRef
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
useThrottledRef<T>(value: Ref<T>, delay?: number): Ref<T>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- `value` — Ref to throttle
|
|
75
|
+
- `delay` — Minimum interval in milliseconds. Default: 200
|
|
76
|
+
- Returns a ref with throttled value
|