Skip to content

Commit

Permalink
[IMP] Separate Smooth Scrolling into Separate Import
Browse files Browse the repository at this point in the history
  • Loading branch information
woodbrettm committed Dec 9, 2023
1 parent 3f85ab5 commit 7c90d68
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-buttons-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'css-preflight': minor
---

Separate out smooth scrolling into its own import
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ import 'css-preflight'; // styles/preflight.css
import 'css-preflight/preflight'; // ALIAS: styles/preflight.css

import 'css-preflight/enhancements'; // styles/enhancements.css

import 'css-preflight/smooth-scroll'; // styles/smooth-scroll.css
import 'css-preflight/rem-same-px'; // styles/rem-same-px.css
```

#### Typical Setup

```javascript
import 'css-preflight/preflight';
import 'css-preflight';
import 'css-preflight/enhancements';
```

Expand All @@ -71,9 +71,12 @@ Both are exactly the same.

These are small enhancements added to the main preflight:

- Enables smooth scrolling to anchor points (e.g. #about). Disabled for `prefers-reduced-motion`.
- Adds `text-wrap: balance` on h1-h6 and blockquote. Helps prevent hanging words on newlines.

### Smooth Scroll

Enables smooth scrolling to anchor points (e.g. #about). Disabled for `prefers-reduced-motion`.

### Rem Same Px

Sets rem equal to 1px at the root for easier design-dev handoff. This calculation is done
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
".": "./styles/preflight.css",
"./preflight": "./styles/preflight.css",
"./enhancements": "./styles/enhancements.css",
"./smooth-scroll": "./styles/smooth-scroll.css",
"./rem-same-px": "./styles/rem-same-px.css"
},
"files": [
Expand Down
15 changes: 0 additions & 15 deletions styles/enhancements.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
Adds smooth scrolling when a user is navigated to an
anchor on a page.
*/

:root {
scroll-behavior: smooth;
}

@media (prefers-reduced-motion) {
:root {
scroll-behavior: auto;
}
}

/*
Helps prevent single words on a newline,
which can make a title seem unbalanced.
Expand Down
14 changes: 14 additions & 0 deletions styles/smooth-scroll.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Adds smooth scrolling when a user is navigated to an
anchor on a page.
*/

:root {
scroll-behavior: smooth;
}

@media (prefers-reduced-motion) {
:root {
scroll-behavior: auto;
}
}

0 comments on commit 7c90d68

Please sign in to comment.