From 132e2561bdeb346a23ac2009fa11b8c652f4b889 Mon Sep 17 00:00:00 2001 From: Matthew Kalinin Date: Thu, 4 Apr 2024 15:59:20 +0300 Subject: [PATCH] add fallback icon --- docs/icons.md | 1 + example/default-markers/react/index.tsx | 2 +- example/default-markers/vanilla/index.ts | 2 +- example/default-markers/vue/index.ts | 2 +- src/icons/icon-name.ts | 1 + src/icons/icons.ts | 3 +++ tools/icons/fetch-icons.ts | 4 +++- 7 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/icons.md b/docs/icons.md index 28f5b74..5bfafd7 100644 --- a/docs/icons.md +++ b/docs/icons.md @@ -37,6 +37,7 @@ | drugstores | ![drugstores](../static/icons/drugstores_24.svg) | ![drugstores](../static/icons/drugstores_14.svg) | | dry_cleaning | ![dry_cleaning](../static/icons/dry_cleaning_24.svg) | ![dry_cleaning](../static/icons/dry_cleaning_14.svg) | | equestrian | ![equestrian](../static/icons/equestrian_24.svg) | ![equestrian](../static/icons/equestrian_14.svg) | +| fallback | ![fallback](../static/icons/fallback_24.svg) | ![fallback](../static/icons/fallback_14.svg) | | fast_food | ![fast_food](../static/icons/fast_food_24.svg) | ![fast_food](../static/icons/fast_food_14.svg) | | film_studio | ![film_studio](../static/icons/film_studio_24.svg) | ![film_studio](../static/icons/film_studio_14.svg) | | fire_station | ![fire_station](../static/icons/fire_station_24.svg) | ![fire_station](../static/icons/fire_station_14.svg) | diff --git a/example/default-markers/react/index.tsx b/example/default-markers/react/index.tsx index e4df753..dd888f5 100644 --- a/example/default-markers/react/index.tsx +++ b/example/default-markers/react/index.tsx @@ -27,7 +27,7 @@ async function main() { (map = x)}> - + ); } diff --git a/example/default-markers/vanilla/index.ts b/example/default-markers/vanilla/index.ts index 9c2c602..47e0678 100644 --- a/example/default-markers/vanilla/index.ts +++ b/example/default-markers/vanilla/index.ts @@ -14,7 +14,7 @@ async function main() { map.addChild(new MMapDefaultFeaturesLayer({})); const defaultMarker = new MMapDefaultMarker({ - iconName: 'building', + iconName: 'fallback', color: 'bluebell', coordinates: MARKER_LOCATION }); diff --git a/example/default-markers/vue/index.ts b/example/default-markers/vue/index.ts index 63eece1..70b6cab 100644 --- a/example/default-markers/vue/index.ts +++ b/example/default-markers/vue/index.ts @@ -28,7 +28,7 @@ async function main() { - + ` }); app.mount('#app'); diff --git a/src/icons/icon-name.ts b/src/icons/icon-name.ts index 2e1e72a..a69b724 100644 --- a/src/icons/icon-name.ts +++ b/src/icons/icon-name.ts @@ -33,6 +33,7 @@ export type IconName = | 'drugstores' | 'dry_cleaning' | 'equestrian' + | 'fallback' | 'fast_food' | 'film_studio' | 'fire_station' diff --git a/src/icons/icons.ts b/src/icons/icons.ts index 1de3256..510abe2 100644 --- a/src/icons/icons.ts +++ b/src/icons/icons.ts @@ -57,6 +57,8 @@ import dry_cleaning_14 from '../../static/icons/dry_cleaning_14.svg'; import dry_cleaning_24 from '../../static/icons/dry_cleaning_24.svg'; import equestrian_14 from '../../static/icons/equestrian_14.svg'; import equestrian_24 from '../../static/icons/equestrian_24.svg'; +import fallback_14 from '../../static/icons/fallback_14.svg'; +import fallback_24 from '../../static/icons/fallback_24.svg'; import fast_food_14 from '../../static/icons/fast_food_14.svg'; import fast_food_24 from '../../static/icons/fast_food_24.svg'; import film_studio_14 from '../../static/icons/film_studio_14.svg'; @@ -249,6 +251,7 @@ export const icons: Icons = { drugstores: {normal: drugstores_24, small: drugstores_14}, dry_cleaning: {normal: dry_cleaning_24, small: dry_cleaning_14}, equestrian: {normal: equestrian_24, small: equestrian_14}, + fallback: {normal: fallback_24, small: fallback_14}, fast_food: {normal: fast_food_24, small: fast_food_14}, film_studio: {normal: film_studio_24, small: film_studio_14}, fire_station: {normal: fire_station_24, small: fire_station_14}, diff --git a/tools/icons/fetch-icons.ts b/tools/icons/fetch-icons.ts index deef2a8..f823ba3 100644 --- a/tools/icons/fetch-icons.ts +++ b/tools/icons/fetch-icons.ts @@ -19,6 +19,8 @@ const AVAILABLE_SIZES = [14, 24]; const REGION_CODE_REGEXP = /_([a-z]{2})_/; /** RegExp for getting the size from the component name*/ export const SIZE_REGEXP = /_([0-9]{2})/; +/** RegExp to discard rubrics fallbacks */ +const RUBRIC_FALLBACK_REGEXP = /fallback_.+\d{2}$/; const INTL_REGION_CODES = new Intl.DisplayNames(['en', 'ru'], {type: 'region'}); /** A number between 0.01 and 4, the image scaling factor */ const IMAGE_SCALE = 1; @@ -92,7 +94,7 @@ const getIconDescriptions = (components: Node<'COMPONENT'>[], availableSizes: nu return false; } // without fallback icons - if (component.name.includes('fallback')) { + if (RUBRIC_FALLBACK_REGEXP.test(component.name)) { return false; } const {height, width} = component.absoluteBoundingBox;