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
{{ message }}
This repository was archived by the owner on Jul 18, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+73Lines changed: 73 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,6 +72,79 @@ The config file is where all of your design system specs live. See this [example
72
72
73
73
The first breakpoint min-width media query is not used to save kilobytes, but we recommend stating it anyways for future artboard-making tools.
74
74
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
+
@includemedia-query('sm') {
87
+
border: 2pxsolidhotpink;
88
+
}
89
+
}
90
+
```
91
+
92
+
**Output CSS**
93
+
```css
94
+
@mediascreenand (min-width: 20rem) {
95
+
button {
96
+
border: 2pxsolidhotpink;
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
+
@mediascreenand (min-width: 20rem) {
109
+
button {
110
+
@includemedia-query('sm') {
111
+
max-width: get-fluid-size('sm', 1);
112
+
}
113
+
}
114
+
}
115
+
```
116
+
117
+
**Output CSS**
118
+
```css
119
+
@mediascreenand (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
+
@includemedia-query('sm') {
133
+
max-width: get-fixed-size(10);
134
+
}
135
+
}
136
+
```
137
+
138
+
**Output CSS**
139
+
```css
140
+
@mediascreenand (min-width: 20rem) {
141
+
button {
142
+
max-width: 5rem;
143
+
}
144
+
}
145
+
```
146
+
147
+
75
148
## Legacy support
76
149
77
150
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