ucss 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d3c03ac29c7181f247ab6aa0303f2457f120755a9048661e1ad1b41f28e5133e
4
+ data.tar.gz: 8014cb34fb82bd0afa631c96c86a9577c6079edcfb934d257153ca6ae3eaa518
5
+ SHA512:
6
+ metadata.gz: 968d568ecd5eac6222300022bc07c89654c7cf128460f35fa4d2ae11859aa53cefbfee0f9d5793b7e2ba1bec32b3bfe4f1b226e0a6de96574bf48ad6618d1148
7
+ data.tar.gz: a16263251d63c59858d36dd9a66c4be9c42d35ce43c2894d03791d82507a38134e458246f76dae9aa5279544dac9024c653b9e1450d3488858c666a404388f6d
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+
2
+ /.bundle/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ /.vagrant/
12
+ /ubuntu-xenial-16.04-cloudimg-console.log
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 1.0.0 / 2021-09-02
2
+
3
+ * Initial release!
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ucss (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (13.0.3)
10
+
11
+ PLATFORMS
12
+ x86_64-darwin-20
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 2.2.10)
16
+ rake (~> 13.0)
17
+ ucss!
18
+
19
+ BUNDLED WITH
20
+ 2.2.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Sean Walker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # ucss
2
+
3
+ _Tailwind jit inspired utility css generator_
4
+
5
+ # What
6
+
7
+ This gem reads files in your view folders for tailwind-like classes and writes the resulting utility css classes to a css file.
8
+
9
+ Kind of like tailwind-jit, almost.
10
+
11
+ # Install
12
+
13
+ ```sh
14
+ gem install ucss
15
+ ```
16
+
17
+ or in your gemfile
18
+
19
+ ```ruby
20
+ gem 'ucss'
21
+ ```
22
+
23
+ # Usage
24
+
25
+ ```ruby
26
+ ucss = UCss.new
27
+ ucss.read(from: './views')
28
+ ucss.write(to: './assets/css/utility.css')
29
+ ```
30
+
31
+ # Scan-ability
32
+
33
+ This won't pick up dynamic string stuff so let's say you're using [markaby](https://github.com/markaby/markaby) and you have something like this:
34
+
35
+ ```ruby
36
+ gap = 1
37
+ div class: "flex gap-#{gap}" do
38
+ "this is an element"
39
+ end
40
+ ```
41
+
42
+ That won't work, here's how to get it working:
43
+
44
+ ```ruby
45
+ gap = 1
46
+ gaps = ['gap-1']
47
+
48
+ div class: "flex #{gaps[gap]}" do
49
+ 'this is an element'
50
+ end
51
+ ```
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ end
6
+
7
+ desc "Run tests"
8
+ task :default => :test
data/lib/ucss.rb ADDED
@@ -0,0 +1,377 @@
1
+ class UCss
2
+ REGEX = /[^[%w\[]^<>"'`\s]*[^<>"'`\s:^[\[\]]]/
3
+
4
+ CLASS_MAP = {
5
+ 'black' => '#000',
6
+ 'white' => '#fff',
7
+ 'rose' => {
8
+ '50' => '#fff1f2',
9
+ '100' => '#ffe4e6',
10
+ '200' => '#fecdd3',
11
+ '300' => '#fda4af',
12
+ '400' => '#fb7185',
13
+ '500' => '#f43f5e',
14
+ '600' => '#e11d48',
15
+ '700' => '#be123c',
16
+ '800' => '#9f1239',
17
+ '900' => '#881337'
18
+ },
19
+ 'pink' => {
20
+ '50' => '#fdf2f8',
21
+ '100' => '#fce7f3',
22
+ '200' => '#fbcfe8',
23
+ '300' => '#f9a8d4',
24
+ '400' => '#f472b6',
25
+ '500' => '#ec4899',
26
+ '600' => '#db2777',
27
+ '700' => '#be185d',
28
+ '800' => '#9d174d',
29
+ '900' => '#831843'
30
+ },
31
+ 'fuchsia' => {
32
+ '50' => '#fdf4ff',
33
+ '100' => '#fae8ff',
34
+ '200' => '#f5d0fe',
35
+ '300' => '#f0abfc',
36
+ '400' => '#e879f9',
37
+ '500' => '#d946ef',
38
+ '600' => '#c026d3',
39
+ '700' => '#a21caf',
40
+ '800' => '#86198f',
41
+ '900' => '#701a75'
42
+ },
43
+ 'purple' => {
44
+ '50' => '#faf5ff',
45
+ '100' => '#f3e8ff',
46
+ '200' => '#e9d5ff',
47
+ '300' => '#d8b4fe',
48
+ '400' => '#c084fc',
49
+ '500' => '#a855f7',
50
+ '600' => '#9333ea',
51
+ '700' => '#7e22ce',
52
+ '800' => '#6b21a8',
53
+ '900' => '#581c87'
54
+ },
55
+ 'violet' => {
56
+ '50' => '#f5f3ff',
57
+ '100' => '#ede9fe',
58
+ '200' => '#ddd6fe',
59
+ '300' => '#c4b5fd',
60
+ '400' => '#a78bfa',
61
+ '500' => '#8b5cf6',
62
+ '600' => '#7c3aed',
63
+ '700' => '#6d28d9',
64
+ '800' => '#5b21b6',
65
+ '900' => '#4c1d95'
66
+ },
67
+ 'indigo' => {
68
+ '50' => '#eef2ff',
69
+ '100' => '#e0e7ff',
70
+ '200' => '#c7d2fe',
71
+ '300' => '#a5b4fc',
72
+ '400' => '#818cf8',
73
+ '500' => '#6366f1',
74
+ '600' => '#4f46e5',
75
+ '700' => '#4338ca',
76
+ '800' => '#3730a3',
77
+ '900' => '#312e81'
78
+ },
79
+ 'blue' => {
80
+ '50' => '#eff6ff',
81
+ '100' => '#dbeafe',
82
+ '200' => '#bfdbfe',
83
+ '300' => '#93c5fd',
84
+ '400' => '#60a5fa',
85
+ '500' => '#3b82f6',
86
+ '600' => '#2563eb',
87
+ '700' => '#1d4ed8',
88
+ '800' => '#1e40af',
89
+ '900' => '#1e3a8a'
90
+ },
91
+ 'sky' => {
92
+ '50' => '#f0f9ff',
93
+ '100' => '#e0f2fe',
94
+ '200' => '#bae6fd',
95
+ '300' => '#7dd3fc',
96
+ '400' => '#38bdf8',
97
+ '500' => '#0ea5e9',
98
+ '600' => '#0284c7',
99
+ '700' => '#0369a1',
100
+ '800' => '#075985',
101
+ '900' => '#0c4a6e'
102
+ },
103
+ 'cyan' => {
104
+ '50' => '#ecfeff',
105
+ '100' => '#cffafe',
106
+ '200' => '#a5f3fc',
107
+ '300' => '#67e8f9',
108
+ '400' => '#22d3ee',
109
+ '500' => '#06b6d4',
110
+ '600' => '#0891b2',
111
+ '700' => '#0e7490',
112
+ '800' => '#155e75',
113
+ '900' => '#164e63'
114
+ },
115
+ 'teal' => {
116
+ '50' => '#f0fdfa',
117
+ '100' => '#ccfbf1',
118
+ '200' => '#99f6e4',
119
+ '300' => '#5eead4',
120
+ '400' => '#2dd4bf',
121
+ '500' => '#14b8a6',
122
+ '600' => '#0d9488',
123
+ '700' => '#0f766e',
124
+ '800' => '#115e59',
125
+ '900' => '#134e4a'
126
+ },
127
+ 'emerald' => {
128
+ '50' => '#ecfdf5',
129
+ '100' => '#d1fae5',
130
+ '200' => '#a7f3d0',
131
+ '300' => '#6ee7b7',
132
+ '400' => '#34d399',
133
+ '500' => '#10b981',
134
+ '600' => '#059669',
135
+ '700' => '#047857',
136
+ '800' => '#065f46',
137
+ '900' => '#064e3b'
138
+ },
139
+ 'green'=>{
140
+ '50' => '#f0fdf4',
141
+ '100' => '#dcfce7',
142
+ '200' => '#bbf7d0',
143
+ '300' => '#86efac',
144
+ '400' => '#4ade80',
145
+ '500' => '#22c55e',
146
+ '600' => '#16a34a',
147
+ '700' => '#15803d',
148
+ '800' => '#166534',
149
+ '900' => '#14532d'
150
+ },
151
+ 'lime'=>{
152
+ '50' => '#f7fee7',
153
+ '100' => '#ecfccb',
154
+ '200' => '#d9f99d',
155
+ '300' => '#bef264',
156
+ '400' => '#a3e635',
157
+ '500' => '#84cc16',
158
+ '600' => '#65a30d',
159
+ '700' => '#4d7c0f',
160
+ '800' => '#3f6212',
161
+ '900' => '#365314'
162
+ },
163
+ 'yellow'=>{
164
+ '50' => '#fefce8',
165
+ '100' => '#fef9c3',
166
+ '200' => '#fef08a',
167
+ '300' => '#fde047',
168
+ '400' => '#facc15',
169
+ '500' => '#eab308',
170
+ '600' => '#ca8a04',
171
+ '700' => '#a16207',
172
+ '800' => '#854d0e',
173
+ '900' => '#713f12'
174
+ },
175
+ 'amber'=>{
176
+ '50' => '#fffbeb',
177
+ '100' => '#fef3c7',
178
+ '200' => '#fde68a',
179
+ '300' => '#fcd34d',
180
+ '400' => '#fbbf24',
181
+ '500' => '#f59e0b',
182
+ '600' => '#d97706',
183
+ '700' => '#b45309',
184
+ '800' => '#92400e',
185
+ '900' => '#78350f'
186
+ },
187
+ 'orange'=>{
188
+ '50' => '#fff7ed',
189
+ '100' => '#ffedd5',
190
+ '200' => '#fed7aa',
191
+ '300' => '#fdba74',
192
+ '400' => '#fb923c',
193
+ '500' => '#f97316',
194
+ '600' => '#ea580c',
195
+ '700' => '#c2410c',
196
+ '800' => '#9a3412',
197
+ '900' => '#7c2d12'
198
+ },
199
+ 'red'=>{
200
+ '50' => '#fef2f2',
201
+ '100' => '#fee2e2',
202
+ '200' => '#fecaca',
203
+ '300' => '#fca5a5',
204
+ '400' => '#f87171',
205
+ '500' => '#ef4444',
206
+ '600' => '#dc2626',
207
+ '700' => '#b91c1c',
208
+ '800' => '#991b1b',
209
+ '900' => '#7f1d1d'
210
+ },
211
+ 'warmGray'=>{
212
+ '50' => '#fafaf9',
213
+ '100' => '#f5f5f4',
214
+ '200' => '#e7e5e4',
215
+ '300' => '#d6d3d1',
216
+ '400' => '#a8a29e',
217
+ '500' => '#78716c',
218
+ '600' => '#57534e',
219
+ '700' => '#44403c',
220
+ '800' => '#292524',
221
+ '900' => '#1c1917'
222
+ },
223
+ 'trueGray'=>{
224
+ '50' => '#fafafa',
225
+ '100' => '#f5f5f5',
226
+ '200' => '#e5e5e5',
227
+ '300' => '#d4d4d4',
228
+ '400' => '#a3a3a3',
229
+ '500' => '#737373',
230
+ '600' => '#525252',
231
+ '700' => '#404040',
232
+ '800' => '#262626',
233
+ '900' => '#171717'
234
+ },
235
+ 'gray'=>{
236
+ '50' => '#fafafa',
237
+ '100' => '#f4f4f5',
238
+ '200' => '#e4e4e7',
239
+ '300' => '#d4d4d8',
240
+ '400' => '#a1a1aa',
241
+ '500' => '#71717a',
242
+ '600' => '#52525b',
243
+ '700' => '#3f3f46',
244
+ '800' => '#27272a',
245
+ '900' => '#18181b'
246
+ },
247
+ 'coolGray'=>{
248
+ '50' => '#f9fafb',
249
+ '100' => '#f3f4f6',
250
+ '200' => '#e5e7eb',
251
+ '300' => '#d1d5db',
252
+ '400' => '#9ca3af',
253
+ '500' => '#6b7280',
254
+ '600' => '#4b5563',
255
+ '700' => '#374151',
256
+ '800' => '#1f2937',
257
+ '900' => '#111827'
258
+ },
259
+ 'blueGray'=>{
260
+ '50' => '#f8fafc',
261
+ '100' => '#f1f5f9',
262
+ '200' => '#e2e8f0',
263
+ '300' => '#cbd5e1',
264
+ '400' => '#94a3b8',
265
+ '500' => '#64748b',
266
+ '600' => '#475569',
267
+ '700' => '#334155',
268
+ '800' => '#1e293b',
269
+ '900' => '#0f172a'
270
+ },
271
+ 'px' => '1px',
272
+ '0' => '0px',
273
+ '0.5' => '0.125rem',
274
+ '1' => '0.25rem',
275
+ '1.5' => '0.375rem',
276
+ '2' => '0.5rem',
277
+ '2.5' => '0.625rem',
278
+ '3' => '0.75rem',
279
+ '3.5' => '0.875rem',
280
+ '4' => '1rem',
281
+ '5' => '1.25rem',
282
+ '6' => '1.5rem',
283
+ '7' => '1.75rem',
284
+ '8' => '2rem',
285
+ '9' => '2.25rem',
286
+ '10' => '2.5rem',
287
+ '11' => '2.75rem',
288
+ '12' => '3rem',
289
+ '14' => '3.5rem',
290
+ '16' => '4rem',
291
+ '20' => '5rem',
292
+ '24' => '6rem',
293
+ '28' => '7rem',
294
+ '32' => '8rem',
295
+ '36' => '9rem',
296
+ '40' => '10rem',
297
+ '44' => '11rem',
298
+ '48' => '12rem',
299
+ '52' => '13rem',
300
+ '56' => '14rem',
301
+ '60' => '15rem',
302
+ '64' => '16rem',
303
+ '72' => '18rem',
304
+ '80' => '20rem',
305
+ '96' => '24rem',
306
+ 'bg' => 'background',
307
+ 'p' => 'padding',
308
+ 'm' => 'margin',
309
+ 'my'=> [
310
+ 'margin-top',
311
+ 'margin-bottom'
312
+ ],
313
+ 'mx'=> [
314
+ 'margin-left',
315
+ 'margin-right'
316
+ ],
317
+ 'text' => 'color',
318
+ 'text-left' => 'text-align: left',
319
+ 'text-right' => 'text-align: right',
320
+ 'stretch' => 'stretch',
321
+ 'center' => 'center',
322
+ 'flex' => 'display: flex',
323
+ 'self' => 'align-self',
324
+ 'items' => 'align-items',
325
+ 'flex-start' => 'flex-start',
326
+ 'flex-end' => 'flex-end',
327
+ 'flex-row' => 'flex-direction: row',
328
+ 'flex-col' => 'flex-direction: col',
329
+ 'gap' => 'gap',
330
+ 'auto' => 'auto'
331
+ }.freeze
332
+
333
+ def initialize
334
+ @output = './assets/css/utility.css'
335
+ @input = './views/**/*.*'
336
+ @matches = []
337
+ end
338
+
339
+ def body(name)
340
+ # check for a direct key value pair
341
+ return ".#{name} { #{CLASS_MAP[name]}; }" if CLASS_MAP[name]
342
+
343
+ # otherwise split it up and get property/value pair from modifiers
344
+ parts = name.split('-')
345
+
346
+ property = CLASS_MAP[parts[0]]
347
+
348
+ return if property.nil? || property&.empty?
349
+
350
+ value = CLASS_MAP.dig(*parts.drop(1))
351
+
352
+ content = "#{property}: #{value};"
353
+
354
+ content = property.map { |p| "#{p}: #{value};" }.join(' ') if property.is_a?(Array)
355
+
356
+ ".#{name} { #{content} }"
357
+ end
358
+
359
+ def content(classes = @matches)
360
+ classes.map { |name| body(name) }.compact.join("\n")
361
+ end
362
+
363
+ def read(from: @input)
364
+ files = Dir[from]
365
+
366
+ files.each do |f|
367
+ s = File.read f
368
+ @matches << s.scan(REGEX)
369
+ end
370
+
371
+ @matches = @matches.flatten.compact.uniq
372
+ end
373
+
374
+ def write(to: @output)
375
+ File.write to, content(@matches)
376
+ end
377
+ end
data/ucss.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'ucss'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'ucss'
7
+ spec.version = '1.0.0'
8
+ spec.authors = ['Sean Walker']
9
+ spec.email = ['']
10
+
11
+ spec.summary = %q{Tailwind jit inspired utility css generator}
12
+ spec.description = %q{This gem reads files in your view folders for tailwind-like classes and writes the resulting utility css classes to a css file.
13
+ }
14
+ spec.homepage = 'https://github.com/swlkr/ucss'
15
+ spec.license = 'MIT'
16
+
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/swlkr/ucss'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/swlkr/ucss/CHANGELOG.md'
21
+ else
22
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
23
+ 'public gem pushes.'
24
+ end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.bindir = 'exe'
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ['lib']
34
+
35
+ spec.add_development_dependency 'bundler', '~> 2.2.10'
36
+ spec.add_development_dependency 'rake', '~> 13.0'
37
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ucss
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sean Walker
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.2.10
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.2.10
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ description: 'This gem reads files in your view folders for tailwind-like classes
42
+ and writes the resulting utility css classes to a css file.
43
+
44
+ '
45
+ email:
46
+ - ''
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - CHANGELOG.md
53
+ - Gemfile
54
+ - Gemfile.lock
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - lib/ucss.rb
59
+ - ucss.gemspec
60
+ homepage: https://github.com/swlkr/ucss
61
+ licenses:
62
+ - MIT
63
+ metadata:
64
+ homepage_uri: https://github.com/swlkr/ucss
65
+ source_code_uri: https://github.com/swlkr/ucss
66
+ changelog_uri: https://github.com/swlkr/ucss/CHANGELOG.md
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.2.22
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Tailwind jit inspired utility css generator
86
+ test_files: []