You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -31,6 +37,20 @@ You can configure a module exactly once. Before using other styles add something
31
37
);
32
38
```
33
39
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
+
34
54
## Features
35
55
36
56
SubModules
@@ -47,11 +67,63 @@ JS features
47
67
* includes a handy `debounce()` function
48
68
* 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
49
69
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.
51
121
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.
53
125
54
-
The breakpoint stuff is probably the hardest to grok without docs, so chat with @davejtoews if you need a primer.
0 commit comments