glimmer-dsl-css 1.2.2 → 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: '09f17a315cf56a9f08a1a91c57cc598f009a62b9badb2eba4da545cb17157f38'
4
- data.tar.gz: 4258369478ff7d33d7d666384d175bf3f0222d7dc792f36e372b028fa38a6339
3
+ metadata.gz: a00ff31e682fcc94d72464388bec42ba14ee932dda12bb3c6013b8dd8e406db5
4
+ data.tar.gz: f78b7fe8fab6e01321ffffb4af61321470e131ccd4da523fed318e753e1b90c6
5
5
  SHA512:
6
- metadata.gz: bc3d9abd5b4773008bba4e7ee710af47677123c0540d9bca7f15c3f25fd2cf3256b72d6fd4ade3400dfc0c8cd2ba990a5ec0c09009b9ba2776a2c21c2c81ec05
7
- data.tar.gz: 66ab0814f1e0ffba0aa4cde5c414763ec0a5b0388a5142b49e72697838b4228b23abd8cb8b77ede45013ce11ab8ca12f0bd7195dba61955cb076cbaefd864a9a
6
+ metadata.gz: 278840c459c817881f89642c343ceb56cf201604adbb7d4b26e6f2d6676f9716245c196269422696d9936cc3795c296d48e52127fe1afb05b26b0c8f91bbfefa
7
+ data.tar.gz: 6e191a28c199a17b44c7e3b5e154d87bb6f36d945eb5e9aafe536fd3db2f87953f79fd99f80af53ef555782052ab822299bfa51ed38308ddec42da9726b723ab
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.3.0
4
+
5
+ - Support media queries
6
+
7
+ ## 1.2.3
8
+
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; }`)
10
+
3
11
  ## 1.2.2
4
12
 
5
13
  - Relax glimmer dependency to between 2.0.0 and 3.0.0
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020-2022 - Andy Maleh
1
+ Copyright (c) 2020-2024 - Andy Maleh
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,29 +1,57 @@
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.2
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
+ ## Ruby Programmable Cascading Style Sheets
2
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-css.svg)](http://badge.fury.io/rb/glimmer-dsl-css)
3
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-css.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-css)
4
5
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-css/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-css?branch=master)
5
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/c7365cdb8556be433115/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-css/maintainability)
6
7
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
8
 
8
- [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for CSS provides Ruby syntax for building CSS (Cascading Style Sheets). It used to be part of the [Glimmer](https://github.com/AndyObtiva/glimmer) library (created in 2007), but eventually got extracted into its own project.
9
+ [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for CSS provides Ruby syntax for building CSS (Cascading Style Sheets). It used to be part of the [Glimmer](https://github.com/AndyObtiva/glimmer) library (created in 2007), but eventually got extracted into its own project.
9
10
 
10
- Within the context of [Glimmer](https://github.com/AndyObtiva/glimmer) app development, Glimmer DSL for CSS is useful in providing CSS for the [SWT Browser widget](https://github.com/AndyObtiva/glimmer-dsl-swt/tree/master#browser-widget).
11
+ Example (you can try in IRB):
12
+
13
+ ```ruby
14
+ require 'glimmer-dsl-css'
15
+ include Glimmer
16
+ @css = css {
17
+ body {
18
+ font_size '1.1em'
19
+ background 'white'
20
+ }
21
+
22
+ rule('body > h1') {
23
+ background_color :red
24
+ font_size 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
+ }
33
+ }
34
+ puts @css
35
+ ```
36
+
37
+ Output (minified CSS):
11
38
 
12
- Additionally, it is useful with [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal).
39
+ ```css
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}}
41
+ ```
13
42
 
14
- **[Glimmer](https://rubygems.org/gems/glimmer) DSL Comparison Table:**
15
- DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
16
- ----|-----------|---------|------------------|------|------|--------
17
- [Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)](https://github.com/AndyObtiva/glimmer-dsl-swt) | Mac / Windows / Linux | Yes | Yes (Canvas Shape DSL) | Very Mature / Scaffolding / Native Executable Packaging / Custom Widgets | Slow JRuby Startup Time / Heavy Memory Footprint | Java / JRuby
18
- [Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)](https://github.com/AndyObtiva/glimmer-dsl-opal) | All Web Browsers | No | Yes (Canvas Shape DSL) | Simpler than All JavaScript Technologies / Auto-Webify Desktop Apps | Setup Process / Only Rails 5 Support for Now | Rails
19
- [Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-libui) | Mac / Windows / Linux | Yes | Yes (Area API) | Fast Startup Time / Light Memory Footprint | LibUI is an Incomplete Mid-Alpha Only | None Other Than MRI Ruby
20
- [Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-tk) | Mac / Windows / Linux | Some Native-Themed Widgets (Not Truly Native) | Yes (Canvas) | Fast Startup Time / Light Memory Footprint | Widgets Do Not Look Truly Native, Espcially on Linux | ActiveTcl / MRI Ruby
21
- [Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-gtk) | Mac / Windows / Linux | Only on Linux | Yes (Cairo) | Complete Access to GNOME Features on Linux (Forte) | Not Native on Mac and Windows | None Other Than MRI Ruby on Linux / Brew Packages on Mac / MSYS & MING Toolchains on Windows / MRI Ruby
22
- [Glimmer DSL for FX (FOX Toolkit Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-fx) | Mac (requires XQuartz) / Windows / Linux | No | Yes (Canvas) | No Prerequisites on Windows (Forte Since Binaries Are Included Out of The Box) | Widgets Do Not Look Native / Mac Usage Obtrusively Starts XQuartz | None Other Than MRI Ruby on Windows / XQuarts on Mac / MRI Ruby
23
- [Glimmer DSL for JFX (JRuby JavaFX Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-jfx) | Mac / Windows / Linux | No | Yes (javafx.scene.shape and javafx.scene.canvas) | Rich in Custom Widgets | Slow JRuby Startup Time / Heavy Memory Footprint / Widgets Do Not Look Native | Java / JRuby / JavaFX SDK
24
- [Glimmer DSL for Swing (JRuby Swing Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-swing) | Mac / Windows / Linux | No | Yes (Java2D) | Very Mature | Slow JRuby Startup Time / Heavy Memory Footprint / Widgets Do Not Look Native | Java / JRuby
25
- [Glimmer DSL for XML (& HTML)](https://github.com/AndyObtiva/glimmer-dsl-xml) | All Web Browsers | No | Yes (SVG) | Programmable / Lighter-weight Than Actual XML | XML Elements Are Sometimes Not Well-Named (Many Types of Input) | None
26
- [Glimmer DSL for CSS](https://github.com/AndyObtiva/glimmer-dsl-css) | All Web Browsers | No | Yes | Programmable | CSS Is Over-Engineered / Too Many Features To Learn | None
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.
44
+
45
+ ```
46
+ rule('body > h1') {
47
+ background_color is_error ? :red : :green
48
+ font_size new_user ? 24 : 20
49
+ }
50
+ ```
51
+
52
+ Within the context of [Glimmer](https://github.com/AndyObtiva/glimmer) app development, Glimmer DSL for CSS is useful in providing CSS for [Glimmer DSL for Web](https://github.com/AndyObtiva/glimmer-dsl-web), [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal), and the [SWT Browser widget](https://github.com/AndyObtiva/glimmer-dsl-swt/tree/master#browser-widget).
53
+
54
+ Learn more about the differences between various [Glimmer](https://github.com/AndyObtiva/glimmer) DSLs by looking at the **[Glimmer DSL Comparison Table](https://github.com/AndyObtiva/glimmer#glimmer-dsl-comparison-table)**.
27
55
 
28
56
  ## Setup
29
57
 
@@ -33,7 +61,7 @@ Please follow these instructions to make the `glimmer` command available on your
33
61
 
34
62
  Run this command to install directly:
35
63
  ```
36
- gem install glimmer-dsl-css -v 1.2.2
64
+ gem install glimmer-dsl-css -v 1.3.0
37
65
  ```
38
66
 
39
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 ...`
@@ -48,7 +76,7 @@ That's it! Requiring the gem activates the Glimmer CSS DSL automatically.
48
76
 
49
77
  Add the following to `Gemfile` (after `glimmer-dsl-swt` and/or `glimmer-dsl-opal` if included too):
50
78
  ```
51
- gem 'glimmer-dsl-css', '~> 1.2.2'
79
+ gem 'glimmer-dsl-css', '~> 1.3.0'
52
80
  ```
53
81
 
54
82
  And, then run:
@@ -66,15 +94,22 @@ That's it! Requiring the gem activates the Glimmer CSS DSL automatically.
66
94
 
67
95
  ## CSS DSL
68
96
 
69
- 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 as well as looping from lists while building CSS.
97
+ 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.
98
+
99
+ ```
100
+ _('body > h1') {
101
+ background_color is_error ? :red : :green
102
+ font_size new_user ? 24 : 20
103
+ }
104
+ ```
70
105
 
71
106
  Simply start with `css` keyword and add stylesheet rule sets inside its block using Glimmer DSL syntax.
72
107
  Once done, you may call `to_s` or `to_css` to get the formatted CSS output.
73
108
 
74
109
  `css` is the only top-level keyword in the Glimmer CSS DSL
75
110
 
76
- Selectors may be specified by `s` keyword or HTML element keyword directly (e.g. `body`)
77
- Rule property values may be specified by `pv` keyword or underscored property name directly (e.g. `font_size`)
111
+ Selectors may be specified by any of `_`, `s`, `r`, `ru`, `rul`, `rule` keywords or HTML element keyword directly (e.g. `body`)
112
+ Rule property values may be specified by underscored property name directly (e.g. `font_size`), which is auto-translated to CSS property name by replacing underscores with dashes (e.g. `font-size`)
78
113
 
79
114
  Example (you can try in IRB):
80
115
 
@@ -84,11 +119,11 @@ include Glimmer
84
119
  @css = css {
85
120
  body {
86
121
  font_size '1.1em'
87
- pv 'background', 'white'
122
+ background 'white'
88
123
  }
89
- s('body > h1') {
124
+ r('body > h1') {
90
125
  background_color :red
91
- pv 'font-size', 24
126
+ font_size 24
92
127
  }
93
128
  }
94
129
  puts @css
@@ -100,9 +135,61 @@ Output (minified CSS):
100
135
  body{font-size:1.1em;background:white}body > h1{background-color:red;font-size:24px}
101
136
  ```
102
137
 
138
+ The `body > h1` rule could have been written in any other alternative way:
139
+
140
+ ```ruby
141
+ rule('body > h1') {
142
+ background_color :red
143
+ font_size 24
144
+ }
145
+ ```
146
+
147
+ ```ruby
148
+ rul('body > h1') {
149
+ background_color :red
150
+ font_size 24
151
+ }
152
+ ```
153
+
154
+ ```ruby
155
+ _('body > h1') {
156
+ background_color :red
157
+ font_size 24
158
+ }
159
+ ```
160
+
161
+ ```ruby
162
+ _ 'body > h1' do
163
+ background_color :red
164
+ font_size 24
165
+ end
166
+ ```
167
+
103
168
  ### Numeric Values
104
169
 
105
- As you saw above, numeric values (e.g. `24` in `pv 'font-size', 24`) automatically get suffixed with `px` by convention (e.g. `24px`).
170
+ As you saw above, numeric values (e.g. `24` in `font_size 24`) automatically get suffixed with `px` by convention (e.g. `24px`).
171
+
172
+ ```ruby
173
+ require 'glimmer-dsl-css'
174
+ include Glimmer
175
+ @css = css {
176
+ body {
177
+ font_size '1.1em'
178
+ background 'white'
179
+ }
180
+ _ 'body > h1' do
181
+ background_color :red
182
+ font_size 24
183
+ end
184
+ }
185
+ puts @css
186
+ ```
187
+
188
+ Output (minified CSS):
189
+
190
+ ```css
191
+ body{font-size:1.1em;background:white}body > h1{background-color:red;font-size:24px}
192
+ ```
106
193
 
107
194
  ## Multi-DSL Support
108
195
 
@@ -146,7 +233,7 @@ These features have been suggested. You might see them in a future version of Gl
146
233
 
147
234
  [MIT](LICENSE.txt)
148
235
 
149
- Copyright (c) 2020-2022 - Andy Maleh.
236
+ Copyright (c) 2020-2024 - Andy Maleh.
150
237
 
151
238
  --
152
239
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.3.0
@@ -2,17 +2,17 @@
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.2 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.2"
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 = "2023-06-15"
15
- s.description = "Glimmer DSL for CSS (Cascading Style Sheets)".freeze
14
+ s.date = "2024-05-18"
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 = [
18
18
  "CHANGELOG.md",
@@ -27,49 +27,40 @@ 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",
37
+ "lib/glimmer/dsl/css/element_rule_expression.rb",
38
+ "lib/glimmer/dsl/css/general_rule_expression.rb",
39
+ "lib/glimmer/dsl/css/media_expression.rb",
35
40
  "lib/glimmer/dsl/css/property_expression.rb",
36
41
  "lib/glimmer/dsl/css/pv_expression.rb",
42
+ "lib/glimmer/dsl/css/ru_expression.rb",
43
+ "lib/glimmer/dsl/css/rul_expression.rb",
37
44
  "lib/glimmer/dsl/css/rule_expression.rb",
38
45
  "lib/glimmer/dsl/css/s_expression.rb"
39
46
  ]
40
47
  s.homepage = "http://github.com/AndyObtiva/glimmer-dsl-css".freeze
41
48
  s.licenses = ["MIT".freeze]
42
- s.rubygems_version = "3.2.22".freeze
43
- s.summary = "Glimmer DSL for CSS".freeze
49
+ s.rubygems_version = "3.4.10".freeze
50
+ s.summary = "Glimmer DSL for CSS (Ruby Programmable Cascading Style Sheets)".freeze
44
51
 
45
- if s.respond_to? :specification_version then
46
- s.specification_version = 4
47
- end
52
+ s.specification_version = 4
48
53
 
49
- if s.respond_to? :add_runtime_dependency then
50
- s.add_runtime_dependency(%q<glimmer>.freeze, [">= 2.0.0", "< 3.0.0"])
51
- s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.0"])
52
- s.add_development_dependency(%q<rspec>.freeze, ["~> 3.0"])
53
- s.add_development_dependency(%q<puts_debuggerer>.freeze, [">= 0"])
54
- s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
55
- s.add_development_dependency(%q<jeweler>.freeze, [">= 2.3.9", "< 3.0.0"])
56
- s.add_development_dependency(%q<rdoc>.freeze, [">= 6.2.1", "< 7.0.0"])
57
- s.add_development_dependency(%q<coveralls>.freeze, ["= 0.8.23"])
58
- s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
59
- s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
60
- s.add_development_dependency(%q<rake-tui>.freeze, [">= 0"])
61
- else
62
- s.add_dependency(%q<glimmer>.freeze, [">= 2.0.0", "< 3.0.0"])
63
- s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.0"])
64
- s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
65
- s.add_dependency(%q<puts_debuggerer>.freeze, [">= 0"])
66
- s.add_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
67
- s.add_dependency(%q<jeweler>.freeze, [">= 2.3.9", "< 3.0.0"])
68
- s.add_dependency(%q<rdoc>.freeze, [">= 6.2.1", "< 7.0.0"])
69
- s.add_dependency(%q<coveralls>.freeze, ["= 0.8.23"])
70
- s.add_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
71
- s.add_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
72
- s.add_dependency(%q<rake-tui>.freeze, [">= 0"])
73
- end
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"])
74
65
  end
75
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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 - Andy Maleh
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 - Andy Maleh
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 - Andy Maleh
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 - Andy Maleh
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -21,11 +21,15 @@
21
21
 
22
22
  require 'glimmer/dsl/engine'
23
23
  # Dir[File.expand_path('../*_expression.rb', __FILE__)].each {|f| require f} # cannot in Opal
24
- require 'glimmer/dsl/css/rule_expression'
24
+ require 'glimmer/dsl/css/element_rule_expression'
25
25
  require 'glimmer/dsl/css/dynamic_property_expression'
26
26
  require 'glimmer/dsl/css/css_expression'
27
+ require 'glimmer/dsl/css/rule_expression'
28
+ require 'glimmer/dsl/css/rul_expression'
29
+ require 'glimmer/dsl/css/ru_expression'
27
30
  require 'glimmer/dsl/css/s_expression'
28
31
  require 'glimmer/dsl/css/pv_expression'
32
+ require 'glimmer/dsl/css/media_expression'
29
33
 
30
34
  module Glimmer
31
35
  module DSL
@@ -33,7 +37,8 @@ module Glimmer
33
37
  Engine.add_dynamic_expressions(
34
38
  CSS,
35
39
  %w[
36
- rule
40
+ media
41
+ element_rule
37
42
  dynamic_property
38
43
  ]
39
44
  )
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 - Andy Maleh
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -0,0 +1,45 @@
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/expression'
23
+ require 'glimmer/dsl/parent_expression'
24
+ require 'glimmer/css/style_sheet'
25
+ require 'glimmer/css/rule'
26
+
27
+ module Glimmer
28
+ module DSL
29
+ module CSS
30
+ class ElementRuleExpression < Expression
31
+ include ParentExpression
32
+
33
+ def can_interpret?(parent, keyword, *args, &block)
34
+ parent.is_a?(Glimmer::CSS::StyleSheet) and
35
+ block_given? and
36
+ args.empty?
37
+ end
38
+
39
+ def interpret(parent, keyword, *args, &block)
40
+ Glimmer::CSS::Rule.new(keyword.to_s.downcase, parent: parent)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,48 @@
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/css/style_sheet'
24
+ require 'glimmer/css/rule'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module CSS
29
+ module GeneralRuleExpression
30
+ include ParentExpression
31
+
32
+ def can_interpret?(parent, keyword, *args, &block)
33
+ super(parent, keyword, *args, &block) and
34
+ (
35
+ parent.is_a?(Glimmer::CSS::StyleSheet) or
36
+ parent.is_a?(Glimmer::CSS::MediaQuery)
37
+ ) and
38
+ block_given? and
39
+ !args.empty?
40
+ end
41
+
42
+ def interpret(parent, keyword, *args, &block)
43
+ Glimmer::CSS::Rule.new(args.first.to_s, parent: parent)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ 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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 - Andy Maleh
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 - Andy Maleh
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -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
+ require 'glimmer/dsl/static_expression'
23
+
24
+ require 'glimmer/dsl/css/general_rule_expression'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module CSS
29
+ class RuExpression < StaticExpression
30
+ include GeneralRuleExpression
31
+ end
32
+ end
33
+ end
34
+ end
@@ -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
+ require 'glimmer/dsl/static_expression'
23
+
24
+ require 'glimmer/dsl/css/general_rule_expression'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module CSS
29
+ class RulExpression < StaticExpression
30
+ include GeneralRuleExpression
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 - Andy Maleh
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -19,28 +19,15 @@
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/dsl/expression'
23
- require 'glimmer/dsl/parent_expression'
24
- require 'glimmer/css/style_sheet'
25
- require 'glimmer/css/rule'
22
+ require 'glimmer/dsl/static_expression'
23
+
24
+ require 'glimmer/dsl/css/general_rule_expression'
26
25
 
27
26
  module Glimmer
28
27
  module DSL
29
28
  module CSS
30
- class RuleExpression < Expression
31
- include ParentExpression
32
-
33
- def can_interpret?(parent, keyword, *args, &block)
34
- parent.is_a?(Glimmer::CSS::StyleSheet) and
35
- block_given? and
36
- args.empty?
37
- end
38
-
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
43
- end
29
+ class RuleExpression < StaticExpression
30
+ include GeneralRuleExpression
44
31
  end
45
32
  end
46
33
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 - Andy Maleh
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -20,27 +20,14 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/dsl/static_expression'
23
- require 'glimmer/css/style_sheet'
24
- require 'glimmer/css/rule'
23
+
24
+ require 'glimmer/dsl/css/general_rule_expression'
25
25
 
26
26
  module Glimmer
27
27
  module DSL
28
28
  module CSS
29
29
  class SExpression < StaticExpression
30
- include ParentExpression
31
-
32
- def can_interpret?(parent, keyword, *args, &block)
33
- keyword == 's' and
34
- parent.is_a?(Glimmer::CSS::StyleSheet) and
35
- block_given? and
36
- !args.empty?
37
- end
38
-
39
- 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
- end
30
+ include GeneralRuleExpression
44
31
  end
45
32
  end
46
33
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2022 - Andy Maleh
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -26,3 +26,12 @@ require 'facets/string/camelcase'
26
26
  require 'glimmer'
27
27
 
28
28
  require 'glimmer/dsl/css/dsl'
29
+
30
+ module Glimmer
31
+ def _(selector, &rule_block)
32
+ rule(selector, &rule_block)
33
+ end
34
+ def r(selector, &rule_block)
35
+ rule(selector, &rule_block)
36
+ end
37
+ 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.2
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: 2023-06-15 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
@@ -188,7 +188,7 @@ dependencies:
188
188
  - - ">="
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
- description: Glimmer DSL for CSS (Cascading Style Sheets)
191
+ description: Glimmer DSL for CSS (Ruby Programmable Cascading Style Sheets)
192
192
  email: andy.am@gmail.com
193
193
  executables: []
194
194
  extensions: []
@@ -204,13 +204,20 @@ 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
214
+ - lib/glimmer/dsl/css/element_rule_expression.rb
215
+ - lib/glimmer/dsl/css/general_rule_expression.rb
216
+ - lib/glimmer/dsl/css/media_expression.rb
212
217
  - lib/glimmer/dsl/css/property_expression.rb
213
218
  - lib/glimmer/dsl/css/pv_expression.rb
219
+ - lib/glimmer/dsl/css/ru_expression.rb
220
+ - lib/glimmer/dsl/css/rul_expression.rb
214
221
  - lib/glimmer/dsl/css/rule_expression.rb
215
222
  - lib/glimmer/dsl/css/s_expression.rb
216
223
  homepage: http://github.com/AndyObtiva/glimmer-dsl-css
@@ -232,8 +239,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
239
  - !ruby/object:Gem::Version
233
240
  version: '0'
234
241
  requirements: []
235
- rubygems_version: 3.2.22
242
+ rubygems_version: 3.4.10
236
243
  signing_key:
237
244
  specification_version: 4
238
- summary: Glimmer DSL for CSS
245
+ summary: Glimmer DSL for CSS (Ruby Programmable Cascading Style Sheets)
239
246
  test_files: []