picocrank 1.8.7 → 1.8.9
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/workflows/pages.yml +2 -3
- package/README.md +1 -1
- package/package.json +4 -4
- package/vue/components/Sidebar.vue +76 -19
- package/vue/components/Table.vue +0 -3
- package/vue/views/App.vue +2 -2
|
@@ -24,8 +24,7 @@ jobs:
|
|
|
24
24
|
- name: Setup Node.js
|
|
25
25
|
uses: actions/setup-node@v4
|
|
26
26
|
with:
|
|
27
|
-
node-version: "
|
|
28
|
-
cache: 'npm'
|
|
27
|
+
node-version: "22"
|
|
29
28
|
|
|
30
29
|
- name: Install dependencies
|
|
31
30
|
run: npm ci
|
|
@@ -50,4 +49,4 @@ jobs:
|
|
|
50
49
|
steps:
|
|
51
50
|
- name: Deploy to GitHub Pages
|
|
52
51
|
id: deployment
|
|
53
|
-
uses: actions/deploy-pages@v4
|
|
52
|
+
uses: actions/deploy-pages@v4
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img alt = "project logo" src = "logo.png" width = "128" />
|
|
3
3
|
<h1>PicoCrank</h1>
|
|
4
4
|
|
|
5
|
-
A set of
|
|
5
|
+
A lightweight set of Vue components built on the [FemtoCrank](https://github.com/jamesread/femtocrank) global CSS theme.
|
|
6
6
|
|
|
7
7
|
[](#none)
|
|
8
8
|
[](https://discord.gg/jhYWWpNJ3v)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "picocrank",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.9",
|
|
4
4
|
"description": "A set of zero dependency Vue components built on the Femtocrank global CSS theme.",
|
|
5
5
|
"main": "vite.config.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"url": "https://github.com/jamesread/picocrank/issues"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@hugeicons/core-free-icons": "^
|
|
21
|
+
"@hugeicons/core-free-icons": "^2.0.0",
|
|
22
22
|
"@hugeicons/vue": "^1.0.3",
|
|
23
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
23
|
+
"@vitejs/plugin-vue": "^6.0.2",
|
|
24
24
|
"femtocrank": "^2.4.11",
|
|
25
25
|
"unplugin-vue-components": "^30.0.0",
|
|
26
|
-
"vite": "^7.2.
|
|
26
|
+
"vite": "^7.2.4",
|
|
27
27
|
"vue": "^3.5.24",
|
|
28
28
|
"vue-router": "^4.6.3"
|
|
29
29
|
},
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
<!-- Render separator if link is a separator -->
|
|
20
20
|
<div v-if="link.type === 'separator'" class="separator"></div>
|
|
21
21
|
<div v-else-if="link.type === 'callback'">
|
|
22
|
-
<a href="#" @click.prevent="link.callback()">
|
|
22
|
+
<a href="#" @click.prevent="handleLinkClick(() => link.callback())">
|
|
23
23
|
<HugeiconsIcon :icon="link.icon" />
|
|
24
24
|
<span>{{ link.title }}</span>
|
|
25
25
|
</a>
|
|
26
26
|
</div>
|
|
27
27
|
<div v-else-if="link.type === 'html'" v-html="link.html"></div>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
<router-link v-else v-bind="link.props || {}" :to="link.to || link.path" :class="{ active: isActive(link) }" @click="handleLinkClick()">
|
|
29
|
+
<HugeiconsIcon :icon="link.icon" />
|
|
30
|
+
<span>{{ link.title }}</span>
|
|
31
|
+
</router-link>
|
|
32
32
|
</li>
|
|
33
33
|
</ul>
|
|
34
34
|
</nav>
|
|
@@ -49,22 +49,44 @@ const navigationLinks = ref([])
|
|
|
49
49
|
const route = useRoute()
|
|
50
50
|
const router = useRouter()
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Add a router link to the sidebar navigation
|
|
54
|
+
* @param {string} link - Route name
|
|
55
|
+
* @param {string|null} altTitle - Optional alternative title
|
|
56
|
+
* @param {object} options - Additional options
|
|
57
|
+
* @param {object} options.params - Route params to pass (e.g., { id: 1 })
|
|
58
|
+
* @param {object} options.props - Props to pass to router-link (e.g., { replace: true, custom: true })
|
|
59
|
+
* @param {object|string} options.to - Override the 'to' prop (if provided, takes precedence over params)
|
|
60
|
+
*/
|
|
61
|
+
function addRouterLink(link, altTitle = null, options = {}) {
|
|
62
|
+
const foundRoute = router.getRoutes().find(r => r.name === link)
|
|
63
|
+
|
|
64
|
+
if (!foundRoute) {
|
|
65
|
+
console.warn(`Route "${link}" not found`)
|
|
66
|
+
return
|
|
67
|
+
}
|
|
54
68
|
|
|
55
|
-
const title = altTitle ||
|
|
69
|
+
const title = altTitle || foundRoute.meta?.title || foundRoute.name
|
|
56
70
|
|
|
57
|
-
if
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
71
|
+
// Determine the 'to' value: use options.to if provided, otherwise construct from params, or fall back to path
|
|
72
|
+
let toValue = foundRoute.path
|
|
73
|
+
if (options.to) {
|
|
74
|
+
toValue = options.to
|
|
75
|
+
} else if (options.params) {
|
|
76
|
+
toValue = { name: link, params: options.params }
|
|
77
|
+
}
|
|
65
78
|
|
|
66
|
-
|
|
79
|
+
const routeLink = {
|
|
80
|
+
name: link,
|
|
81
|
+
title: title,
|
|
82
|
+
path: foundRoute.path,
|
|
83
|
+
to: toValue,
|
|
84
|
+
icon: foundRoute.meta?.icon || PinIcon,
|
|
85
|
+
type: 'route',
|
|
86
|
+
props: options.props || {}
|
|
67
87
|
}
|
|
88
|
+
|
|
89
|
+
addNavigationLink(routeLink)
|
|
68
90
|
}
|
|
69
91
|
|
|
70
92
|
function addNavigationLink(link) {
|
|
@@ -145,8 +167,43 @@ function close() {
|
|
|
145
167
|
isStuck.value = false
|
|
146
168
|
}
|
|
147
169
|
|
|
148
|
-
function isActive(
|
|
149
|
-
|
|
170
|
+
function isActive(link) {
|
|
171
|
+
// If link has a 'to' object with a name, compare route name and params
|
|
172
|
+
if (link.to && typeof link.to === 'object' && link.to.name) {
|
|
173
|
+
// Compare route names first
|
|
174
|
+
if (route.name !== link.to.name) {
|
|
175
|
+
return false
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// If params are specified in the link, all specified params must match
|
|
179
|
+
if (link.to.params && Object.keys(link.to.params).length > 0) {
|
|
180
|
+
const linkParams = link.to.params
|
|
181
|
+
const routeParams = route.params
|
|
182
|
+
|
|
183
|
+
// Check if all params in link.to.params match route.params
|
|
184
|
+
for (const key in linkParams) {
|
|
185
|
+
if (String(routeParams[key]) !== String(linkParams[key])) {
|
|
186
|
+
return false
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Route name matches, and either no params specified or all params match
|
|
192
|
+
return true
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Fall back to path comparison for string paths
|
|
196
|
+
const linkPath = typeof link.to === 'string' ? link.to : link.path
|
|
197
|
+
return route.path === linkPath
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function handleLinkClick(callback = null) {
|
|
201
|
+
if (callback) {
|
|
202
|
+
callback()
|
|
203
|
+
}
|
|
204
|
+
if (!isStuck.value) {
|
|
205
|
+
close()
|
|
206
|
+
}
|
|
150
207
|
}
|
|
151
208
|
|
|
152
209
|
defineExpose({
|
package/vue/components/Table.vue
CHANGED
|
@@ -80,7 +80,6 @@
|
|
|
80
80
|
return [...items.value].sort((a, b) => {
|
|
81
81
|
const av = a[col];
|
|
82
82
|
const bv = b[col];
|
|
83
|
-
console.log("sort values", col, av, bv)
|
|
84
83
|
|
|
85
84
|
if (av === bv) return 0;
|
|
86
85
|
if (av === null || av === undefined) return 1;
|
|
@@ -123,8 +122,6 @@
|
|
|
123
122
|
sortBy.value = header.key;
|
|
124
123
|
sortDir.value = 'asc';
|
|
125
124
|
}
|
|
126
|
-
|
|
127
|
-
console.log(`Sorting by ${sortBy.value} in ${sortDir.value} order`);
|
|
128
125
|
}
|
|
129
126
|
</script>
|
|
130
127
|
|
package/vue/views/App.vue
CHANGED
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
sidebar.value.addRouterLink('TableExample')
|
|
60
60
|
sidebar.value.addRouterLink('CalendarExample')
|
|
61
61
|
sidebar.value.addSeparator('separator-1');
|
|
62
|
-
sidebar.value.addRouterLink('ViewItem', { id: 1 })
|
|
62
|
+
sidebar.value.addRouterLink('ViewItem', 'View Awesome Item', { params: { id: 1 } })
|
|
63
63
|
sidebar.value.addSeparator('separator-2');
|
|
64
|
-
sidebar.value.addCallback('
|
|
64
|
+
sidebar.value.addCallback('Callback Example', helloWorld, { icon: Pin02Icon })
|
|
65
65
|
sidebar.value.addSeparator('separator-3');
|
|
66
66
|
sidebar.value.addHtml('<h2 style = "padding: 0.75em;">Administration</h2>', { name: 'admin-heading' })
|
|
67
67
|
sidebar.value.addRouterLink('Admin')
|