utility_colors 1.0.0 → 1.0.2
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 +4 -4
- data/README.md +1 -1
- data/Rakefile +8 -8
- data/lib/generators/templates/config/utility_colors.rb +1 -1
- data/lib/generators/templates/palettes/_color-variables.scss +34 -34
- data/lib/generators/utility_colors/config_generator.rb +13 -13
- data/lib/generators/utility_colors/generate_generator.rb +31 -31
- data/lib/utility_colors/builders.rb +4 -3
- data/lib/utility_colors/colors.rb +4 -4
- data/lib/utility_colors/configuration.rb +2 -2
- data/lib/utility_colors/exports.rb +54 -54
- data/lib/utility_colors/imports.rb +42 -42
- data/lib/utility_colors/properties.rb +77 -77
- data/lib/utility_colors/version.rb +1 -1
- data/lib/utility_colors.rb +15 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b724d22935983f69caf72f8a4d7f4fda4cb36d9170e3f2bdb903af17429ca3e0
|
4
|
+
data.tar.gz: 2b73c4015dbe484f7ef4e8912ef471273b28580e518275dc729c60f695aad117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90e3859529d811fe17f01c4b419c109e3f9b05359ec14fb6fccd39fa8bab7b4322d39d8a73f24be3a1a63e09c58fe811cc4fcd21632b1542cd45c05f25ad1c11
|
7
|
+
data.tar.gz: 455b3b7cc322b728261aea0647b06b1eeb1685788e30fa60cadd6dbc7af086b019df392ad2237039bb41bd07f9fdc266db0dbe46f66a3dce8529f94616d4ef89
|
data/README.md
CHANGED
@@ -83,7 +83,7 @@ What types of classes should be built:
|
|
83
83
|
| regular_classes | Should 'regular' classes be built, e.g. ".bg--red-50" | true | Boolean | true / false |
|
84
84
|
| breakpoint_classes | Should 'breakpoint' classes be built, e.g. ".md\\|color--black" | false | Boolean | true / false |
|
85
85
|
| pseudo_classes | Should 'pseudo' classes be built, e.g. ".hover\\|border-c--blue-50:hover" | false | Boolean | true / false |
|
86
|
-
|
|
86
|
+
| pseudo_breakpoint_classes | Should 'regular' classes be built, e.g. ".hover\\|md\\|bg--blue-50:hover" | false | Boolean | true / false |
|
87
87
|
|
88
88
|
### Extra Information
|
89
89
|
|
data/Rakefile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
|
8
|
-
task default: :spec
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task default: :spec
|
@@ -1,34 +1,34 @@
|
|
1
|
-
// v0.1.8 Absolute Sources
|
2
|
-
|
3
|
-
$red: hsl(2, 78%, 64%);
|
4
|
-
$rust: hsl(16, 82%, 62%);
|
5
|
-
$orange: hsl(31, 90%, 65%);
|
6
|
-
$gold: hsl(46, 93%, 54%);
|
7
|
-
$yellow: hsl(58, 87%, 55%);
|
8
|
-
$pear: hsl(80, 74%, 57%);
|
9
|
-
$green: hsl(110, 69%, 58%);
|
10
|
-
$seaside: hsl(156, 78%, 57%);
|
11
|
-
$cyan: hsl(180, 69%, 37%);
|
12
|
-
$capri: hsl(197, 90%, 46%);
|
13
|
-
$blue: hsl(214, 78%, 36%);
|
14
|
-
$iris: hsl(265, 87%, 57%);
|
15
|
-
$purple: hsl(279, 85%, 56%);
|
16
|
-
$magenta: hsl(300, 64%, 66%);
|
17
|
-
$pink: hsl(320, 74%, 66%);
|
18
|
-
$satin: hsl(348, 74%, 57%);
|
19
|
-
$cement: hsl(42, 6%, 87%);
|
20
|
-
$grey: hsl(0, 3%, 46%);
|
21
|
-
$base: hsl(0, 3%, 46%);
|
22
|
-
|
23
|
-
// v0.1.8 Relative Sources
|
24
|
-
|
25
|
-
$success: $green-400;
|
26
|
-
$danger: $red-400;
|
27
|
-
$information: $blue-400;
|
28
|
-
$warning: $gold-400;
|
29
|
-
|
30
|
-
// v0.1.8 Single Sources
|
31
|
-
|
32
|
-
$white: #fff;
|
33
|
-
$black: #000;
|
34
|
-
$translucent: rgba(#000, 0.45);
|
1
|
+
// v0.1.8 Absolute Sources
|
2
|
+
|
3
|
+
$red: hsl(2, 78%, 64%);
|
4
|
+
$rust: hsl(16, 82%, 62%);
|
5
|
+
$orange: hsl(31, 90%, 65%);
|
6
|
+
$gold: hsl(46, 93%, 54%);
|
7
|
+
$yellow: hsl(58, 87%, 55%);
|
8
|
+
$pear: hsl(80, 74%, 57%);
|
9
|
+
$green: hsl(110, 69%, 58%);
|
10
|
+
$seaside: hsl(156, 78%, 57%);
|
11
|
+
$cyan: hsl(180, 69%, 37%);
|
12
|
+
$capri: hsl(197, 90%, 46%);
|
13
|
+
$blue: hsl(214, 78%, 36%);
|
14
|
+
$iris: hsl(265, 87%, 57%);
|
15
|
+
$purple: hsl(279, 85%, 56%);
|
16
|
+
$magenta: hsl(300, 64%, 66%);
|
17
|
+
$pink: hsl(320, 74%, 66%);
|
18
|
+
$satin: hsl(348, 74%, 57%);
|
19
|
+
$cement: hsl(42, 6%, 87%);
|
20
|
+
$grey: hsl(0, 3%, 46%);
|
21
|
+
$base: hsl(0, 3%, 46%);
|
22
|
+
|
23
|
+
// v0.1.8 Relative Sources
|
24
|
+
|
25
|
+
$success: $green-400;
|
26
|
+
$danger: $red-400;
|
27
|
+
$information: $blue-400;
|
28
|
+
$warning: $gold-400;
|
29
|
+
|
30
|
+
// v0.1.8 Single Sources
|
31
|
+
|
32
|
+
$white: #fff;
|
33
|
+
$black: #000;
|
34
|
+
$translucent: rgba(#000, 0.45);
|
@@ -1,13 +1,13 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UtilityColors
|
4
|
-
module Generators
|
5
|
-
class ConfigGenerator < Rails::Generators::Base
|
6
|
-
source_root File.expand_path('../../..', __dir__)
|
7
|
-
|
8
|
-
def copy_config
|
9
|
-
copy_file 'lib/generators/templates/config/utility_colors.rb', 'config/initializers/utility_colors.rb'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UtilityColors
|
4
|
+
module Generators
|
5
|
+
class ConfigGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('../../..', __dir__)
|
7
|
+
|
8
|
+
def copy_config
|
9
|
+
copy_file 'lib/generators/templates/config/utility_colors.rb', 'config/initializers/utility_colors.rb'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,31 +1,31 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UtilityColors
|
4
|
-
module Generators
|
5
|
-
class GenerateGenerator < Rails::Generators::Base
|
6
|
-
def generate_utility_colors
|
7
|
-
# TODO: check if the v0.1.8 scss files exists
|
8
|
-
# "app/app/assets/stylesheets/utility_colors_files" directory
|
9
|
-
self.class.config_format_warn if File.exist?('config/utility_colors.yml') || File.exist?('config/utility_colors.json')
|
10
|
-
|
11
|
-
if UtilityColors.configuration.enable_environments.include?(Rails.env.to_sym)
|
12
|
-
UtilityColors::Colors.generate
|
13
|
-
else
|
14
|
-
self.class.disabled_warn
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
# TODO: add links to README for migration
|
21
|
-
def self.config_format_warn
|
22
|
-
warn 'WARNING: Utility Colors now uses an initializer to set config. You need to migrate and remove your YML/JSON file.'
|
23
|
-
end
|
24
|
-
|
25
|
-
# TODO: add links to README for environment setting
|
26
|
-
def self.disabled_warn
|
27
|
-
warn 'ERROR: Utility Colors is disabled for this environment. Color classes will not be generated.'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UtilityColors
|
4
|
+
module Generators
|
5
|
+
class GenerateGenerator < Rails::Generators::Base
|
6
|
+
def generate_utility_colors
|
7
|
+
# TODO: check if the v0.1.8 scss files exists
|
8
|
+
# "app/app/assets/stylesheets/utility_colors_files" directory
|
9
|
+
self.class.config_format_warn if File.exist?('config/utility_colors.yml') || File.exist?('config/utility_colors.json')
|
10
|
+
|
11
|
+
if UtilityColors.configuration.enable_environments.include?(Rails.env.to_sym)
|
12
|
+
UtilityColors::Colors.generate
|
13
|
+
else
|
14
|
+
self.class.disabled_warn
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# TODO: add links to README for migration
|
21
|
+
def self.config_format_warn
|
22
|
+
warn 'WARNING: Utility Colors now uses an initializer to set config. You need to migrate and remove your YML/JSON file.'
|
23
|
+
end
|
24
|
+
|
25
|
+
# TODO: add links to README for environment setting
|
26
|
+
def self.disabled_warn
|
27
|
+
warn 'ERROR: Utility Colors is disabled for this environment. Color classes will not be generated.'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -10,22 +10,23 @@ module UtilityColors
|
|
10
10
|
{ class_name => "#{content.join(': ')};" }
|
11
11
|
end
|
12
12
|
|
13
|
+
# ';' are already in the content from the above source method
|
13
14
|
# 'md|color--red-400'
|
14
15
|
def self.utility_pseudo_classes_creation(class_name, content, pseudo)
|
15
16
|
content = [content] unless content.is_a?(Array)
|
16
|
-
{ "#{pseudo}
|
17
|
+
{ "#{pseudo}\\|#{class_name}:#{pseudo}" => content.join(': ') }
|
17
18
|
end
|
18
19
|
|
19
20
|
# 'hover|color--red-400'
|
20
21
|
def self.utility_breakpoint_classes_creation(class_name, content, initial, screen_size)
|
21
22
|
content = [content] unless content.is_a?(Array)
|
22
|
-
{ "#{initial}
|
23
|
+
{ "#{initial}\\|#{class_name}" => "@media only screen and (min-width: #{screen_size - 1}) { #{content.join(': ')} }" }
|
23
24
|
end
|
24
25
|
|
25
26
|
# 'hover|md|color--red-400'
|
26
27
|
def self.utility_pseudo_breakpoint_classes_creation(class_name, content, pseudo, initial, screen_size)
|
27
28
|
content = [content] unless content.is_a?(Array)
|
28
|
-
{ "#{pseudo}
|
29
|
+
{ "#{pseudo}\\|#{initial}\\|#{class_name}:#{pseudo}" => "@media only screen and (min-width: #{screen_size - 1}) { #{content.join(': ')} }" }
|
29
30
|
end
|
30
31
|
|
31
32
|
# Bulk Methods
|
@@ -30,14 +30,14 @@ module UtilityColors
|
|
30
30
|
puts 'Generated breakpoint colour classes...'
|
31
31
|
end
|
32
32
|
|
33
|
-
if configuration.
|
33
|
+
if configuration.pseudo_classes
|
34
34
|
generated_pseudo_classes = UtilityColors::Builders.bulk_pseudo_class_creation(generated_source_classes)
|
35
|
-
puts 'Generated
|
35
|
+
puts 'Generated pseudo colour classes...'
|
36
36
|
end
|
37
37
|
|
38
|
-
if configuration.
|
38
|
+
if configuration.pseudo_breakpoint_classes
|
39
39
|
generated_pseudo_breakpoint_classes = UtilityColors::Builders.bulk_pseudo_breakpoint_class_creation(generated_source_classes)
|
40
|
-
puts 'Generated breakpoint colour classes...'
|
40
|
+
puts 'Generated pseudo breakpoint colour classes...'
|
41
41
|
end
|
42
42
|
|
43
43
|
generated_classes = {}.merge(generated_regular_classes, generated_breakpoint_classes, generated_pseudo_classes, generated_pseudo_breakpoint_classes)
|
@@ -5,7 +5,7 @@ module UtilityColors
|
|
5
5
|
attr_accessor :enable_environments,
|
6
6
|
:import_palettes_filepath,
|
7
7
|
:output_filename, :output_dated, :output_files, :output_prefix, :output_suffix,
|
8
|
-
:regular_classes, :breakpoint_classes, :pseudo_classes, :
|
8
|
+
:regular_classes, :breakpoint_classes, :pseudo_classes, :pseudo_breakpoint_classes # :utility_palettes_configuration
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
# Enabled Environments
|
@@ -25,7 +25,7 @@ module UtilityColors
|
|
25
25
|
@regular_classes = true
|
26
26
|
@breakpoint_classes = false
|
27
27
|
@pseudo_classes = false
|
28
|
-
@
|
28
|
+
@pseudo_breakpoint_classes = false
|
29
29
|
|
30
30
|
# Configuration instance for UtilityPalettes
|
31
31
|
# @utility_palettes_configuration = UtilityPalettes::Configuration.new
|
@@ -1,54 +1,54 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UtilityColors
|
4
|
-
class Exports
|
5
|
-
def self.json(filename, output_classes)
|
6
|
-
# TODO: determine if they imported scss or css and return the variables keys in that way
|
7
|
-
# TODO: determine if the style value should use a syntax variable or be converted to hardcoded value
|
8
|
-
content = JSON.pretty_generate(output_classes.transform_values { |class_content| class_content.gsub('£$', '$').gsub('$£', '') })
|
9
|
-
filepath = "#{filename}.json"
|
10
|
-
|
11
|
-
# Create directory if it doesn't exist
|
12
|
-
FileUtils.mkdir_p(File.dirname(filepath))
|
13
|
-
File.write(filepath, content)
|
14
|
-
|
15
|
-
puts 'Exporting utility colour classes JSON...'
|
16
|
-
true
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.scss(filename, output_classes)
|
20
|
-
# TODO: determine if the style value should use the syntax variable or be converted to hardcoded value
|
21
|
-
content = output_classes.collect { |class_name, class_content| "#{class_name} {\n\t#{class_content.gsub('£$', '$').gsub('$£', '')}\n}" }.join("\n\n")
|
22
|
-
filepath = "#{filename}.scss"
|
23
|
-
|
24
|
-
# Create directory if it doesn't exist
|
25
|
-
FileUtils.mkdir_p(File.dirname(filepath))
|
26
|
-
File.write(filepath, content)
|
27
|
-
|
28
|
-
puts 'Exporting utility colour classes SCSS...'
|
29
|
-
true
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.css(filename, output_classes)
|
33
|
-
# TODO: add root for variables at top? Leave for now as this is all based off a palette file where they should exist (easy copy and paste for devs)
|
34
|
-
# TODO: determine if the style value should use the syntax variable or be converted to hardcoded value
|
35
|
-
content = output_classes.collect { |class_name, class_content| "#{class_name} {\n\t#{class_content.gsub('£$', 'var(--').gsub('$£', ')')}\n}" }.join("\n\n")
|
36
|
-
filepath = "#{filename}.css"
|
37
|
-
|
38
|
-
# Create directory if it doesn't exist
|
39
|
-
FileUtils.mkdir_p(File.dirname(filepath))
|
40
|
-
File.write(filepath, content)
|
41
|
-
|
42
|
-
puts 'Exporting utility colour classes CSS...'
|
43
|
-
true
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.append_percentage(value)
|
47
|
-
"#{value}%"
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.append_alpha(alpha)
|
51
|
-
"/ #{alpha * 100}"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UtilityColors
|
4
|
+
class Exports
|
5
|
+
def self.json(filename, output_classes)
|
6
|
+
# TODO: determine if they imported scss or css and return the variables keys in that way
|
7
|
+
# TODO: determine if the style value should use a syntax variable or be converted to hardcoded value
|
8
|
+
content = JSON.pretty_generate(output_classes.transform_values { |class_content| class_content.gsub('£$', '$').gsub('$£', '') })
|
9
|
+
filepath = "#{filename}.json"
|
10
|
+
|
11
|
+
# Create directory if it doesn't exist
|
12
|
+
FileUtils.mkdir_p(File.dirname(filepath))
|
13
|
+
File.write(filepath, content)
|
14
|
+
|
15
|
+
puts 'Exporting utility colour classes JSON...'
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.scss(filename, output_classes)
|
20
|
+
# TODO: determine if the style value should use the syntax variable or be converted to hardcoded value
|
21
|
+
content = output_classes.collect { |class_name, class_content| "#{class_name} {\n\t#{class_content.gsub('£$', '$').gsub('$£', '')}\n}" }.join("\n\n")
|
22
|
+
filepath = "#{filename}.scss"
|
23
|
+
|
24
|
+
# Create directory if it doesn't exist
|
25
|
+
FileUtils.mkdir_p(File.dirname(filepath))
|
26
|
+
File.write(filepath, content)
|
27
|
+
|
28
|
+
puts 'Exporting utility colour classes SCSS...'
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.css(filename, output_classes)
|
33
|
+
# TODO: add root for variables at top? Leave for now as this is all based off a palette file where they should exist (easy copy and paste for devs)
|
34
|
+
# TODO: determine if the style value should use the syntax variable or be converted to hardcoded value
|
35
|
+
content = output_classes.collect { |class_name, class_content| "#{class_name} {\n\t#{class_content.gsub('£$', 'var(--').gsub('$£', ')')}\n}" }.join("\n\n")
|
36
|
+
filepath = "#{filename}.css"
|
37
|
+
|
38
|
+
# Create directory if it doesn't exist
|
39
|
+
FileUtils.mkdir_p(File.dirname(filepath))
|
40
|
+
File.write(filepath, content)
|
41
|
+
|
42
|
+
puts 'Exporting utility colour classes CSS...'
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.append_percentage(value)
|
47
|
+
"#{value}%"
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.append_alpha(alpha)
|
51
|
+
"/ #{alpha * 100}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,42 +1,42 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UtilityColors
|
4
|
-
class Imports
|
5
|
-
def self.import
|
6
|
-
import_path = UtilityColors.configuration.import_palettes_filepath
|
7
|
-
|
8
|
-
if import_path.present? && File.file?(import_path)
|
9
|
-
case File.extname(import_path)
|
10
|
-
when '.json'
|
11
|
-
UtilityColors::Imports.json(import_path)
|
12
|
-
when '.scss'
|
13
|
-
UtilityColors::Imports.scss(import_path)
|
14
|
-
when '.css'
|
15
|
-
UtilityColors::Imports.css(import_path)
|
16
|
-
else
|
17
|
-
warn 'WARNING: Palette file could not be imported as it is not JSON, SCSS, or CSS.'
|
18
|
-
{}
|
19
|
-
end
|
20
|
-
else
|
21
|
-
{}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def self.json(import_path)
|
28
|
-
# expecting a normal json hash of name and value
|
29
|
-
JSON.parse(File.read(import_path))
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.scss(import_path)
|
33
|
-
# expecting a normal scss file of variables
|
34
|
-
File.read(import_path).scan(/\$([^:]+):\s*([^;]+);/).to_h
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.css(import_path)
|
38
|
-
# expecting a normal css file of variables
|
39
|
-
File.read(import_path).scan(/--([^:]+):\s*([^;]+);/).to_h
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UtilityColors
|
4
|
+
class Imports
|
5
|
+
def self.import
|
6
|
+
import_path = UtilityColors.configuration.import_palettes_filepath
|
7
|
+
|
8
|
+
if import_path.present? && File.file?(import_path)
|
9
|
+
case File.extname(import_path)
|
10
|
+
when '.json'
|
11
|
+
UtilityColors::Imports.json(import_path)
|
12
|
+
when '.scss'
|
13
|
+
UtilityColors::Imports.scss(import_path)
|
14
|
+
when '.css'
|
15
|
+
UtilityColors::Imports.css(import_path)
|
16
|
+
else
|
17
|
+
warn 'WARNING: Palette file could not be imported as it is not JSON, SCSS, or CSS.'
|
18
|
+
{}
|
19
|
+
end
|
20
|
+
else
|
21
|
+
{}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def self.json(import_path)
|
28
|
+
# expecting a normal json hash of name and value
|
29
|
+
JSON.parse(File.read(import_path))
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.scss(import_path)
|
33
|
+
# expecting a normal scss file of variables
|
34
|
+
File.read(import_path).scan(/\$([^:]+):\s*([^;]+);/).to_h
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.css(import_path)
|
38
|
+
# expecting a normal css file of variables
|
39
|
+
File.read(import_path).scan(/--([^:]+):\s*([^;]+);/).to_h
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -1,77 +1,77 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UtilityColors
|
4
|
-
class Properties
|
5
|
-
def self.get_property(*keys)
|
6
|
-
keys = [keys] unless keys.is_a?(Array)
|
7
|
-
|
8
|
-
property = UtilityColors::Properties.send(keys[0])
|
9
|
-
property = property.dig(*keys.slice(1..-1)) if keys.length > 1
|
10
|
-
|
11
|
-
property
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.screen_sizes
|
15
|
-
{
|
16
|
-
'sm' => '325px',
|
17
|
-
'md' => '768px',
|
18
|
-
'lg' => '1024px',
|
19
|
-
'xl' => '1440px'
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.pseudo_input
|
24
|
-
[
|
25
|
-
'checked',
|
26
|
-
'disabled',
|
27
|
-
'enabled',
|
28
|
-
'focus'
|
29
|
-
]
|
30
|
-
end
|
31
|
-
|
32
|
-
# TODO: add it in
|
33
|
-
def self.pseudo_input_extra
|
34
|
-
[
|
35
|
-
'in-range',
|
36
|
-
'invalid',
|
37
|
-
'optional',
|
38
|
-
'out-of-range',
|
39
|
-
'read-only',
|
40
|
-
'read-write',
|
41
|
-
'require',
|
42
|
-
'valid'
|
43
|
-
]
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.pseudo_action
|
47
|
-
[
|
48
|
-
'active',
|
49
|
-
'hover',
|
50
|
-
'link',
|
51
|
-
'target',
|
52
|
-
'visited'
|
53
|
-
]
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.pseudo_child
|
57
|
-
[
|
58
|
-
'root',
|
59
|
-
'first-child',
|
60
|
-
'first-of-type',
|
61
|
-
'last-child',
|
62
|
-
'last-of-type',
|
63
|
-
'only-of-type',
|
64
|
-
'only-child',
|
65
|
-
'empty'
|
66
|
-
# // nth-child(n},
|
67
|
-
# // nth-last-child(n},
|
68
|
-
# // nth-last-of-type(n},
|
69
|
-
# // nth-of-type(n},
|
70
|
-
]
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.pseudos
|
74
|
-
UtilityColors::Properties.pseudo_input + UtilityColors::Properties.pseudo_action + UtilityColors::Properties.pseudo_child
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UtilityColors
|
4
|
+
class Properties
|
5
|
+
def self.get_property(*keys)
|
6
|
+
keys = [keys] unless keys.is_a?(Array)
|
7
|
+
|
8
|
+
property = UtilityColors::Properties.send(keys[0])
|
9
|
+
property = property.dig(*keys.slice(1..-1)) if keys.length > 1
|
10
|
+
|
11
|
+
property
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.screen_sizes
|
15
|
+
{
|
16
|
+
'sm' => '325px',
|
17
|
+
'md' => '768px',
|
18
|
+
'lg' => '1024px',
|
19
|
+
'xl' => '1440px'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.pseudo_input
|
24
|
+
[
|
25
|
+
'checked',
|
26
|
+
'disabled',
|
27
|
+
'enabled',
|
28
|
+
'focus'
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
# TODO: add it in
|
33
|
+
def self.pseudo_input_extra
|
34
|
+
[
|
35
|
+
'in-range',
|
36
|
+
'invalid',
|
37
|
+
'optional',
|
38
|
+
'out-of-range',
|
39
|
+
'read-only',
|
40
|
+
'read-write',
|
41
|
+
'require',
|
42
|
+
'valid'
|
43
|
+
]
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.pseudo_action
|
47
|
+
[
|
48
|
+
'active',
|
49
|
+
'hover',
|
50
|
+
'link',
|
51
|
+
'target',
|
52
|
+
'visited'
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.pseudo_child
|
57
|
+
[
|
58
|
+
'root',
|
59
|
+
'first-child',
|
60
|
+
'first-of-type',
|
61
|
+
'last-child',
|
62
|
+
'last-of-type',
|
63
|
+
'only-of-type',
|
64
|
+
'only-child',
|
65
|
+
'empty'
|
66
|
+
# // nth-child(n},
|
67
|
+
# // nth-last-child(n},
|
68
|
+
# // nth-last-of-type(n},
|
69
|
+
# // nth-of-type(n},
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.pseudos
|
74
|
+
UtilityColors::Properties.pseudo_input + UtilityColors::Properties.pseudo_action + UtilityColors::Properties.pseudo_child
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/utility_colors.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'utility_colors/version'
|
4
|
-
|
5
|
-
require_relative 'utility_colors/configuration'
|
6
|
-
require_relative 'utility_colors/builders'
|
7
|
-
require_relative 'utility_colors/colors'
|
8
|
-
require_relative 'utility_colors/exports'
|
9
|
-
require_relative 'utility_colors/imports'
|
10
|
-
require_relative 'utility_colors/properties'
|
11
|
-
|
12
|
-
module UtilityColors
|
13
|
-
class Error < StandardError; end
|
14
|
-
# Your code goes here...
|
15
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'utility_colors/version'
|
4
|
+
|
5
|
+
require_relative 'utility_colors/configuration'
|
6
|
+
require_relative 'utility_colors/builders'
|
7
|
+
require_relative 'utility_colors/colors'
|
8
|
+
require_relative 'utility_colors/exports'
|
9
|
+
require_relative 'utility_colors/imports'
|
10
|
+
require_relative 'utility_colors/properties'
|
11
|
+
|
12
|
+
module UtilityColors
|
13
|
+
class Error < StandardError; end
|
14
|
+
# Your code goes here...
|
15
|
+
end
|