Created
July 13, 2024 12:51
-
-
Save iamrobert/1c001bf1e5d247cc13467d2a2178ff3c to your computer and use it in GitHub Desktop.
Baseline grid Toggle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var urlParams = new URLSearchParams(window.location.search); | |
if (urlParams.has('grid')) { | |
document.body.classList.add("bgrid"); | |
} | |
/* + BGRID | |
======================================================================*/ | |
// Keyboard event listener for Ctrl + ; | |
document.addEventListener('keydown', function (event) { | |
// Check if Ctrl is pressed and the key is ';' | |
if (event.ctrlKey && event.key === ';') { | |
document.body.classList.toggle('bgrid'); | |
event.preventDefault(); // Prevent any default action for this key combination | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add a Baseline Grid
Instructions
Toggle Baseline Grid with Keyboard Shortcut:
Ctrl + ;
to toggle the baseline grid on and off.Add
bgrid
Class to Body (optional):bgrid
class is used to show the baseline grid..bgrid
class to display the grid.Persistent Baseline Grid with URL Parameter (optional):
?grid
to the URL.?grid
is present, the baseline grid will be displayed.Baseline Grid CSS Styles
CSS Variables
--step-0
clamp(1rem, 0.9565rem + 0.2174vi, 1.125rem)
--lh
1.7
Baseline CSS