Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.

Commit 52359ea

Browse files
author
Jen Downs
committed
docs(utilities): Added documentation in README for v2 utility functions.
1 parent e638be2 commit 52359ea

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,79 @@ The config file is where all of your design system specs live. See this [example
7272

7373
The first breakpoint min-width media query is not used to save kilobytes, but we recommend stating it anyways for future artboard-making tools.
7474

75+
## Utility Mixin and Functions
76+
77+
Gridish has several utility SCSS functions and a mixin to help you add sizing to elements and components within your grid by using your own grid configuration.
78+
79+
80+
### Media Query Mixin
81+
You can use the media query mixin to use breakpoints you've defined.
82+
83+
**Example SCSS**
84+
```scss
85+
button {
86+
@include media-query('sm') {
87+
border: 2px solid hotpink;
88+
}
89+
}
90+
```
91+
92+
**Output CSS**
93+
```css
94+
@media screen and (min-width: 20rem) {
95+
button {
96+
border: 2px solid hotpink;
97+
}
98+
}
99+
```
100+
101+
Moreover, can then **combine this mixin with the functions below** to construct media queries that set fluid and fixed sizes based on your grid configuration.
102+
103+
### Get a Fluid Size
104+
Use the `get-fluid-size()` SCSS function to calculate a fluid width based on: (1) a defined breakpoints, and (2) a number of columns to span, relative to the number of available columns for the given breakpoint.
105+
106+
**Example SCSS**
107+
```scss
108+
@media screen and (min-width: 20rem) {
109+
button {
110+
@include media-query('sm') {
111+
max-width: get-fluid-size('sm', 1);
112+
}
113+
}
114+
}
115+
```
116+
117+
**Output CSS**
118+
```css
119+
@media screen and (min-width: 20rem) {
120+
button {
121+
max-width: 25vw;
122+
}
123+
}
124+
```
125+
126+
### Get a Fixed Size
127+
Use the `get-fixed-size()` SCSS function to calculate a fixed size based on a number of fixed nondimensional units multiplied by the base value from the current row height of the grid (`$rowHeight`);
128+
129+
**Example SCSS**
130+
```scss
131+
button {
132+
@include media-query('sm') {
133+
max-width: get-fixed-size(10);
134+
}
135+
}
136+
```
137+
138+
**Output CSS**
139+
```css
140+
@media screen and (min-width: 20rem) {
141+
button {
142+
max-width: 5rem;
143+
}
144+
}
145+
```
146+
147+
75148
## Legacy support
76149

77150
If you are supporting browsers that lack [CSS Grid Layout support](https://developer.mozilla.org/en-US/docs/Web/CSS/grid#Browser_compatibility), you can use `css-gridish/yourPrefix-legacy.min.css` and the legacy classes detailed in the `README.md`. With the legacy file and classes, the browsers that do not support the final CSS Grid Legacy spec will fallback to a CSS Flexbox alternative. The CSS Flexbox alternative supports embedded subgrids that still reflect the overall grid system’s column structure.

0 commit comments

Comments
 (0)