refactor: Media queries (#2680)

This commit is contained in:
Jed Fox 2020-12-27 16:27:25 -05:00 committed by GitHub
parent 6f82a88b79
commit b8d13c98b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 21 additions and 17 deletions

View File

@ -218,7 +218,7 @@
left: 2px; left: 2px;
} }
@media #{$media-query} { @media #{$is-mobile-query} {
display: none; display: none;
} }
} }

View File

@ -74,7 +74,7 @@
z-index: 1; z-index: 1;
} }
@media #{$media-query} { @media #{$is-mobile-query} {
.context-menu-option { .context-menu-option {
display: block; display: block;

View File

@ -18,7 +18,7 @@
margin: 0; margin: 0;
} }
@media #{$media-query} { @media #{$is-mobile-query} {
.Dialog { .Dialog {
--metric: calc(var(--space-factor) * 4); --metric: calc(var(--space-factor) * 4);
--inset-left: #{"max(var(--metric), var(--sal))"}; --inset-left: #{"max(var(--metric), var(--sal))"};

View File

@ -37,7 +37,7 @@
} }
} }
@media (max-width: 550px) { @media #{$is-mobile-query} {
.ExportDialog { .ExportDialog {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -51,9 +51,7 @@
.ExportDialog__actions > * { .ExportDialog__actions > * {
margin-bottom: calc(var(--space-factor) * 3); margin-bottom: calc(var(--space-factor) * 3);
} }
}
@media #{$media-query} {
.ExportDialog__preview canvas { .ExportDialog__preview canvas {
max-height: 30vh; max-height: 30vh;
} }

View File

@ -1,5 +1,8 @@
@import "../css/_variables"; @import "../css/_variables";
// this is loosely based on the longest hint text
$wide-viewport-width: 1000px;
.excalidraw { .excalidraw {
.HintViewer { .HintViewer {
pointer-events: none; pointer-events: none;
@ -16,12 +19,9 @@
color: $oc-gray-6; color: $oc-gray-6;
font-size: 0.8rem; font-size: 0.8rem;
@media (min-width: 1200px) { @media #{$is-mobile-query} {
white-space: pre;
}
@media #{$media-query} {
position: static; position: static;
padding-right: 2em;
} }
> span { > span {

View File

@ -110,7 +110,7 @@
:root[dir="rtl"] & { :root[dir="rtl"] & {
left: 2px; left: 2px;
} }
@media #{$media-query} { @media #{$is-mobile-query} {
display: none; display: none;
} }
} }

View File

@ -40,7 +40,7 @@
background: var(--bg-color-island); background: var(--bg-color-island);
backdrop-filter: none; backdrop-filter: none;
@media #{$media-query} { @media #{$is-mobile-query} {
max-width: 100%; max-width: 100%;
} }
} }
@ -74,7 +74,7 @@
top: calc(var(--space-factor) * 5); top: calc(var(--space-factor) * 5);
} }
@media #{$media-query} { @media #{$is-mobile-query} {
.Modal { .Modal {
padding: 0; padding: 0;
} }

View File

@ -142,6 +142,7 @@
user-select: none; user-select: none;
} }
// shrink shape icons on small viewports to make them fit
@media (max-width: 425px) { @media (max-width: 425px) {
.Shape .ToolIcon__icon { .Shape .ToolIcon__icon {
width: 2rem; width: 2rem;
@ -153,6 +154,8 @@
} }
} }
// move the lock button out of the way on small viewports
// it begins to collide with the GitHub icon before we switch to mobile mode
@media (max-width: 760px) { @media (max-width: 760px) {
.ToolIcon.ToolIcon__lock { .ToolIcon.ToolIcon__lock {
display: inline-block; display: inline-block;
@ -162,6 +165,7 @@
margin-left: 0; margin-left: 0;
border-radius: 20px 0 0 20px; border-radius: 20px 0 0 20px;
z-index: 1;
background-color: var(--button-gray-1); background-color: var(--button-gray-1);
@ -189,7 +193,7 @@
margin-left: 5px; margin-left: 5px;
margin-top: 1px; margin-top: 1px;
@media #{$media-query} { @media #{$is-mobile-query} {
display: none; display: none;
} }
} }

View File

@ -1,3 +1,4 @@
@import "open-color/open-color.scss"; @import "open-color/open-color.scss";
$media-query: "(max-width: 600px), (max-height: 500px) and (max-width: 1000px)"; // keep up to date with is-mobile.tsx
$is-mobile-query: "(max-width: 600px), (max-height: 500px) and (max-width: 1000px)";

View File

@ -441,7 +441,7 @@
} }
} }
@media #{$media-query} { @media #{$is-mobile-query} {
aside { aside {
display: none; display: none;
} }

View File

@ -11,6 +11,7 @@ export const IsMobileProvider = ({
if (!query.current) { if (!query.current) {
query.current = window.matchMedia query.current = window.matchMedia
? window.matchMedia( ? window.matchMedia(
// keep up to date with _variables.scss
"(max-width: 640px), (max-height: 500px) and (max-width: 1000px)", "(max-width: 640px), (max-height: 500px) and (max-width: 1000px)",
) )
: (({ : (({