Skip to content

Commit

Permalink
enhance(language-menu): explain "Remember language" setting with link
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Sep 25, 2024
1 parent a870a84 commit 2402f28
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
18 changes: 16 additions & 2 deletions client/src/ui/organisms/article-actions/language-menu/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
background-color: unset;
}

.group {
align-items: center;
display: flex;
gap: 0.5em;
}

.switch {
display: flex;
}
Expand All @@ -39,9 +45,17 @@
font-style: italic;
font-variation-settings: "slnt" -10;
margin-top: 0.5em;
}

.icon {
margin-right: unset;
}

a[href] .icon-question-mark {
background-color: var(--icon-secondary);

.icon {
margin-right: unset;
&:hover {
background-color: var(--text-link);
}
}
}
Expand Down
28 changes: 21 additions & 7 deletions client/src/ui/organisms/article-actions/language-menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/jsx-no-target-blank */
import { useEffect, useState } from "react";
import { useLocation } from "react-router-dom";

Expand All @@ -17,6 +18,8 @@ import {
} from "../../../../utils";
import { GleanThumbs } from "../../../atoms/thumbs";
import { Switch } from "../../../atoms/switch";
import { Icon } from "../../../atoms/icon";
import { Tooltip } from "../../../../observatory/tooltip";

Check warning on line 22 in client/src/ui/organisms/article-actions/language-menu/index.tsx

View workflow job for this annotation

GitHub Actions / Build head

'Tooltip' is defined but never used

Check warning on line 22 in client/src/ui/organisms/article-actions/language-menu/index.tsx

View workflow job for this annotation

GitHub Actions / lint

'Tooltip' is defined but never used

Check warning on line 22 in client/src/ui/organisms/article-actions/language-menu/index.tsx

View workflow job for this annotation

GitHub Actions / lighthouse

'Tooltip' is defined but never used

Check warning on line 22 in client/src/ui/organisms/article-actions/language-menu/index.tsx

View workflow job for this annotation

GitHub Actions / build

'Tooltip' is defined but never used

Check warning on line 22 in client/src/ui/organisms/article-actions/language-menu/index.tsx

View workflow job for this annotation

GitHub Actions / build

'Tooltip' is defined but never used

Check warning on line 22 in client/src/ui/organisms/article-actions/language-menu/index.tsx

View workflow job for this annotation

GitHub Actions / test

'Tooltip' is defined but never used

// This needs to match what's set in 'libs/constants.js' on the server/builder!
const PREFERRED_LOCALE_COOKIE_NAME = "preferredlocale";
Expand Down Expand Up @@ -154,15 +157,26 @@ function LocaleRedirectSetting() {
}
}

// eslint-disable react/jsx-no-target-blank
return (
<form className="submenu-item locale-redirect-setting">
<Switch
name="locale-redirect"
checked={locale === preferredLocale}
toggle={toggle}
>
Remember language
</Switch>
<div className="group">
<Switch
name="locale-redirect"
checked={locale === preferredLocale}
toggle={toggle}
>
Remember language
</Switch>
<a
href="https://github.com/orgs/mdn/discussions"
rel="external noopener"
target="_blank"
title="Enable this setting to automatically switch to this language when it's available. (Click to learn more.)"
>
<Icon name="question-mark" />
</a>
</div>
<GleanThumbs feature="locale-redirect" question="Is this useful?" />
</form>
);
Expand Down

0 comments on commit 2402f28

Please sign in to comment.