-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/map type toggle button #43
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<script> | ||
import { createEventDispatcher } from 'svelte'; | ||
|
||
const dispatch = createEventDispatcher(); | ||
export let mapTypeId = 'roadmap'; | ||
|
||
const mapTypes = ['roadmap', 'satellite', 'hybrid', 'terrain']; | ||
|
||
function cycleMapType() { | ||
const currentIndex = mapTypes.indexOf(mapTypeId); | ||
const nextIndex = (currentIndex + 1) % mapTypes.length; | ||
mapTypeId = mapTypes[nextIndex]; | ||
dispatch('mapTypeChanged', mapTypeId); | ||
} | ||
|
||
function getMapTypeIcon(type) { | ||
switch (type) { | ||
case 'roadmap': | ||
return '🗺️'; | ||
case 'satellite': | ||
return '🛰️'; | ||
case 'hybrid': | ||
return '🌎'; | ||
case 'terrain': | ||
return '⛰️'; | ||
default: | ||
return '🗺️'; | ||
} | ||
} | ||
</script> | ||
|
||
<button class="map-type-button" on:click={cycleMapType}> | ||
{getMapTypeIcon(mapTypeId)} | ||
</button> | ||
|
||
<style> | ||
.map-type-button { | ||
background-color: #fff; | ||
border-radius: 2px; | ||
box-shadow: 0 1px 4px -1px rgba(0, 0, 0, 0.3); | ||
margin: 10px; | ||
font-size: 25px; | ||
color: #666; | ||
overflow: hidden; | ||
height: 40px; | ||
width: 40px; | ||
position: absolute; | ||
bottom: 5.8em; | ||
right: 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.map-type-button:hover { | ||
background-color: #f0f0f0; | ||
} | ||
</style> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To maintain consistency, you can use the Tailwind CSS inline at the button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I noticed that we use tailwind in the codebase. I’m not familiar with it yet, but I plan to learn it and rewrite the styles using tailwind. I initially wrote in regular css because I saw that the location button was already styled that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, no problem. We will add the button CSS code into a global CSS file in the future.