Skip to content

Commit

Permalink
feat(frontend): support custom media constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Feb 15, 2022
1 parent 4588739 commit 4dfd302
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions packages/frontend/lib/postcss.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const fs = require("fs");
const path = require("path");
const postcss = require("postcss");
const postcssEasyImport = require("postcss-easy-import");
const postcssExtendRule = require("postcss-extend-rule");

module.exports = (async () => {
const options = {
from: path.join(__dirname, "..", "styles/app.css"),
plugins: [postcssEasyImport, postcssExtendRule],
plugins: [
require("postcss-easy-import"),
require("postcss-custom-media"),
require("postcss-extend-rule"),
],
};

const css = fs.readFileSync(options.from, "utf8");
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"markdown-it-prism": "^2.2.0",
"nunjucks": "^3.2.3",
"postcss": "^8.3.6",
"postcss-custom-media": "^8.0.0",
"postcss-easy-import": "^3.0.0",
"postcss-extend-rule": "^4.0.0"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/styles/config/custom-media.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@custom-media --upto-small-viewport (width < 480px);
@custom-media --from-small-viewport (width >= 480px);
@custom-media --upto-medium-viewport (width < 720px);
@custom-media --from-medium-viewport (width >= 720px);
@custom-media --upto-large-viewport (width <= 1024px);
@custom-media --from-large-viewport (width > 1024px);

0 comments on commit 4dfd302

Please sign in to comment.