@hkdigital/lib-core 0.3.11 → 0.3.13
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 +173 -149
- package/dist/assets/autospuiten/car-paint-picker.js +41 -41
- package/dist/assets/autospuiten/labels.js +7 -7
- package/dist/classes/data/IterableTree.js +242 -242
- package/dist/classes/data/Selector.js +190 -190
- package/dist/classes/data/index.js +2 -2
- package/dist/classes/data/typedef.js +9 -9
- package/dist/classes/event-emitter/EventEmitter.js +273 -273
- package/dist/classes/event-emitter/index.js +2 -2
- package/dist/classes/index.js +4 -4
- package/dist/classes/promise/HkPromise.js +384 -384
- package/dist/classes/promise/index.js +1 -1
- package/dist/classes/stores/SubscribersCount.js +107 -107
- package/dist/classes/stores/index.js +1 -1
- package/dist/classes/streams/LogTransformStream.js +19 -19
- package/dist/classes/streams/ServerEventsStore.js +111 -111
- package/dist/classes/streams/TimeStampSource.js +26 -26
- package/dist/classes/streams/index.js +3 -3
- package/dist/classes/svelte/finite-state-machine/FiniteStateMachine.svelte.js +133 -133
- package/dist/classes/svelte/finite-state-machine/index.js +1 -1
- package/dist/classes/svelte/index.js +1 -11
- package/dist/classes/svelte/loading-state-machine/LoadingStateMachine.svelte.js +109 -109
- package/dist/classes/svelte/loading-state-machine/constants.js +16 -16
- package/dist/classes/svelte/loading-state-machine/index.js +3 -3
- package/dist/config/README.md +197 -196
- package/dist/config/generators/imagetools.js +189 -189
- package/dist/config/generators/vite.js +148 -142
- package/dist/config/imagetools.d.ts +72 -72
- package/dist/config/vite.js +4 -4
- package/dist/constants/bases/index.js +13 -13
- package/dist/constants/http/headers.js +6 -6
- package/dist/constants/http/index.js +2 -2
- package/dist/constants/http/methods.js +14 -14
- package/dist/constants/index.js +6 -6
- package/dist/constants/mime/application.js +5 -5
- package/dist/constants/mime/audio.js +13 -13
- package/dist/constants/mime/image.js +3 -3
- package/dist/constants/mime/index.js +4 -4
- package/dist/constants/mime/text.js +2 -2
- package/dist/constants/regexp/README.md +96 -95
- package/dist/constants/regexp/index.js +31 -31
- package/dist/constants/regexp/inspiratie.js__ +95 -95
- package/dist/constants/regexp/text.d.ts +4 -4
- package/dist/constants/regexp/text.js +49 -49
- package/dist/constants/regexp/url.js +3 -3
- package/dist/constants/regexp/user.js +29 -29
- package/dist/constants/states/drag.js +6 -6
- package/dist/constants/states/drop.js +6 -6
- package/dist/constants/states/index.js +4 -4
- package/dist/constants/states/input.js +11 -11
- package/dist/constants/states/submit.js +4 -4
- package/dist/constants/time/index.js +28 -28
- package/dist/css/utilities.css +43 -43
- package/dist/design/README.md +405 -405
- package/dist/design/config/design-config.js +73 -73
- package/dist/design/generators/index.js +288 -288
- package/dist/design/index.js +96 -96
- package/dist/design/plugins/skeleton.js +208 -208
- package/dist/design/tailwind-theme-extend.js +158 -158
- package/dist/design/themes/README.md +102 -102
- package/dist/design/themes/hkdev/components/blocks/text-block.css +34 -34
- package/dist/design/themes/hkdev/components/boxes/game-box.css +11 -11
- package/dist/design/themes/hkdev/components/buttons/button-icon-steeze.css +22 -22
- package/dist/design/themes/hkdev/components/buttons/button-text.css +32 -32
- package/dist/design/themes/hkdev/components/buttons/button.css +146 -146
- package/dist/design/themes/hkdev/components/buttons/skip-button.css +5 -5
- package/dist/design/themes/hkdev/components/drag-drop/draggable.css +73 -73
- package/dist/design/themes/hkdev/components/drag-drop/drop-zone.css +58 -58
- package/dist/design/themes/hkdev/components/icons/icon-steeze.css +15 -15
- package/dist/design/themes/hkdev/components/inputs/text-input.css +102 -102
- package/dist/design/themes/hkdev/components/panels/panel.css +25 -25
- package/dist/design/themes/hkdev/components/rows/panel-grid-row.css +4 -4
- package/dist/design/themes/hkdev/components/rows/panel-row-2.css +5 -5
- package/dist/design/themes/hkdev/components.css +29 -29
- package/dist/design/themes/hkdev/debug.css +1 -1
- package/dist/design/themes/hkdev/global/layout.css +32 -32
- package/dist/design/themes/hkdev/global/on-colors.css +32 -32
- package/dist/design/themes/hkdev/globals.css +3 -3
- package/dist/design/themes/hkdev/responsive.css +12 -12
- package/dist/design/themes/hkdev/theme-ext.js +12 -12
- package/dist/design/themes/hkdev/theme.css +218 -218
- package/dist/design/utils/clamp.js +66 -66
- package/dist/design/utils/root-vars.js +102 -102
- package/dist/design/utils/scaling.js +228 -228
- package/dist/design/utils/states.js +22 -22
- package/dist/errors/api.js +9 -9
- package/dist/errors/generic.js +20 -20
- package/dist/errors/http.js +16 -16
- package/dist/errors/index.js +5 -5
- package/dist/errors/jwt.js +5 -5
- package/dist/errors/promise.js +25 -25
- package/dist/logging/README.md +158 -0
- package/dist/logging/index.d.ts +3 -1
- package/dist/logging/index.js +11 -7
- package/dist/logging/internal/adapters/console.js +114 -114
- package/dist/logging/internal/adapters/index.js +2 -2
- package/dist/logging/internal/adapters/pino.js +160 -142
- package/dist/logging/internal/adapters/typedef.js +10 -10
- package/dist/logging/internal/{unified-logger/constants.js → constants.js} +22 -22
- package/dist/logging/internal/factories/client.d.ts +1 -1
- package/dist/logging/internal/factories/client.js +21 -21
- package/dist/logging/internal/factories/server.d.ts +1 -1
- package/dist/logging/internal/factories/server.js +22 -22
- package/dist/logging/internal/factories/universal.d.ts +2 -2
- package/dist/logging/internal/factories/universal.js +22 -22
- package/dist/logging/internal/{unified-logger → logger}/Logger.d.ts +2 -2
- package/dist/logging/internal/{unified-logger → logger}/Logger.js +217 -217
- package/dist/logging/internal/logger/index.d.ts +1 -0
- package/dist/logging/internal/logger/index.js +1 -0
- package/dist/logging/internal/{unified-logger/typedef.d.ts → typedef.d.ts} +2 -1
- package/dist/logging/internal/{unified-logger/typedef.js → typedef.js} +21 -17
- package/dist/network/README.md +172 -172
- package/dist/network/cache/IndexedDbCache.js +1407 -1407
- package/dist/network/cache/MemoryResponseCache.js +138 -138
- package/dist/network/cache/index.js +5 -5
- package/dist/network/cache/typedef.js +41 -41
- package/dist/network/cache.js +3 -3
- package/dist/network/http/caching.js +261 -261
- package/dist/network/http/errors.js +97 -97
- package/dist/network/http/headers.js +75 -75
- package/dist/network/http/http-request.js +578 -578
- package/dist/network/http/index.js +22 -22
- package/dist/network/http/json-request.js +224 -224
- package/dist/network/http/mocks.js +65 -65
- package/dist/network/http/response.js +318 -318
- package/dist/network/http/test-data__/content-length-test-hkdigital-small.V4HfZyBQ.avif +0 -0
- package/dist/network/http/typedef.js +93 -93
- package/dist/network/http/url.js +52 -52
- package/dist/network/http.js +5 -5
- package/dist/network/loaders/README.md +254 -254
- package/dist/network/loaders/audio/AudioLoader.svelte.js +58 -58
- package/dist/network/loaders/audio/AudioScene.svelte.js +324 -324
- package/dist/network/loaders/audio/mocks.js +35 -35
- package/dist/network/loaders/audio.js +1 -1
- package/dist/network/loaders/image/ImageLoader.svelte.js +44 -44
- package/dist/network/loaders/image/ImageScene.svelte.js +248 -248
- package/dist/network/loaders/image/ImageVariantsLoader.svelte.js +150 -150
- package/dist/network/loaders/image/index.js +4 -4
- package/dist/network/loaders/image/mocks.js +35 -35
- package/dist/network/loaders/image/typedef.js +8 -8
- package/dist/network/loaders/image/utils/index.js +86 -86
- package/dist/network/loaders/image.js +7 -7
- package/dist/network/loaders/typedef.js +38 -38
- package/dist/network/loaders.js +2 -2
- package/dist/network/states/NetworkLoader.svelte.js +338 -338
- package/dist/network/states/constants.js +3 -3
- package/dist/network/states/index.js +3 -3
- package/dist/network/states/mocks.js +30 -30
- package/dist/network/states/typedef.js +8 -8
- package/dist/network/typedef.js +9 -9
- package/dist/services/README.md +200 -0
- package/dist/services/index.d.ts +6 -1
- package/dist/services/index.js +8 -1
- package/dist/services/{internal/service-base → service-base}/ServiceBase.d.ts +2 -2
- package/dist/services/{internal/service-base → service-base}/ServiceBase.js +462 -462
- package/dist/services/{internal/service-base → service-base}/constants.d.ts +0 -12
- package/dist/services/{internal/service-base → service-base}/constants.js +98 -110
- package/dist/services/{internal/service-base → service-base}/index.js +3 -3
- package/dist/services/{internal/service-base → service-base}/typedef.d.ts +1 -1
- package/dist/services/{internal/service-base → service-base}/typedef.js +101 -101
- package/dist/services/{internal/service-manager → service-manager}/ServiceManager.d.ts +2 -2
- package/dist/services/{internal/service-manager → service-manager}/ServiceManager.js +608 -608
- package/dist/services/{internal/service-manager → service-manager}/constants.js +6 -6
- package/dist/services/{internal/service-manager → service-manager}/typedef.js +90 -90
- package/dist/states/index.js +1 -1
- package/dist/states/navigation.svelte.js +55 -55
- package/dist/stores/index.js +1 -1
- package/dist/stores/theme.js +80 -80
- package/dist/typedef/context.js +6 -6
- package/dist/typedef/drag.js +25 -25
- package/dist/typedef/drop.js +12 -12
- package/dist/typedef/index.d.ts +1 -0
- package/dist/typedef/index.js +4 -4
- package/dist/ui/components/button-group/ButtonGroup.svelte +82 -82
- package/dist/ui/components/button-group/typedef.js +10 -10
- package/dist/ui/components/compare-left-right/CompareLeftRight.svelte +179 -179
- package/dist/ui/components/compare-left-right/index.js +1 -1
- package/dist/ui/components/game-box/GameBox.svelte +577 -577
- package/dist/ui/components/game-box/gamebox.util.js +83 -83
- package/dist/ui/components/hk-app-layout/HkAppLayout.state.svelte.js +25 -25
- package/dist/ui/components/hk-app-layout/HkAppLayout.svelte +251 -251
- package/dist/ui/components/image-box/ImageBox.svelte +210 -210
- package/dist/ui/components/image-box/index.js +5 -5
- package/dist/ui/components/image-box/typedef.js +32 -32
- package/dist/ui/components/index.js +23 -23
- package/dist/ui/components/presenter/ImageSlide.svelte +64 -64
- package/dist/ui/components/presenter/Presenter.state.svelte.js +638 -638
- package/dist/ui/components/presenter/Presenter.svelte +142 -142
- package/dist/ui/components/presenter/constants.js +7 -7
- package/dist/ui/components/presenter/index.js +10 -10
- package/dist/ui/components/presenter/typedef.js +106 -106
- package/dist/ui/components/presenter/util.js +210 -210
- package/dist/ui/components/virtual-viewport/VirtualViewport.svelte +196 -196
- package/dist/ui/primitives/area/HkArea.svelte +49 -49
- package/dist/ui/primitives/area/HkGridArea.svelte +77 -77
- package/dist/ui/primitives/area/index.js +2 -2
- package/dist/ui/primitives/buttons/button/Button.svelte +82 -82
- package/dist/ui/primitives/buttons/button-icon-steeze/SteezeIconButton.svelte +30 -30
- package/dist/ui/primitives/buttons/button-text/TextButton.svelte +21 -21
- package/dist/ui/primitives/buttons/index.js +3 -3
- package/dist/ui/primitives/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte +146 -146
- package/dist/ui/primitives/debug/index.js +1 -1
- package/dist/ui/primitives/drag-drop/DragController.js +44 -44
- package/dist/ui/primitives/drag-drop/DragDropContext.svelte +111 -111
- package/dist/ui/primitives/drag-drop/Draggable.svelte +519 -519
- package/dist/ui/primitives/drag-drop/DropZone.svelte +258 -258
- package/dist/ui/primitives/drag-drop/DropZoneArea.svelte +119 -119
- package/dist/ui/primitives/drag-drop/DropZoneList.svelte +125 -125
- package/dist/ui/primitives/drag-drop/actions.js +26 -26
- package/dist/ui/primitives/drag-drop/drag-state.svelte.js +322 -322
- package/dist/ui/primitives/drag-drop/index.js +7 -7
- package/dist/ui/primitives/drag-drop/util.js +85 -85
- package/dist/ui/primitives/hkdev/blocks/TextBlock.svelte +46 -46
- package/dist/ui/primitives/hkdev/buttons/CheckButton.svelte +62 -62
- package/dist/ui/primitives/icons/HkIcon.svelte +86 -86
- package/dist/ui/primitives/icons/HkTabIcon.svelte +116 -116
- package/dist/ui/primitives/icons/SteezeIcon.svelte +97 -97
- package/dist/ui/primitives/icons/index.js +6 -6
- package/dist/ui/primitives/icons/typedef.js +16 -16
- package/dist/ui/primitives/index.js +2 -2
- package/dist/ui/primitives/inputs/index.js +1 -1
- package/dist/ui/primitives/inputs/text-input/TestTextInput.svelte__ +102 -0
- package/dist/ui/primitives/inputs/text-input/TextInput.svelte +223 -223
- package/dist/ui/primitives/inputs/text-input/TextInput.svelte___ +83 -0
- package/dist/ui/primitives/inputs/text-input/assets/IconInvalid.svelte +14 -14
- package/dist/ui/primitives/inputs/text-input/assets/IconValid.svelte +12 -12
- package/dist/ui/primitives/layout/grid-layers/GridLayers.svelte +63 -63
- package/dist/ui/primitives/layout/grid-layers/GridLayers.svelte__heightFrom__ +372 -0
- package/dist/ui/primitives/layout/grid-layers/util.js +74 -74
- package/dist/ui/primitives/layout/index.js +1 -1
- package/dist/ui/primitives/panels/index.js +1 -1
- package/dist/ui/primitives/panels/panel/Panel.svelte +43 -43
- package/dist/ui/primitives/rows/index.js +3 -3
- package/dist/ui/primitives/rows/panel-grid-row/PanelGridRow.svelte +104 -104
- package/dist/ui/primitives/rows/panel-row-2/PanelRow2.svelte +40 -40
- package/dist/ui/primitives/tab-bar/HkTabBar.state.svelte.js +149 -149
- package/dist/ui/primitives/tab-bar/HkTabBar.svelte +74 -74
- package/dist/ui/primitives/tab-bar/HkTabBarSelector.state.svelte.js +93 -93
- package/dist/ui/primitives/tab-bar/HkTabBarSelector.svelte +49 -49
- package/dist/ui/primitives/tab-bar/index.js +17 -17
- package/dist/ui/primitives/tab-bar/typedef.js +11 -11
- package/dist/util/array/index.js +436 -436
- package/dist/util/bases/base58.js +262 -262
- package/dist/util/bases/index.js +1 -1
- package/dist/util/compare/index.js +247 -247
- package/dist/util/css/css-vars.js +83 -83
- package/dist/util/css/index.js +1 -1
- package/dist/util/env/index.js +9 -9
- package/dist/util/exceptions/index.d.ts +4 -3
- package/dist/util/exceptions/index.js +26 -23
- package/dist/util/expect/arrays.js +47 -47
- package/dist/util/expect/index.js +259 -259
- package/dist/util/expect/primitives.js +55 -55
- package/dist/util/expect/url.js +60 -60
- package/dist/util/function/index.js +218 -218
- package/dist/util/geo/index.js +26 -26
- package/dist/util/index.js +7 -7
- package/dist/util/is/index.js +147 -147
- package/dist/util/iterate/index.js +204 -204
- package/dist/util/object/index.js +1345 -1345
- package/dist/util/singleton/index.js +97 -97
- package/dist/util/string/array-path.js +75 -75
- package/dist/util/string/convert.js +54 -54
- package/dist/util/string/fs.js +226 -226
- package/dist/util/string/index.js +5 -5
- package/dist/util/string/interpolate.js +61 -61
- package/dist/util/string/pad.js +10 -10
- package/dist/util/svelte/index.js +4 -4
- package/dist/util/svelte/loading/loading-tracker.svelte.js +108 -108
- package/dist/util/svelte/observe/index.js +49 -49
- package/dist/util/svelte/state-context/index.js +117 -117
- package/dist/util/svelte/wait/index.js +38 -38
- package/dist/util/sveltekit/index.js +1 -1
- package/dist/util/sveltekit/route-folders/index.js +101 -101
- package/dist/util/time/index.js +328 -328
- package/dist/util/unique/index.js +231 -231
- package/dist/valibot/README.md +61 -50
- package/dist/valibot/index.js +8 -8
- package/dist/valibot/parsers/date.js__ +10 -0
- package/dist/valibot/parsers/email.d.ts +12 -0
- package/dist/valibot/parsers/email.js +34 -0
- package/dist/valibot/parsers/url.js +110 -110
- package/dist/valibot/parsers/user.js +23 -23
- package/dist/valibot/parsers.js +3 -3
- package/package.json +131 -131
- package/dist/logging/internal/unified-logger/index.d.ts +0 -3
- package/dist/logging/internal/unified-logger/index.js +0 -6
- package/dist/services/internal/index.d.ts +0 -6
- package/dist/services/internal/index.js +0 -8
- /package/dist/logging/internal/{unified-logger/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/services/{internal/service-base → service-base}/index.d.ts +0 -0
- /package/dist/services/{internal/service-manager → service-manager}/constants.d.ts +0 -0
- /package/dist/services/{internal/service-manager → service-manager}/typedef.d.ts +0 -0
package/dist/design/README.md
CHANGED
|
@@ -1,405 +1,405 @@
|
|
|
1
|
-
# HKdigital Design System
|
|
2
|
-
|
|
3
|
-
A comprehensive, responsive design system built for SvelteKit applications. This system provides consistent scaling, typography, spacing, and theming across all screen sizes using CSS custom properties and Tailwind CSS.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
### Basic Usage
|
|
8
|
-
|
|
9
|
-
```javascript
|
|
10
|
-
// tailwind.config.js
|
|
11
|
-
import {
|
|
12
|
-
spacing,
|
|
13
|
-
fontSize,
|
|
14
|
-
borderRadius,
|
|
15
|
-
customUtilitiesPlugin
|
|
16
|
-
} from '@hkdigital/lib-core/design/index.js';
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
theme: {
|
|
20
|
-
extend: {
|
|
21
|
-
spacing,
|
|
22
|
-
fontSize,
|
|
23
|
-
borderRadius
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
plugins: [
|
|
27
|
-
customUtilitiesPlugin
|
|
28
|
-
]
|
|
29
|
-
};
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
```svelte
|
|
33
|
-
<!-- +layout.svelte -->
|
|
34
|
-
<script>
|
|
35
|
-
import { DESIGN, CLAMPING, rootDesignVarsHTML } from '@hkdigital/lib-core/design';
|
|
36
|
-
</script>
|
|
37
|
-
|
|
38
|
-
<svelte:head>
|
|
39
|
-
{@html rootDesignVarsHTML(DESIGN, CLAMPING)}
|
|
40
|
-
</svelte:head>
|
|
41
|
-
|
|
42
|
-
{@render children()}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Core Concepts
|
|
46
|
-
|
|
47
|
-
### Responsive Scaling System
|
|
48
|
-
|
|
49
|
-
The design system is built around a **1024×768 design reference** that automatically scales to any screen size with sensible minimum and maximum bounds.
|
|
50
|
-
|
|
51
|
-
#### CSS Variables Created:
|
|
52
|
-
- `--scale-ui`: Clamped UI scaling (0.3× to 2×)
|
|
53
|
-
- `--scale-text-base`: Base text scaling (0.75× to 1.5×)
|
|
54
|
-
- `--scale-text-heading`: Heading text scaling (0.75× to 2.25×)
|
|
55
|
-
- `--scale-text-ui`: UI text scaling (0.5× to 1.25×)
|
|
56
|
-
|
|
57
|
-
## Spacing Classes
|
|
58
|
-
|
|
59
|
-
### UI Points
|
|
60
|
-
**Primary method for UI element spacing:**
|
|
61
|
-
|
|
62
|
-
```html
|
|
63
|
-
<div class="p-20up m-10up">
|
|
64
|
-
<!-- 20px padding, 10px margin at design size -->
|
|
65
|
-
<!-- Automatically scales with viewport -->
|
|
66
|
-
</div>
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Available: `1up`, `2up`, `4up`, `5up`, `6up`, `10up`, `20up`, `30up`, `40up`, `50up`, `60up`, `70up`, `80up`, `90up`, `100up`, `120up`, `140up`, `160up`, `180up`, `200up`
|
|
70
|
-
|
|
71
|
-
### Text-Based Spacing
|
|
72
|
-
**For spacing relative to text size:**
|
|
73
|
-
|
|
74
|
-
```html
|
|
75
|
-
<div class="mb-16bt"> <!-- Base text spacing -->
|
|
76
|
-
<div class="p-12ut"> <!-- UI text spacing -->
|
|
77
|
-
<div class="mt-24ht"> <!-- Heading text spacing -->
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Available for all text point sizes: `1ut/bt/ht`, `2ut/bt/ht`, `4ut/bt/ht`, `6ut/bt/ht`, `8ut/bt/ht`, `10ut/bt/ht`, `11ut/bt/ht`, `12ut/bt/ht`, `16ut/bt/ht`, `20ut/bt/ht`, `24ut/bt/ht`, `28ut/bt/ht`, `32ut/bt/ht`, `36ut/bt/ht`, `50ut/bt/ht`
|
|
81
|
-
|
|
82
|
-
### Alternative Viewport Units
|
|
83
|
-
```html
|
|
84
|
-
<div class="w-100wp h-50hp"> <!-- Width/height points -->
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Typography Classes
|
|
88
|
-
|
|
89
|
-
### Complete Typography Styles
|
|
90
|
-
**Use `type-` classes for complete text styling:**
|
|
91
|
-
|
|
92
|
-
```html
|
|
93
|
-
<h1 class="type-heading-h1">Main Title</h1>
|
|
94
|
-
<h2 class="type-heading-h2">Section Title</h2>
|
|
95
|
-
<h3 class="type-heading-h3">Subsection</h3>
|
|
96
|
-
<p class="type-base-md">Body paragraph text</p>
|
|
97
|
-
<span class="type-ui-sm">Interface text</span>
|
|
98
|
-
|
|
99
|
-
<!-- Dark mode variants -->
|
|
100
|
-
<h1 class="type-heading-h1-dark">Dark mode title</h1>
|
|
101
|
-
<p class="type-base-md-dark">Dark mode paragraph</p>
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
**Available Typography Classes:**
|
|
105
|
-
- **Headings**: `type-heading-h1`, `type-heading-h2`, `type-heading-h3`, `type-heading-h4`, `type-heading-h5`
|
|
106
|
-
- **Body Text**: `type-base-sm`, `type-base-md`, `type-base-lg`
|
|
107
|
-
- **UI Text**: `type-ui-sm`, `type-ui-md`, `type-ui-lg`
|
|
108
|
-
- **Dark Variants**: Add `-dark` suffix to any class
|
|
109
|
-
|
|
110
|
-
### Font Size Only
|
|
111
|
-
**Use `text-` classes for font size only:**
|
|
112
|
-
|
|
113
|
-
```html
|
|
114
|
-
<p class="text-base-md">16px scaled base text</p>
|
|
115
|
-
<h2 class="text-heading-h2">28px scaled heading</h2>
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## Border & Radius Classes
|
|
119
|
-
|
|
120
|
-
### Border Radius
|
|
121
|
-
```html
|
|
122
|
-
<div class="rounded-xs"> <!-- 5px scaled -->
|
|
123
|
-
<div class="rounded-sm"> <!-- 10px scaled -->
|
|
124
|
-
<div class="rounded-md"> <!-- 25px scaled -->
|
|
125
|
-
<div class="rounded-lg"> <!-- 35px scaled -->
|
|
126
|
-
<div class="rounded-none"> <!-- 0px -->
|
|
127
|
-
<div class="rounded-full"> <!-- 9999px -->
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### Border & Stroke Width
|
|
131
|
-
```html
|
|
132
|
-
<div class="border-width-thin"> <!-- 1px scaled -->
|
|
133
|
-
<div class="border-width-normal"> <!-- 2px scaled -->
|
|
134
|
-
<div class="border-width-thick"> <!-- 4px scaled -->
|
|
135
|
-
|
|
136
|
-
<svg class="stroke-normal"> <!-- 2px scaled stroke -->
|
|
137
|
-
<div class="outline-thick"> <!-- 4px scaled outline -->
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Colors (Theme hkdev)
|
|
141
|
-
|
|
142
|
-
### Brand Colors
|
|
143
|
-
```html
|
|
144
|
-
<div class="bg-primary-500 text-primary-contrast-500">
|
|
145
|
-
<div class="bg-secondary-600 text-secondary-contrast-600">
|
|
146
|
-
<div class="bg-tertiary-400 text-tertiary-contrast-400">
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Surface Colors (Neutrals)
|
|
150
|
-
```html
|
|
151
|
-
<div class="bg-surface-50"> <!-- Lightest -->
|
|
152
|
-
<div class="bg-surface-500"> <!-- Medium -->
|
|
153
|
-
<div class="bg-surface-950"> <!-- Darkest -->
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Status Colors
|
|
157
|
-
```html
|
|
158
|
-
<div class="bg-success-500 text-success-contrast-500">
|
|
159
|
-
<div class="bg-warning-500 text-warning-contrast-500">
|
|
160
|
-
<div class="bg-error-500 text-error-contrast-500">
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
**Auto Contrast**: Each color includes automatic contrast colors for accessibility. Use `text-{color}-contrast-{shade}` for optimal readability.
|
|
164
|
-
|
|
165
|
-
## Component Styling
|
|
166
|
-
|
|
167
|
-
Components use `data-` attributes with CSS custom properties:
|
|
168
|
-
|
|
169
|
-
```html
|
|
170
|
-
<button data-component="button" data-role="primary">
|
|
171
|
-
Primary Button
|
|
172
|
-
</button>
|
|
173
|
-
|
|
174
|
-
<button data-component="button" data-role="secondary">
|
|
175
|
-
Secondary Button
|
|
176
|
-
</button>
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Utility Functions
|
|
180
|
-
|
|
181
|
-
### CSS Variable Utilities
|
|
182
|
-
|
|
183
|
-
```javascript
|
|
184
|
-
import {
|
|
185
|
-
getRootCssDesignWidth,
|
|
186
|
-
getRootCssDesignHeight,
|
|
187
|
-
getAllRootScalingVars
|
|
188
|
-
} from '@hkdigital/lib-core/design';
|
|
189
|
-
|
|
190
|
-
// Get current design dimensions
|
|
191
|
-
const designWidth = getRootCssDesignWidth(); // 1024
|
|
192
|
-
const designHeight = getRootCssDesignHeight(); // 768
|
|
193
|
-
|
|
194
|
-
// Get all current scaling factors
|
|
195
|
-
const scales = getAllRootScalingVars();
|
|
196
|
-
// Returns: { scaleW, scaleH, scaleViewport, scaleUI, scaleTextBase, scaleTextHeading, scaleTextUI }
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### Clamp Utilities
|
|
200
|
-
|
|
201
|
-
```javascript
|
|
202
|
-
import { clamp, getClampParams } from '@hkdigital/lib-core/design';
|
|
203
|
-
|
|
204
|
-
// Mathematical clamp function
|
|
205
|
-
const value = clamp(0.5, 0.3, 2.0); // Returns 0.5 (clamped between 0.5 and 2.0)
|
|
206
|
-
|
|
207
|
-
// Extract clamp parameters from CSS variables
|
|
208
|
-
const params = getClampParams('scale-ui');
|
|
209
|
-
// Returns: { min: 0.3, max: 2.0 }
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### Component State Classes
|
|
213
|
-
|
|
214
|
-
```javascript
|
|
215
|
-
import { toStateClasses } from '@hkdigital/lib-core/design';
|
|
216
|
-
|
|
217
|
-
// Generate state classes from object
|
|
218
|
-
const classes = toStateClasses({
|
|
219
|
-
selected: true,
|
|
220
|
-
loading: false,
|
|
221
|
-
error: true,
|
|
222
|
-
disabled: false
|
|
223
|
-
});
|
|
224
|
-
// Returns: "state-selected state-error"
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
```html
|
|
228
|
-
<!-- Usage in components -->
|
|
229
|
-
<button class={toStateClasses({ selected, disabled, loading })}>
|
|
230
|
-
Button Text
|
|
231
|
-
</button>
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### Responsive Scaling
|
|
235
|
-
|
|
236
|
-
#### Viewport-Based Scaling
|
|
237
|
-
|
|
238
|
-
```javascript
|
|
239
|
-
import { enableScalingUI } from '@hkdigital/lib-core/design';
|
|
240
|
-
|
|
241
|
-
// Enable automatic viewport scaling
|
|
242
|
-
const cleanup = enableScalingUI(DESIGN, CLAMPING);
|
|
243
|
-
|
|
244
|
-
// Call cleanup when component is destroyed
|
|
245
|
-
onDestroy(cleanup);
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
#### Container-Based Scaling
|
|
249
|
-
|
|
250
|
-
```javascript
|
|
251
|
-
import { enableContainerScaling } from '@hkdigital/lib-core/design';
|
|
252
|
-
|
|
253
|
-
let containerElement;
|
|
254
|
-
|
|
255
|
-
// Enable scaling for specific container
|
|
256
|
-
const cleanup = enableContainerScaling({
|
|
257
|
-
container: containerElement,
|
|
258
|
-
design: DESIGN,
|
|
259
|
-
clamping: CLAMPING,
|
|
260
|
-
useResizeObserver: true
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
// Optional custom dimension getter
|
|
264
|
-
const cleanupCustom = enableContainerScaling({
|
|
265
|
-
container: containerElement,
|
|
266
|
-
design: DESIGN,
|
|
267
|
-
clamping: CLAMPING,
|
|
268
|
-
getDimensions: () => ({ width: 800, height: 600 })
|
|
269
|
-
});
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
```svelte
|
|
273
|
-
<!-- Svelte component example -->
|
|
274
|
-
<script>
|
|
275
|
-
import { onMount, onDestroy } from 'svelte';
|
|
276
|
-
import { enableContainerScaling, DESIGN, CLAMPING } from '@hkdigital/lib-core/design';
|
|
277
|
-
|
|
278
|
-
let containerElement;
|
|
279
|
-
let cleanup;
|
|
280
|
-
|
|
281
|
-
onMount(() => {
|
|
282
|
-
cleanup = enableContainerScaling({
|
|
283
|
-
container: containerElement,
|
|
284
|
-
design: DESIGN,
|
|
285
|
-
clamping: CLAMPING
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
onDestroy(() => {
|
|
290
|
-
cleanup?.();
|
|
291
|
-
});
|
|
292
|
-
</script>
|
|
293
|
-
|
|
294
|
-
<div bind:this={containerElement} class="scaled-container">
|
|
295
|
-
<!-- Content that scales with container -->
|
|
296
|
-
<div class="p-20up text-base-md">Responsive content</div>
|
|
297
|
-
</div>
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
## Advanced Usage
|
|
301
|
-
|
|
302
|
-
### Custom Design Configuration
|
|
303
|
-
|
|
304
|
-
```javascript
|
|
305
|
-
// your-project/src/lib/design/design-config.js
|
|
306
|
-
import {
|
|
307
|
-
generateTextBasedSpacing,
|
|
308
|
-
generateTextStyles
|
|
309
|
-
} from '@hkdigital/lib-core/design';
|
|
310
|
-
|
|
311
|
-
// Custom design dimensions
|
|
312
|
-
export const CUSTOM_DESIGN = {
|
|
313
|
-
width: 1440,
|
|
314
|
-
height: 900
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
// Custom text sizes
|
|
318
|
-
export const CUSTOM_TEXT_SIZES = {
|
|
319
|
-
sm: { size: 12, lineHeight: 1.4 },
|
|
320
|
-
md: { size: 16, lineHeight: 1.4 },
|
|
321
|
-
lg: { size: 20, lineHeight: 1.4 }
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
// Generate custom extensions
|
|
325
|
-
export const customSpacing = generateTextBasedSpacing([8, 12, 16, 24, 32]);
|
|
326
|
-
export const customFontSize = generateTextStyles(CUSTOM_TEXT_SIZES, 'base');
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
### Available Generator Functions
|
|
330
|
-
|
|
331
|
-
```javascript
|
|
332
|
-
import {
|
|
333
|
-
generateTextBasedSpacing, // ut/bt/ht spacing units
|
|
334
|
-
generateViewportBasedSpacing, // up/wp/hp spacing units
|
|
335
|
-
generateTextStyles, // Complete typography styles
|
|
336
|
-
generateBorderRadiusStyles, // Border radius with scaling
|
|
337
|
-
generateWidthStyles // Border/stroke width with scaling
|
|
338
|
-
} from '@hkdigital/lib-core/design';
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
### Configuration Objects
|
|
342
|
-
|
|
343
|
-
All configuration objects are exported for customization:
|
|
344
|
-
|
|
345
|
-
```javascript
|
|
346
|
-
import {
|
|
347
|
-
DESIGN, // { width: 1024, height: 768 }
|
|
348
|
-
CLAMPING, // Min/max scale bounds
|
|
349
|
-
TEXT_POINT_SIZES, // [1, 2, 4, 6, 8, 10, ...]
|
|
350
|
-
VIEWPORT_POINT_SIZES, // [1, 2, 4, 5, 6, 10, ...]
|
|
351
|
-
TEXT_BASE_SIZES, // { sm: {...}, md: {...}, lg: {...} }
|
|
352
|
-
TEXT_HEADING_SIZES, // { h1: {...}, h2: {...}, ... }
|
|
353
|
-
TEXT_UI_SIZES, // { sm: {...}, md: {...}, lg: {...} }
|
|
354
|
-
RADIUS_SIZES, // Border radius configurations
|
|
355
|
-
BORDER_WIDTH_SIZES, // Border width configurations
|
|
356
|
-
STROKE_WIDTH_SIZES // Stroke width configurations
|
|
357
|
-
} from '@hkdigital/lib-core/design';
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
## Best practices
|
|
361
|
-
|
|
362
|
-
### Do's ✅
|
|
363
|
-
- Use `up` units for UI spacing: `p-20up`, `m-10up`
|
|
364
|
-
- Use `type-` classes for complete typography: `type-base-md`
|
|
365
|
-
- Use `ut/bt/ht` for text-related spacing: `mb-16bt`
|
|
366
|
-
- Use contrast colors for accessibility: `text-primary-contrast-500`
|
|
367
|
-
- Test across multiple screen sizes
|
|
368
|
-
|
|
369
|
-
### Don'ts ❌
|
|
370
|
-
- Don't use hardcoded pixel values: `p-4` → use `p-4up`
|
|
371
|
-
- Don't forget dark mode variants: add `-dark` classes
|
|
372
|
-
- Don't use `text-` classes when you need complete typography styling
|
|
373
|
-
|
|
374
|
-
## Themes
|
|
375
|
-
|
|
376
|
-
The system includes the complete **theme hkdev** with:
|
|
377
|
-
- Color palette (primary, secondary, tertiary, status, surface)
|
|
378
|
-
- Component styles (buttons, panels, inputs, etc.)
|
|
379
|
-
- Typography settings (fonts, weights, spacing)
|
|
380
|
-
- Responsive behavior
|
|
381
|
-
|
|
382
|
-
Themes are public and can be extended or customized by other projects.
|
|
383
|
-
|
|
384
|
-
## Browser Support
|
|
385
|
-
|
|
386
|
-
- Modern browsers with CSS custom properties support
|
|
387
|
-
- CSS `clamp()` function support
|
|
388
|
-
- Viewport units (`vw`, `vh`) support
|
|
389
|
-
|
|
390
|
-
## Migration Guide
|
|
391
|
-
|
|
392
|
-
If migrating from the old structure:
|
|
393
|
-
|
|
394
|
-
```javascript
|
|
395
|
-
// OLD
|
|
396
|
-
import { DESIGN } from '$lib/design/design-config.js';
|
|
397
|
-
import { customUtilitiesPlugin } from '$lib/design/skeleton.js';
|
|
398
|
-
|
|
399
|
-
// NEW
|
|
400
|
-
import { DESIGN, customUtilitiesPlugin } from '@hkdigital/lib-core/design';
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
---
|
|
404
|
-
|
|
405
|
-
For more examples and advanced usage, see the `/examples` routes in this library.
|
|
1
|
+
# HKdigital Design System
|
|
2
|
+
|
|
3
|
+
A comprehensive, responsive design system built for SvelteKit applications. This system provides consistent scaling, typography, spacing, and theming across all screen sizes using CSS custom properties and Tailwind CSS.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### Basic Usage
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
// tailwind.config.js
|
|
11
|
+
import {
|
|
12
|
+
spacing,
|
|
13
|
+
fontSize,
|
|
14
|
+
borderRadius,
|
|
15
|
+
customUtilitiesPlugin
|
|
16
|
+
} from '@hkdigital/lib-core/design/index.js';
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
theme: {
|
|
20
|
+
extend: {
|
|
21
|
+
spacing,
|
|
22
|
+
fontSize,
|
|
23
|
+
borderRadius
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
plugins: [
|
|
27
|
+
customUtilitiesPlugin
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```svelte
|
|
33
|
+
<!-- +layout.svelte -->
|
|
34
|
+
<script>
|
|
35
|
+
import { DESIGN, CLAMPING, rootDesignVarsHTML } from '@hkdigital/lib-core/design';
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<svelte:head>
|
|
39
|
+
{@html rootDesignVarsHTML(DESIGN, CLAMPING)}
|
|
40
|
+
</svelte:head>
|
|
41
|
+
|
|
42
|
+
{@render children()}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Core Concepts
|
|
46
|
+
|
|
47
|
+
### Responsive Scaling System
|
|
48
|
+
|
|
49
|
+
The design system is built around a **1024×768 design reference** that automatically scales to any screen size with sensible minimum and maximum bounds.
|
|
50
|
+
|
|
51
|
+
#### CSS Variables Created:
|
|
52
|
+
- `--scale-ui`: Clamped UI scaling (0.3× to 2×)
|
|
53
|
+
- `--scale-text-base`: Base text scaling (0.75× to 1.5×)
|
|
54
|
+
- `--scale-text-heading`: Heading text scaling (0.75× to 2.25×)
|
|
55
|
+
- `--scale-text-ui`: UI text scaling (0.5× to 1.25×)
|
|
56
|
+
|
|
57
|
+
## Spacing Classes
|
|
58
|
+
|
|
59
|
+
### UI Points
|
|
60
|
+
**Primary method for UI element spacing:**
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<div class="p-20up m-10up">
|
|
64
|
+
<!-- 20px padding, 10px margin at design size -->
|
|
65
|
+
<!-- Automatically scales with viewport -->
|
|
66
|
+
</div>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Available: `1up`, `2up`, `4up`, `5up`, `6up`, `10up`, `20up`, `30up`, `40up`, `50up`, `60up`, `70up`, `80up`, `90up`, `100up`, `120up`, `140up`, `160up`, `180up`, `200up`
|
|
70
|
+
|
|
71
|
+
### Text-Based Spacing
|
|
72
|
+
**For spacing relative to text size:**
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<div class="mb-16bt"> <!-- Base text spacing -->
|
|
76
|
+
<div class="p-12ut"> <!-- UI text spacing -->
|
|
77
|
+
<div class="mt-24ht"> <!-- Heading text spacing -->
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Available for all text point sizes: `1ut/bt/ht`, `2ut/bt/ht`, `4ut/bt/ht`, `6ut/bt/ht`, `8ut/bt/ht`, `10ut/bt/ht`, `11ut/bt/ht`, `12ut/bt/ht`, `16ut/bt/ht`, `20ut/bt/ht`, `24ut/bt/ht`, `28ut/bt/ht`, `32ut/bt/ht`, `36ut/bt/ht`, `50ut/bt/ht`
|
|
81
|
+
|
|
82
|
+
### Alternative Viewport Units
|
|
83
|
+
```html
|
|
84
|
+
<div class="w-100wp h-50hp"> <!-- Width/height points -->
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Typography Classes
|
|
88
|
+
|
|
89
|
+
### Complete Typography Styles
|
|
90
|
+
**Use `type-` classes for complete text styling:**
|
|
91
|
+
|
|
92
|
+
```html
|
|
93
|
+
<h1 class="type-heading-h1">Main Title</h1>
|
|
94
|
+
<h2 class="type-heading-h2">Section Title</h2>
|
|
95
|
+
<h3 class="type-heading-h3">Subsection</h3>
|
|
96
|
+
<p class="type-base-md">Body paragraph text</p>
|
|
97
|
+
<span class="type-ui-sm">Interface text</span>
|
|
98
|
+
|
|
99
|
+
<!-- Dark mode variants -->
|
|
100
|
+
<h1 class="type-heading-h1-dark">Dark mode title</h1>
|
|
101
|
+
<p class="type-base-md-dark">Dark mode paragraph</p>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Available Typography Classes:**
|
|
105
|
+
- **Headings**: `type-heading-h1`, `type-heading-h2`, `type-heading-h3`, `type-heading-h4`, `type-heading-h5`
|
|
106
|
+
- **Body Text**: `type-base-sm`, `type-base-md`, `type-base-lg`
|
|
107
|
+
- **UI Text**: `type-ui-sm`, `type-ui-md`, `type-ui-lg`
|
|
108
|
+
- **Dark Variants**: Add `-dark` suffix to any class
|
|
109
|
+
|
|
110
|
+
### Font Size Only
|
|
111
|
+
**Use `text-` classes for font size only:**
|
|
112
|
+
|
|
113
|
+
```html
|
|
114
|
+
<p class="text-base-md">16px scaled base text</p>
|
|
115
|
+
<h2 class="text-heading-h2">28px scaled heading</h2>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Border & Radius Classes
|
|
119
|
+
|
|
120
|
+
### Border Radius
|
|
121
|
+
```html
|
|
122
|
+
<div class="rounded-xs"> <!-- 5px scaled -->
|
|
123
|
+
<div class="rounded-sm"> <!-- 10px scaled -->
|
|
124
|
+
<div class="rounded-md"> <!-- 25px scaled -->
|
|
125
|
+
<div class="rounded-lg"> <!-- 35px scaled -->
|
|
126
|
+
<div class="rounded-none"> <!-- 0px -->
|
|
127
|
+
<div class="rounded-full"> <!-- 9999px -->
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Border & Stroke Width
|
|
131
|
+
```html
|
|
132
|
+
<div class="border-width-thin"> <!-- 1px scaled -->
|
|
133
|
+
<div class="border-width-normal"> <!-- 2px scaled -->
|
|
134
|
+
<div class="border-width-thick"> <!-- 4px scaled -->
|
|
135
|
+
|
|
136
|
+
<svg class="stroke-normal"> <!-- 2px scaled stroke -->
|
|
137
|
+
<div class="outline-thick"> <!-- 4px scaled outline -->
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Colors (Theme hkdev)
|
|
141
|
+
|
|
142
|
+
### Brand Colors
|
|
143
|
+
```html
|
|
144
|
+
<div class="bg-primary-500 text-primary-contrast-500">
|
|
145
|
+
<div class="bg-secondary-600 text-secondary-contrast-600">
|
|
146
|
+
<div class="bg-tertiary-400 text-tertiary-contrast-400">
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Surface Colors (Neutrals)
|
|
150
|
+
```html
|
|
151
|
+
<div class="bg-surface-50"> <!-- Lightest -->
|
|
152
|
+
<div class="bg-surface-500"> <!-- Medium -->
|
|
153
|
+
<div class="bg-surface-950"> <!-- Darkest -->
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Status Colors
|
|
157
|
+
```html
|
|
158
|
+
<div class="bg-success-500 text-success-contrast-500">
|
|
159
|
+
<div class="bg-warning-500 text-warning-contrast-500">
|
|
160
|
+
<div class="bg-error-500 text-error-contrast-500">
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Auto Contrast**: Each color includes automatic contrast colors for accessibility. Use `text-{color}-contrast-{shade}` for optimal readability.
|
|
164
|
+
|
|
165
|
+
## Component Styling
|
|
166
|
+
|
|
167
|
+
Components use `data-` attributes with CSS custom properties:
|
|
168
|
+
|
|
169
|
+
```html
|
|
170
|
+
<button data-component="button" data-role="primary">
|
|
171
|
+
Primary Button
|
|
172
|
+
</button>
|
|
173
|
+
|
|
174
|
+
<button data-component="button" data-role="secondary">
|
|
175
|
+
Secondary Button
|
|
176
|
+
</button>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Utility Functions
|
|
180
|
+
|
|
181
|
+
### CSS Variable Utilities
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
import {
|
|
185
|
+
getRootCssDesignWidth,
|
|
186
|
+
getRootCssDesignHeight,
|
|
187
|
+
getAllRootScalingVars
|
|
188
|
+
} from '@hkdigital/lib-core/design';
|
|
189
|
+
|
|
190
|
+
// Get current design dimensions
|
|
191
|
+
const designWidth = getRootCssDesignWidth(); // 1024
|
|
192
|
+
const designHeight = getRootCssDesignHeight(); // 768
|
|
193
|
+
|
|
194
|
+
// Get all current scaling factors
|
|
195
|
+
const scales = getAllRootScalingVars();
|
|
196
|
+
// Returns: { scaleW, scaleH, scaleViewport, scaleUI, scaleTextBase, scaleTextHeading, scaleTextUI }
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Clamp Utilities
|
|
200
|
+
|
|
201
|
+
```javascript
|
|
202
|
+
import { clamp, getClampParams } from '@hkdigital/lib-core/design';
|
|
203
|
+
|
|
204
|
+
// Mathematical clamp function
|
|
205
|
+
const value = clamp(0.5, 0.3, 2.0); // Returns 0.5 (clamped between 0.5 and 2.0)
|
|
206
|
+
|
|
207
|
+
// Extract clamp parameters from CSS variables
|
|
208
|
+
const params = getClampParams('scale-ui');
|
|
209
|
+
// Returns: { min: 0.3, max: 2.0 }
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Component State Classes
|
|
213
|
+
|
|
214
|
+
```javascript
|
|
215
|
+
import { toStateClasses } from '@hkdigital/lib-core/design';
|
|
216
|
+
|
|
217
|
+
// Generate state classes from object
|
|
218
|
+
const classes = toStateClasses({
|
|
219
|
+
selected: true,
|
|
220
|
+
loading: false,
|
|
221
|
+
error: true,
|
|
222
|
+
disabled: false
|
|
223
|
+
});
|
|
224
|
+
// Returns: "state-selected state-error"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
```html
|
|
228
|
+
<!-- Usage in components -->
|
|
229
|
+
<button class={toStateClasses({ selected, disabled, loading })}>
|
|
230
|
+
Button Text
|
|
231
|
+
</button>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Responsive Scaling
|
|
235
|
+
|
|
236
|
+
#### Viewport-Based Scaling
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
import { enableScalingUI } from '@hkdigital/lib-core/design';
|
|
240
|
+
|
|
241
|
+
// Enable automatic viewport scaling
|
|
242
|
+
const cleanup = enableScalingUI(DESIGN, CLAMPING);
|
|
243
|
+
|
|
244
|
+
// Call cleanup when component is destroyed
|
|
245
|
+
onDestroy(cleanup);
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### Container-Based Scaling
|
|
249
|
+
|
|
250
|
+
```javascript
|
|
251
|
+
import { enableContainerScaling } from '@hkdigital/lib-core/design';
|
|
252
|
+
|
|
253
|
+
let containerElement;
|
|
254
|
+
|
|
255
|
+
// Enable scaling for specific container
|
|
256
|
+
const cleanup = enableContainerScaling({
|
|
257
|
+
container: containerElement,
|
|
258
|
+
design: DESIGN,
|
|
259
|
+
clamping: CLAMPING,
|
|
260
|
+
useResizeObserver: true
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// Optional custom dimension getter
|
|
264
|
+
const cleanupCustom = enableContainerScaling({
|
|
265
|
+
container: containerElement,
|
|
266
|
+
design: DESIGN,
|
|
267
|
+
clamping: CLAMPING,
|
|
268
|
+
getDimensions: () => ({ width: 800, height: 600 })
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
```svelte
|
|
273
|
+
<!-- Svelte component example -->
|
|
274
|
+
<script>
|
|
275
|
+
import { onMount, onDestroy } from 'svelte';
|
|
276
|
+
import { enableContainerScaling, DESIGN, CLAMPING } from '@hkdigital/lib-core/design';
|
|
277
|
+
|
|
278
|
+
let containerElement;
|
|
279
|
+
let cleanup;
|
|
280
|
+
|
|
281
|
+
onMount(() => {
|
|
282
|
+
cleanup = enableContainerScaling({
|
|
283
|
+
container: containerElement,
|
|
284
|
+
design: DESIGN,
|
|
285
|
+
clamping: CLAMPING
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
onDestroy(() => {
|
|
290
|
+
cleanup?.();
|
|
291
|
+
});
|
|
292
|
+
</script>
|
|
293
|
+
|
|
294
|
+
<div bind:this={containerElement} class="scaled-container">
|
|
295
|
+
<!-- Content that scales with container -->
|
|
296
|
+
<div class="p-20up text-base-md">Responsive content</div>
|
|
297
|
+
</div>
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## Advanced Usage
|
|
301
|
+
|
|
302
|
+
### Custom Design Configuration
|
|
303
|
+
|
|
304
|
+
```javascript
|
|
305
|
+
// your-project/src/lib/design/design-config.js
|
|
306
|
+
import {
|
|
307
|
+
generateTextBasedSpacing,
|
|
308
|
+
generateTextStyles
|
|
309
|
+
} from '@hkdigital/lib-core/design';
|
|
310
|
+
|
|
311
|
+
// Custom design dimensions
|
|
312
|
+
export const CUSTOM_DESIGN = {
|
|
313
|
+
width: 1440,
|
|
314
|
+
height: 900
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
// Custom text sizes
|
|
318
|
+
export const CUSTOM_TEXT_SIZES = {
|
|
319
|
+
sm: { size: 12, lineHeight: 1.4 },
|
|
320
|
+
md: { size: 16, lineHeight: 1.4 },
|
|
321
|
+
lg: { size: 20, lineHeight: 1.4 }
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// Generate custom extensions
|
|
325
|
+
export const customSpacing = generateTextBasedSpacing([8, 12, 16, 24, 32]);
|
|
326
|
+
export const customFontSize = generateTextStyles(CUSTOM_TEXT_SIZES, 'base');
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Available Generator Functions
|
|
330
|
+
|
|
331
|
+
```javascript
|
|
332
|
+
import {
|
|
333
|
+
generateTextBasedSpacing, // ut/bt/ht spacing units
|
|
334
|
+
generateViewportBasedSpacing, // up/wp/hp spacing units
|
|
335
|
+
generateTextStyles, // Complete typography styles
|
|
336
|
+
generateBorderRadiusStyles, // Border radius with scaling
|
|
337
|
+
generateWidthStyles // Border/stroke width with scaling
|
|
338
|
+
} from '@hkdigital/lib-core/design';
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Configuration Objects
|
|
342
|
+
|
|
343
|
+
All configuration objects are exported for customization:
|
|
344
|
+
|
|
345
|
+
```javascript
|
|
346
|
+
import {
|
|
347
|
+
DESIGN, // { width: 1024, height: 768 }
|
|
348
|
+
CLAMPING, // Min/max scale bounds
|
|
349
|
+
TEXT_POINT_SIZES, // [1, 2, 4, 6, 8, 10, ...]
|
|
350
|
+
VIEWPORT_POINT_SIZES, // [1, 2, 4, 5, 6, 10, ...]
|
|
351
|
+
TEXT_BASE_SIZES, // { sm: {...}, md: {...}, lg: {...} }
|
|
352
|
+
TEXT_HEADING_SIZES, // { h1: {...}, h2: {...}, ... }
|
|
353
|
+
TEXT_UI_SIZES, // { sm: {...}, md: {...}, lg: {...} }
|
|
354
|
+
RADIUS_SIZES, // Border radius configurations
|
|
355
|
+
BORDER_WIDTH_SIZES, // Border width configurations
|
|
356
|
+
STROKE_WIDTH_SIZES // Stroke width configurations
|
|
357
|
+
} from '@hkdigital/lib-core/design';
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## Best practices
|
|
361
|
+
|
|
362
|
+
### Do's ✅
|
|
363
|
+
- Use `up` units for UI spacing: `p-20up`, `m-10up`
|
|
364
|
+
- Use `type-` classes for complete typography: `type-base-md`
|
|
365
|
+
- Use `ut/bt/ht` for text-related spacing: `mb-16bt`
|
|
366
|
+
- Use contrast colors for accessibility: `text-primary-contrast-500`
|
|
367
|
+
- Test across multiple screen sizes
|
|
368
|
+
|
|
369
|
+
### Don'ts ❌
|
|
370
|
+
- Don't use hardcoded pixel values: `p-4` → use `p-4up`
|
|
371
|
+
- Don't forget dark mode variants: add `-dark` classes
|
|
372
|
+
- Don't use `text-` classes when you need complete typography styling
|
|
373
|
+
|
|
374
|
+
## Themes
|
|
375
|
+
|
|
376
|
+
The system includes the complete **theme hkdev** with:
|
|
377
|
+
- Color palette (primary, secondary, tertiary, status, surface)
|
|
378
|
+
- Component styles (buttons, panels, inputs, etc.)
|
|
379
|
+
- Typography settings (fonts, weights, spacing)
|
|
380
|
+
- Responsive behavior
|
|
381
|
+
|
|
382
|
+
Themes are public and can be extended or customized by other projects.
|
|
383
|
+
|
|
384
|
+
## Browser Support
|
|
385
|
+
|
|
386
|
+
- Modern browsers with CSS custom properties support
|
|
387
|
+
- CSS `clamp()` function support
|
|
388
|
+
- Viewport units (`vw`, `vh`) support
|
|
389
|
+
|
|
390
|
+
## Migration Guide
|
|
391
|
+
|
|
392
|
+
If migrating from the old structure:
|
|
393
|
+
|
|
394
|
+
```javascript
|
|
395
|
+
// OLD
|
|
396
|
+
import { DESIGN } from '$lib/design/design-config.js';
|
|
397
|
+
import { customUtilitiesPlugin } from '$lib/design/skeleton.js';
|
|
398
|
+
|
|
399
|
+
// NEW
|
|
400
|
+
import { DESIGN, customUtilitiesPlugin } from '@hkdigital/lib-core/design';
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
405
|
+
For more examples and advanced usage, see the `/examples` routes in this library.
|