tailwind_theme 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tailwind_theme/version.rb +1 -1
- data/lib/tailwind_theme.rb +13 -5
- data/spec/fixtures/test-theme.yml +3 -1
- data/spec/tailwind_theme/theme_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84b51de462d19381fd5ca8b0f59fc4dbd868b1a9d76038e8b69bc44bf2b7c7b7
|
4
|
+
data.tar.gz: 937ae47435258ed338e80adaa5106f7577d85426d3f95573b4db1b8bcf1b1d0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31b143b742d196ada6ddbdc0a44146960aea3233ff73b2dd22bc133e567378e69b5c1c01dce3dd83841e593fdb45d0e105275e621460c72a17984baba027cf81
|
7
|
+
data.tar.gz: 887428da5aea0aa9fc6bc5697eff4c5e2e3f7db3108acd42502c770c5f7d088a299f8622a315d75ccfe85518157385fc44536a16798562ee63aafe56f8584980
|
data/lib/tailwind_theme.rb
CHANGED
@@ -35,7 +35,7 @@ module TailwindTheme
|
|
35
35
|
def self.load_file(path)
|
36
36
|
contents = File.read path
|
37
37
|
contents = ERB.new(contents).result if path.end_with?(".erb")
|
38
|
-
Theme.new YAML.safe_load(contents)
|
38
|
+
Theme.new YAML.safe_load(contents, aliases: true, filename: path)
|
39
39
|
end
|
40
40
|
|
41
41
|
# Generate the missing CSS class name from the path
|
@@ -70,6 +70,8 @@ module TailwindTheme
|
|
70
70
|
#
|
71
71
|
# @param [String, Symbol, Array<String, Symbol>] path the path to the css classes or sub theme
|
72
72
|
# @param [Hash<Symbol, Object>] options the options to use when parsing the css theme
|
73
|
+
# @option options [prepend] prepend the classnames before merging the Tailwind Classes
|
74
|
+
# @option options [append] append the classnames before merging the Tailwind Classes
|
73
75
|
# @option options [Boolean] raise raise an `IndexError` if the `path` does not exist
|
74
76
|
# @option options [Object] object the object to apply the sub theme
|
75
77
|
# @option options [Hash<String, Object>] attributes the attributes to apply the sub theme. Overrides
|
@@ -84,13 +86,15 @@ module TailwindTheme
|
|
84
86
|
# @raise [ArgumentError] if processing an object theme and the object or attributes option is not defined
|
85
87
|
def css(path, options = {})
|
86
88
|
classnames = build path, options
|
87
|
-
merge classnames
|
89
|
+
merge classnames, options
|
88
90
|
end
|
89
91
|
|
90
92
|
# Get the merged Tailwind CSS classes. Raises an IndexError if the path cannot be found.
|
91
93
|
#
|
92
94
|
# @param [String, Symbol, Array<String, Symbol>] path the path to the css classes or sub theme
|
93
95
|
# @param [Hash<Symbol, Object>] options the options to use when parsing the css theme
|
96
|
+
# @option options [prepend] prepend the classnames before merging the Tailwind Classes
|
97
|
+
# @option options [append] append the classnames before merging the Tailwind Classes
|
94
98
|
# @option options [Object] object the object to apply the sub theme
|
95
99
|
# @option options [Hash<String, Object>] attributes the attributes to apply the sub theme. Overrides
|
96
100
|
# the attributes defined in `options[:object]`.
|
@@ -107,6 +111,8 @@ module TailwindTheme
|
|
107
111
|
#
|
108
112
|
# @param [Array<String, Symbol, Array<String, Symbol>>] paths the array of paths to combine
|
109
113
|
# @param [Hash<Symbol, Object>] options the options to use when parsing the css theme
|
114
|
+
# @option options [prepend] prepend the classnames before merging the Tailwind Classes
|
115
|
+
# @option options [append] append the classnames before merging the Tailwind Classes
|
110
116
|
# @option options [Boolean] raise raise an `IndexError` if the a path does not exist
|
111
117
|
# @option options [Object] object the object to apply the sub theme
|
112
118
|
# @option options [Hash<String, Object>] attributes the attributes to apply the sub theme. Overrides
|
@@ -121,7 +127,7 @@ module TailwindTheme
|
|
121
127
|
# @raise [ArgumentError] if processing an object theme and the object or attributes option is not defined
|
122
128
|
def merge_css(paths, options = {})
|
123
129
|
classnames = paths.map { |path| build path, options }.compact.join(" ")
|
124
|
-
merge classnames
|
130
|
+
merge classnames, options
|
125
131
|
end
|
126
132
|
|
127
133
|
# Combine multiple paths and merging the combined Tailwind CSS classes. Raises an IndexError if a path
|
@@ -129,6 +135,8 @@ module TailwindTheme
|
|
129
135
|
#
|
130
136
|
# @param [Array<String, Symbol, Array<String, Symbol>>] paths the array of paths to combine
|
131
137
|
# @param [Hash<Symbol, Object>] options the options to use when parsing the css theme
|
138
|
+
# @option options [prepend] prepend the classnames before merging the Tailwind Classes
|
139
|
+
# @option options [append] append the classnames before merging the Tailwind Classes
|
132
140
|
# @option options [Object] object the object to apply the sub theme
|
133
141
|
# @option options [Hash<String, Object>] attributes the attributes to apply the sub theme. Overrides
|
134
142
|
# the attributes defined in `options[:object]`.
|
@@ -273,8 +281,8 @@ module TailwindTheme
|
|
273
281
|
end
|
274
282
|
end
|
275
283
|
|
276
|
-
def merge(classnames)
|
277
|
-
classnames = Array(classnames).flatten.compact.join(" ")
|
284
|
+
def merge(classnames, options)
|
285
|
+
classnames = Array(classnames).prepend(options[:prepend]).append(options[:append]).flatten.compact.join(" ")
|
278
286
|
TailwindTheme.merger.merge classnames
|
279
287
|
end
|
280
288
|
end
|
@@ -25,6 +25,14 @@ RSpec.describe TailwindTheme::Theme do
|
|
25
25
|
expect(theme.css("multipart.key")).to eq "multi-part-key"
|
26
26
|
end
|
27
27
|
|
28
|
+
it "appends the class name" do
|
29
|
+
expect(theme.css("multipart.key", append: "p-6")).to eq "multi-part-key p-6"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "prepend the class name" do
|
33
|
+
expect(theme.css("multipart.key", prepend: "p-6")).to eq "p-6 multi-part-key"
|
34
|
+
end
|
35
|
+
|
28
36
|
context "when string css path" do
|
29
37
|
it "returns a css string" do
|
30
38
|
expect(theme.css("basic")).to eq "basic-classes"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailwind_theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Fawks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tailwind_merge
|