Skip to content
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

Control for users to switch languages #622

Merged
merged 20 commits into from
Dec 19, 2022
Merged

Control for users to switch languages #622

merged 20 commits into from
Dec 19, 2022

Conversation

ZeLonewolf
Copy link
Member

Fixes #21

This PR adds a widget that allows a user to select the languages for display:

Initial view:
image

When the control is opened
image

If the user clears the language list, it will revert to the browser settings.

We may want to move this over to the buttons, like the samples and the coming legend PR, but I assume that can be tweaked later.

The list of languages is also hard-coded, and the UX is entirely in English. However, I think this is a reasonable starting point from which we can welcome enhancements.

Copy link
Member

@Pengor Pengor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and reviewed code changes, looks great!

src/js/language_label.js Outdated Show resolved Hide resolved
src/js/language_label.js Outdated Show resolved Hide resolved
@@ -326,10 +326,18 @@ map.on("styleimagemissing", function (e) {
Shield.missingIconHandler(map, e);
});

window.addEventListener("languagechange", (event) => {
console.log(`Changed to ${navigator.languages}`);
export function hotReloadMap() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn’t have to be exported anymore.

src/js/language_label.js Outdated Show resolved Hide resolved
height: "5em",
width: "20em",
"margin-bottom": "4em",
"margin-top": "0.3em",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only see a couple of the suggestions at a time, because the suggestion menu only appears below the textbox that’s already pretty far down the page. If Tokenfield doesn’t support automatically flipping the menu above the textbox, we should find a different place for the setting as tail work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not appear to have that option unfortunately:
https://github.com/KaneCohen/tokenfield

Comment on lines +119 to +122
Object.assign(element.style, {
margin: "0 2.5px",
color: "#444",
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we should move non-dynamic CSS styling to a stylesheet or at least the <style> element in index.html. But this is OK for now if we’re going to redesign the feature soon anyways.

@ZeLonewolf ZeLonewolf merged commit 5ffb766 into main Dec 19, 2022
@ZeLonewolf ZeLonewolf deleted the zlw-language-switch branch December 19, 2022 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User-switchable languages
3 participants