@hkdigital/lib-core 0.3.14 → 0.4.3
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 +18 -9
- package/dist/auth/errors.d.ts +1 -0
- package/dist/auth/errors.js +1 -0
- package/dist/{states → browser/navigation}/navigation.svelte.js +1 -1
- package/dist/browser/navigation.d.ts +1 -0
- package/dist/browser/navigation.js +1 -0
- package/dist/config/README.md +5 -5
- package/dist/config/generators/imagetools.d.ts +2 -0
- package/dist/config/generators/imagetools.js +23 -10
- package/dist/config/generators/vite.js +1 -1
- package/dist/config/imagetools.d.ts +5 -5
- package/dist/config/typedef.d.ts +11 -0
- package/dist/config/typedef.js +17 -0
- package/dist/design/README.md +211 -66
- package/dist/design/config/{design-config.d.ts → design-tokens.d.ts} +23 -10
- package/dist/design/config/design-tokens.js +107 -0
- package/dist/design/generators/index.d.ts +51 -0
- package/dist/design/generators/index.js +124 -0
- package/dist/design/index.d.ts +3 -4
- package/dist/design/index.js +24 -41
- package/dist/design/plugins/skeleton.d.ts +4 -2
- package/dist/design/plugins/skeleton.js +3 -2
- package/dist/design/themes/hkdev/components/buttons/button-text.css +38 -25
- package/dist/design/themes/hkdev/theme-ext.js +1 -1
- package/dist/design/utils/clamp.js +1 -1
- package/dist/design/utils/root-vars.d.ts +50 -39
- package/dist/design/utils/root-vars.js +127 -29
- package/dist/{classes/data → generic/data/classes}/IterableTree.js +2 -2
- package/dist/{classes/data → generic/data/classes}/Selector.js +1 -1
- package/dist/generic/data/classes/typedef.d.ts +24 -0
- package/dist/generic/data/classes/typedef.js +14 -0
- package/dist/generic/data.d.ts +2 -0
- package/dist/generic/data.js +2 -0
- package/dist/generic/errors.d.ts +2 -0
- package/dist/generic/errors.js +2 -0
- package/dist/generic/events.d.ts +1 -0
- package/dist/generic/events.js +1 -0
- package/dist/{classes/promise → generic/promises/classes}/HkPromise.d.ts +17 -7
- package/dist/{classes/promise → generic/promises/classes}/HkPromise.js +20 -10
- package/dist/generic/promises.d.ts +1 -0
- package/dist/generic/promises.js +1 -0
- package/dist/{classes/streams → generic/streaming/classes}/ServerEventsStore.d.ts +1 -1
- package/dist/{classes/streams → generic/streaming/classes}/ServerEventsStore.js +2 -2
- package/dist/generic/streaming.d.ts +3 -0
- package/dist/generic/streaming.js +3 -0
- package/dist/generic/typedef.d.ts +1 -0
- package/dist/generic/typedef.js +1 -0
- package/dist/index.js +1 -0
- package/dist/logging/errors.d.ts +7 -0
- package/dist/logging/errors.js +11 -0
- package/dist/logging/index.d.ts +2 -3
- package/dist/logging/index.js +3 -4
- package/dist/logging/internal/adapters/console.d.ts +1 -16
- package/dist/logging/internal/adapters/console.js +322 -14
- package/dist/logging/internal/adapters/formatting.d.ts +69 -0
- package/dist/logging/internal/adapters/formatting.js +395 -0
- package/dist/logging/internal/adapters/pino.js +128 -27
- package/dist/logging/internal/adapters/typedef.d.ts +30 -0
- package/dist/logging/internal/adapters/typedef.js +11 -0
- package/dist/logging/internal/factories/client.js +1 -1
- package/dist/logging/internal/factories/server.js +12 -2
- package/dist/logging/internal/logger/Logger.d.ts +9 -7
- package/dist/logging/internal/logger/Logger.js +44 -9
- package/dist/logging/internal/test-errors.d.ts +35 -0
- package/dist/logging/internal/test-errors.js +137 -0
- package/dist/network/cache/IndexedDbCache.d.ts +1 -1
- package/dist/network/cache/MemoryResponseCache.d.ts +5 -0
- package/dist/network/cache/MemoryResponseCache.js +5 -2
- package/dist/network/errors.d.ts +2 -0
- package/dist/network/errors.js +2 -0
- package/dist/network/http/caching.js +1 -1
- package/dist/network/http/errors.d.ts +2 -2
- package/dist/network/http/errors.js +5 -13
- package/dist/network/http/http-request.js +1 -1
- package/dist/network/http/json-request.js +1 -1
- package/dist/network/http/response.js +1 -1
- package/dist/network/http/url.js +1 -1
- package/dist/network/loaders/README.md +14 -7
- package/dist/network/loaders/audio/AudioScene.svelte.js +3 -2
- package/dist/network/loaders/image/ImageLoader.svelte.d.ts +2 -2
- package/dist/network/loaders/image/ImageLoader.svelte.js +1 -1
- package/dist/network/loaders/image/ImageScene.svelte.d.ts +2 -2
- package/dist/network/loaders/image/ImageScene.svelte.js +9 -8
- package/dist/network/loaders/image/ImageVariantsLoader.svelte.d.ts +5 -5
- package/dist/network/loaders/image/ImageVariantsLoader.svelte.js +14 -13
- package/dist/network/loaders/image/utils/index.d.ts +2 -2
- package/dist/network/loaders/image/utils/index.js +9 -12
- package/dist/network/loaders/typedef.d.ts +0 -9
- package/dist/network/loaders/typedef.js +0 -12
- package/dist/network/states/NetworkLoader.svelte.d.ts +1 -1
- package/dist/network/states/NetworkLoader.svelte.js +3 -2
- package/dist/services/index.d.ts +0 -2
- package/dist/services/index.js +0 -3
- package/dist/services/service-base/ServiceBase.d.ts +2 -2
- package/dist/services/service-base/ServiceBase.js +15 -11
- package/dist/services/service-base/typedef.d.ts +2 -31
- package/dist/services/service-base/typedef.js +3 -2
- package/dist/services/service-manager/ServiceManager.d.ts +3 -3
- package/dist/services/service-manager/ServiceManager.js +2 -2
- package/dist/services/service-manager/typedef.d.ts +3 -3
- package/dist/services/service-manager/typedef.js +3 -3
- package/dist/services/typedef.d.ts +2 -0
- package/dist/services/typedef.js +2 -0
- package/dist/{classes/svelte → state/classes}/loading-state-machine/LoadingStateMachine.svelte.d.ts +1 -1
- package/dist/{classes/svelte → state/classes}/loading-state-machine/LoadingStateMachine.svelte.js +1 -1
- package/dist/state/classes/subscribers-count/index.d.ts +1 -0
- package/dist/state/classes/subscribers-count/index.js +1 -0
- package/dist/state/classes.d.ts +3 -0
- package/dist/state/classes.js +3 -0
- package/dist/{util/svelte/state-context/index.d.ts → state/context/state-context.d.ts} +1 -1
- package/dist/{util/svelte/state-context/index.js → state/context/state-context.js} +4 -4
- package/dist/state/context.d.ts +1 -0
- package/dist/state/context.js +1 -0
- package/dist/state/stores.d.ts +1 -0
- package/dist/state/stores.js +1 -0
- package/dist/ui/README.md +49 -0
- package/dist/ui/components/button-group/index.d.ts +1 -0
- package/dist/ui/components/button-group/index.js +1 -0
- package/dist/ui/{primitives → components}/drag-drop/DragDropContext.svelte +1 -1
- package/dist/ui/{primitives → components}/drag-drop/DragDropContext.svelte.d.ts +1 -1
- package/dist/ui/{primitives → components}/drag-drop/Draggable.svelte +2 -2
- package/dist/ui/{primitives → components}/drag-drop/Draggable.svelte.d.ts +1 -1
- package/dist/ui/{primitives → components}/drag-drop/DropZone.svelte +4 -4
- package/dist/ui/{primitives → components}/drag-drop/DropZone.svelte.d.ts +3 -3
- package/dist/ui/{primitives → components}/drag-drop/DropZoneArea.svelte +3 -3
- package/dist/ui/{primitives → components}/drag-drop/DropZoneArea.svelte.d.ts +4 -4
- package/dist/ui/{primitives → components}/drag-drop/DropZoneList.svelte +3 -3
- package/dist/ui/{primitives → components}/drag-drop/DropZoneList.svelte.d.ts +3 -3
- package/dist/ui/{primitives → components}/drag-drop/drag-state.svelte.d.ts +11 -11
- package/dist/ui/{primitives → components}/drag-drop/drag-state.svelte.js +5 -5
- package/dist/ui/components/drag-drop/typedef.d.ts +2 -0
- package/dist/ui/components/drag-drop/typedef.js +2 -0
- package/dist/ui/components/game-box/GameBox.svelte +1 -1
- package/dist/ui/components/game-box/index.d.ts +1 -0
- package/dist/ui/components/game-box/index.js +1 -0
- package/dist/ui/components/grid-layers/index.d.ts +1 -0
- package/dist/ui/components/grid-layers/index.js +1 -0
- package/dist/ui/{primitives/layout → components}/grid-layers/util.js +1 -1
- package/dist/ui/components/hk-app-layout/HkAppLayout.state.svelte.d.ts +3 -3
- package/dist/ui/components/hk-app-layout/HkAppLayout.state.svelte.js +3 -4
- package/dist/ui/components/hk-app-layout/index.d.ts +1 -0
- package/dist/ui/components/hk-app-layout/index.js +1 -0
- package/dist/ui/components/image-box/ImageBox.svelte +2 -2
- package/dist/ui/components/image-box/ImageBox.svelte.d.ts +3 -3
- package/dist/ui/components/image-box/index.d.ts +1 -1
- package/dist/ui/components/presenter/ImageSlide.svelte +1 -1
- package/dist/ui/components/presenter/ImageSlide.svelte.d.ts +2 -2
- package/dist/ui/components/presenter/Presenter.state.svelte.d.ts +3 -3
- package/dist/ui/components/presenter/Presenter.state.svelte.js +1 -1
- package/dist/ui/components/presenter/Presenter.svelte +1 -1
- package/dist/ui/components/presenter/Presenter.svelte.d.ts +1 -1
- package/dist/ui/{primitives → components}/rows/panel-grid-row/PanelGridRow.svelte.d.ts +1 -1
- package/dist/ui/{primitives → components}/rows/panel-row-2/PanelRow2.svelte.d.ts +1 -1
- package/dist/ui/{primitives → components}/tab-bar/HkTabBar.state.svelte.d.ts +3 -3
- package/dist/ui/{primitives → components}/tab-bar/HkTabBar.state.svelte.js +4 -2
- package/dist/ui/{primitives → components}/tab-bar/HkTabBar.svelte +2 -2
- package/dist/ui/{primitives → components}/tab-bar/HkTabBar.svelte.d.ts +2 -2
- package/dist/ui/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +19 -0
- package/dist/ui/{primitives → components}/tab-bar/HkTabBarSelector.state.svelte.js +2 -2
- package/dist/ui/{primitives → components}/tab-bar/HkTabBarSelector.svelte +1 -1
- package/dist/ui/{primitives → components}/tab-bar/HkTabBarSelector.svelte.d.ts +2 -2
- package/dist/ui/{primitives → components}/tab-bar/typedef.d.ts +1 -1
- package/dist/ui/{primitives → components}/tab-bar/typedef.js +1 -1
- package/dist/ui/components/typedef.d.ts +5 -0
- package/dist/ui/components/typedef.js +5 -0
- package/dist/ui/components/virtual-viewport/index.d.ts +1 -0
- package/dist/ui/components/virtual-viewport/index.js +1 -0
- package/dist/ui/components.d.ts +11 -0
- package/dist/ui/components.js +11 -0
- package/dist/ui/{primitives/hkdev → dev}/blocks/TextBlock.svelte +1 -1
- package/dist/ui/{primitives/debug → dev}/debug-panel-design-scaling/DebugPanelDesignScaling.svelte +8 -8
- package/dist/ui/dev.d.ts +3 -0
- package/dist/ui/dev.js +3 -0
- package/dist/ui/primitives/buttons/button/Button.svelte.d.ts +1 -1
- package/dist/ui/primitives/buttons/button-text/TextButton.svelte +1 -1
- package/dist/ui/primitives/typedef.d.ts +1 -0
- package/dist/ui/primitives/typedef.js +1 -0
- package/dist/ui/primitives.d.ts +5 -0
- package/dist/ui/primitives.js +5 -0
- package/dist/ui/typedef.d.ts +2 -0
- package/dist/ui/typedef.js +2 -0
- package/dist/util/array/index.js +1 -1
- package/dist/util/bases/base58.d.ts +3 -3
- package/dist/util/bases/base58.js +3 -3
- package/dist/util/compare/index.d.ts +4 -5
- package/dist/util/compare/index.js +3 -4
- package/dist/util/exceptions/index.js +1 -1
- package/dist/util/expect/arrays.d.ts +11 -11
- package/dist/util/expect/arrays.js +14 -6
- package/dist/util/expect/index.js +2 -2
- package/dist/util/expect/primitives.d.ts +6 -5
- package/dist/util/expect/primitives.js +15 -5
- package/dist/util/expect/url.d.ts +6 -5
- package/dist/util/expect/url.js +15 -5
- package/dist/util/function/index.d.ts +1 -14
- package/dist/util/index.d.ts +5 -0
- package/dist/util/index.js +13 -0
- package/dist/util/is/index.d.ts +3 -2
- package/dist/util/is/index.js +2 -1
- package/dist/util/iterate/index.d.ts +6 -8
- package/dist/util/iterate/index.js +5 -5
- package/dist/util/object/index.d.ts +1 -2
- package/dist/util/object/index.js +2 -3
- package/dist/util/ssr/index.d.ts +16 -0
- package/dist/util/ssr/index.js +44 -0
- package/dist/util/svelte/index.d.ts +1 -1
- package/dist/util/svelte/index.js +1 -1
- package/dist/util/time/index.d.ts +2 -2
- package/dist/util/time/index.js +1 -1
- package/dist/valibot/index.d.ts +1 -1
- package/dist/valibot/index.js +27 -1
- package/package.json +4 -4
- package/dist/assets/autospuiten/car-paint-picker/army-green.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/electric-blue.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/lemon-yellow.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/opaque-purple.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/rusty.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/sunset-orange.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/tomato-red.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker.d.ts +0 -17
- package/dist/assets/autospuiten/car-paint-picker.js +0 -41
- package/dist/assets/autospuiten/labels.d.ts +0 -7
- package/dist/assets/autospuiten/labels.js +0 -7
- package/dist/classes/data/index.d.ts +0 -2
- package/dist/classes/data/index.js +0 -2
- package/dist/classes/event-emitter/index.d.ts +0 -1
- package/dist/classes/event-emitter/index.js +0 -2
- package/dist/classes/index.d.ts +0 -4
- package/dist/classes/index.js +0 -4
- package/dist/classes/promise/index.d.ts +0 -1
- package/dist/classes/promise/index.js +0 -1
- package/dist/classes/stores/index.d.ts +0 -1
- package/dist/classes/stores/index.js +0 -1
- package/dist/classes/streams/index.d.ts +0 -3
- package/dist/classes/streams/index.js +0 -3
- package/dist/classes/svelte/index.d.ts +0 -1
- package/dist/classes/svelte/index.js +0 -1
- package/dist/design/config/design-config.js +0 -73
- package/dist/design/tailwind-theme-extend.d.ts +0 -23
- package/dist/design/tailwind-theme-extend.js +0 -158
- package/dist/errors/index.d.ts +0 -5
- package/dist/errors/index.js +0 -5
- package/dist/logging/internal/factories/universal.d.ts +0 -9
- package/dist/logging/internal/factories/universal.js +0 -22
- package/dist/services/service-base/index.d.ts +0 -3
- package/dist/services/service-base/index.js +0 -3
- package/dist/states/index.d.ts +0 -1
- package/dist/states/index.js +0 -1
- package/dist/stores/index.d.ts +0 -1
- package/dist/stores/index.js +0 -1
- package/dist/typedef/index.d.ts +0 -4
- package/dist/typedef/index.js +0 -4
- package/dist/ui/primitives/debug/index.d.ts +0 -1
- package/dist/ui/primitives/debug/index.js +0 -1
- package/dist/ui/primitives/index.d.ts +0 -0
- package/dist/ui/primitives/index.js +0 -2
- package/dist/ui/primitives/layout/grid-layers/GridLayers.svelte__heightFrom__ +0 -372
- package/dist/ui/primitives/layout/index.d.ts +0 -1
- package/dist/ui/primitives/layout/index.js +0 -1
- package/dist/ui/primitives/tab-bar/HkTabBarSelector.state.svelte.d.ts +0 -19
- /package/dist/{errors → auth/errors}/jwt.d.ts +0 -0
- /package/dist/{errors → auth/errors}/jwt.js +0 -0
- /package/dist/{states → browser/navigation}/navigation.svelte.d.ts +0 -0
- /package/dist/{classes/data → generic/data/classes}/IterableTree.d.ts +0 -0
- /package/dist/{classes/data → generic/data/classes}/Selector.d.ts +0 -0
- /package/dist/{classes → generic}/data/typedef.d.ts +0 -0
- /package/dist/{classes → generic}/data/typedef.js +0 -0
- /package/dist/{errors → generic/errors}/generic.d.ts +0 -0
- /package/dist/{errors → generic/errors}/generic.js +0 -0
- /package/dist/{errors → generic/errors}/promise.d.ts +0 -0
- /package/dist/{errors → generic/errors}/promise.js +0 -0
- /package/dist/{classes/event-emitter → generic/events/classes}/EventEmitter.d.ts +0 -0
- /package/dist/{classes/event-emitter → generic/events/classes}/EventEmitter.js +0 -0
- /package/dist/{classes/streams → generic/streaming/classes}/LogTransformStream.d.ts +0 -0
- /package/dist/{classes/streams → generic/streaming/classes}/LogTransformStream.js +0 -0
- /package/dist/{classes/streams → generic/streaming/classes}/TimeStampSource.d.ts +0 -0
- /package/dist/{classes/streams → generic/streaming/classes}/TimeStampSource.js +0 -0
- /package/dist/logging/{internal/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/logging/{internal/constants.js → constants.js} +0 -0
- /package/dist/logging/{internal/typedef.d.ts → typedef.d.ts} +0 -0
- /package/dist/logging/{internal/typedef.js → typedef.js} +0 -0
- /package/dist/{errors → network/errors}/api.d.ts +0 -0
- /package/dist/{errors → network/errors}/api.js +0 -0
- /package/dist/{errors → network/errors}/http.d.ts +0 -0
- /package/dist/{errors → network/errors}/http.js +0 -0
- /package/dist/{classes/svelte → state/classes}/finite-state-machine/FiniteStateMachine.svelte.d.ts +0 -0
- /package/dist/{classes/svelte → state/classes}/finite-state-machine/FiniteStateMachine.svelte.js +0 -0
- /package/dist/{classes/svelte → state/classes}/finite-state-machine/index.d.ts +0 -0
- /package/dist/{classes/svelte → state/classes}/finite-state-machine/index.js +0 -0
- /package/dist/{classes/svelte → state/classes}/loading-state-machine/constants.d.ts +0 -0
- /package/dist/{classes/svelte → state/classes}/loading-state-machine/constants.js +0 -0
- /package/dist/{classes/svelte → state/classes}/loading-state-machine/index.d.ts +0 -0
- /package/dist/{classes/svelte → state/classes}/loading-state-machine/index.js +0 -0
- /package/dist/{classes/stores → state/classes/subscribers-count}/SubscribersCount.d.ts +0 -0
- /package/dist/{classes/stores → state/classes/subscribers-count}/SubscribersCount.js +0 -0
- /package/dist/{typedef/context.d.ts → state/context/typedef.d.ts} +0 -0
- /package/dist/{typedef/context.js → state/context/typedef.js} +0 -0
- /package/dist/{stores → state/stores}/theme.d.ts +0 -0
- /package/dist/{stores → state/stores}/theme.js +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/DragController.d.ts +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/DragController.js +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/actions.d.ts +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/actions.js +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/index.d.ts +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/index.js +0 -0
- /package/dist/{typedef → ui/components/drag-drop/typedef}/drag.d.ts +0 -0
- /package/dist/{typedef → ui/components/drag-drop/typedef}/drag.js +0 -0
- /package/dist/{typedef → ui/components/drag-drop/typedef}/drop.d.ts +0 -0
- /package/dist/{typedef → ui/components/drag-drop/typedef}/drop.js +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/util.d.ts +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/util.js +0 -0
- /package/dist/ui/{primitives/layout → components}/grid-layers/GridLayers.svelte +0 -0
- /package/dist/ui/{primitives/layout → components}/grid-layers/GridLayers.svelte.d.ts +0 -0
- /package/dist/ui/{primitives/layout → components}/grid-layers/util.d.ts +0 -0
- /package/dist/ui/{primitives → components}/rows/index.d.ts +0 -0
- /package/dist/ui/{primitives → components}/rows/index.js +0 -0
- /package/dist/ui/{primitives → components}/rows/panel-grid-row/PanelGridRow.svelte +0 -0
- /package/dist/ui/{primitives → components}/rows/panel-row-2/PanelRow2.svelte +0 -0
- /package/dist/ui/{primitives → components}/tab-bar/index.d.ts +0 -0
- /package/dist/ui/{primitives → components}/tab-bar/index.js +0 -0
- /package/dist/ui/{primitives/hkdev → dev}/blocks/TextBlock.svelte.d.ts +0 -0
- /package/dist/ui/{primitives/hkdev → dev}/buttons/CheckButton.svelte +0 -0
- /package/dist/ui/{primitives/hkdev → dev}/buttons/CheckButton.svelte.d.ts +0 -0
- /package/dist/ui/{primitives/debug → dev}/debug-panel-design-scaling/DebugPanelDesignScaling.svelte.d.ts +0 -0
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Core library that we use to power up our SvelteKit projects
|
|
4
4
|
|
|
5
5
|
This is a library for [SvelteKit](https://svelte.dev/) projects.
|
|
6
|
-
It contains common code
|
|
6
|
+
It contains common code, base components and documentation that help you with setting up a new project.
|
|
7
7
|
|
|
8
8
|
## Using the library
|
|
9
9
|
|
|
@@ -88,10 +88,19 @@ For detailed configuration options, see the [config documentation](./src/lib/con
|
|
|
88
88
|
|
|
89
89
|
### Import JS, Svelte files and Typedefs
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
Main folders in lib have an index.js, but may also have a more specific export file e.g. http.js or cache.js (@see $lib/network).
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
Main folders (should) have a typedef.js that can be used in JSdoc comments.
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
// Import Latin char constant for use in regular expressions
|
|
97
|
+
import { LCHAR } from '@hkdigital/lib-core/constants/regexp/index.js';
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
/**
|
|
102
|
+
* @param {import('@hkdigital/lib-core/network/typedef.js').JsonGetOptions} JsonGetOptions
|
|
103
|
+
*/
|
|
95
104
|
```
|
|
96
105
|
|
|
97
106
|
### Import CSS
|
|
@@ -122,18 +131,18 @@ export default {
|
|
|
122
131
|
To build your library:
|
|
123
132
|
|
|
124
133
|
```bash
|
|
125
|
-
|
|
134
|
+
pnpm run package
|
|
126
135
|
```
|
|
127
136
|
|
|
128
|
-
##
|
|
137
|
+
## Running the showcase app
|
|
129
138
|
|
|
130
|
-
To
|
|
139
|
+
To use the showcase app that illustrates the code in this lib
|
|
131
140
|
|
|
132
141
|
```bash
|
|
133
|
-
|
|
142
|
+
pnpm run dev
|
|
134
143
|
```
|
|
135
144
|
|
|
136
|
-
You can preview the production build with `
|
|
145
|
+
You can preview the production build with `pnpm run preview`.
|
|
137
146
|
|
|
138
147
|
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
|
139
148
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./errors/jwt.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './errors/jwt.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { nav } from "./navigation/navigation.svelte.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { nav } from './navigation/navigation.svelte.js';
|
package/dist/config/README.md
CHANGED
|
@@ -12,7 +12,7 @@ The `vite.js` provides generators for common Vite setups used across HKdigital p
|
|
|
12
12
|
// vite.config.js
|
|
13
13
|
import { defineConfig } from 'vitest/config';
|
|
14
14
|
import { sveltekit } from '@sveltejs/kit/vite';
|
|
15
|
-
import { generateViteConfig } from '@hkdigital/lib-
|
|
15
|
+
import { generateViteConfig } from '@hkdigital/lib-core/config/vite.js';
|
|
16
16
|
|
|
17
17
|
export default defineConfig(
|
|
18
18
|
await generateViteConfig({
|
|
@@ -50,7 +50,7 @@ export default defineConfig(
|
|
|
50
50
|
'import.meta.env.VITE_API_URL': JSON.stringify('https://api.example.com')
|
|
51
51
|
},
|
|
52
52
|
imagetoolsOptions: {
|
|
53
|
-
widths: [
|
|
53
|
+
widths: [1920, 1536, 1024, 640]
|
|
54
54
|
}
|
|
55
55
|
})
|
|
56
56
|
);
|
|
@@ -106,7 +106,7 @@ pnpm add -D vite-imagetools
|
|
|
106
106
|
For TypeScript and JavaScript projects using VS Code or other TypeScript-aware editors, add to your `app.d.ts`:
|
|
107
107
|
|
|
108
108
|
```typescript
|
|
109
|
-
import '@hkdigital/lib-
|
|
109
|
+
import '@hkdigital/lib-core/config/imagetools.d.ts';
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
**Why this is needed:**
|
|
@@ -157,7 +157,7 @@ import { resolve } from 'path';
|
|
|
157
157
|
import {
|
|
158
158
|
generateDefaultDirectives,
|
|
159
159
|
generateResponseConfigs
|
|
160
|
-
} from '@hkdigital/lib-
|
|
160
|
+
} from '@hkdigital/lib-core/config/imagetools-config.js';
|
|
161
161
|
|
|
162
162
|
const packageJson = JSON.parse(
|
|
163
163
|
readFileSync(resolve('./package.json'), 'utf-8')
|
|
@@ -189,7 +189,7 @@ export default defineConfig({
|
|
|
189
189
|
// vite.config.js
|
|
190
190
|
import { defineConfig } from 'vitest/config';
|
|
191
191
|
import { sveltekit } from '@sveltejs/kit/vite';
|
|
192
|
-
import { generateViteConfig } from '@hkdigital/lib-
|
|
192
|
+
import { generateViteConfig } from '@hkdigital/lib-core/config/vite.js';
|
|
193
193
|
|
|
194
194
|
export default defineConfig(
|
|
195
195
|
await generateViteConfig()
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @param {object} [options]
|
|
6
6
|
* @param {number[]} [options.widths=DEFAULT_WIDTHS]
|
|
7
|
+
* @param {number[]} [options.thumbnailWidth=DEFAULT_THUMBNAIL_WIDTH]
|
|
7
8
|
*
|
|
8
9
|
* @returns {(
|
|
9
10
|
* entries: [string, string[]][]
|
|
@@ -11,6 +12,7 @@
|
|
|
11
12
|
*/
|
|
12
13
|
export function generateResponseConfigs(options?: {
|
|
13
14
|
widths?: number[];
|
|
15
|
+
thumbnailWidth?: number[];
|
|
14
16
|
}): (entries: [string, string[]][]) => (Record<string, string | string[]>[]);
|
|
15
17
|
/**
|
|
16
18
|
* Configures and returns a function that can be used as
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
const DEFAULT_WIDTHS = [
|
|
1
|
+
const DEFAULT_WIDTHS = [1920, 1536, 1024, 640];
|
|
2
|
+
|
|
3
|
+
const DEFAULT_THUMBNAIL_WIDTH = 150;
|
|
2
4
|
|
|
3
5
|
const DEFAULT_PRESETS = {
|
|
4
6
|
default: {
|
|
5
7
|
format: 'avif',
|
|
6
|
-
quality: '90'
|
|
8
|
+
quality: '90',
|
|
9
|
+
as: 'metadata'
|
|
7
10
|
},
|
|
8
11
|
render: {
|
|
9
12
|
format: 'jpg',
|
|
@@ -44,6 +47,7 @@ const DEFAULT_PRESETS = {
|
|
|
44
47
|
*
|
|
45
48
|
* @param {object} [options]
|
|
46
49
|
* @param {number[]} [options.widths=DEFAULT_WIDTHS]
|
|
50
|
+
* @param {number[]} [options.thumbnailWidth=DEFAULT_THUMBNAIL_WIDTH]
|
|
47
51
|
*
|
|
48
52
|
* @returns {(
|
|
49
53
|
* entries: [string, string[]][]
|
|
@@ -70,21 +74,30 @@ export function generateResponseConfigs(options) {
|
|
|
70
74
|
|
|
71
75
|
// @ts-ignore
|
|
72
76
|
const responsiveConfig = entries.find(([key]) => key === 'responsive');
|
|
77
|
+
// console.log('responsiveConfig found:', !!responsiveConfig);
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
// Directive 'responsive' was not set => return original config
|
|
79
|
+
const widths = options?.widths ?? DEFAULT_WIDTHS;
|
|
76
80
|
|
|
77
|
-
|
|
81
|
+
// Always include the main image(s) and a thumbnail version
|
|
82
|
+
const thumbnailConfig = {
|
|
83
|
+
...configPairs,
|
|
84
|
+
w: String(options?.thumbnailWidth ?? DEFAULT_THUMBNAIL_WIDTH)
|
|
85
|
+
};
|
|
78
86
|
|
|
79
|
-
|
|
80
|
-
// return
|
|
87
|
+
if (!responsiveConfig) {
|
|
88
|
+
// Directive 'responsive' was not set => return original + thumbnail
|
|
89
|
+
const originalConfig = configPairs; // No 'w' means original dimensions
|
|
90
|
+
// console.log('Returning original + thumbnail configs:', [originalConfig, thumbnailConfig]);
|
|
91
|
+
return [originalConfig, thumbnailConfig];
|
|
81
92
|
}
|
|
82
93
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return widths.map((w) => {
|
|
94
|
+
// Directive 'responsive' was set => return responsive widths + thumbnail
|
|
95
|
+
const responsiveConfigs = widths.map((w) => {
|
|
86
96
|
return { ...configPairs, w: String(w) };
|
|
87
97
|
});
|
|
98
|
+
const result = [...responsiveConfigs, thumbnailConfig];
|
|
99
|
+
// console.log('Returning responsive + thumbnail configs:', result);
|
|
100
|
+
return result;
|
|
88
101
|
};
|
|
89
102
|
}
|
|
90
103
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
type ImageMeta = import('
|
|
2
|
-
type ImageSource = import('
|
|
1
|
+
type ImageMeta = import('./typedef.js').ImageMeta;
|
|
2
|
+
type ImageSource = import('./typedef.js').ImageSource;
|
|
3
3
|
|
|
4
4
|
declare module '*?responsive' {
|
|
5
|
-
const out:
|
|
5
|
+
const out: ImageSource;
|
|
6
6
|
export default out;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
declare module '*&responsive' {
|
|
10
|
-
const out:
|
|
10
|
+
const out: ImageSource;
|
|
11
11
|
export default out;
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -57,7 +57,7 @@ declare module '*?preset=savedata' {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
declare module '*&preset=savedata' {
|
|
60
|
-
const out:
|
|
60
|
+
const out: ImageSource;
|
|
61
61
|
export default out;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration type definitions for imagetools and build-time image processing
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {object} ImageMeta
|
|
7
|
+
* @property {string} src
|
|
8
|
+
* @property {number} width
|
|
9
|
+
* @property {number} height
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {ImageMeta[]} ImageSource
|
|
14
|
+
* Array of ImageMeta objects (always array format)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export default {};
|
package/dist/design/README.md
CHANGED
|
@@ -9,39 +9,109 @@ A comprehensive, responsive design system built for SvelteKit applications. This
|
|
|
9
9
|
```javascript
|
|
10
10
|
// tailwind.config.js
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
borderRadius,
|
|
12
|
+
generateTailwindThemeExtensions,
|
|
13
|
+
designTokens,
|
|
15
14
|
customUtilitiesPlugin
|
|
16
15
|
} from '@hkdigital/lib-core/design/index.js';
|
|
17
16
|
|
|
17
|
+
const themeExtensions = generateTailwindThemeExtensions(designTokens);
|
|
18
|
+
|
|
19
|
+
/** @type {import('tailwindcss').Config} \*/
|
|
18
20
|
export default {
|
|
21
|
+
// Include @hkdigital libraries in content so Tailwind processes
|
|
22
|
+
// their design system classes and components for proper styling
|
|
23
|
+
content: [
|
|
24
|
+
'./node_modules/@hkdigital/**/*.{html,js,svelte}',
|
|
25
|
+
'./src/**/*.{html,js,svelte}'
|
|
26
|
+
],
|
|
19
27
|
theme: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
fontSize,
|
|
23
|
-
borderRadius
|
|
24
|
-
}
|
|
28
|
+
// Extend Tailwind's default theme using the design system tokens
|
|
29
|
+
extend: themeExtensions
|
|
25
30
|
},
|
|
26
31
|
plugins: [
|
|
32
|
+
// Generate custom utility classes like 'type-heading-h2'
|
|
27
33
|
customUtilitiesPlugin
|
|
28
34
|
]
|
|
29
35
|
};
|
|
30
36
|
```
|
|
31
37
|
|
|
32
|
-
```
|
|
38
|
+
```html
|
|
33
39
|
<!-- +layout.svelte -->
|
|
34
40
|
<script>
|
|
35
|
-
import {
|
|
41
|
+
import { designTokens, designTokensToRootCssVars } from '@hkdigital/lib-core/design/index.js';
|
|
36
42
|
</script>
|
|
37
43
|
|
|
38
44
|
<svelte:head>
|
|
39
|
-
{@html
|
|
45
|
+
{@html designTokensToRootCssVars(designTokens)}
|
|
40
46
|
</svelte:head>
|
|
41
47
|
|
|
42
48
|
{@render children()}
|
|
43
49
|
```
|
|
44
50
|
|
|
51
|
+
## Using Design System Classes in External CSS
|
|
52
|
+
|
|
53
|
+
When using design system utilities like `p-16up`, `bg-surface-300`, or `border-primary-500` in external CSS files (loaded via `<style src="./style.css"></style>`), you **must** include the `@reference` directive at the top of your CSS file.
|
|
54
|
+
|
|
55
|
+
**SVELTE preprocess**
|
|
56
|
+
You need svelte preprocess to process external CSS files in your svelte files!
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
<div data-page>
|
|
60
|
+
<p>Hello there!</p>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<style src="./style.css"></style>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### ✅ Correct Usage
|
|
67
|
+
|
|
68
|
+
```css
|
|
69
|
+
/* style.css */
|
|
70
|
+
@reference '../../app.css';
|
|
71
|
+
|
|
72
|
+
[data-page] {
|
|
73
|
+
& .my-component {
|
|
74
|
+
@apply p-16up bg-surface-300 border border-primary-500;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### ❌ Common Mistake
|
|
80
|
+
|
|
81
|
+
```css
|
|
82
|
+
/* style.css - MISSING @reference directive */
|
|
83
|
+
[data-page] {
|
|
84
|
+
& .my-component {
|
|
85
|
+
@apply p-16up bg-surface-300; /* ERROR: Cannot apply unknown utility class */
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Path Resolution
|
|
91
|
+
|
|
92
|
+
The `@reference` path must be relative to your CSS file's location:
|
|
93
|
+
|
|
94
|
+
E.g. `/src/routes/examples/style.css` → `@reference '../../app.css'`
|
|
95
|
+
|
|
96
|
+
```svelte
|
|
97
|
+
<style>
|
|
98
|
+
[data-page] {
|
|
99
|
+
& .my-component {
|
|
100
|
+
@apply p-16up bg-surface-300 border border-primary-500;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Troubleshooting
|
|
107
|
+
|
|
108
|
+
If you see errors like:
|
|
109
|
+
- `Cannot apply unknown utility class 'p-16up'`
|
|
110
|
+
- `Cannot apply unknown utility class 'bg-surface-300'`
|
|
111
|
+
- `Are you using CSS modules or similar and missing @reference?`
|
|
112
|
+
|
|
113
|
+
**Solution**: Add `@reference` directive with the correct relative path to your `app.css` file.
|
|
114
|
+
|
|
45
115
|
## Core Concepts
|
|
46
116
|
|
|
47
117
|
### Responsive Scaling System
|
|
@@ -162,6 +232,9 @@ Available for all text point sizes: `1ut/bt/ht`, `2ut/bt/ht`, `4ut/bt/ht`, `6ut/
|
|
|
162
232
|
|
|
163
233
|
**Auto Contrast**: Each color includes automatic contrast colors for accessibility. Use `text-{color}-contrast-{shade}` for optimal readability.
|
|
164
234
|
|
|
235
|
+
**Skeleton**
|
|
236
|
+
This library is based on both Tailwind and Skeleton. See [Skeleton Design Colors](https://www.skeleton.dev/docs/design/colors).
|
|
237
|
+
|
|
165
238
|
## Component Styling
|
|
166
239
|
|
|
167
240
|
Components use `data-` attributes with CSS custom properties:
|
|
@@ -185,7 +258,7 @@ import {
|
|
|
185
258
|
getRootCssDesignWidth,
|
|
186
259
|
getRootCssDesignHeight,
|
|
187
260
|
getAllRootScalingVars
|
|
188
|
-
} from '@hkdigital/lib-core/design';
|
|
261
|
+
} from '@hkdigital/lib-core/design/index.js';
|
|
189
262
|
|
|
190
263
|
// Get current design dimensions
|
|
191
264
|
const designWidth = getRootCssDesignWidth(); // 1024
|
|
@@ -199,7 +272,7 @@ const scales = getAllRootScalingVars();
|
|
|
199
272
|
### Clamp Utilities
|
|
200
273
|
|
|
201
274
|
```javascript
|
|
202
|
-
import { clamp, getClampParams } from '@hkdigital/lib-core/design';
|
|
275
|
+
import { clamp, getClampParams } from '@hkdigital/lib-core/design/index.js';
|
|
203
276
|
|
|
204
277
|
// Mathematical clamp function
|
|
205
278
|
const value = clamp(0.5, 0.3, 2.0); // Returns 0.5 (clamped between 0.5 and 2.0)
|
|
@@ -212,7 +285,7 @@ const params = getClampParams('scale-ui');
|
|
|
212
285
|
### Component State Classes
|
|
213
286
|
|
|
214
287
|
```javascript
|
|
215
|
-
import { toStateClasses } from '@hkdigital/lib-core/design';
|
|
288
|
+
import { toStateClasses } from '@hkdigital/lib-core/design/index.js';
|
|
216
289
|
|
|
217
290
|
// Generate state classes from object
|
|
218
291
|
const classes = toStateClasses({
|
|
@@ -236,10 +309,10 @@ const classes = toStateClasses({
|
|
|
236
309
|
#### Viewport-Based Scaling
|
|
237
310
|
|
|
238
311
|
```javascript
|
|
239
|
-
import { enableScalingUI } from '@hkdigital/lib-core/design';
|
|
312
|
+
import { enableScalingUI, designTokens } from '@hkdigital/lib-core/design/index.js';
|
|
240
313
|
|
|
241
314
|
// Enable automatic viewport scaling
|
|
242
|
-
const cleanup = enableScalingUI(DESIGN, CLAMPING);
|
|
315
|
+
const cleanup = enableScalingUI(designTokens.DESIGN, designTokens.CLAMPING);
|
|
243
316
|
|
|
244
317
|
// Call cleanup when component is destroyed
|
|
245
318
|
onDestroy(cleanup);
|
|
@@ -248,23 +321,23 @@ onDestroy(cleanup);
|
|
|
248
321
|
#### Container-Based Scaling
|
|
249
322
|
|
|
250
323
|
```javascript
|
|
251
|
-
import { enableContainerScaling } from '@hkdigital/lib-core/design';
|
|
324
|
+
import { enableContainerScaling, designTokens } from '@hkdigital/lib-core/design/index.js';
|
|
252
325
|
|
|
253
326
|
let containerElement;
|
|
254
327
|
|
|
255
328
|
// Enable scaling for specific container
|
|
256
329
|
const cleanup = enableContainerScaling({
|
|
257
330
|
container: containerElement,
|
|
258
|
-
design: DESIGN,
|
|
259
|
-
clamping: CLAMPING,
|
|
331
|
+
design: designTokens.DESIGN,
|
|
332
|
+
clamping: designTokens.CLAMPING,
|
|
260
333
|
useResizeObserver: true
|
|
261
334
|
});
|
|
262
335
|
|
|
263
336
|
// Optional custom dimension getter
|
|
264
337
|
const cleanupCustom = enableContainerScaling({
|
|
265
338
|
container: containerElement,
|
|
266
|
-
design: DESIGN,
|
|
267
|
-
clamping: CLAMPING,
|
|
339
|
+
design: designTokens.DESIGN,
|
|
340
|
+
clamping: designTokens.CLAMPING,
|
|
268
341
|
getDimensions: () => ({ width: 800, height: 600 })
|
|
269
342
|
});
|
|
270
343
|
```
|
|
@@ -273,7 +346,7 @@ const cleanupCustom = enableContainerScaling({
|
|
|
273
346
|
<!-- Svelte component example -->
|
|
274
347
|
<script>
|
|
275
348
|
import { onMount, onDestroy } from 'svelte';
|
|
276
|
-
import { enableContainerScaling,
|
|
349
|
+
import { enableContainerScaling, designTokens } from '@hkdigital/lib-core/design/index.js';
|
|
277
350
|
|
|
278
351
|
let containerElement;
|
|
279
352
|
let cleanup;
|
|
@@ -281,8 +354,8 @@ const cleanupCustom = enableContainerScaling({
|
|
|
281
354
|
onMount(() => {
|
|
282
355
|
cleanup = enableContainerScaling({
|
|
283
356
|
container: containerElement,
|
|
284
|
-
design: DESIGN,
|
|
285
|
-
clamping: CLAMPING
|
|
357
|
+
design: designTokens.DESIGN,
|
|
358
|
+
clamping: designTokens.CLAMPING
|
|
286
359
|
});
|
|
287
360
|
});
|
|
288
361
|
|
|
@@ -302,59 +375,107 @@ const cleanupCustom = enableContainerScaling({
|
|
|
302
375
|
### Custom Design Configuration
|
|
303
376
|
|
|
304
377
|
```javascript
|
|
305
|
-
// your-project/src/lib/design/design-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
378
|
+
// your-project/src/lib/design/design-tokens.js
|
|
379
|
+
export const designTokens = {
|
|
380
|
+
DESIGN: {
|
|
381
|
+
width: 1440,
|
|
382
|
+
height: 900
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
CLAMPING: {
|
|
386
|
+
ui: { min: 0.4, max: 1.8 },
|
|
387
|
+
textBase: { min: 0.8, max: 1.4 },
|
|
388
|
+
textHeading: { min: 0.8, max: 2.0 },
|
|
389
|
+
textUi: { min: 0.6, max: 1.2 }
|
|
390
|
+
},
|
|
316
391
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
392
|
+
TEXT_POINT_SIZES: [4, 8, 12, 16, 20, 24, 32],
|
|
393
|
+
VIEWPORT_POINT_SIZES: [10, 20, 30, 40, 50, 100, 200],
|
|
394
|
+
|
|
395
|
+
TEXT_BASE_SIZES: {
|
|
396
|
+
sm: { size: 12, lineHeight: 1.4 },
|
|
397
|
+
md: { size: 16, lineHeight: 1.4 },
|
|
398
|
+
lg: { size: 20, lineHeight: 1.4 }
|
|
399
|
+
},
|
|
400
|
+
|
|
401
|
+
TEXT_HEADING_SIZES: {
|
|
402
|
+
h1: { size: 36, lineHeight: 1.2 },
|
|
403
|
+
h2: { size: 30, lineHeight: 1.2 },
|
|
404
|
+
h3: { size: 26, lineHeight: 1.2 }
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
TEXT_UI_SIZES: {
|
|
408
|
+
sm: { size: 12, lineHeight: 1.2 },
|
|
409
|
+
md: { size: 14, lineHeight: 1.2 },
|
|
410
|
+
lg: { size: 16, lineHeight: 1.2 }
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
RADIUS_SIZES: {
|
|
414
|
+
none: '0px',
|
|
415
|
+
sm: { size: 8 },
|
|
416
|
+
md: { size: 16 },
|
|
417
|
+
lg: { size: 24 },
|
|
418
|
+
full: '9999px'
|
|
419
|
+
},
|
|
420
|
+
|
|
421
|
+
BORDER_WIDTH_SIZES: {
|
|
422
|
+
thin: { size: 1 },
|
|
423
|
+
normal: { size: 2 },
|
|
424
|
+
thick: { size: 3 }
|
|
425
|
+
},
|
|
426
|
+
|
|
427
|
+
STROKE_WIDTH_SIZES: {
|
|
428
|
+
thin: { size: 1 },
|
|
429
|
+
normal: { size: 2 },
|
|
430
|
+
thick: { size: 3 }
|
|
431
|
+
}
|
|
322
432
|
};
|
|
323
433
|
|
|
324
|
-
//
|
|
325
|
-
|
|
326
|
-
|
|
434
|
+
// your-project/tailwind.config.js
|
|
435
|
+
import { generateTailwindThemeExtensions, customUtilitiesPlugin } from '@hkdigital/lib-core/design/index.js';
|
|
436
|
+
import { designTokens } from './src/lib/design/design-tokens.js';
|
|
437
|
+
|
|
438
|
+
const themeExtensions = generateTailwindThemeExtensions(designTokens);
|
|
439
|
+
|
|
440
|
+
export default {
|
|
441
|
+
theme: {
|
|
442
|
+
extend: themeExtensions
|
|
443
|
+
},
|
|
444
|
+
plugins: [customUtilitiesPlugin]
|
|
445
|
+
};
|
|
327
446
|
```
|
|
328
447
|
|
|
329
448
|
### Available Generator Functions
|
|
330
449
|
|
|
450
|
+
Individual generator functions are available for advanced customization:
|
|
451
|
+
|
|
331
452
|
```javascript
|
|
332
453
|
import {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
454
|
+
generateTailwindThemeExtensions, // Complete theme extension generator
|
|
455
|
+
generateTextBasedSpacing, // ut/bt/ht spacing units
|
|
456
|
+
generateViewportBasedSpacing, // up/wp/hp spacing units
|
|
457
|
+
generateTextStyles, // Complete typography styles
|
|
458
|
+
generateBorderRadiusStyles, // Border radius with scaling
|
|
459
|
+
generateWidthStyles // Border/stroke width with scaling
|
|
460
|
+
} from '@hkdigital/lib-core/design/index.js';
|
|
461
|
+
|
|
462
|
+
// Example: Generate only spacing for a custom configuration
|
|
463
|
+
const customSpacing = generateTextBasedSpacing([4, 8, 12, 16, 24]);
|
|
339
464
|
```
|
|
340
465
|
|
|
341
|
-
###
|
|
466
|
+
### Default Design Tokens
|
|
342
467
|
|
|
343
|
-
|
|
468
|
+
The default design tokens are available for reference or as a starting point:
|
|
344
469
|
|
|
345
470
|
```javascript
|
|
346
|
-
import {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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';
|
|
471
|
+
import { designTokens } from '@hkdigital/lib-core/design/index.js';
|
|
472
|
+
|
|
473
|
+
console.log(designTokens.DESIGN); // { width: 1024, height: 768 }
|
|
474
|
+
console.log(designTokens.CLAMPING); // Min/max scale bounds
|
|
475
|
+
console.log(designTokens.TEXT_POINT_SIZES); // [1, 2, 4, 6, 8, 10, ...]
|
|
476
|
+
console.log(designTokens.VIEWPORT_POINT_SIZES); // [1, 2, 4, 5, 6, 10, ...]
|
|
477
|
+
console.log(designTokens.TEXT_BASE_SIZES); // { sm: {...}, md: {...}, lg: {...} }
|
|
478
|
+
// ... and all other token configurations
|
|
358
479
|
```
|
|
359
480
|
|
|
360
481
|
## Best practices
|
|
@@ -393,11 +514,35 @@ If migrating from the old structure:
|
|
|
393
514
|
|
|
394
515
|
```javascript
|
|
395
516
|
// OLD
|
|
396
|
-
import {
|
|
397
|
-
|
|
517
|
+
import {
|
|
518
|
+
spacing,
|
|
519
|
+
fontSize,
|
|
520
|
+
borderRadius,
|
|
521
|
+
customUtilitiesPlugin
|
|
522
|
+
} from '@hkdigital/lib-core/design/index.js';
|
|
523
|
+
|
|
524
|
+
export default {
|
|
525
|
+
theme: {
|
|
526
|
+
extend: { spacing, fontSize, borderRadius }
|
|
527
|
+
},
|
|
528
|
+
plugins: [customUtilitiesPlugin]
|
|
529
|
+
};
|
|
398
530
|
|
|
399
531
|
// NEW
|
|
400
|
-
import {
|
|
532
|
+
import {
|
|
533
|
+
generateTailwindThemeExtensions,
|
|
534
|
+
designTokens,
|
|
535
|
+
customUtilitiesPlugin
|
|
536
|
+
} from '@hkdigital/lib-core/design/index.js';
|
|
537
|
+
|
|
538
|
+
const themeExtensions = generateTailwindThemeExtensions(designTokens);
|
|
539
|
+
|
|
540
|
+
export default {
|
|
541
|
+
theme: {
|
|
542
|
+
extend: themeExtensions
|
|
543
|
+
},
|
|
544
|
+
plugins: [customUtilitiesPlugin]
|
|
545
|
+
};
|
|
401
546
|
```
|
|
402
547
|
|
|
403
548
|
---
|