@hanology/cham-browser 0.4.10 → 0.4.12

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": "@hanology/cham-browser",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "CHAM — browser-compatible parser, serializer, and site generator for Classical Han Annotated Markdown",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { computed } from 'vue'
2
3
  import type { AnnotationLayer } from '../types'
3
4
 
4
5
  const props = defineProps<{
@@ -13,7 +14,12 @@ const emit = defineEmits<{
13
14
  'update:annotationsVisible': [visible: boolean]
14
15
  }>()
15
16
 
16
- const hasLayers = () => props.layers.length > 1
17
+ // Only named layers (skip 'default' base annotations are always shown)
18
+ const toggleableLayers = computed(() =>
19
+ props.layers.filter(l => l.id !== 'default')
20
+ )
21
+
22
+ const hasLayers = () => toggleableLayers.value.length > 0
17
23
 
18
24
  function toggleAnnotations() {
19
25
  if (props.annotationsVisible) {
@@ -21,7 +27,7 @@ function toggleAnnotations() {
21
27
  if (hasLayers()) emit('update:activeIds', [])
22
28
  } else {
23
29
  emit('update:annotationsVisible', true)
24
- if (hasLayers()) emit('update:activeIds', props.layers.map(l => l.id))
30
+ if (hasLayers()) emit('update:activeIds', toggleableLayers.value.map(l => l.id))
25
31
  }
26
32
  }
27
33
 
@@ -47,16 +53,15 @@ function toggleLayer(id: string) {
47
53
  @click="toggleAnnotations"
48
54
  :title="annotationsVisible ? '隱藏注釋' : '顯示注釋'"
49
55
  >注</button>
50
- <div v-if="hasLayers() && annotationsVisible" class="ann-layers">
51
- <button
52
- v-for="layer in layers"
53
- :key="layer.id"
54
- class="ann-layer-btn"
55
- :class="{ active: activeIds.includes(layer.id) }"
56
- @click="toggleLayer(layer.id)"
57
- :title="layer.label"
58
- >{{ layer.shortLabel }}</button>
59
- </div>
56
+ <button
57
+ v-for="layer in toggleableLayers"
58
+ :key="layer.id"
59
+ v-show="annotationsVisible"
60
+ class="ann-layer-btn"
61
+ :class="{ active: activeIds.includes(layer.id) }"
62
+ @click="toggleLayer(layer.id)"
63
+ :title="layer.label"
64
+ >{{ layer.shortLabel }}</button>
60
65
  </div>
61
66
  </template>
62
67
 
@@ -65,7 +70,7 @@ function toggleLayer(id: string) {
65
70
  display: flex;
66
71
  flex-direction: column;
67
72
  gap: 6px;
68
- align-items: stretch;
73
+ align-items: center;
69
74
  }
70
75
 
71
76
  .ann-toggle {
@@ -81,9 +86,6 @@ function toggleLayer(id: string) {
81
86
  letter-spacing: 0;
82
87
  cursor: pointer;
83
88
  transition: all 0.2s;
84
- display: flex;
85
- align-items: center;
86
- justify-content: center;
87
89
  }
88
90
 
89
91
  .ann-toggle:hover {
@@ -99,14 +101,9 @@ function toggleLayer(id: string) {
99
101
  color: #fff;
100
102
  }
101
103
 
102
- .ann-layers {
103
- display: flex;
104
- flex-direction: column;
105
- gap: 4px;
106
- }
107
-
108
104
  .ann-layer-btn {
109
- padding: 5px 10px;
105
+ width: 36px;
106
+ padding: 5px 0;
110
107
  border: 1px solid var(--border);
111
108
  border-radius: 4px;
112
109
  background: none;
@@ -142,7 +139,7 @@ function toggleLayer(id: string) {
142
139
  font-size: 17px;
143
140
  }
144
141
  .ann-layer-btn {
145
- padding: 6px 12px;
142
+ width: 40px;
146
143
  font-size: 12px;
147
144
  }
148
145
  }