Skip to content

Commit b209edb

Browse files
Implement initial media query template functions
| Always adjust media queries to the content individually and not vice-versa. | The design supports the content. Not the other way around. Like documented in the GH-52, Nord Docs uses the mobile-first pattern and follows the great "Google Developer Responsive Web Design guidelines (1). The recommended way is to create media queries not based on any device sizes but individually based on the content which is unique for each project. This is the best practice and, contrary to most popular CSS framework like Bootstrap, the correct way since each site is different and there are thousands of devices and in the future new sizes will appear. Therefore, this commit includes the initial media query template functions that define the smallest `min-width` query `base` (`<320px`) and `minimal` (`>=320px`). References: (1) https://developers.google.com/web/fundamentals/design-and-ux/responsive Associated epic: GH-52 GH-61
1 parent 1924af4 commit b209edb

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

src/styles/theme/breakpoints.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]>
3+
* Copyright (C) 2018-present Sven Greb <[email protected]>
4+
*
5+
* Project: Nord Docs
6+
* Repository: https://github.com/arcticicestudio/nord-docs
7+
* License: MIT
8+
*/
9+
10+
/**
11+
* @author Arctic Ice Studio <[email protected]>
12+
* @author Sven Greb <[email protected]>
13+
* @since 0.3.0
14+
*/
15+
16+
/**
17+
* Breakpoints for the "mobile-first" pattern based on and adjusted to the site content.
18+
*
19+
* @type {Object}
20+
* @since 0.3.0
21+
*/
22+
const breakpoints = { minimal: 320 };
23+
24+
export default breakpoints;

src/styles/theme/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@
1414
* @since 0.2.0
1515
*/
1616

17+
import breakpoints from "./breakpoints";
1718
import colors, { nord, palettes } from "./colors";
1819
import globals from "./globals";
20+
import media from "./media";
1921
import motion from "./motion";
2022
import normalize from "./normalize";
2123
import { generateMediaQuery, themedMode, themedModeVariant } from "./utils";
2224
import typography from "./typography";
2325
import { MODE_BRIGHT_SNOW_FLURRY, MODE_DARK_NIGHT_FROST, THEME_KEY_MODE } from "./constants";
2426

25-
const theme = { colors, motion, typography };
27+
const theme = { breakpoints, colors, media, motion, typography };
2628

2729
export {
2830
colors,

src/styles/theme/media.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]>
3+
* Copyright (C) 2018-present Sven Greb <[email protected]>
4+
*
5+
* Project: Nord Docs
6+
* Repository: https://github.com/arcticicestudio/nord-docs
7+
* License: MIT
8+
*/
9+
10+
/**
11+
* @author Arctic Ice Studio <[email protected]>
12+
* @author Sven Greb <[email protected]>
13+
* @since 0.2.0
14+
*/
15+
16+
import { em } from "polished";
17+
18+
import breakpoints from "./breakpoints";
19+
import typography from "./typography";
20+
import { generateMediaQuery } from "./utils";
21+
22+
/**
23+
* Provides media query template functions based on the configured breakpoints.
24+
*
25+
* @type {Object}
26+
* @since 0.3.0
27+
*/
28+
const media = {
29+
base: generateMediaQuery`(max-width: ${em(breakpoints.minimal - 1, typography.sizes.root)})`,
30+
minimal: generateMediaQuery`(min-width: ${em(breakpoints.minimal, typography.sizes.root)})`,
31+
breakpoints
32+
};
33+
34+
export default media;

0 commit comments

Comments
 (0)