picocrank 1.1.3 → 1.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "picocrank",
3
- "version": "1.1.3",
3
+ "version": "1.2.1",
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": {
@@ -163,6 +163,7 @@ li {
163
163
  margin: 0;
164
164
  padding: 0;
165
165
  }
166
+
166
167
  .navigation-links a,
167
168
  .supplemental-links a {
168
169
  display: flex;
@@ -189,6 +190,23 @@ li {
189
190
  margin-top: 1rem;
190
191
  }
191
192
 
193
+ @media (prefers-color-scheme: dark) {
194
+ .navigation-links a,
195
+ .supplemental-links a {
196
+ color: #f8f9fa;
197
+ }
198
+
199
+ .navigation-links a:hover,
200
+ .supplemental-links a:hover {
201
+ background: #343a40;
202
+ color: #007bff;
203
+ }
204
+
205
+ .supplemental-links {
206
+ border-top: 1px solid #444;
207
+ }
208
+ }
209
+
192
210
  @media (max-width: 768px) {
193
211
  .sidebar {
194
212
  width: 100%;
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <table class = "row-hover">
3
3
  <thead>
4
- <th v-for="(header, index) in visibleHeaders" :key="index" @click="toggleSort(header)" :class="{ sortable: header.sortable }">
5
- {{ header.label }}
4
+ <th v-for="(header, index) in visibleHeaders" :key="index" @click="toggleSort(header)" :class="{ sortable: header.sortable }" :style="{ width: header.width || 'auto' }">
5
+ {{ header.label || header.key }}
6
6
 
7
7
  <span v-if="header.sortable" style:= "width: 1.5em; display: inline-block; text-align: center;">
8
8
  <span v-if="sortBy === header.key">
@@ -16,15 +16,18 @@
16
16
  <tr v-if="pagedItems.length === 0">
17
17
  <td :colspan="visibleHeaders.length">No items found</td>
18
18
  </tr>
19
- <tr v-else v-for="(item, index) in pagedItems" :key="index">
19
+ <tr v-else v-for="(row, index) in pagedItems" :key="index">
20
20
  <td v-for="(header, index) in visibleHeaders" :key="index" :class="{ hidden: header.hidden }">
21
- <span v-if = "header.linkFunc">
22
- <router-link :to="header.linkFunc(item)" class = "link">
23
- {{ item[header.key] }}
24
- </router-link>
25
- </span>
21
+ <component
22
+ v-if="slotFor(header.key)"
23
+ :is="slotFor(header.key)"
24
+ :class="{ hidden: header.hidden }"
25
+ :row="row"
26
+ :value="row[header.key]"
27
+ :key="index"
28
+ />
26
29
  <span v-else>
27
- {{ item[header.key] }}
30
+ {{ row[header.key] }}
28
31
  </span>
29
32
  </td>
30
33
  </tr>
@@ -36,7 +39,7 @@
36
39
  </template>
37
40
 
38
41
  <script setup>
39
- import { ref, computed, onMounted, watch } from 'vue';
42
+ import { ref, computed, onMounted, watch, useSlots } from 'vue';
40
43
  import Pagination from './Pagination.vue';
41
44
 
42
45
  const sortBy = ref(null);
@@ -55,6 +58,14 @@
55
58
  },
56
59
  });
57
60
 
61
+ const slots = useSlots()
62
+
63
+ function slotFor(key) {
64
+ let s = slots[`cell-${key}`];
65
+
66
+ return s || slots.cell || null;
67
+ }
68
+
58
69
  const items = computed(() => {
59
70
  const arr = [...props.data];
60
71
 
@@ -100,10 +111,7 @@
100
111
  const totalPages = computed(() => Math.ceil(total.value / pageSize.value));
101
112
 
102
113
  const visibleHeaders = computed(() => {
103
- return props.headers.map(header => ({
104
- ...header,
105
- hidden: header.hidden === true,
106
- }));
114
+ return props.headers.filter(h => !h.hidden);
107
115
  });
108
116
 
109
117
  function toggleSort(header) {
@@ -12,6 +12,17 @@
12
12
  :data = "data"
13
13
  :headers = "headers"
14
14
  >
15
+ <template #cell-name="{ row, value }">
16
+ <router-link :to="{ name: 'ViewItem', params: { id: row.name } }">
17
+ {{ value }}
18
+ </router-link>
19
+ </template>
20
+
21
+ <template #cell-city="{ row, value }">
22
+ <span class = "subtle">
23
+ {{ value }}
24
+ </span>
25
+ </template>
15
26
  </Table>
16
27
  </Section>
17
28
  </template>
@@ -20,24 +31,16 @@
20
31
  import { ref, onMounted } from 'vue'
21
32
 
22
33
  const headers = ref([
23
- { key: "name", label: "Name", sortable: true, hidden: true, linkFunc: getLink },
24
- { key: "age", label: "Age", sortable: false, hidden: false, linkFunc: null },
25
- { key: "city", label: "City", sortable: true, hidden: false, link: null },
34
+ { key: "name", label: "Name", sortable: true, hidden: false, width: "20%" },
35
+ { key: "age", label: "Age", sortable: false },
36
+ { key: "city", label: "City", sortable: true, width: "200px" },
26
37
  ])
27
38
 
28
-
29
- function getLink(row) {
30
- return {
31
- name: "ViewItem",
32
- params: { id: row.name.toLowerCase() }
33
- }
34
- }
35
-
36
39
  const data = ref([])
37
40
 
38
41
  onMounted(() => {
39
42
  data.value = [
40
- { name: "Alice", age: 30, city: "New York" },
43
+ { name: "Alice", age: 30, city: "New York", foo: "bar" },
41
44
  { name: "Bob", age: 25, city: "Los Angeles" },
42
45
  { name: "Charlie", age: 35, city: "Chicago" },
43
46
  { name: "David", age: 28, city: "Houston" },