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

Add close button to sidebar #38

Merged
merged 5 commits into from
Nov 26, 2021
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
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
<details class="main">
<summary></summary>
<div class="sidebar">
<button type="button" class="close-options-button">
<span aria-hidden="true">&#10005;</span>
</button>
<form>
<div class="preprocess">
<div class="other-input">
Expand Down
16 changes: 16 additions & 0 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ details[open]:not(.main) > summary::after {
content: '▼';
}

details.main .close-options-button {
display: none;
position: absolute;
top: 0.5rem;
right: 0.5rem;
width: 2.2rem;
height: 2.2rem;
margin: 0;
font-size: 1rem;
}

@media (max-width: 414px) {
summary,
label,
Expand All @@ -175,6 +186,7 @@ details[open]:not(.main) > summary::after {
}

details[open].main > .sidebar {
max-width: calc(100% - var(--space) * 4);
backdrop-filter: saturate(180%) blur(20px);
background-color: var(--sidebar-background-color);
}
Expand All @@ -201,6 +213,10 @@ details[open]:not(.main) > summary::after {
z-index: -1;
opacity: 0;
}

details.main[open] .close-options-button {
display: inline-block;
}
}

.input-image {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/de-DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const translations = {
considerDPR: 'Pixelverhältnis des Geräts beachten',

tweak: 'Anpassen',
closeOptions: 'Schließen',

optimizingSVG: 'Optmiere SVG',
copiedSVG: 'SVG kopiert',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/el-GR.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const translations = {
considerDPR: 'Λάβετε υπόψη την αναλογία pixel της συσκευής',

tweak: 'Προσαρμογή',
closeOptions: 'Κλείσιμο',

optimizingSVG: 'Βελτιστοποίηση SVG',
copiedSVG: 'SVG Αντιγράφηκε',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const translations = {
considerDPR: 'Consider Device Pixel Ratio',

tweak: 'Tweak',
closeOptions: 'Close',

optimizingSVG: 'Optimizing SVG',
copiedSVG: 'Copied SVG',
Expand Down
2 changes: 2 additions & 0 deletions src/js/domrefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const toast = document.querySelector('.toast');
const dropContainer = document.documentElement;
const details = document.querySelector('details.main');
const summary = document.querySelector('summary');
const closeOptionsButton = document.querySelector('.close-options-button');

const dpr = window.devicePixelRatio;

Expand Down Expand Up @@ -83,5 +84,6 @@ export {
progress,
details,
summary,
closeOptionsButton,
dpr,
};
8 changes: 7 additions & 1 deletion src/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
progress,
details,
summary,
closeOptionsButton,
} from './domrefs.js';
import {
resetZoomAndPan,
Expand Down Expand Up @@ -299,7 +300,7 @@ const initUI = async () => {
await i18n.getTranslations();
changeLanguage();

const mediaQueryList = window.matchMedia('(max-width: 400px)');
const mediaQueryList = window.matchMedia('(max-width: 414px)');
const onMaxWidthMatch = () => {
if (mediaQueryList.matches) {
details.open = false;
Expand Down Expand Up @@ -417,6 +418,7 @@ const changeLanguage = () => {
summary.innerHTML = '';
summary.append(createIcon(optionsIcon));
summary.append(document.createTextNode(i18n.t('tweak')));
closeOptionsButton.ariaLabel = i18n.t('closeOptions');
};

resetAllButton.addEventListener('click', async () => {
Expand Down Expand Up @@ -479,4 +481,8 @@ window.addEventListener(
}, 250),
);

closeOptionsButton.addEventListener('click', () => {
details.open = false;
});

export { initUI, filters, filterInputs, showToast, COLORS, SCALE, POTRACE };