Skip to content

Commit

Permalink
Media query improvements (#70)
Browse files Browse the repository at this point in the history
* breakpoint variables

* use breakpoint-xs

* use breakpoint-sm

* update node engine to 18.19.1

* use breakpoint-md

* use breakpoint-lg

* make media query ranges inclusive of lower number

* fix warning

* tweak header styles

---------

Co-authored-by: tblackwell-tm <[email protected]>
  • Loading branch information
t-blackwell and tblackwell-tm authored Mar 4, 2024
1 parent c8799a7 commit 9aa7a9e
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.20.2
18.19.1
15 changes: 10 additions & 5 deletions example/src/App.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
body {
margin: 0;
font-family: 'Roboto', arial, sans-serif;
font-family: arial, sans-serif;
}
header {
display: flex;
align-items: center;
gap: 0.5rem;
color: #fff;
background: #24292e;
padding: 1.3rem 1.5rem;
}
.logo {
font-family: 'Vollkorn', serif;
font-size: 1.6rem;
letter-spacing: -0.02em;
margin: 0;
}
.example {
font-size: 1.4rem;
margin-left: 0.4rem;
opacity: 0.7;
font-size: 1.2rem;
background-color: white;
color: #24292e;
padding: 0.25rem 0.5rem;
border-radius: 4px;
}
main {
margin: 0 auto;
Expand Down
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function App() {
<input
checked={showDefinitions}
id="show-definitions"
onClick={() => setShowDefinitions(!showDefinitions)}
onChange={() => setShowDefinitions(!showDefinitions)}
type="checkbox"
/>
<label htmlFor="show-definitions">Show definitions</label>
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"lint:fix": "yarn lint --fix",
"test": "jest --config jest.config.js"
},
"engines": {
"node": "=18.19.1"
},
"browserslist": [
">0.01%",
"not ie 11",
Expand Down
8 changes: 8 additions & 0 deletions src/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/** Breakpoints **/
$breakpoint-xs: 576px;
$breakpoint-sm: 768px;
$breakpoint-md: 992px;
$breakpoint-lg: 1200px;
$breakpoint-xl: 1400px;
$breakpoint-xxl: 99999px;

/** Layout **/
$grid-size: 10px;
$line-height: $grid-size * 2.2;
Expand Down
2 changes: 1 addition & 1 deletion src/components/AnagramHelper/AnagramHelper.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
}

/** Breakpoints **/
.MyCrossword--xs {
@media (width <= vars.$breakpoint-xs) {
.AnagramHelper[style] {
width: auto !important;
min-width: auto !important;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Clue/Clue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}

/** Breakpoints **/
.MyCrossword--md {
@media (vars.$breakpoint-sm <= width <= vars.$breakpoint-md) {
.Clue {
scroll-margin-top: vars.$grid-size * 2.3;
}
Expand Down
19 changes: 9 additions & 10 deletions src/components/Clues/Clues.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
}

/** Breakpoints **/
.MyCrossword--xxl,
.MyCrossword--xl,
.MyCrossword--lg {
@media (width > vars.$breakpoint-md) {
.Clues__listBody {
overflow-y: auto;
border-bottom: 1px dotted vars.$light-grey;
Expand All @@ -35,40 +33,41 @@
}
}

.MyCrossword--md {
@media (vars.$breakpoint-sm <= width <= vars.$breakpoint-md) {
.Clues {
flex-direction: column;
overflow-y: auto;
border-bottom: 1px dotted vars.$light-grey;
margin: 0 vars.$grid-size;
scrollbar-width: thin;
}
.Clues__list {
.Clues .Clues__list {
width: 100%;
margin: 0;
}
.Clues__list--down {
.Clues .Clues__list--down {
margin-top: vars.$grid-size * 2;
.Clues__listHeader {
top: -1px;
}
}
}

.MyCrossword--sm {

@media (vars.$breakpoint-xs <= width <= vars.$breakpoint-sm) {
.Clues {
margin-top: vars.$grid-size;
}
}

.MyCrossword--xs {
@media (width <= vars.$breakpoint-xs) {
.Clues {
flex-direction: column;
}
.Clues__list {
.Clues .Clues__list {
width: 100%;
}
.Clues__list--down {
.Clues .Clues__list--down {
margin-top: vars.$grid-size * 2;
}
}
6 changes: 4 additions & 2 deletions src/components/Crossword/Crossword.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use '_variables' as vars;

.MyCrossword {
.Crossword {
display: flex;
Expand All @@ -8,13 +10,13 @@
}

/** Breakpoints **/
.MyCrossword--xs {
@media (width <= vars.$breakpoint-xs) {
.Crossword {
flex-direction: column;
}
}

.MyCrossword--sm {
@media (vars.$breakpoint-xs <= width <= vars.$breakpoint-sm) {
.Crossword {
flex-direction: column;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Grid/Grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}

/** Breakpoints **/
.MyCrossword--xs {
@media (width <= vars.$breakpoint-xs) {
.Grid[style] {
width: auto !important;
height: auto !important;
Expand All @@ -35,7 +35,7 @@
}
}

.MyCrossword--sm {
@media (vars.$breakpoint-xs <= width <= vars.$breakpoint-sm) {
.Grid {
scroll-margin-top: vars.$grid-size * 5;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/GridError/GridError.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
}

/** Breakpoints **/
.MyCrossword--xs {
.GridError {
@media (width <= vars.$breakpoint-xs) {
.MyCrossword .GridError {
width: auto;
}
}

0 comments on commit 9aa7a9e

Please sign in to comment.