@emberbox/ui 0.6.1 → 0.7.0

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": "@emberbox/ui",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Shared look and building blocks of the Emberbox tools, built on Nuxt UI.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Tactical symbols after DIN 14034-6 and the recommendations of the BBK for DV 102. The drawings
3
- * follow the system of the recommendations (basic form, size mark, writing) without copying their
4
- * artwork.
2
+ * Tactical symbols after the recommendations "Taktische Zeichen im Bevölkerungsschutz" of the BBK
3
+ * (2024, for FwDV 102 / DV 102). The drawings follow the system of the recommendations (basic form,
4
+ * size mark, writing) without copying their artwork.
5
5
  *
6
6
  * A symbol is built as a tree of SVG elements: `TacticalSymbol` renders the tree as Vue nodes in
7
7
  * the page, and `renderSvg` writes it as an escaped string for map icons. Every symbol is drawn on
@@ -14,10 +14,13 @@
14
14
  /** The organisation a unit belongs to, which sets its colours. */
15
15
  export type Organisation = 'fire' | 'medical'
16
16
 
17
- /** The basic form of a unit's symbol. */
18
- export type SymbolShape = 'vehicle' | 'container' | 'trailer' | 'boat' | 'unit'
17
+ /**
18
+ * The basic form of a unit's symbol. `squad` is not part of the recommendations: a compact,
19
+ * rounded form that sets a dismounted squad apart from vehicles on a busy map.
20
+ */
21
+ export type SymbolShape = 'vehicle' | 'container' | 'trailer' | 'boat' | 'unit' | 'squad'
19
22
 
20
- /** The size of a unit, shown by dots or a bar above its symbol. */
23
+ /** The size of a tactical unit, shown by dots above its symbol: Trupp, Staffel, Gruppe, Zug. */
21
24
  export type UnitSize = 'squad' | 'section' | 'group' | 'platoon'
22
25
 
23
26
  /** Marks of places and events of an incident. */
@@ -57,6 +60,7 @@ const RED = 'var(--color-signal-500)'
57
60
  const WHITE = 'white'
58
61
  const STROKE = 3
59
62
  const MAX_TEXT_WIDTH = 86
63
+ const SQUAD_TEXT_WIDTH = 62
60
64
 
61
65
  interface Colours {
62
66
  fill: string
@@ -108,10 +112,10 @@ export function renderSvg(node: SvgElement): string {
108
112
  }
109
113
 
110
114
  /** The writing inside a symbol, squeezed to fit when it is long. */
111
- function label(text: string, x: number, y: number, colour: string): SvgElement {
115
+ function label(text: string, x: number, y: number, colour: string, maxWidth = MAX_TEXT_WIDTH): SvgElement {
112
116
  const size = text.length > 8 ? 17 : 22
113
- const squeeze: Attributes = text.length * size * 0.5 > MAX_TEXT_WIDTH
114
- ? {textLength: MAX_TEXT_WIDTH, lengthAdjust: 'spacingAndGlyphs'}
117
+ const squeeze: Attributes = text.length * size * 0.5 > maxWidth
118
+ ? {textLength: maxWidth, lengthAdjust: 'spacingAndGlyphs'}
115
119
  : {}
116
120
  return {
117
121
  tag: 'text',
@@ -124,13 +128,18 @@ function label(text: string, x: number, y: number, colour: string): SvgElement {
124
128
  }
125
129
  }
126
130
 
127
- /** The dots or bar above a unit that tell its size. */
131
+ /** Where the dots of each unit size sit above the symbol: one, two stacked, two apart, three in a row. */
132
+ const SIZE_DOTS: Record<UnitSize, [number, number][]> = {
133
+ squad: [[60, 6]],
134
+ section: [[60, 3], [60, 10]],
135
+ group: [[52, 6], [68, 6]],
136
+ platoon: [[50, 6], [60, 6], [70, 6]],
137
+ }
138
+
139
+ /** The dots above a unit that tell its size, after the BBK recommendations of 2010 and 2024 alike. */
128
140
  function sizeMark(size: UnitSize | undefined, colour: string): SvgElement[] {
129
141
  if (!size) return []
130
- if (size === 'platoon') return [element('line', {x1: 60, y1: 1, x2: 60, y2: 11, ...stroked(colour)})]
131
- const count = {squad: 1, section: 2, group: 3}[size]
132
- return Array.from({length: count}, (_, index) =>
133
- element('circle', {cx: 60 + (index - (count - 1) / 2) * 10, cy: 6, r: 3.5, fill: colour}))
142
+ return SIZE_DOTS[size].map(([cx, cy]) => element('circle', {cx, cy, r: 3, fill: colour}))
134
143
  }
135
144
 
136
145
  /** The basic form of a unit's symbol, with the writing inside. */
@@ -157,10 +166,12 @@ function body(shape: SymbolShape, colour: Colours, text: string): SvgElement[] {
157
166
  return [element('path', {d: 'M10 16 H110 L100 56 Q60 72 20 56 Z', ...outline}), label(text, 60, 36, colour.text)]
158
167
  case 'unit':
159
168
  return [element('rect', {x: 10, y: 16, width: 100, height: 52, ...outline}), label(text, 60, 42, colour.text)]
169
+ case 'squad':
170
+ return [element('rect', {x: 24, y: 18, width: 72, height: 46, rx: 14, ...outline}), label(text, 60, 41, colour.text, SQUAD_TEXT_WIDTH)]
160
171
  }
161
172
  }
162
173
 
163
- /** The symbol of a unit: a vehicle, container, trailer, boat or squad. */
174
+ /** The symbol of a unit: a vehicle, container, trailer, boat, unit or dismounted squad. */
164
175
  export function unitSymbolTree(spec: SymbolSpec): SvgElement {
165
176
  const colour = colours(spec.organisation)
166
177
  return canvas([...sizeMark(spec.size, colour.line), ...body(spec.shape, colour, spec.text)])