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

[Mobile only] 言語選択ドロップダウンの改善 #337

Merged
merged 4 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions assets/js/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ document.onscroll = () => {
};
const navbar = () => {
$('.drawer').drawer();

$('.drawer-menu-item').click(function() {
$('.drawer').drawer('close');
$('.drawer-menu-item').click(function(e) {
if (!e.target.classList.contains('not-closed-menu-item')) {
$('.drawer').drawer('close');
}
});
};

Expand Down
2 changes: 1 addition & 1 deletion assets/preact_build/internationalization.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/preact_build/internationalization.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/preact_build/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/preact_build/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/preact_build/polyfill.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/preact_build/polyfill.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/preact_build/sindan.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/preact_build/sindan.js.map

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,16 @@
>お問い合わせ</a
>
</li>
<div id="preact-i18n" style="display: inline;"></div>
<li class="drawer-dropdown">
<a
class="drawer-menu-item not-closed-menu-item"
data-toggle="dropdown"
role="button"
aria-expanded="false"
>Language<span class="drawer-caret"></span
></a>
<ul id="preact-i18n" class="drawer-dropdown-menu"></ul>
</li>
</ul>
</nav>
</div>
Expand Down
57 changes: 18 additions & 39 deletions preact/i18n/Switcher.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {FunctionalComponent, h} from 'preact';
import {Fragment, FunctionalComponent, h} from 'preact';
import {useCallback, useEffect, useRef, useState} from 'preact/hooks';

import I18n from './i18n';
// @ts-ignore
import scoped from 'scoped-style';

const styled = scoped(h);

const Switcher: FunctionalComponent = () => {
const [select, setSelect] = useState('ja');
Expand All @@ -20,41 +16,24 @@ const Switcher: FunctionalComponent = () => {
}, []);

return (
<li class="drawer-dropdown">
<a
class="drawer-menu-item"
data-toggle="dropdown"
role="button"
aria-expanded="false">
<div style="display: inline;">Language</div>

<span class="drawer-caret"></span>
</a>
<ul class="drawer-dropdown-menu">
<li>
<a class="drawer-dropdown-menu-item" onClick={setLanguage('ja')}>
日本語
</a>
</li>
<li>
<a class="drawer-dropdown-menu-item" onClick={setLanguage('en')}>
English
</a>
</li>
<li>
<a class="drawer-dropdown-menu-item" onClick={setLanguage('zh')}>
中文
</a>
</li>
</ul>
</li>
<Fragment>
<li>
<a class="drawer-dropdown-menu-item" onClick={setLanguage('ja')}>
日本語
</a>
</li>
<li>
<a class="drawer-dropdown-menu-item" onClick={setLanguage('en')}>
English
</a>
</li>
<li>
<a class="drawer-dropdown-menu-item" onClick={setLanguage('zh')}>
中文
</a>
</li>
</Fragment>
);
};

const ClickSpan = styled('span')`
cursor: ${({select}: any) => (select ? '' : 'pointer')};
margin: 3px;
opacity: ${({select}: any) => (select ? 1 : 0.4)};
`;

export default Switcher;