Skip to content

Commit 5166b98

Browse files
committed
📝 (readme) begins fleshing out docs
1 parent 54c3df9 commit 5166b98

File tree

1 file changed

+75
-3
lines changed

1 file changed

+75
-3
lines changed

README.md

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ Resources:
1111
* https://css-tricks.com/introducing-sass-modules/
1212
* https://stackoverflow.com/questions/63289593/overriding-a-large-number-of-default-values-with-the-use-rule-in-sass-scss
1313

14+
## Installation
15+
16+
```
17+
yarn add @evanshunt/derekstrap;
18+
```
19+
1420
## Usage
1521

1622
### With @import
@@ -31,6 +37,20 @@ You can configure a module exactly once. Before using other styles add something
3137
);
3238
```
3339

40+
### JavaScript
41+
42+
Initialization example shown here. See [below](#Details/Examples) for details on specific module use.
43+
44+
```
45+
// This should be the path to your SCSS entry point which pulls in the Derekstrap SCSS.
46+
import breakpointList from '../styles/main.scss';
47+
48+
import { Derekstrap, Breakpoints } from '@evanshunt/derekstrap';
49+
50+
Derekstrap.init();
51+
Breakpoints.init(breakpointList);
52+
```
53+
3454
## Features
3555

3656
SubModules
@@ -47,11 +67,63 @@ JS features
4767
* includes a handy `debounce()` function
4868
* breakpoint object that you can pass an array of breakpoints to, and you can then check the object to determine your current breakpoint, or listen for a breakpoint change event. You can actually pull in the Derekstrap Sass breakpoints into the JS via a sass :export block. It'll work even if you update/override the Derekstrap `$breakpointList` var
4969

50-
## Examples
70+
## Details / Examples
71+
72+
### Breakpoints
73+
74+
The breakpoints module consists of both SCSS and JS pieces. The SCSS piece is just a set of variables that doesn't do much on it's own, but it is used by other modules to configure responsive sizing, and by the JS piece to enable JS conditions and triggers tied to the same SCSS breakpoints. The breakpoints module assumes a mobile first design pattern; it is used to generate `min-width` media queries.
75+
76+
You can override and individual breakpoint by configuring the variable for that breakpoint
77+
78+
```
79+
@use '~@evanshunt/derekstrap' with (
80+
$tablet: 800px
81+
);
82+
```
83+
84+
Or you can add to the breakpoint list by configuring the map variable which contains all the breakpoints
85+
86+
```
87+
@use '~@evanshunt/derekstrap' with (
88+
$breakpointList: (
89+
'large-phone': 414px,
90+
'tablet': 720px,
91+
'desktop': 992px,
92+
'desktop-large': 1440px,
93+
'desktop-extra-large': 1920px,
94+
'desktop-gargantuan:': 3840px
95+
)
96+
);
97+
```
98+
99+
#### CSS Exports
100+
101+
If you take a look at [breakpoints/_variables.scss](breakpoints/_variables.scss), you'll notice that it ends with an `:export` statement. This statement allows us to pass values that can will be parsed by `[css-loader](https://github.com/webpack-contrib/css-loader)` and available within a JavaScript file which imports the SCSS. Documentation can be found [here](https://github.com/css-modules/icss#export).
102+
103+
#### JS usage
104+
105+
The breakpoints module needs to be imported and initialized with a breakpoint list in order to work. Making use of the CSS export mentioned above you can initialize the JS module with the breakpoints found in your SCSS. This should be done in your project code rather than within the module in order for any project overrides to be inherited in the JS.
106+
107+
##### Initilization
108+
109+
```
110+
// This should be the path to your SCSS entry point which pulls in the Derekstrap SCSS.
111+
import breakpointList from '../styles/main.scss';
112+
113+
import { Breakpoints } from '@evanshunt/derekstrap';
114+
115+
Breakpoints.init(breakpointList);
116+
```
117+
118+
##### Methods
119+
120+
After initilization. The following methods can be used.
51121

52-
Big ol' @TODO here....
122+
* `Breakpoints.get()`: returns an array of breakpoints that the current viewport size has surpassed.
123+
* `Breakpoints.getCurrent()`: returns the largest single breakpoint that the current viewport size has surpassed.
124+
* `minWidth($breakpointName)`: when passed a string value corresponding to a breakpoint name returns a boolean indicating whether the current viewport size has surpassed the given breakpoint.
53125

54-
The breakpoint stuff is probably the hardest to grok without docs, so chat with @davejtoews if you need a primer.
126+
##### Events
55127

56128
## Gotchas
57129

0 commit comments

Comments
 (0)