feather-k-demo-utils 0.0.26 → 0.0.28
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/.github/instructions/featherk-demo-integration.md +86 -0
- package/DEMO-UTILS.md +133 -0
- package/README.md +50 -22
- package/package.json +9 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Feather K Demo Integration Instructions
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
Standardize how demo projects integrate feather-k-demo-utils and FeatherK styles so each demo is consistent, version-aware, and easy to publish.
|
|
5
|
+
|
|
6
|
+
## Required Checks
|
|
7
|
+
|
|
8
|
+
1. Verify feather-k-demo-utils dependency is current
|
|
9
|
+
- Read package.json dependencies.
|
|
10
|
+
- Check latest published version from npm for feather-k-demo-utils.
|
|
11
|
+
- If package.json is behind, update dependency to latest compatible version and note the change.
|
|
12
|
+
|
|
13
|
+
2. Verify FeatherK styles dependency and CDN strategy
|
|
14
|
+
- Keep @featherk/styles in dependencies for local compatibility.
|
|
15
|
+
- In Vite config, define a FeatherK CDN URL constant using a version token, typically latest unless the demo requires a pinned version.
|
|
16
|
+
|
|
17
|
+
3. Verify publish metadata in Vite config
|
|
18
|
+
- Ensure import.meta.env.PUBLISH_DATE is defined via Vite define.
|
|
19
|
+
- If process.env is used in vite.config.ts, ensure @types/node exists in devDependencies.
|
|
20
|
+
|
|
21
|
+
4. Verify HTML stylesheet injection via Vite
|
|
22
|
+
- Prefer transformIndexHtml plugin in vite.config.ts to inject the stylesheet link into head.
|
|
23
|
+
- Keep index.html free of hardcoded FeatherK stylesheet link when using plugin injection.
|
|
24
|
+
|
|
25
|
+
5. Verify demo CSS integration
|
|
26
|
+
- Ensure main entry imports feather-k-demo-utils/styles/demo.css.
|
|
27
|
+
- Keep local scoped overrides minimal and component-focused.
|
|
28
|
+
- Comment out any global styles that may conflict with the base demo styles and report them for resolution.
|
|
29
|
+
|
|
30
|
+
6. Verify demo stats wiring
|
|
31
|
+
- Ensure App imports DemoStats from feather-k-demo-utils.
|
|
32
|
+
- Ensure version is derived from the FeatherK CDN URL using getFeatherkStylesVersionFromUrl.
|
|
33
|
+
- Ensure publish date and version are passed to DemoStats.
|
|
34
|
+
|
|
35
|
+
7. Verify Volta configuration in package.json
|
|
36
|
+
- Ensure a top-level `volta` block exists in package.json.
|
|
37
|
+
- Ensure pinned `node` is the latest active LTS release used by the repo standard.
|
|
38
|
+
- Ensure pinned `npm` is the latest stable version compatible with that Node LTS.
|
|
39
|
+
- Prefer keeping the `volta` block at the end of package.json for consistency.
|
|
40
|
+
|
|
41
|
+
## Expected Integration Pattern
|
|
42
|
+
|
|
43
|
+
1. package.json
|
|
44
|
+
- dependencies include feather-k-demo-utils and @featherk/styles
|
|
45
|
+
- devDependencies include @types/node when vite.config.ts references process.env
|
|
46
|
+
- includes a top-level `volta` block with pinned runtime tooling (`node` and `npm`)
|
|
47
|
+
- `volta.node` targets latest active Node LTS for the repo
|
|
48
|
+
- `volta.npm` targets latest npm compatible with that Node LTS
|
|
49
|
+
|
|
50
|
+
2. vite.config.ts
|
|
51
|
+
- Define FEATHERK_STYLES_CDN_URL constant
|
|
52
|
+
- Define PUBLISH_DATE via define import.meta.env.PUBLISH_DATE
|
|
53
|
+
- Add transformIndexHtml plugin that injects:
|
|
54
|
+
- tag: link
|
|
55
|
+
- rel: stylesheet
|
|
56
|
+
- href: FEATHERK_STYLES_CDN_URL
|
|
57
|
+
- injectTo: head
|
|
58
|
+
- Define import.meta.env.FEATHERK_STYLES_CDN_URL for app usage
|
|
59
|
+
|
|
60
|
+
3. index.html
|
|
61
|
+
- No hardcoded FeatherK stylesheet URL if transformIndexHtml is active
|
|
62
|
+
|
|
63
|
+
4. main.ts
|
|
64
|
+
- Import feather-k-demo-utils/styles/demo.css once at app bootstrap
|
|
65
|
+
|
|
66
|
+
5. App.vue
|
|
67
|
+
- Import DemoStats and getFeatherkStylesVersionFromUrl
|
|
68
|
+
- Compute version from import.meta.env.FEATHERK_STYLES_CDN_URL
|
|
69
|
+
- Render DemoStats with version and publish date
|
|
70
|
+
|
|
71
|
+
## Validation Steps
|
|
72
|
+
|
|
73
|
+
1. Build succeeds with no TypeScript errors.
|
|
74
|
+
2. dist index output contains injected FeatherK stylesheet link.
|
|
75
|
+
3. App displays demo stats with version and publish date.
|
|
76
|
+
4. Demo CSS classes render correctly.
|
|
77
|
+
5. Volta config exists and the pinned Node version matches project expectations.
|
|
78
|
+
6. Volta config includes pinned `node` and `npm` versions.
|
|
79
|
+
7. `volta.node` and `volta.npm` align with latest LTS + compatible npm policy.
|
|
80
|
+
|
|
81
|
+
## Notes
|
|
82
|
+
|
|
83
|
+
- Default FeatherK CDN version should usually be latest for demos unless testing a specific release.
|
|
84
|
+
- Prefer centralizing version constants in vite.config.ts rather than duplicating values across files.
|
|
85
|
+
- Keep instructions minimal, deterministic, and reusable across component demo repositories.
|
|
86
|
+
- For runtime tooling, prefer latest active Node LTS and latest compatible npm unless a repo-specific exception is documented.
|
package/DEMO-UTILS.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# feather-k-demo-utils integration notes
|
|
2
|
+
|
|
3
|
+
Demo projects should use `feather-k-demo-utils` for demo styling and a shared stats footer. Use the steps below to integrate a consuming Vite + Vue 3 app.
|
|
4
|
+
|
|
5
|
+
## 1) Install the package
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install feather-k-demo-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For TypeScript projects that need Node type definitions (for example when using `process`), also install the Node types:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install --save-dev @types/node
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 2) Import demo CSS once (app entry)
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
// src/main.ts
|
|
21
|
+
import "feather-k-demo-utils/styles/demo.css";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This brings in demo-only styling (layout, spacing, and `DemoStats` styles).
|
|
25
|
+
|
|
26
|
+
## 3) Configure required Vite env values and HTML style injection
|
|
27
|
+
|
|
28
|
+
This setup injects `FEATHERK_STYLES_CDN_URL` and `PUBLISH_DATE` using Vite `define`, and also injects a `<link rel="stylesheet">` tag into `index.html` via a Vite plugin.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// vite.config.ts
|
|
32
|
+
import { defineConfig, type Plugin } from "vite";
|
|
33
|
+
import vue from "@vitejs/plugin-vue";
|
|
34
|
+
|
|
35
|
+
const version = "latest";
|
|
36
|
+
const FEATHERK_STYLES_CDN_URL =
|
|
37
|
+
`https://cdn.jsdelivr.net/npm/@featherk/styles@${version}/dist/v8.2.0/css/featherk.css`;
|
|
38
|
+
|
|
39
|
+
const injectFeatherkStyles = (): Plugin => ({
|
|
40
|
+
name: "inject-featherk-styles",
|
|
41
|
+
transformIndexHtml() {
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
tag: "link",
|
|
45
|
+
attrs: {
|
|
46
|
+
rel: "stylesheet",
|
|
47
|
+
href: FEATHERK_STYLES_CDN_URL,
|
|
48
|
+
},
|
|
49
|
+
injectTo: "head",
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export default defineConfig({
|
|
56
|
+
plugins: [vue(), injectFeatherkStyles()],
|
|
57
|
+
define: {
|
|
58
|
+
"import.meta.env.FEATHERK_STYLES_CDN_URL": JSON.stringify(
|
|
59
|
+
FEATHERK_STYLES_CDN_URL,
|
|
60
|
+
),
|
|
61
|
+
"import.meta.env.PUBLISH_DATE": JSON.stringify(
|
|
62
|
+
process.env.PUBLISH_DATE ||
|
|
63
|
+
new Date().toLocaleString("en-US", {
|
|
64
|
+
year: "numeric",
|
|
65
|
+
month: "2-digit",
|
|
66
|
+
day: "2-digit",
|
|
67
|
+
hour: "2-digit",
|
|
68
|
+
minute: "2-digit",
|
|
69
|
+
hour12: true,
|
|
70
|
+
dayPeriod: "short",
|
|
71
|
+
}),
|
|
72
|
+
),
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Notes:
|
|
78
|
+
- The `inject-featherk-styles` plugin writes the stylesheet link into the final `index.html` `<head>`.
|
|
79
|
+
- `FEATHERK_STYLES_CDN_URL` should point at the exact `@featherk/styles` CSS you want to showcase.
|
|
80
|
+
- `PUBLISH_DATE` can be injected at build time (for CI) or defaulted as shown.
|
|
81
|
+
|
|
82
|
+
## 4) Render DemoStats in your app
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<script setup lang="ts">
|
|
86
|
+
import { computed } from "vue";
|
|
87
|
+
import { DemoStats } from "feather-k-demo-utils";
|
|
88
|
+
import { getFeatherkStylesVersionFromUrl } from "feather-k-demo-utils/utils";
|
|
89
|
+
|
|
90
|
+
const PUBLISH_DATE = import.meta.env.PUBLISH_DATE;
|
|
91
|
+
const version = computed(() => getFeatherkStylesVersionFromUrl(import.meta.env.FEATHERK_STYLES_CDN_URL),
|
|
92
|
+
);
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<template>
|
|
96
|
+
<DemoStats v-if="version" :version="version" :publishDate="PUBLISH_DATE" />
|
|
97
|
+
</template>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`DemoStats` renders the version and publish date, and links to the demo-utils README if the publish date is missing.
|
|
101
|
+
|
|
102
|
+
## 5) (Optional) Pin the dependency version
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"dependencies": {
|
|
107
|
+
"feather-k-demo-utils": "^0.0.26"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Demo Layout Structure (required for consistent utility styles)
|
|
113
|
+
|
|
114
|
+
```html
|
|
115
|
+
<!-- App.vue top level "demo-app" -->
|
|
116
|
+
<div class="demo-app">
|
|
117
|
+
<!-- each demo (if there are multiple)-->
|
|
118
|
+
<div class="featherk-demo">
|
|
119
|
+
<form class="demo-form">
|
|
120
|
+
<!-- one or more .fk-field-block rows -->
|
|
121
|
+
|
|
122
|
+
<div class="demo-actions">
|
|
123
|
+
<!-- action buttons (Clear / Submit, etc.) -->
|
|
124
|
+
</div>
|
|
125
|
+
</form>
|
|
126
|
+
|
|
127
|
+
<div class="demo-notes">
|
|
128
|
+
<!-- notes content -->
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
Keep this aligned with whichever demo-utils release you want to display.
|
package/README.md
CHANGED
|
@@ -1,33 +1,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# feather-k-demo-utils
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared demo utilities for Feather K Vue component demo repositories.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Purpose
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`feather-k-demo-utils` centralizes common demo functionality used across feather-k-<control> demo projects, including:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- Shared demo styles
|
|
10
|
+
- Shared demo UI components (such as `DemoStats`)
|
|
11
|
+
- Shared utility helpers (for example, CDN/version helpers)
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
This package is intended for internal/demo scenarios and consistency across Feather K demos, not as a general-purpose application UI library.
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
npm login
|
|
15
|
+
## What's Included
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
npm publish --access public
|
|
17
|
+
- `feather-k-demo-utils` (root exports)
|
|
18
|
+
- Demo components and top-level exports
|
|
19
|
+
- `feather-k-demo-utils/components`
|
|
20
|
+
- Component-focused exports
|
|
21
|
+
- `feather-k-demo-utils/utils`
|
|
22
|
+
- Utility helpers used by demo apps
|
|
23
|
+
- `feather-k-demo-utils/styles/demo.css`
|
|
24
|
+
- Demo-only stylesheet for shared demo layout and component styling
|
|
25
25
|
|
|
26
|
-
##
|
|
26
|
+
## Quick Usage
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Install:
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
```bash
|
|
31
|
+
npm install feather-k-demo-utils
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Import demo styles once in your app entry:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import "feather-k-demo-utils/styles/demo.css";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Import what you need:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { DemoStats } from "feather-k-demo-utils";
|
|
44
|
+
import { getFeatherkStylesVersionFromUrl } from "feather-k-demo-utils/utils";
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
For full integration steps (Vite env setup, stylesheet injection, and `DemoStats` usage), see [DEMO-UTILS.md](https://github.com/NantHealth/feather-k-demo-utils/blob/integration/DEMO-UTILS.md).
|
|
48
|
+
|
|
49
|
+
## Publishing
|
|
50
|
+
|
|
51
|
+
Package publishing is handled via npm.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm login
|
|
55
|
+
npm run build
|
|
56
|
+
npm publish
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Build-Time Publish Date
|
|
31
60
|
|
|
32
|
-
|
|
33
|
-
see [DEMO-UTILS.md](https://github.com/NantHealth/feather-k-demo-utils/blob/integration/DEMO-UTILS.md)
|
|
61
|
+
This package does not export an in-package `PUBLISH_DATE`. If a consuming demo needs publish date display, inject it at build time (for example via Vite `define`) in the consuming app.
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "feather-k-demo-utils",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.28",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.es.js",
|
|
7
7
|
"module": "lib/index.es.js",
|
|
8
8
|
"types": "lib/index.d.ts",
|
|
9
9
|
"author": "Feather K Team",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"description": "
|
|
11
|
+
"description": "Utilities for feather-k demos only",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "https://github.com/NantHealth/feather-k-demo-utils.git"
|
|
@@ -60,6 +60,8 @@
|
|
|
60
60
|
"vue-tsc": "^3.1.4"
|
|
61
61
|
},
|
|
62
62
|
"files": [
|
|
63
|
+
"DEMO-UTILS.md",
|
|
64
|
+
".github/instructions/featherk-demo-integration.md",
|
|
63
65
|
"lib/index.es.js",
|
|
64
66
|
"lib/index.d.ts",
|
|
65
67
|
"lib/index.umd.js",
|
|
@@ -67,5 +69,9 @@
|
|
|
67
69
|
"lib/utils",
|
|
68
70
|
"lib/styles",
|
|
69
71
|
"lib/*.js"
|
|
70
|
-
]
|
|
72
|
+
],
|
|
73
|
+
"volta": {
|
|
74
|
+
"node": "24.14.0",
|
|
75
|
+
"npm": "11.11.0"
|
|
76
|
+
}
|
|
71
77
|
}
|