@@ -61,23 +61,180 @@ element {
61
61
}
62
62
```
63
63
64
- ### Transform centering
64
+ # SCSS snippets
65
65
66
- ``` css
67
- element .center {
68
- position : absolute ;
69
- top : 50% ;
70
- left : 50% ;
71
- transform : translate (-50% , -50% );
66
+ ``` scss
67
+ @mixin block ($b ) {
68
+ $self : #{$namespace } - #{$b } !global;
69
+ .#{$self } {
70
+ @content ;
71
+ }
72
+ }
73
+
74
+ @mixin b ($block ) {
75
+ @include block ($block ) {
76
+ @content ;
77
+ }
78
+ }
79
+
80
+ @mixin e ($element , $parent : ' root' ) {
81
+ @if $parent == ' root' {
82
+ & __#{$element} {
83
+ @content ;
84
+ }
85
+ } @else {
86
+ & #{$parent } __#{$element } {
87
+ @content ;
88
+ }
89
+ }
90
+ }
91
+
92
+ @mixin m ($modifier , $parent : ' root' ) {
93
+ @if $parent == ' root' {
94
+ & --#{$modifier} {
95
+ @content ;
96
+ }
97
+ } @else {
98
+ & #{$parent } -- #{$modifier } {
99
+ @content ;
100
+ }
101
+ }
102
+ }
103
+
104
+ @mixin icon ($w , $h , $bg , $type : ' png' ) {
105
+ width : #{$w } px;
106
+ height : #{$h } px;
107
+ background : none no-repeat center / 100% ;
108
+ @if $type == ' svg' {
109
+ background-image : url (' #{$bg } .svg' );
110
+ } @else {
111
+ background-image : url (' #{$bg } .png' );
112
+ @media (min-resolution : 2dppx ) {
113
+ background-image : url (' #{$bg } @2x.png' );
114
+ }
115
+ @media (min-resolution : 3dppx ) {
116
+ background-image : url (' #{$bg } @3x.png' );
117
+ }
118
+ }
72
119
}
73
- element .justify-center {
120
+
121
+ @mixin one-pix-line ($pos : ' bottom' , $style : solid , $color ) {
122
+ $prop : border- #{$pos } ;
123
+ @if $pos == ' all' {
124
+ $prop : border ;
125
+ }
126
+ #{$prop } : 1px $style $color ;
127
+ @media (min-resolution : 2dppx ) {
128
+ #{$prop } : .5px $style $color ;
129
+ }
130
+ @media (min-resolution : 3dppx ) {
131
+ #{$prop } : .333333px $style $color ;
132
+ }
133
+ @media (min-resolution : 4dppx ) {
134
+ #{$prop } : .25px $style $color ;
135
+ }
136
+ }
137
+
138
+ @mixin text-ellipsis ($width : 100% ) {
139
+ width : $width ;
140
+ overflow : hidden ;
141
+ white-space : nowrap ;
142
+ word-wrap : normal ;
143
+ text-overflow : ellipsis ;
144
+ }
145
+
146
+ @mixin text-wrap () {
147
+ white-space : pre-wrap ;
148
+ word-wrap : break-word ;
149
+ }
150
+
151
+ @mixin center--x () {
74
152
position : absolute ;
75
153
left : 50% ;
76
154
transform : translateX (-50% );
155
+ @content ;
77
156
}
78
- element .align-center {
157
+
158
+ @mixin center--y () {
79
159
position : absolute ;
80
160
top : 50% ;
81
161
transform : translateY (-50% );
162
+ @content ;
163
+ }
164
+
165
+ @mixin position--t--r ($p : absolute , $t : 0 , $r : 0 ) {
166
+ position : $p ;
167
+ top : $t ;
168
+ right : $r ;
169
+ @content ;
170
+ }
171
+
172
+ @mixin position--t--b ($p : absolute , $t : 0 , $b : 0 ) {
173
+ position : $p ;
174
+ top : $t ;
175
+ bottom : $b ;
176
+ @content ;
177
+ }
178
+
179
+ @mixin position--t--l ($p : absolute , $t : 0 , $l : 0 ) {
180
+ position : $p ;
181
+ top : $t ;
182
+ left : $l ;
183
+ @content ;
184
+ }
185
+
186
+ @mixin position--b--r ($p : absolute , $b : 0 , $r : 0 ) {
187
+ position : $p ;
188
+ right : $r ;
189
+ bottom : $b ;
190
+ @content ;
191
+ }
192
+
193
+ @mixin position--b--l ($p : absolute , $b : 0 , $l : 0 ) {
194
+ position : $p ;
195
+ bottom : $b ;
196
+ left : $l ;
197
+ @content ;
198
+ }
199
+
200
+ @mixin position--r--l ($p : absolute , $r : 0 , $l : 0 ) {
201
+ position : $p ;
202
+ right : $r ;
203
+ left : $l ;
204
+ @content ;
205
+ }
206
+
207
+ @mixin position--overlay ($p : absolute ) {
208
+ position : $p ;
209
+ top : 0 ;
210
+ right : 0 ;
211
+ bottom : 0 ;
212
+ left : 0 ;
213
+ }
214
+
215
+ @mixin flex-box {
216
+ display : flex ;
217
+ & > * {
218
+ flex : 0 0 auto ;
219
+ }
220
+ }
221
+
222
+ @mixin h-box {
223
+ @include flex-box ;
224
+ flex-direction : row ;
225
+ @content ;
226
+ }
227
+
228
+ @mixin v-box {
229
+ @include flex-box ;
230
+ flex-direction : column ;
231
+ @content ;
232
+ }
233
+
234
+ @mixin box-center {
235
+ @include flex-box ;
236
+ align-items : center ;
237
+ justify-content : center ;
238
+ @content ;
82
239
}
83
240
```
0 commit comments