glimmer-dsl-css 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 967caae689a729dcf6c70d97a761bc48da8e8d285cd19348aada3dee83ffc32a
4
- data.tar.gz: 8f896b942182779e573bed0a4c039efbabe724b40b3d82dff6ded1d5d0ebe8fd
3
+ metadata.gz: a00ff31e682fcc94d72464388bec42ba14ee932dda12bb3c6013b8dd8e406db5
4
+ data.tar.gz: f78b7fe8fab6e01321ffffb4af61321470e131ccd4da523fed318e753e1b90c6
5
5
  SHA512:
6
- metadata.gz: b5faae751daf2f5e6c608682fd8c035993f4fef13ce7fa2c8ff21100b30f09338939cb7d3e9b33f225632ee203a5f858610c1992bf14954dc1e0efc1b135dbf6
7
- data.tar.gz: '018c7875e4fcbd9c32012f0a489c5524de5cd76be406e1349ce0665204f5f4dac27e27ad0e98e30924816467f2c3ba66aa768533adbb26fa68f5ba506c0b8def'
6
+ metadata.gz: 278840c459c817881f89642c343ceb56cf201604adbb7d4b26e6f2d6676f9716245c196269422696d9936cc3795c296d48e52127fe1afb05b26b0c8f91bbfefa
7
+ data.tar.gz: 6e191a28c199a17b44c7e3b5e154d87bb6f36d945eb5e9aafe536fd3db2f87953f79fd99f80af53ef555782052ab822299bfa51ed38308ddec42da9726b723ab
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.3.0
4
+
5
+ - Support media queries
6
+
3
7
  ## 1.2.3
4
8
 
5
9
  - Add `r`, `ru`, `rul`, `rule`, `_` alternatives to `s` for specifying a CSS rule selector with a block of expressions (e.g. `r('body > h1') { color: red; }`)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for CSS 1.2.3
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for CSS 1.3.0
2
2
  ## Ruby Programmable Cascading Style Sheets
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-css.svg)](http://badge.fury.io/rb/glimmer-dsl-css)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-css.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-css)
@@ -18,10 +18,18 @@ include Glimmer
18
18
  font_size '1.1em'
19
19
  background 'white'
20
20
  }
21
- r('body > h1') {
21
+
22
+ rule('body > h1') {
22
23
  background_color :red
23
24
  font_size 24
24
25
  }
26
+
27
+ media('screen and (min-width: 30em) and (orientation: landscape)') {
28
+ rule('body#app h1#title') {
29
+ font_size 16
30
+ font_family '"Times New Roman", Times, serif'
31
+ }
32
+ }
25
33
  }
26
34
  puts @css
27
35
  ```
@@ -29,7 +37,7 @@ puts @css
29
37
  Output (minified CSS):
30
38
 
31
39
  ```css
32
- body{font-size:1.1em;background:white}body > h1{background-color:red;font-size:24px}
40
+ body{font-size:1.1em;background:white}body > h1{background-color:red;font-size:24px}@media screen and (min-width: 30em) and (orientation: landscape){body#app h1#title{font-size:16px;font-family:"Times New Roman", Times, serif}}
33
41
  ```
34
42
 
35
43
  The key reason for using the CSS DSL instead of actual CSS is Ruby programmability without getting lost in string concatenations. The CSS DSL helps in including conditional CSS with `if` or ternery expressions as well as looping from lists while building CSS.
@@ -53,7 +61,7 @@ Please follow these instructions to make the `glimmer` command available on your
53
61
 
54
62
  Run this command to install directly:
55
63
  ```
56
- gem install glimmer-dsl-css -v 1.2.3
64
+ gem install glimmer-dsl-css -v 1.3.0
57
65
  ```
58
66
 
59
67
  Note: In case you are using JRuby, `jgem` is JRuby's version of the `gem` command. RVM allows running `gem` as an alias in JRuby. Otherwise, you may also run `jruby -S gem install ...`
@@ -68,7 +76,7 @@ That's it! Requiring the gem activates the Glimmer CSS DSL automatically.
68
76
 
69
77
  Add the following to `Gemfile` (after `glimmer-dsl-swt` and/or `glimmer-dsl-opal` if included too):
70
78
  ```
71
- gem 'glimmer-dsl-css', '~> 1.2.3'
79
+ gem 'glimmer-dsl-css', '~> 1.3.0'
72
80
  ```
73
81
 
74
82
  And, then run:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.3
1
+ 1.3.0
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-css 1.2.3 ruby lib
5
+ # stub: glimmer-dsl-css 1.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-css".freeze
9
- s.version = "1.2.3".freeze
9
+ s.version = "1.3.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2024-01-08"
14
+ s.date = "2024-05-18"
15
15
  s.description = "Glimmer DSL for CSS (Ruby Programmable Cascading Style Sheets)".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -27,13 +27,16 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "glimmer-dsl-css.gemspec",
29
29
  "lib/glimmer-dsl-css.rb",
30
+ "lib/glimmer/css/media_query.rb",
30
31
  "lib/glimmer/css/rule.rb",
32
+ "lib/glimmer/css/rule_composite.rb",
31
33
  "lib/glimmer/css/style_sheet.rb",
32
34
  "lib/glimmer/dsl/css/css_expression.rb",
33
35
  "lib/glimmer/dsl/css/dsl.rb",
34
36
  "lib/glimmer/dsl/css/dynamic_property_expression.rb",
35
37
  "lib/glimmer/dsl/css/element_rule_expression.rb",
36
38
  "lib/glimmer/dsl/css/general_rule_expression.rb",
39
+ "lib/glimmer/dsl/css/media_expression.rb",
37
40
  "lib/glimmer/dsl/css/property_expression.rb",
38
41
  "lib/glimmer/dsl/css/pv_expression.rb",
39
42
  "lib/glimmer/dsl/css/ru_expression.rb",
@@ -43,21 +46,21 @@ Gem::Specification.new do |s|
43
46
  ]
44
47
  s.homepage = "http://github.com/AndyObtiva/glimmer-dsl-css".freeze
45
48
  s.licenses = ["MIT".freeze]
46
- s.rubygems_version = "3.5.3".freeze
49
+ s.rubygems_version = "3.4.10".freeze
47
50
  s.summary = "Glimmer DSL for CSS (Ruby Programmable Cascading Style Sheets)".freeze
48
51
 
49
52
  s.specification_version = 4
50
53
 
51
- s.add_runtime_dependency(%q<glimmer>.freeze, [">= 2.0.0".freeze, "< 3.0.0".freeze])
52
- s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.0".freeze])
53
- s.add_development_dependency(%q<rspec>.freeze, ["~> 3.0".freeze])
54
- s.add_development_dependency(%q<puts_debuggerer>.freeze, [">= 0".freeze])
55
- s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0".freeze, "< 14.0.0".freeze])
56
- s.add_development_dependency(%q<jeweler>.freeze, [">= 2.3.9".freeze, "< 3.0.0".freeze])
57
- s.add_development_dependency(%q<rdoc>.freeze, [">= 6.2.1".freeze, "< 7.0.0".freeze])
58
- s.add_development_dependency(%q<coveralls>.freeze, ["= 0.8.23".freeze])
59
- s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1".freeze])
60
- s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0".freeze])
61
- s.add_development_dependency(%q<rake-tui>.freeze, [">= 0".freeze])
54
+ s.add_runtime_dependency(%q<glimmer>.freeze, [">= 2.0.0", "< 3.0.0"])
55
+ s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.0"])
56
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 3.0"])
57
+ s.add_development_dependency(%q<puts_debuggerer>.freeze, [">= 0"])
58
+ s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
59
+ s.add_development_dependency(%q<jeweler>.freeze, [">= 2.3.9", "< 3.0.0"])
60
+ s.add_development_dependency(%q<rdoc>.freeze, [">= 6.2.1", "< 7.0.0"])
61
+ s.add_development_dependency(%q<coveralls>.freeze, ["= 0.8.23"])
62
+ s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
63
+ s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
64
+ s.add_development_dependency(%q<rake-tui>.freeze, [">= 0"])
62
65
  end
63
66
 
@@ -0,0 +1,34 @@
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ module Glimmer
23
+ module CSS
24
+ class MediaQuery < Rule
25
+ include RuleComposite
26
+
27
+ def to_css
28
+ css = "@media #{selector}{"
29
+ css += rules.map(&:to_css).join
30
+ css += "}"
31
+ end
32
+ end
33
+ end
34
+ end
@@ -24,9 +24,11 @@ module Glimmer
24
24
  class Rule
25
25
  attr_reader :selector, :properties
26
26
 
27
- def initialize(selector)
27
+ def initialize(selector, parent:)
28
28
  @selector = selector
29
29
  @properties = {}
30
+ @parent = parent
31
+ parent.rules << self
30
32
  end
31
33
 
32
34
  def add_property(keyword, *args)
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ module Glimmer
23
+ module CSS
24
+ module RuleComposite
25
+ def rules
26
+ @rules ||= []
27
+ end
28
+ end
29
+ end
30
+ end
@@ -19,16 +19,13 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
+ require 'glimmer/css/rule_composite'
22
23
  require 'glimmer/css/rule'
23
24
 
24
25
  module Glimmer
25
26
  module CSS
26
27
  class StyleSheet
27
- attr_reader :rules
28
-
29
- def initialize
30
- @rules = []
31
- end
28
+ include RuleComposite
32
29
 
33
30
  def to_css
34
31
  rules.map(&:to_css).join
@@ -29,6 +29,7 @@ require 'glimmer/dsl/css/rul_expression'
29
29
  require 'glimmer/dsl/css/ru_expression'
30
30
  require 'glimmer/dsl/css/s_expression'
31
31
  require 'glimmer/dsl/css/pv_expression'
32
+ require 'glimmer/dsl/css/media_expression'
32
33
 
33
34
  module Glimmer
34
35
  module DSL
@@ -36,6 +37,7 @@ module Glimmer
36
37
  Engine.add_dynamic_expressions(
37
38
  CSS,
38
39
  %w[
40
+ media
39
41
  element_rule
40
42
  dynamic_property
41
43
  ]
@@ -37,9 +37,7 @@ module Glimmer
37
37
  end
38
38
 
39
39
  def interpret(parent, keyword, *args, &block)
40
- Glimmer::CSS::Rule.new(keyword.to_s.downcase).tap do |rule|
41
- parent.rules << rule
42
- end
40
+ Glimmer::CSS::Rule.new(keyword.to_s.downcase, parent: parent)
43
41
  end
44
42
  end
45
43
  end
@@ -31,15 +31,16 @@ module Glimmer
31
31
 
32
32
  def can_interpret?(parent, keyword, *args, &block)
33
33
  super(parent, keyword, *args, &block) and
34
- parent.is_a?(Glimmer::CSS::StyleSheet) and
34
+ (
35
+ parent.is_a?(Glimmer::CSS::StyleSheet) or
36
+ parent.is_a?(Glimmer::CSS::MediaQuery)
37
+ ) and
35
38
  block_given? and
36
39
  !args.empty?
37
40
  end
38
41
 
39
42
  def interpret(parent, keyword, *args, &block)
40
- Glimmer::CSS::Rule.new(args.first.to_s).tap do |rule|
41
- parent.rules << rule
42
- end
43
+ Glimmer::CSS::Rule.new(args.first.to_s, parent: parent)
43
44
  end
44
45
  end
45
46
  end
@@ -0,0 +1,47 @@
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/dsl/parent_expression'
23
+ require 'glimmer/dsl/static_expression'
24
+
25
+ require 'glimmer/css/style_sheet'
26
+ require 'glimmer/css/media_query'
27
+
28
+ module Glimmer
29
+ module DSL
30
+ module CSS
31
+ class MediaExpression < StaticExpression
32
+ include ParentExpression
33
+
34
+ def can_interpret?(parent, keyword, *args, &block)
35
+ super(parent, keyword, *args, &block) and
36
+ parent.is_a?(Glimmer::CSS::StyleSheet) and
37
+ block_given? and
38
+ !args.empty?
39
+ end
40
+
41
+ def interpret(parent, keyword, *args, &block)
42
+ Glimmer::CSS::MediaQuery.new(args.first.to_s, parent: parent)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-css
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -204,13 +204,16 @@ files:
204
204
  - VERSION
205
205
  - glimmer-dsl-css.gemspec
206
206
  - lib/glimmer-dsl-css.rb
207
+ - lib/glimmer/css/media_query.rb
207
208
  - lib/glimmer/css/rule.rb
209
+ - lib/glimmer/css/rule_composite.rb
208
210
  - lib/glimmer/css/style_sheet.rb
209
211
  - lib/glimmer/dsl/css/css_expression.rb
210
212
  - lib/glimmer/dsl/css/dsl.rb
211
213
  - lib/glimmer/dsl/css/dynamic_property_expression.rb
212
214
  - lib/glimmer/dsl/css/element_rule_expression.rb
213
215
  - lib/glimmer/dsl/css/general_rule_expression.rb
216
+ - lib/glimmer/dsl/css/media_expression.rb
214
217
  - lib/glimmer/dsl/css/property_expression.rb
215
218
  - lib/glimmer/dsl/css/pv_expression.rb
216
219
  - lib/glimmer/dsl/css/ru_expression.rb
@@ -236,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
239
  - !ruby/object:Gem::Version
237
240
  version: '0'
238
241
  requirements: []
239
- rubygems_version: 3.5.3
242
+ rubygems_version: 3.4.10
240
243
  signing_key:
241
244
  specification_version: 4
242
245
  summary: Glimmer DSL for CSS (Ruby Programmable Cascading Style Sheets)