feat: inline SVG icons and small UI pieces
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c5ae5484a8
commit
08b48e6415
|
|
@ -0,0 +1,66 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { BuildingType } from '~/types/game'
|
||||||
|
|
||||||
|
defineProps<{ type: BuildingType }>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- Line glyphs in currentColor, one per building type. Sprites per level come in M7. -->
|
||||||
|
<template>
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1.7"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
class="shrink-0"
|
||||||
|
>
|
||||||
|
<g v-if="type === 'headquarters'">
|
||||||
|
<path d="M3 21h18" />
|
||||||
|
<path d="M5 21V11h14v10" />
|
||||||
|
<path d="M3 11l9-6 9 6" />
|
||||||
|
<path d="M10 21v-5h4v5" />
|
||||||
|
<path d="M12 5V2l3 1-3 1" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="type === 'storage'">
|
||||||
|
<rect x="4" y="5" width="16" height="15" rx="1.5" />
|
||||||
|
<path d="M4 10h16M4 15h16" />
|
||||||
|
<path d="M8 5v15M16 5v15" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="type === 'farm'">
|
||||||
|
<path d="M12 21V8" />
|
||||||
|
<path d="M12 8c-3 0-4-2-4-4 2 0 4 1 4 4zM12 8c3 0 4-2 4-4-2 0-4 1-4 4z" />
|
||||||
|
<path d="M12 13c-3 0-4-2-4-4 2 0 4 1 4 4zM12 13c3 0 4-2 4-4-2 0-4 1-4 4z" />
|
||||||
|
<path d="M12 18c-3 0-4-2-4-4 2 0 4 1 4 4zM12 18c3 0 4-2 4-4-2 0-4 1-4 4z" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="type === 'timber_camp'">
|
||||||
|
<path d="M12 3l5.5 7H15l4 6H5l4-6H6.5z" />
|
||||||
|
<path d="M12 16v5" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="type === 'clay_pit'">
|
||||||
|
<rect x="3" y="14" width="8" height="5" rx="0.6" />
|
||||||
|
<rect x="13" y="14" width="8" height="5" rx="0.6" />
|
||||||
|
<rect x="8" y="8" width="8" height="5" rx="0.6" />
|
||||||
|
<path d="M2 21h20" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="type === 'iron_mine'">
|
||||||
|
<path d="M5 19L15 9" />
|
||||||
|
<path d="M10 5.5c3.5-1.5 7-.5 9 1.5 2 2 3 5.5 1.5 9-1-3-2.5-5-4.5-7S13 6.5 10 5.5z" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="type === 'hiding_place'">
|
||||||
|
<path d="M3 20c0-8 4-14 9-14s9 6 9 14" />
|
||||||
|
<path d="M8 20c0-4 1.8-7 4-7s4 3 4 7" />
|
||||||
|
<path d="M2 20h20" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="type === 'wall'">
|
||||||
|
<path d="M3 20V8h3v3h3V8h3v3h3V8h3v3h3V8v12z" />
|
||||||
|
<path d="M3 15.5h18M9 15.5V20M15 15.5V20M6 11v4.5M12 11v4.5M18 11v4.5" />
|
||||||
|
</g>
|
||||||
|
<g v-else>
|
||||||
|
<path d="M6 21V3" />
|
||||||
|
<path d="M6 4h11l-2.5 4L17 12H6" />
|
||||||
|
<path d="M3 21h6" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { BuildingType } from '~/types/game'
|
||||||
|
|
||||||
|
defineProps<{ type: BuildingType }>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- The building glyph on its coloured square, for lists and the queue. -->
|
||||||
|
<template>
|
||||||
|
<span class="grid shrink-0 place-items-center rounded-lg border" :style="buildingTileStyle(type)">
|
||||||
|
<IconBuilding :type="type" class="size-[60%]" />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { Resource } from '~/types/game'
|
||||||
|
|
||||||
|
defineProps<{ resource: Resource }>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- Small filled glyphs in each resource's own colours. -->
|
||||||
|
<template>
|
||||||
|
<svg viewBox="0 0 24 24" aria-hidden="true" class="shrink-0">
|
||||||
|
<g v-if="resource === 'wood'">
|
||||||
|
<rect x="2.5" y="12" width="17" height="7" rx="3.5" fill="#9a6232" />
|
||||||
|
<circle cx="19" cy="15.5" r="3.5" fill="#e7c08f" stroke="#9a6232" stroke-width="1.2" />
|
||||||
|
<circle cx="19" cy="15.5" r="1.3" fill="none" stroke="#b98450" stroke-width="0.8" />
|
||||||
|
<rect x="5.5" y="5" width="13" height="7" rx="3.5" fill="#7d4f24" />
|
||||||
|
<circle cx="18" cy="8.5" r="3.5" fill="#e7c08f" stroke="#7d4f24" stroke-width="1.2" />
|
||||||
|
<circle cx="18" cy="8.5" r="1.3" fill="none" stroke="#b98450" stroke-width="0.8" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="resource === 'clay'">
|
||||||
|
<rect x="2" y="13" width="9.5" height="6.5" rx="1" fill="#c25e35" />
|
||||||
|
<rect x="12.5" y="13" width="9.5" height="6.5" rx="1" fill="#a94d29" />
|
||||||
|
<rect x="7" y="5.5" width="10" height="6.5" rx="1" fill="#d97a4d" />
|
||||||
|
<path d="M3 15h7.5M13.5 15H21M8 7.5h8" stroke="#f3b393" stroke-width="0.9" stroke-linecap="round" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="resource === 'iron'">
|
||||||
|
<path d="M5.5 9h13l3.5 9H2z" fill="#6b7787" />
|
||||||
|
<path d="M5.5 9h13l-1.6 3.4H7.1z" fill="#aab5c3" />
|
||||||
|
<path d="M8 14.5h8" stroke="#8d99a8" stroke-width="1" stroke-linecap="round" />
|
||||||
|
</g>
|
||||||
|
<g v-else>
|
||||||
|
<path d="M12 22V7.5" stroke="#9a6a10" stroke-width="1.6" stroke-linecap="round" />
|
||||||
|
<ellipse cx="12" cy="4.6" rx="1.8" ry="2.8" fill="#e8b10f" />
|
||||||
|
<ellipse cx="9.3" cy="9.6" rx="1.8" ry="2.8" transform="rotate(-32 9.3 9.6)" fill="#d39b08" />
|
||||||
|
<ellipse cx="14.7" cy="9.6" rx="1.8" ry="2.8" transform="rotate(32 14.7 9.6)" fill="#d39b08" />
|
||||||
|
<ellipse cx="9.3" cy="14.4" rx="1.8" ry="2.8" transform="rotate(-32 9.3 14.4)" fill="#c08a06" />
|
||||||
|
<ellipse cx="14.7" cy="14.4" rx="1.8" ry="2.8" transform="rotate(32 14.7 14.4)" fill="#c08a06" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
export type UiIconName = 'close' | 'clock' | 'hammer' | 'up' | 'minus' | 'plus' | 'pin' | 'users' | 'globe' | 'logout'
|
||||||
|
|
||||||
|
defineProps<{ name: UiIconName }>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- Interface glyphs in currentColor. -->
|
||||||
|
<template>
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
class="shrink-0"
|
||||||
|
>
|
||||||
|
<path v-if="name === 'close'" d="M6 6l12 12M18 6L6 18" />
|
||||||
|
<g v-else-if="name === 'clock'">
|
||||||
|
<circle cx="12" cy="12" r="9" />
|
||||||
|
<path d="M12 7v5l3 2" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="name === 'hammer'">
|
||||||
|
<path d="M14 7l-9.5 9.5a1.8 1.8 0 0 0 2.5 2.5L16.5 9.5" />
|
||||||
|
<path d="M12.5 5.5l3-3 6 6-3 3z" />
|
||||||
|
</g>
|
||||||
|
<path v-else-if="name === 'up'" d="M12 19V5M6 11l6-6 6 6" />
|
||||||
|
<path v-else-if="name === 'minus'" d="M6 12h12" />
|
||||||
|
<path v-else-if="name === 'plus'" d="M12 6v12M6 12h12" />
|
||||||
|
<g v-else-if="name === 'pin'">
|
||||||
|
<path d="M12 21s-6-5.5-6-11a6 6 0 0 1 12 0c0 5.5-6 11-6 11z" />
|
||||||
|
<circle cx="12" cy="10" r="2" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="name === 'users'">
|
||||||
|
<circle cx="9" cy="8" r="3.5" />
|
||||||
|
<path d="M2.5 20c.5-3.5 3-5.5 6.5-5.5s6 2 6.5 5.5" />
|
||||||
|
<path d="M16 4.5a3.5 3.5 0 0 1 0 7M18 14.5c2 .6 3.2 2.5 3.5 5.5" />
|
||||||
|
</g>
|
||||||
|
<g v-else-if="name === 'globe'">
|
||||||
|
<circle cx="12" cy="12" r="9" />
|
||||||
|
<path d="M3 12h18M12 3c2.5 2.7 3.8 5.7 3.8 9s-1.3 6.3-3.8 9c-2.5-2.7-3.8-5.7-3.8-9S9.5 5.7 12 3z" />
|
||||||
|
</g>
|
||||||
|
<g v-else>
|
||||||
|
<path d="M15 4h3a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-3" />
|
||||||
|
<path d="M10 16l-4-4 4-4M6 12h10" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
const props = withDefaults(defineProps<{ value: number; tone?: 'amber' | 'emerald' | 'rose' | 'sky' }>(), {
|
||||||
|
tone: 'amber',
|
||||||
|
})
|
||||||
|
|
||||||
|
const fill = {
|
||||||
|
amber: 'bg-amber-500',
|
||||||
|
emerald: 'bg-emerald-500',
|
||||||
|
rose: 'bg-rose-500',
|
||||||
|
sky: 'bg-sky-500',
|
||||||
|
}
|
||||||
|
|
||||||
|
const width = computed(() => `${Math.round(Math.min(1, Math.max(0, props.value)) * 100)}%`)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- A thin fill bar, 0..1. -->
|
||||||
|
<template>
|
||||||
|
<div class="h-1.5 w-full overflow-hidden rounded-full bg-parchment-200">
|
||||||
|
<div class="h-full rounded-full transition-[width] duration-300" :class="fill[tone]" :style="{ width }" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { Cost, Resources } from '~/types/game'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
cost: Cost
|
||||||
|
/** Projected stock; amounts the village lacks show in red. */
|
||||||
|
have?: Resources | null
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const list = ['wood', 'clay', 'iron'] as const
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<span class="inline-flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs tabular-nums">
|
||||||
|
<span
|
||||||
|
v-for="r in list"
|
||||||
|
:key="r"
|
||||||
|
class="inline-flex items-center gap-1"
|
||||||
|
:class="have && have[r] < cost[r] ? 'font-semibold text-rose-700' : 'text-ink-700'"
|
||||||
|
:title="$t(`resources.${r}`)"
|
||||||
|
>
|
||||||
|
<IconResource :resource="r" class="size-4" />
|
||||||
|
{{ cost[r] }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import type { BuildingType } from '~/types/game'
|
||||||
|
|
||||||
|
/** Tile colours per building type: a soft fill and a darker line for border and glyph. */
|
||||||
|
export const BUILDING_COLORS: Record<BuildingType, { fill: string; line: string }> = {
|
||||||
|
headquarters: { fill: '#f6e3bf', line: '#a8661b' },
|
||||||
|
storage: { fill: '#ece0cb', line: '#80603f' },
|
||||||
|
farm: { fill: '#eef2cf', line: '#76892a' },
|
||||||
|
timber_camp: { fill: '#dfecd5', line: '#3f7a37' },
|
||||||
|
clay_pit: { fill: '#f6dccd', line: '#b0502a' },
|
||||||
|
iron_mine: { fill: '#e3e7ed', line: '#55606f' },
|
||||||
|
hiding_place: { fill: '#ebe3f2', line: '#6e5390' },
|
||||||
|
wall: { fill: '#e7e3dc', line: '#6a6257' },
|
||||||
|
rally_point: { fill: '#f6dfdf', line: '#a63a3a' },
|
||||||
|
}
|
||||||
|
|
||||||
|
export const buildingTileStyle = (type: BuildingType) => ({
|
||||||
|
backgroundColor: BUILDING_COLORS[type].fill,
|
||||||
|
borderColor: BUILDING_COLORS[type].line,
|
||||||
|
color: BUILDING_COLORS[type].line,
|
||||||
|
})
|
||||||
Loading…
Reference in New Issue