second to last commit hopefully final features and Ui refinements
This commit is contained in:
37
src/lib/utils/stampIcons.js
Normal file
37
src/lib/utils/stampIcons.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// --- "passport stamps" icon set ---------------------------------------------
|
||||
// Curated set of simple outline icons (lucide-style: 24x24 viewBox,
|
||||
// stroke-based, no fill) representing generic "places" - the centerpiece of
|
||||
// each passport stamp badge (see Stamp.svelte). `paths` is the inner SVG
|
||||
// markup, dropped directly into Stamp.svelte's <svg> wrapper via {@html}.
|
||||
export const STAMP_ICONS = [
|
||||
{ id: 'mountain', paths: '<path d="M3 20h18"/><path d="M5 20 11 6l4 7 2-3 3 6"/>' },
|
||||
{ id: 'building', paths: '<rect x="5" y="3" width="14" height="18" rx="1"/><path d="M9 21v-4h6v4"/><path d="M9 7h1M14 7h1M9 11h1M14 11h1"/>' },
|
||||
{ id: 'tree', paths: '<path d="M12 22v-6"/><path d="M12 2 7 10h3l-4 6h12l-4-6h3z"/>' },
|
||||
{ id: 'wave', paths: '<path d="M2 11c1.5-2 3.5-2 5 0s3.5 2 5 0 3.5-2 5 0 3.5 2 5 0"/><path d="M2 17c1.5-2 3.5-2 5 0s3.5 2 5 0 3.5-2 5 0 3.5 2 5 0"/>' },
|
||||
{ id: 'star', paths: '<path d="M12 2l2.9 6.5L22 9l-5 4.9 1.2 7.1L12 17.3 5.8 21 7 13.9 2 9l7.1-.5z"/>' },
|
||||
{ id: 'leaf', paths: '<path d="M11 20A7 7 0 0 1 4 13c0-6 7-11 13-11 0 6-2 13-6 16-1 1-2 2-2 2z"/><path d="M5 17c5-5 9-9 12-12"/>' },
|
||||
{ id: 'sun', paths: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/>' },
|
||||
{ id: 'moon', paths: '<path d="M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8z"/>' },
|
||||
{ id: 'landmark', paths: '<path d="M3 22h18"/><path d="M5 22V11M9 22V11M15 22V11M19 22V11"/><path d="M2 11 12 4l10 7z"/>' },
|
||||
{ id: 'compass', paths: '<circle cx="12" cy="12" r="9"/><path d="M15.5 8.5 13 13l-4.5 2.5L11 11z"/>' }
|
||||
];
|
||||
|
||||
// Deterministic string hash (DJB2 variant) - the same input string always
|
||||
// produces the same number, which is what lets the same place always pick
|
||||
// the same icon (see pickStampIcon below).
|
||||
function hashString(str) {
|
||||
let hash = 5381;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
hash = (hash * 33) ^ str.charCodeAt(i);
|
||||
}
|
||||
return Math.abs(hash);
|
||||
}
|
||||
|
||||
// Picks an icon for a place deterministically: "City, Country" always maps
|
||||
// to the same icon, so earning a stamp for the same city twice (hypothetically)
|
||||
// would always show the same icon - without needing to store any extra
|
||||
// city->icon mapping.
|
||||
export function pickStampIcon(city, country) {
|
||||
const index = hashString(`${city}, ${country}`) % STAMP_ICONS.length;
|
||||
return STAMP_ICONS[index];
|
||||
}
|
||||
Reference in New Issue
Block a user