utility_palettes 0.1.1 → 1.0.1
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 +137 -123
- data/Rakefile +8 -8
- data/lib/generators/templates/config/utility_palettes.rb +55 -0
- data/lib/generators/utility_palettes/config_generator.rb +13 -13
- data/lib/generators/utility_palettes/generate_generator.rb +29 -35
- data/lib/utility_palettes/configuration.rb +83 -25
- data/lib/utility_palettes/defaults.rb +48 -46
- data/lib/utility_palettes/outputs.rb +126 -122
- data/lib/utility_palettes/palettes.rb +120 -133
- data/lib/utility_palettes/sequences.rb +88 -90
- data/lib/utility_palettes/swatch.rb +107 -108
- data/lib/utility_palettes/version.rb +5 -5
- data/lib/utility_palettes.rb +18 -16
- metadata +3 -4
- data/lib/generators/templates/config/utility_palettes.yml +0 -36
- data/lib/utility_palettes/validations.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7db3ff622d508b9b3ec237a56f185e7e530c0e71fe01bdb35ce44ba909914876
|
4
|
+
data.tar.gz: d2a05bcb1c34d3ae1a98e16cbacabc7e354441608f7bc03a452c07239b15b6d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00e88a3d02edd7aba94e4a4c1bce0f7a926e0bc47c3f95bcd7c29d62dd7c878b5cf74c3a8de65a0b5da75c526620b8012371486937b220600363a705d07ec2f0
|
7
|
+
data.tar.gz: acaa16e80c37e7895a67e7314038fd86218dcf12290ae3bfa55144fee7fbff412624e8ac86f8199a7dfd8c245d51aa46c493b17ea9c77f939d08677ac7dcefaf
|
data/README.md
CHANGED
@@ -1,123 +1,137 @@
|
|
1
|
-
# UtilityPalettes
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
###
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
##
|
122
|
-
|
123
|
-
|
1
|
+
# UtilityPalettes
|
2
|
+
|
3
|
+

|
4
|
+
[](https://rubygems.org/gems/utility_palettes)
|
5
|
+
|
6
|
+
> Generate your own colour palettes in an instance.
|
7
|
+
|
8
|
+
Utility Palettes is an ruby gem package for use in ruby or other projects that generates palettes and shades based on supplied colours.
|
9
|
+
Take a single colour and generate a full tailwind-style set of "absolute" shades ranging from -50 to -900 where the given colour is inserted into the range where it suits best.
|
10
|
+
Or generate "relative" shades that have the supplied colour at it's core and add a -light and -dark shade.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Install the gem and add to the application's Gemfile by executing:
|
15
|
+
|
16
|
+
```bash
|
17
|
+
bundle add utility_palettes
|
18
|
+
```
|
19
|
+
|
20
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
21
|
+
|
22
|
+
```bash
|
23
|
+
gem install utility_palettes
|
24
|
+
```
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
To get the config file:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
rails generate utility_palettes:config
|
32
|
+
```
|
33
|
+
|
34
|
+
To generate the palettes:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
rails generate utility_palettes:generate
|
38
|
+
```
|
39
|
+
|
40
|
+
## Configuration
|
41
|
+
|
42
|
+
>[!NOTE]
|
43
|
+
> UtilityPalettes has moved to a Ruby Config file so if you used the YML config previously you will need to migrate off that now.
|
44
|
+
> Run `rails generate utility_palettes:config` to get the new config and move your values across.
|
45
|
+
> Most keys have stayed the same apart from some prepends and the `enable_environments` key which determines what environments code can be run in.
|
46
|
+
|
47
|
+
### Environment
|
48
|
+
|
49
|
+
Set the environment that the sub-data will be read in, meaning that the palette generator can only be run in certain environments.
|
50
|
+
|
51
|
+
| Option | Default | Value Type | Possible Values |
|
52
|
+
| :------------------- | :------------: | :--------: | :--------------------: |
|
53
|
+
| enable_environments | [:development] | Array | <any Rails.env symbol> |
|
54
|
+
|
55
|
+
### Defaults
|
56
|
+
|
57
|
+
Should the default colours be included for the palette generator. Even if they are included, they can be overwritten by the user's own colour of the same name:
|
58
|
+
|
59
|
+
| Option | Default | Value Type | Possible Values |
|
60
|
+
| :---------------- | :-----: | :--------: | :-------------: |
|
61
|
+
| default_absolutes | true | Boolean | true / false |
|
62
|
+
| default_relatives | true | Boolean | true / false |
|
63
|
+
| default_singles | true | Boolean | true / false |
|
64
|
+
|
65
|
+
### Output
|
66
|
+
|
67
|
+
How the output file and values should be written:
|
68
|
+
|
69
|
+
| Option | Description | Default | Value Type | Possible Values |
|
70
|
+
| :------------ | :-------------------------------------------------------------------------------- | :----------------: | :--------: | :-----------------------------------------------------: |
|
71
|
+
| ouput_filename | Where the file should be output to including filename, without the file extension | 'utility_palettes' | String | <any filepath string> |
|
72
|
+
| ouput_dated | Should a timestamp be included in the filenames | false | Boolean | true / false |
|
73
|
+
| ouput_files | The types of files the palette should be output in | ['scss'] | Array | json, scss, css |
|
74
|
+
| ouput_format | The colour syntax the output colours should be written in | hex | String | rgb, hsl, hsv, hsb, cmyk, cielab, lab, cielch, lch, hex |
|
75
|
+
| ouput_prefix | A string that is appended to the start of all colour names, i.e. 'up-' | nil | String | <any string> |
|
76
|
+
| ouput_suffix | A string that is appended to the end of all colour names, i.e. '-col' | nil | String | <any string> |
|
77
|
+
|
78
|
+
### Method (WIP)
|
79
|
+
|
80
|
+
It allows you to determine how you want the colours to be adjusted to create the variance in your palette, but for now all colour adjustments are made by changing the HSL values as it is the best combination of the simple yet effective and accurate method available.
|
81
|
+
In the future you will be able to shift the colours by changing values for different colour models and colour spaces; like RGB, CieLAB, OkLCH and others.
|
82
|
+
|
83
|
+
| Option | Description | Default | Value Type | Possible Values |
|
84
|
+
| :------- | :----------------------------------------------- | :-----: | :--------: | :-------------: |
|
85
|
+
| method | What colour space to adjust the colour values in | 'hsl' | String | hsl |
|
86
|
+
|
87
|
+
### Steps (WIP)
|
88
|
+
|
89
|
+
Defines the percentage you want each colour to be adjusted by when moving through the colour palette. For now all steps are for the HSL method of adjusting colours
|
90
|
+
In the future you will be able to shift the colours by changing values for different colour models and colour spaces; like RGB, CieLAB, OkLCH and others.
|
91
|
+
|
92
|
+
| Option | Description | Default | Possible Values |
|
93
|
+
| :------ | :----------------------------------: | :-----: | :-------------: |
|
94
|
+
| steps_h | How much to adjust the hue by | 0 | 0 - 100 |
|
95
|
+
| steps_s | How much to adjust the saturation by | 3 | 0 - 100 |
|
96
|
+
| steps_l | How much to adjust the lightness by | 8 | 0 - 100 |
|
97
|
+
|
98
|
+
### Colours
|
99
|
+
|
100
|
+
You can define colour names and values that you would like to create an "absolute palette"; where for each colour given, a range of colours are output with -50, -100, ..., -900 suffixes using that colour as the base.
|
101
|
+
|
102
|
+
You can define colour names and values that you would like to create an "relative palette"; where for each colour given, a -light and -dark colour are generated one step up and down from the base colour.
|
103
|
+
If a colour is included in both the "absolutes" and "relatives" sections, then the -light and -dark colours will match with colours in the absolute palette.
|
104
|
+
|
105
|
+
You can define colour names and values that you would like copied directly to the output as you have defined them.
|
106
|
+
|
107
|
+
All these options all colours to be passed in the same way; as a hash.
|
108
|
+
The key is the base name of the colour.
|
109
|
+
The value can be;
|
110
|
+
|
111
|
+
- a string such as '#ff0000' or 'rgb(51, 102, 204)',
|
112
|
+
- a hash of colour space keys and values such as { r: 51, g: 102, b: 204 } or { h: 30, s: 50, l: 75 },
|
113
|
+
- a 'reference' to a colour the is previously defined be using that colour name as the value but prepended with '$', such as '$red' (this felt useful if there are colours if you re-use the same colours under different use names)
|
114
|
+
|
115
|
+
| Option | Default | Possible Values |
|
116
|
+
| :-------- | :-----: | :-----------------------------------: |
|
117
|
+
| absolutes | {} | { '<colour name>' => <colour value> } |
|
118
|
+
| relatives | {} | { '<colour name>' => <colour value> } |
|
119
|
+
| singles | {} | { '<colour name>' => <colour value> } |
|
120
|
+
|
121
|
+
## Development
|
122
|
+
|
123
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
124
|
+
|
125
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
126
|
+
|
127
|
+
## Contributing
|
128
|
+
|
129
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/louiswdavis/utility_palettes>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/louiswdavis/utility_palettes/blob/master/CODE_OF_CONDUCT.md).
|
130
|
+
|
131
|
+
## License
|
132
|
+
|
133
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
134
|
+
|
135
|
+
## Code of Conduct
|
136
|
+
|
137
|
+
Everyone interacting in the UtilityPalettes project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/louiswdavis/utility_palettes/blob/master/CODE_OF_CONDUCT.md).
|
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
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
UtilityPalettes.configure do |config|
|
4
|
+
# Enabled Environments
|
5
|
+
# config.enable_environments = [:development]
|
6
|
+
|
7
|
+
# Defaults
|
8
|
+
# config.default_absolutes = true
|
9
|
+
# config.default_relatives = true
|
10
|
+
# config.default_singles = true
|
11
|
+
|
12
|
+
# Output
|
13
|
+
# config.output_filename = 'utility_palettes'
|
14
|
+
# config.output_dated = false
|
15
|
+
# config.output_files = ['scss']
|
16
|
+
# config.output_format = 'hex'
|
17
|
+
# config.output_prefix = nil
|
18
|
+
# config.output_suffix = nil
|
19
|
+
|
20
|
+
# Method
|
21
|
+
# config.method = 'hsl'
|
22
|
+
|
23
|
+
# Steps
|
24
|
+
# config.steps_h = 0
|
25
|
+
# config.steps_s = 3
|
26
|
+
# config.steps_l = 8
|
27
|
+
|
28
|
+
# Colors - Absolutes
|
29
|
+
# config.absolutes = {
|
30
|
+
# 'teal' => '#2cb1bc',
|
31
|
+
# 'orange' => '#e35f00',
|
32
|
+
# 'green' => '#28b840',
|
33
|
+
# 'purple' => '#4f3bbf'
|
34
|
+
# }
|
35
|
+
|
36
|
+
# Colors - Relatives
|
37
|
+
# config.relatives = {
|
38
|
+
# 'success' => '#28b840',
|
39
|
+
# 'information' => '#2cb1bc'
|
40
|
+
# }
|
41
|
+
|
42
|
+
# Colors - Singles
|
43
|
+
# config.singles = {
|
44
|
+
# 'grey-50' => '#fafafa',
|
45
|
+
# 'grey-100' => '#f5f5f5',
|
46
|
+
# 'grey-200' => '#e5e5e5',
|
47
|
+
# 'grey-300' => '#d4d4d4',
|
48
|
+
# 'grey-400' => '#a3a3a3',
|
49
|
+
# 'grey-500' => '#737373',
|
50
|
+
# 'grey-600' => '#525252',
|
51
|
+
# 'grey-700' => '#404040',
|
52
|
+
# 'grey-800' => '#262626',
|
53
|
+
# 'grey-900' => '#171717'
|
54
|
+
# }
|
55
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UtilityPalettes
|
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_palettes.
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UtilityPalettes
|
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_palettes.rb', 'config/initializers/utility_palettes.rb'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,35 +1,29 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UtilityPalettes
|
4
|
-
module Generators
|
5
|
-
class GenerateGenerator < Rails::Generators::Base
|
6
|
-
def generate_utility_palettes
|
7
|
-
config
|
8
|
-
|
9
|
-
if
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
def self.disabled_warn
|
31
|
-
warn 'ERROR: Utility Palettes is disabled for this environment'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UtilityPalettes
|
4
|
+
module Generators
|
5
|
+
class GenerateGenerator < Rails::Generators::Base
|
6
|
+
def generate_utility_palettes
|
7
|
+
self.class.config_format_warn if File.exist?('config/utility_palettes.yml') || File.exist?('config/utility_palettes.json')
|
8
|
+
|
9
|
+
if UtilityPalettes.configuration.enable_environments.include?(Rails.env.to_sym)
|
10
|
+
UtilityPalettes::Palettes.generate
|
11
|
+
else
|
12
|
+
self.class.disabled_warn
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# TODO: add links to README for migration
|
19
|
+
def self.config_format_warn
|
20
|
+
warn 'WARNING: Utility Palettes now uses an initializer to set config. You need to migrate and remove your YML/JSON file.'
|
21
|
+
end
|
22
|
+
|
23
|
+
# TODO: add links to README for environment setting
|
24
|
+
def self.disabled_warn
|
25
|
+
warn 'ERROR: Utility Palettes is disabled for this environment. Palettes will not be generated.'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,25 +1,83 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UtilityPalettes
|
4
|
-
class Configuration
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UtilityPalettes
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :enable_environments,
|
6
|
+
:use_default_absolutes, :use_default_relatives, :use_default_singles,
|
7
|
+
:output_filename, :output_dated, :output_files, :output_format, :output_prefix, :output_suffix,
|
8
|
+
:method, :steps_h, :steps_s, :steps_l, :steps_r, :steps_g, :steps_b,
|
9
|
+
:absolutes, :relatives, :singles
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
# Enabled Environments
|
13
|
+
@enable_environments = [:development]
|
14
|
+
|
15
|
+
# Defaults
|
16
|
+
@use_default_absolutes = true
|
17
|
+
@use_default_relatives = true
|
18
|
+
@use_default_singles = true
|
19
|
+
|
20
|
+
# Output
|
21
|
+
@output_filename = 'utility_palettes'
|
22
|
+
@output_dated = false
|
23
|
+
@output_files = ['scss']
|
24
|
+
@output_format = 'hex'
|
25
|
+
@output_prefix = ''
|
26
|
+
@output_suffix = ''
|
27
|
+
|
28
|
+
# Method
|
29
|
+
@method = 'hsl'
|
30
|
+
|
31
|
+
# Steps
|
32
|
+
@steps_h = 0
|
33
|
+
@steps_s = 3
|
34
|
+
@steps_l = 8
|
35
|
+
@steps_r = 9
|
36
|
+
@steps_g = 9
|
37
|
+
@steps_b = 9
|
38
|
+
|
39
|
+
# Colors - Absolutes
|
40
|
+
@absolutes = {}
|
41
|
+
|
42
|
+
# Colors - Relatives
|
43
|
+
@relatives = {}
|
44
|
+
|
45
|
+
# Colors - Singles
|
46
|
+
@singles = {}
|
47
|
+
end
|
48
|
+
|
49
|
+
def reset!
|
50
|
+
self.initialize
|
51
|
+
end
|
52
|
+
|
53
|
+
def validate_settings
|
54
|
+
warn "ERROR: The colour sequence method you have submitted to Utility Palettes < #{@method} > is not available" unless @method.to_s.in?(['hsl'])
|
55
|
+
|
56
|
+
# warn "ERROR: The colour sequence steps you have submitted to Utility Palettes < #{@steps} > have not been formatted as a hash" unless @steps.is_a?(Hash)
|
57
|
+
|
58
|
+
warn "ERROR: The output files you have submitted to Utility Palettes < #{@output_files} > have not been formatted as an array" unless @absolutes.is_a?(Array)
|
59
|
+
|
60
|
+
warn "ERROR: The absolute swatches you have submitted to Utility Palettes < #{@absolutes} > have not been formatted as a hash" unless @absolutes.is_a?(Hash)
|
61
|
+
warn "ERROR: The relative swatches you have submitted to Utility Palettes < #{@relatives} > have not been formatted as a hash" unless @relatives.is_a?(Hash)
|
62
|
+
warn "ERROR: The single swatches you have submitted to Utility Palettes < #{@singles} > have not been formatted as a hash" unless @singles.is_a?(Hash)
|
63
|
+
|
64
|
+
[@method.to_s.in?(['hsl']), @absolutes.is_a?(Hash), @relatives.is_a?(Hash), @singles.is_a?(Hash)].all?
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class << self
|
69
|
+
attr_writer :configuration
|
70
|
+
|
71
|
+
def configuration
|
72
|
+
@configuration ||= Configuration.new
|
73
|
+
end
|
74
|
+
|
75
|
+
def configure
|
76
|
+
yield(configuration)
|
77
|
+
end
|
78
|
+
|
79
|
+
def reset_configuration!
|
80
|
+
@configuration = Configuration.new
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|