forked from bansal/pattern.css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pattern.scss
204 lines (177 loc) · 5.83 KB
/
pattern.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
$pattern-prefix : 'pattern' !default;
$pattern-sizes : (sm:10px,
md:25px,
lg:50px,
xl:100px,
) !default;
$pattern-list: ('checks',
'grid',
'grid',
'dots',
'cross-dots',
'vertical-lines',
'horizontal-lines',
'diagonal-lines',
'vertical-stripes',
'horizontal-stripes',
'diagonal-stripes',
'triangles',
'zigzag'
) !default;
$dots : (sm:.5px,
md:1px,
lg:1.5px,
xl:2px) !default;
// .bg-checks-{sm, md, lg, xl}
@if index($pattern-list, 'checks') {
@each $name,
$size in $pattern-sizes {
.#{$pattern-prefix}-checks-#{$name} {
background-image:
repeating-linear-gradient(45deg, currentColor 25%, transparent 25%, transparent 75%, currentColor 75%, currentColor),
repeating-linear-gradient(45deg, currentColor 25%, transparent 25%, transparent 75%, currentColor 75%, currentColor);
background-position: 0 0,
#{$size} #{$size};
background-size: calc(2 * #{$size}) calc(2 * #{$size});
}
}
}
// .bg-grid-{sm, md, lg, xl}
@if index($pattern-list, 'grid') {
@each $name,
$size in $pattern-sizes {
.#{$pattern-prefix}-grid-#{$name} {
background-image:
linear-gradient(currentColor 1px, transparent 1px),
linear-gradient(to right, currentColor 1px, transparent 1px);
background-size: #{$size} #{$size};
// background-position: calc(-0.5 * #{$size}) calc(-0.5 * #{$size});
}
}
}
// .bg-dots-{sm, md, lg, xl}
@if index($pattern-list, 'dots') {
@each $name,
$size in $dots {
.#{$pattern-prefix}-dots-#{$name} {
background-image: radial-gradient(currentColor #{$size}, transparent #{$size});
background-size: calc(10 * #{$size}) calc(10 * #{$size});
}
}
}
// .bg-cross-dots-{sm, md, lg, xl}
@if index($pattern-list, 'cross-dots') {
@each $name,
$size in $dots {
.#{$pattern-prefix}-cross-dots-#{$name} {
background-image: radial-gradient(currentColor #{$size}, transparent #{$size}),
radial-gradient(currentColor #{$size}, transparent #{$size});
background-size: calc(20 * #{$size}) calc(20 * #{$size});
background-position: 0 0,
calc(10 * #{$size}) calc(10 * #{$size});
}
}
}
@each $name,
$size in $pattern-sizes {
// .bg-vertical-lines-{sm, md, lg, xl}
@if index($pattern-list, 'vertical-lines') {
.#{$pattern-prefix}-vertical-lines-#{$name} {
background-image: repeating-linear-gradient(to right,
currentColor,
currentColor 1px,
transparent 1px,
transparent);
background-size: #{$size} #{$size};
}
}
// .bg-horizontal-lines-{sm, md, lg, xl}
@if index($pattern-list, 'horizontal-lines') {
.#{$pattern-prefix}-horizontal-lines-#{$name} {
background-image: repeating-linear-gradient(0deg,
currentColor,
currentColor 1px,
transparent 1px,
transparent);
background-size: #{$size} #{$size};
}
}
// .bg-diagonal-lines-{sm, md, lg, xl}
@if index($pattern-list, 'diagonal-lines') {
.#{$pattern-prefix}-diagonal-lines-#{$name} {
background-image: repeating-linear-gradient(45deg,
currentColor 0,
currentColor 1px,
transparent 0,
transparent 50%);
background-size: #{$size} #{$size};
}
}
}
@each $name,
$size in $pattern-sizes {
// .bg-vertical-stripes-{sm, md, lg, xl}
@if index($pattern-list, 'vertical-stripes') {
.#{$pattern-prefix}-vertical-stripes-#{$name} {
background-image: linear-gradient(90deg, transparent 50%, currentColor 50%);
background-size: #{$size} #{$size};
}
}
// .bg-horizontal-stripes-{sm, md, lg, xl}
@if index($pattern-list, 'horizontal-stripes') {
.#{$pattern-prefix}-horizontal-stripes-#{$name} {
background-image: linear-gradient(0deg, transparent 50%, currentColor 50%);
background-size: #{$size} #{$size};
}
}
// .bg-diagonal-stripes-{sm, md, lg, xl}
@if index($pattern-list, 'diagonal-stripes') {
.#{$pattern-prefix}-diagonal-stripes-#{$name} {
background: repeating-linear-gradient(45deg,
transparent,
transparent #{$size},
currentColor #{$size},
currentColor calc(2 * #{$size}));
}
}
}
// .bg-zigzag-{sm, md, lg, xl}
@if index($pattern-list, 'zigzag') {
@each $name,
$size in $pattern-sizes {
.#{$pattern-prefix}-zigzag-#{$name} {
background: linear-gradient(135deg, currentColor 25%, transparent 25%) -#{$size} 0,
linear-gradient(225deg, currentColor 25%, transparent 25%) -#{$size} 0,
linear-gradient(315deg, currentColor 25%, transparent 25%),
linear-gradient(45deg, currentColor 25%, transparent 25%);
background-size: calc(2 * #{$size}) calc(2 * #{$size});
}
}
}
// .bg-triangles-{sm, md, lg, xl}
@if index($pattern-list, 'triangles') {
@each $name,
$size in $pattern-sizes {
.#{$pattern-prefix}-triangles-#{$name} {
background-image: linear-gradient(45deg,
currentColor 50%,
transparent 50%);
background-size: #{$size} #{$size};
}
}
}
// .text-pattern
.text-pattern {
background-clip: text;
-webkit-text-fill-color: transparent;
}
// Width and Height
@each $name,
$size in $pattern-sizes {
.#{$pattern-prefix}-w-#{$name} {
width: $size;
}
.#{$pattern-prefix}-h-#{$name} {
height: $size;
}
}