From: Daniel Karbach Date: Fri, 28 Jul 2023 12:28:26 +0000 (+0200) Subject: map marker icons X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=1811c6021240a95f505cc2d49f592dc1bf56ac89;p=alttp.git map marker icons --- diff --git a/database/migrations/2023_07_28_121522_map_marker.php b/database/migrations/2023_07_28_121522_map_marker.php new file mode 100644 index 0000000..fdc831a --- /dev/null +++ b/database/migrations/2023_07_28_121522_map_marker.php @@ -0,0 +1,32 @@ +string('marker')->nullable()->default(null); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('technique_maps', function(Blueprint $table) { + $table->dropColumn('marker'); + }); + } +}; diff --git a/resources/js/components/common/ZeldaIcon.js b/resources/js/components/common/ZeldaIcon.js index 9194cde..ef07b92 100644 --- a/resources/js/components/common/ZeldaIcon.js +++ b/resources/js/components/common/ZeldaIcon.js @@ -83,20 +83,21 @@ const getIconURL = name => { } }; -const ZeldaIcon = ({ name }) => { +const ZeldaIcon = ({ name, title }) => { const { t } = useTranslation(); const invert = name.startsWith('not-'); const strippedName = invert ? name.substr(4) : name; const src = getIconURL(strippedName); - const title = t(`icon.zelda.${name}`); + const alt = t(`icon.zelda.${name}`); + const realTitle = title !== '' ? title || alt : null; return {src ? {title} : null} {invert ? @@ -109,6 +110,7 @@ const ZeldaIcon = ({ name }) => { ZeldaIcon.propTypes = { name: PropTypes.string, + title: PropTypes.string, }; export default ZeldaIcon; diff --git a/resources/js/components/map/Pin.js b/resources/js/components/map/Pin.js index 442e16d..9d9b471 100644 --- a/resources/js/components/map/Pin.js +++ b/resources/js/components/map/Pin.js @@ -6,6 +6,7 @@ import { useOpenSeadragon } from './OpenSeadragon'; import Overlay from './Overlay'; import Popover from './Popover'; import Icon from '../common/Icon'; +import ZeldaIcon from '../common/ZeldaIcon'; import { getLink, getTranslation } from '../../helpers/Technique'; import i18n from '../../i18n'; @@ -32,10 +33,18 @@ const Pin = ({ pin }) => { } }, [pin]); + const title = React.useMemo(() => { + return getTranslation(pin.technique, 'title', i18n.language); + }, [pin, i18n.language]); + return
- + {pin.marker ? + + : + + } {pin.technique.type === 'location' ?
@@ -48,6 +57,7 @@ const Pin = ({ pin }) => { Pin.propTypes = { pin: PropTypes.shape({ + marker: PropTypes.string, technique: PropTypes.shape({ type: PropTypes.string, }), diff --git a/resources/sass/map.scss b/resources/sass/map.scss index 78c9a2b..8b80ada 100644 --- a/resources/sass/map.scss +++ b/resources/sass/map.scss @@ -5,6 +5,10 @@ stroke-width: 1px; vector-effect: non-scaling-stroke; } + > a .zelda-icon { + height: 1em; + width: 1em; + } } .map-popover {