ucss 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +20 -2
  4. data/lib/ucss.rb +14 -4
  5. data/ucss.gemspec +1 -1
  6. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0096266f718c39f493f75d178c1cbda581bf76416ff10573eb66b90073b11bc
4
- data.tar.gz: 6fe847b810cd6e1f11e27aba47b7e5466fe4bac17bfe7df73c555c032d9344ba
3
+ metadata.gz: f9f1fdff2f5b763b1b87ae73debae30aa1021029cc0409e9ce0ea60a22b04600
4
+ data.tar.gz: 89b93dc7a60c094e1ffcd0b98d8481d8a66466125140001af40c80d64e8ce2fe
5
5
  SHA512:
6
- metadata.gz: 427971e2ab812dc37a6cc27da9d149687a040f6eb909b23fbc6bd94d8176f403e1c89ccc5c0beada87f4f559db0be363666e09cf8872bb122b364d5a7344b9dc
7
- data.tar.gz: a9ae1a21d7a4ef0152c95f1629cc98ceea7b3a1021eea0fec214cc15802e19b1b954183e5f16dbb07c31e25a85656df74a2c386ce9d2c7a10a3326d5e4c0d9cf
6
+ metadata.gz: 1fffbb88d70160721b9f407b7b787c099a32efe1a705a2aed69deb3566931bfd466a99662f8e75ca7a9d12bae7414237e778294822b91f53d82dfc70070bba88
7
+ data.tar.gz: 2b2772c01a957b5c633dfc953116f0dd235d6af03dc64db5755adb40aa895d58cd741954140a8d06710bd2c2b7b09d0ef1de649db04e32ae8a9165c435b15a5f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ucss (1.0.0)
4
+ ucss (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -17,4 +17,4 @@ DEPENDENCIES
17
17
  ucss!
18
18
 
19
19
  BUNDLED WITH
20
- 2.2.22
20
+ 2.2.27
data/README.md CHANGED
@@ -39,13 +39,31 @@ div class: "flex gap-#{gap}" do
39
39
  end
40
40
  ```
41
41
 
42
- That won't work, here's how to get it working:
42
+ That won't work, here's one way to get it working:
43
43
 
44
44
  ```ruby
45
- gap = 1
45
+ gap = 0
46
46
  gaps = ['gap-1']
47
47
 
48
48
  div class: "flex #{gaps[gap]}" do
49
49
  'this is an element'
50
50
  end
51
51
  ```
52
+
53
+ or you could do one better:
54
+
55
+ ```ruby
56
+ def vstack(options = {}, &block)
57
+ div class: "flex flex-row flex-auto items-center #{options[:class]}" do
58
+ yield block if block
59
+ end
60
+ end
61
+
62
+ vstack(class: 'gap-1') do
63
+ div '1'
64
+ div '2'
65
+ div '3'
66
+ end
67
+ ```
68
+
69
+ This is assuming you use markaby of course and you're trying to come up with re-usable bits of html.
data/lib/ucss.rb CHANGED
@@ -3,7 +3,8 @@ require_relative 'spacing'
3
3
  require_relative 'hash'
4
4
 
5
5
  class UCss
6
- REGEX = /[^[%w\[]^<>"'`\s]*[^<>"'`\s:^[\[\]]]/
6
+ REGEX = /[^<>"'`\s]*[^<>"'`\s:]/.freeze
7
+
7
8
 
8
9
  def self.spacing(properties)
9
10
  SPACING.transform_values do |v|
@@ -41,6 +42,8 @@ class UCss
41
42
  CLASS_MAP = {
42
43
  'bg' => colors('background'),
43
44
  'p' => spacing(['padding']),
45
+ 'py' => spacing(%w[padding-top padding-bottom]),
46
+ 'px' => spacing(%w[padding-left padding-right]),
44
47
  'm' => spacing(['margin']),
45
48
  'my' => spacing(%w[margin-top margin-bottom]),
46
49
  'mx' => spacing(%w[margin-left margin-right]),
@@ -72,10 +75,17 @@ class UCss
72
75
  }
73
76
  }.merge(COLORS).freeze
74
77
 
78
+ @@classes = []
79
+
80
+ def self.css(str)
81
+ @@classes << str.split(' ').compact
82
+ @@classes.flatten!.uniq!
83
+ end
84
+
75
85
  def initialize
76
86
  @output = './assets/css/utility.css'
77
87
  @input = './views/**/*.*'
78
- @matches = []
88
+ @matches = @@classes || []
79
89
  end
80
90
 
81
91
  def body(name)
@@ -99,10 +109,10 @@ class UCss
99
109
 
100
110
  files.each do |f|
101
111
  s = File.read f
102
- @matches << s.scan(REGEX)
112
+ @matches += s.scan(REGEX)
103
113
  end
104
114
 
105
- @matches = @matches.flatten.compact.uniq
115
+ @matches.uniq!
106
116
  end
107
117
 
108
118
  def write(to: @output)
data/ucss.gemspec CHANGED
@@ -4,7 +4,7 @@ require 'ucss'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'ucss'
7
- spec.version = '1.1.0'
7
+ spec.version = '1.2.0'
8
8
  spec.authors = ['Sean Walker']
9
9
  spec.email = ['']
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ucss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Walker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-03 00:00:00.000000000 Z
11
+ date: 2021-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler