Skip to content

Commit

Permalink
add fallback icon
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew44-mappable committed Apr 4, 2024
1 parent 870c388 commit 132e256
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/icons.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
2 changes: 1 addition & 1 deletion example/default-markers/react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function main() {
<MMap location={location} ref={(x) => (map = x)}>
<MMapDefaultSchemeLayer />
<MMapDefaultFeaturesLayer />
<MMapDefaultMarker iconName="building" color="bluebell" coordinates={MARKER_LOCATION} />
<MMapDefaultMarker iconName="fallback" color="bluebell" coordinates={MARKER_LOCATION} />
</MMap>
);
}
Expand Down
2 changes: 1 addition & 1 deletion example/default-markers/vanilla/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function main() {
map.addChild(new MMapDefaultFeaturesLayer({}));

const defaultMarker = new MMapDefaultMarker({
iconName: 'building',
iconName: 'fallback',
color: 'bluebell',
coordinates: MARKER_LOCATION
});
Expand Down
2 changes: 1 addition & 1 deletion example/default-markers/vue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function main() {
<MMap :location="LOCATION" :ref="refMap">
<MMapDefaultSchemeLayer />
<MMapDefaultFeaturesLayer />
<MMapDefaultMarker iconName="building" color="bluebell" :coordinates="MARKER_LOCATION"/>
<MMapDefaultMarker iconName="fallback" color="bluebell" :coordinates="MARKER_LOCATION"/>
</MMap>`
});
app.mount('#app');
Expand Down
1 change: 1 addition & 0 deletions src/icons/icon-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type IconName =
| 'drugstores'
| 'dry_cleaning'
| 'equestrian'
| 'fallback'
| 'fast_food'
| 'film_studio'
| 'fire_station'
Expand Down
3 changes: 3 additions & 0 deletions src/icons/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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},
Expand Down
4 changes: 3 additions & 1 deletion tools/icons/fetch-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 132e256

Please sign in to comment.