tints-n-shades 0.1.0
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 +7 -0
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +110 -0
- data/Rakefile +12 -0
- data/assets/logo.svg +212 -0
- data/assets/logo.webp +0 -0
- data/exe/tns +5 -0
- data/lib/tns/cli.rb +53 -0
- data/lib/tns/color/base.rb +24 -0
- data/lib/tns/color/hex.rb +31 -0
- data/lib/tns/color/hsl.rb +77 -0
- data/lib/tns/color/rgb.rb +74 -0
- data/lib/tns/color/shade.rb +14 -0
- data/lib/tns/color/tint.rb +14 -0
- data/lib/tns/color/variant.rb +40 -0
- data/lib/tns/output/css.rb +24 -0
- data/lib/tns/output/output.rb +19 -0
- data/lib/tns/output/sass.rb +23 -0
- data/lib/tns/output/tailwind.rb +23 -0
- data/lib/tns/palette.rb +47 -0
- data/lib/tns/version.rb +5 -0
- data/lib/tns.rb +21 -0
- data/sig/tns.rbs +4 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 96fecd8199049b92d8b3cf968b6bbfe0c619510e0b31e04e2ec2abb647014f4f
|
4
|
+
data.tar.gz: 8c7036b12f8174bbb38df8d6ee0f44162345c4af4757f13baf43c47a2d3b420a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f77e63e912624c90a77a8f9b1fead10937547011176bc3b0ed11723b610fda15ec54c051861fa22c333c91e4ead01e9b4f92ca6e7dd046d7a48568c5675d0d1d
|
7
|
+
data.tar.gz: 0f5ddcb1690eac27b136f715a76ac6c25ece90d41ace943d43406bccc20ece8999244e3aa1e3fa5f954ec9c8231b5c51050b7963d9f82b6380395b414557c894
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-minitest
|
3
|
+
- rubocop-rake
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 3.2
|
7
|
+
NewCops: enable
|
8
|
+
|
9
|
+
Metrics/MethodLength:
|
10
|
+
Max: 15
|
11
|
+
|
12
|
+
Style/StringLiterals:
|
13
|
+
Enabled: true
|
14
|
+
EnforcedStyle: double_quotes
|
15
|
+
|
16
|
+
Style/StringLiteralsInInterpolation:
|
17
|
+
Enabled: true
|
18
|
+
EnforcedStyle: double_quotes
|
19
|
+
|
20
|
+
Layout/LineLength:
|
21
|
+
Max: 120
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hans.schnedlitz@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 hschne
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
<div align="center">
|
2
|
+
|
3
|
+
<img alt="logo" src="assets/logo.webp" width="300px" height="auto">
|
4
|
+
|
5
|
+
### The tints & shades generator for CLI lovers 🩶
|
6
|
+
|
7
|
+
</div>
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Install Tints 'N Shades (TNS) using [Bundler](https://bundler.io/).
|
12
|
+
|
13
|
+
```bash
|
14
|
+
bundle install tints-n-shades
|
15
|
+
```
|
16
|
+
|
17
|
+
Run `tns generate` (or the short variant, `tns g`) with any color you need tints and shades for in hex format.
|
18
|
+
|
19
|
+
```bash
|
20
|
+
tns g #ff7d00
|
21
|
+
--primary-100: #ffe5cc;
|
22
|
+
--primary-200: #ffcb99;
|
23
|
+
--primary-300: #ffb166;
|
24
|
+
--primary-400: #ff9733;
|
25
|
+
--primary-500: #ff7d00;
|
26
|
+
--primary-600: #cc6400;
|
27
|
+
--primary-700: #994b00;
|
28
|
+
--primary-800: #663200;
|
29
|
+
--primary-900: #331900;
|
30
|
+
```
|
31
|
+
|
32
|
+
### Color Formats
|
33
|
+
|
34
|
+
TNS supports outputs in Hex, HSL and RGB formats using the `--color-format` / `-c` argument.
|
35
|
+
|
36
|
+
```bash
|
37
|
+
tns g #ff7d00 -c hex
|
38
|
+
--primary-100: #ffe5cc;
|
39
|
+
--primary-200: #ffcb99;
|
40
|
+
|
41
|
+
tns g #ff7d00 --color-format hsl
|
42
|
+
--primary-100: hsl(29 100 90);
|
43
|
+
--primary-200: hsl(29 100 80);
|
44
|
+
...
|
45
|
+
|
46
|
+
tns g #ff7d00 --color-format rgb
|
47
|
+
--primary-100: rgb(255 229 204);
|
48
|
+
--primary-200: rgb(255 203 153);
|
49
|
+
...
|
50
|
+
```
|
51
|
+
|
52
|
+
### Output Formats
|
53
|
+
|
54
|
+
TNS supports outputting color palettes as CSS variables, SCSS variables, or Tailwind configuration.
|
55
|
+
|
56
|
+
```text
|
57
|
+
tns g #ff7d00 -o css
|
58
|
+
--primary-100: #ffe5cc;
|
59
|
+
--primary-200: #ffcb99;
|
60
|
+
...
|
61
|
+
|
62
|
+
tns g #ff7d00 -o sass
|
63
|
+
$primary-100: #ffe5cc;
|
64
|
+
$primary-200: #ffcb99;
|
65
|
+
...
|
66
|
+
|
67
|
+
tns g #ff7d00 -o tailwind
|
68
|
+
{
|
69
|
+
"primary": {
|
70
|
+
"100": "#ffe5cc",
|
71
|
+
"200": "#ffcb99",
|
72
|
+
...
|
73
|
+
}
|
74
|
+
}
|
75
|
+
...
|
76
|
+
```
|
77
|
+
|
78
|
+
### Others
|
79
|
+
|
80
|
+
To change the name of your color use the `--name` / `-n` argument. For additional configuration options see
|
81
|
+
|
82
|
+
```
|
83
|
+
tns help generate
|
84
|
+
```
|
85
|
+
|
86
|
+
## Why another Color generator?
|
87
|
+
|
88
|
+
While there are numerous palette, tint and shade generators out there, none of them quite fit my use case. That is, taking colors from some palette (e.g. [coolors](https://coolors.co/)) and generating complete CSS/SASS variables in various formats.
|
89
|
+
|
90
|
+
There are tools that will only output Hex variables, other support only Tailwind, and so on. There are none that provide that level of customization that I was looking for.
|
91
|
+
|
92
|
+
Also: None that work on the command line! TNS is a simple executable that lends itself perfectly for scripting.
|
93
|
+
|
94
|
+
## Credit
|
95
|
+
|
96
|
+
This project was primarily inspired by [maketintsandshades.com](https://maketintsandshades.com/) and [tints.dev](https://www.tints.dev/). The starting point code-wise was the [color gem](https://github.com/halostatue/color). The RGB to HSL conversion algorithm is based off of [this Stackoverflow answer](https://stackoverflow.com/a/39147465)
|
97
|
+
|
98
|
+
## Contributing
|
99
|
+
|
100
|
+
Thank you for contributing! :heart:
|
101
|
+
|
102
|
+
Please use [GitHub issues](https://github.com/hschne/mr-loga-loga/issues) to submit bugs or feature requests.
|
103
|
+
|
104
|
+
## License
|
105
|
+
|
106
|
+
The gem is available as open-source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
107
|
+
|
108
|
+
## Code of Conduct
|
109
|
+
|
110
|
+
Everyone interacting in the Tints 'N Shades project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/hschne/tints-n-shades/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/assets/logo.svg
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
|
4
|
+
<svg
|
5
|
+
width="1024"
|
6
|
+
height="1024"
|
7
|
+
viewBox="0 0 270.93333 270.93333"
|
8
|
+
version="1.1"
|
9
|
+
id="svg1"
|
10
|
+
xml:space="preserve"
|
11
|
+
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
12
|
+
sodipodi:docname="logo.svg"
|
13
|
+
inkscape:export-filename="logo.webp"
|
14
|
+
inkscape:export-xdpi="50.096066"
|
15
|
+
inkscape:export-ydpi="50.096066"
|
16
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
17
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
18
|
+
xmlns="http://www.w3.org/2000/svg"
|
19
|
+
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
20
|
+
id="namedview1"
|
21
|
+
pagecolor="#ffffff"
|
22
|
+
bordercolor="#000000"
|
23
|
+
borderopacity="0.25"
|
24
|
+
inkscape:showpageshadow="2"
|
25
|
+
inkscape:pageopacity="0.0"
|
26
|
+
inkscape:pagecheckerboard="0"
|
27
|
+
inkscape:deskcolor="#d1d1d1"
|
28
|
+
inkscape:document-units="mm"
|
29
|
+
inkscape:zoom="0.51654111"
|
30
|
+
inkscape:cx="171.33196"
|
31
|
+
inkscape:cy="369.76728"
|
32
|
+
inkscape:window-width="1896"
|
33
|
+
inkscape:window-height="1026"
|
34
|
+
inkscape:window-x="10"
|
35
|
+
inkscape:window-y="40"
|
36
|
+
inkscape:window-maximized="1"
|
37
|
+
inkscape:current-layer="layer1" /><defs
|
38
|
+
id="defs1" /><g
|
39
|
+
inkscape:label="Layer 1"
|
40
|
+
inkscape:groupmode="layer"
|
41
|
+
id="layer1"><g
|
42
|
+
id="g55"
|
43
|
+
inkscape:label="Font"
|
44
|
+
transform="matrix(1.1626232,0,0,1.1626232,-19.569924,-10.066518)"><g
|
45
|
+
id="g44"
|
46
|
+
inkscape:label="T"><text
|
47
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#ff595e;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
48
|
+
x="27.315277"
|
49
|
+
y="116.79609"
|
50
|
+
id="text17"
|
51
|
+
inkscape:label="T">T</text><text
|
52
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
53
|
+
x="22.302572"
|
54
|
+
y="115.93073"
|
55
|
+
id="text30"
|
56
|
+
inkscape:label="TS">T</text></g><g
|
57
|
+
id="g45"
|
58
|
+
inkscape:label="i"
|
59
|
+
transform="rotate(2.3426673,41.971932,79.914746)"><text
|
60
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#6a4c93;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
61
|
+
x="65.979584"
|
62
|
+
y="116.79609"
|
63
|
+
id="text16"
|
64
|
+
inkscape:label="i">i</text><text
|
65
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
66
|
+
x="64.513428"
|
67
|
+
y="116.70066"
|
68
|
+
id="text31"
|
69
|
+
inkscape:label="i">i</text></g><g
|
70
|
+
id="g46"
|
71
|
+
inkscape:label="n"
|
72
|
+
transform="rotate(-3.4520855,104.10931,73.199047)"><text
|
73
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#8ac926;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
74
|
+
x="80.924408"
|
75
|
+
y="116.79609"
|
76
|
+
id="text15"
|
77
|
+
inkscape:label="n">n</text><text
|
78
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
79
|
+
x="78.396431"
|
80
|
+
y="115.93073"
|
81
|
+
id="text32"
|
82
|
+
inkscape:label="n">n</text></g><g
|
83
|
+
id="g47"
|
84
|
+
inkscape:label="t"
|
85
|
+
transform="rotate(5.7354408,131.79659,93.431277)"><text
|
86
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#ffca3a;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
87
|
+
x="116.95322"
|
88
|
+
y="116.79609"
|
89
|
+
id="text14"
|
90
|
+
inkscape:label="t">t</text><text
|
91
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
92
|
+
x="116.09514"
|
93
|
+
y="115.93073"
|
94
|
+
id="text33"
|
95
|
+
inkscape:label="t">t</text></g><g
|
96
|
+
id="g48"
|
97
|
+
inkscape:label="s"
|
98
|
+
transform="rotate(8.729843,159.2997,96.021775)"><text
|
99
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#ff595e;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
100
|
+
x="147.68002"
|
101
|
+
y="116.79609"
|
102
|
+
id="text13"
|
103
|
+
inkscape:label="s">s</text><text
|
104
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
105
|
+
x="148.24609"
|
106
|
+
y="115.93073"
|
107
|
+
id="text34"
|
108
|
+
inkscape:label="s">s</text></g><g
|
109
|
+
id="g43"
|
110
|
+
inkscape:label="'"
|
111
|
+
transform="translate(-9.2782108,1.5952203)"><text
|
112
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#1982c4;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
113
|
+
x="193.81674"
|
114
|
+
y="116.79609"
|
115
|
+
id="text12"
|
116
|
+
inkscape:label="'">'</text><text
|
117
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
118
|
+
x="196.52121"
|
119
|
+
y="115.93073"
|
120
|
+
id="text35"
|
121
|
+
inkscape:label="'">'</text></g><g
|
122
|
+
id="g42"
|
123
|
+
inkscape:label="N"
|
124
|
+
transform="rotate(6.6188184,208.57506,13.245817)"><text
|
125
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#1982c4;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
126
|
+
x="203.98666"
|
127
|
+
y="116.79609"
|
128
|
+
id="text11"
|
129
|
+
inkscape:label="N">N</text><text
|
130
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
131
|
+
x="204.92886"
|
132
|
+
y="117.37922"
|
133
|
+
id="text36"
|
134
|
+
inkscape:label="N">N</text></g><g
|
135
|
+
id="g49"
|
136
|
+
inkscape:label="S"
|
137
|
+
transform="rotate(-5.7055549,-179.51223,191.02633)"><text
|
138
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#ff595e;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
139
|
+
x="29.671722"
|
140
|
+
y="198.87531"
|
141
|
+
id="text10"
|
142
|
+
inkscape:label="S">S</text><text
|
143
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
144
|
+
x="26.525051"
|
145
|
+
y="201.9677"
|
146
|
+
id="text37"
|
147
|
+
inkscape:label="S">S</text></g><g
|
148
|
+
id="g50"
|
149
|
+
inkscape:label="h"
|
150
|
+
transform="rotate(-3.9207149,-247.85382,162.79964)"><text
|
151
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#1982c4;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
152
|
+
x="71.467621"
|
153
|
+
y="198.87531"
|
154
|
+
id="text9"
|
155
|
+
inkscape:label="h">h</text><text
|
156
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
157
|
+
x="68.501335"
|
158
|
+
y="201.81422"
|
159
|
+
id="text38"
|
160
|
+
inkscape:label="h">h</text></g><g
|
161
|
+
id="g51"
|
162
|
+
inkscape:label="a"
|
163
|
+
transform="rotate(-4.3237801,-191.04605,163.94864)"><text
|
164
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#ffca3a;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
165
|
+
x="107.49643"
|
166
|
+
y="198.87531"
|
167
|
+
id="text8"
|
168
|
+
inkscape:label="a">a</text><text
|
169
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
170
|
+
x="106.20004"
|
171
|
+
y="201.81422"
|
172
|
+
id="text39"
|
173
|
+
inkscape:label="a">a</text></g><g
|
174
|
+
id="g52"
|
175
|
+
inkscape:label="d"
|
176
|
+
transform="translate(0.28208067,-22.981373)"><text
|
177
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#8ac926;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
178
|
+
x="140.85873"
|
179
|
+
y="198.87531"
|
180
|
+
id="text7"
|
181
|
+
inkscape:label="d">d</text><text
|
182
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
183
|
+
x="141.10866"
|
184
|
+
y="201.81422"
|
185
|
+
id="text40"
|
186
|
+
inkscape:label="d">d</text></g><g
|
187
|
+
id="g53"
|
188
|
+
inkscape:label="e"
|
189
|
+
transform="rotate(-2.2676435,-384.09644,164.27468)"><text
|
190
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#6a4c93;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
191
|
+
x="178.46884"
|
192
|
+
y="198.87531"
|
193
|
+
id="text6"
|
194
|
+
inkscape:label="e">e</text><text
|
195
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
196
|
+
x="179.32579"
|
197
|
+
y="200.11247"
|
198
|
+
id="text41"
|
199
|
+
inkscape:label="e">e</text></g><g
|
200
|
+
id="g54"
|
201
|
+
inkscape:label="s"
|
202
|
+
transform="translate(0.28208067,-22.981373)"><text
|
203
|
+
style="font-size:63.5px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:#ff595e;fill-opacity:1;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8"
|
204
|
+
x="211.92416"
|
205
|
+
y="198.87531"
|
206
|
+
id="text5"
|
207
|
+
inkscape:label="s">s</text><text
|
208
|
+
style="font-size:66.4432px;font-family:ToySans;-inkscape-font-specification:ToySans;text-align:center;white-space:pre;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.38423;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.8;stroke-dasharray:none;stroke-opacity:1"
|
209
|
+
x="213.49054"
|
210
|
+
y="199.94696"
|
211
|
+
id="text42"
|
212
|
+
inkscape:label="s">s</text></g></g></g></svg>
|
data/assets/logo.webp
ADDED
Binary file
|
data/exe/tns
ADDED
data/lib/tns/cli.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
require_relative "../tns"
|
6
|
+
|
7
|
+
module TNS
|
8
|
+
# CLI to generate stuff
|
9
|
+
class CLI < Thor
|
10
|
+
desc "generate <color>", "Generate tints and shades from a given color"
|
11
|
+
long_desc <<~LONGDESC
|
12
|
+
Tints 'N Shades (tns) is a tints and shades generator for command line
|
13
|
+
lovers. Generate palettes in CSS/SASS/Tailwind based on a Hex color.
|
14
|
+
|
15
|
+
tns g #ff7d00
|
16
|
+
--primary-100: #ffe5cc;
|
17
|
+
--primary-200: #ffcb99;
|
18
|
+
LONGDESC
|
19
|
+
|
20
|
+
option :name, default: "primary",
|
21
|
+
type: :string,
|
22
|
+
aliases: "-n",
|
23
|
+
desc: "The name of your color"
|
24
|
+
option :output, default: "css",
|
25
|
+
enum: %w[css sass tailwind],
|
26
|
+
type: :string,
|
27
|
+
aliases: "-o",
|
28
|
+
desc: "The output format"
|
29
|
+
option "color-format", default: "hex",
|
30
|
+
enum: %w[hex hsl rgb],
|
31
|
+
type: :string,
|
32
|
+
aliases: "-c",
|
33
|
+
desc: "The color format to use. "
|
34
|
+
def generate(color)
|
35
|
+
rgb = Color::RGB.from_hex(color)
|
36
|
+
name = options["name"]
|
37
|
+
color_format = options["color-format"]
|
38
|
+
output = options["output"]
|
39
|
+
palette = Palette.new(rgb).to(color_format)
|
40
|
+
output = Output.from_argument(output, name)
|
41
|
+
puts output.format(palette)
|
42
|
+
rescue ArgumentError => e
|
43
|
+
# Wrap argument errors into thor errors for nicer reporting to user
|
44
|
+
raise Thor::Error, e.message
|
45
|
+
end
|
46
|
+
|
47
|
+
map "g" => :generate
|
48
|
+
|
49
|
+
def self.exit_on_failure?
|
50
|
+
true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TNS
|
4
|
+
module Color
|
5
|
+
# Base color class
|
6
|
+
class Base
|
7
|
+
def to_css
|
8
|
+
raise NotImplementedError
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
def ==(other)
|
16
|
+
other.class == self.class && other.state == state
|
17
|
+
end
|
18
|
+
|
19
|
+
def state
|
20
|
+
instance_variables.map { |variable| instance_variable_get variable }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TNS
|
4
|
+
module Color
|
5
|
+
# Hex color representation
|
6
|
+
class Hex < Base
|
7
|
+
attr_reader :red, :green, :blue
|
8
|
+
|
9
|
+
def initialize(rgb)
|
10
|
+
@red, @green, @blue = [rgb.red, rgb.green, rgb.blue].map { |color| normalize(color) }
|
11
|
+
|
12
|
+
super()
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_css
|
16
|
+
"##{self}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
"#{red}#{green}#{blue}"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Set color value between allowed range and set to hex representation.
|
26
|
+
def normalize(value)
|
27
|
+
value.round.clamp(0, 255).to_s(16).rjust(2, "0")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TNS
|
4
|
+
module Color
|
5
|
+
# HSL is our base representation for color objects.
|
6
|
+
class HSL
|
7
|
+
attr_reader :hue, :saturation, :lightness
|
8
|
+
|
9
|
+
def initialize(rgb)
|
10
|
+
@hue, @saturation, @lightness = from_rgb(rgb)
|
11
|
+
super()
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_css
|
15
|
+
"hsl(#{self})"
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
format("%<hue>d %<saturation>d %<lightness>d", hue: @hue, saturation: @saturation, lightness: @lightness)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def from_rgb(color)
|
25
|
+
r, g, b = rgb(color)
|
26
|
+
h, s, l = calculate_hsl(r, g, b)
|
27
|
+
|
28
|
+
[(h * 360).round, (s * 100).round, (l * 100).round]
|
29
|
+
end
|
30
|
+
|
31
|
+
def rgb(color)
|
32
|
+
r = color.red
|
33
|
+
g = color.green
|
34
|
+
b = color.blue
|
35
|
+
r /= 255.0
|
36
|
+
g /= 255.0
|
37
|
+
b /= 255.0
|
38
|
+
[r, g, b]
|
39
|
+
end
|
40
|
+
|
41
|
+
def normalize_hsl(min, max)
|
42
|
+
h = (max + min) / 2.0
|
43
|
+
s = (max + min) / 2.0
|
44
|
+
l = (max + min) / 2.0
|
45
|
+
[h, s, l]
|
46
|
+
end
|
47
|
+
|
48
|
+
def calculate_hsl(red, green, blue)
|
49
|
+
min = [red, green, blue].min
|
50
|
+
max = [red, green, blue].max
|
51
|
+
h, s, l = normalize_hsl(min, max)
|
52
|
+
|
53
|
+
if max == min
|
54
|
+
h = 0
|
55
|
+
s = 0 # achromatic
|
56
|
+
else
|
57
|
+
d = max - min
|
58
|
+
s = l >= 0.5 ? d / (2.0 - max - min) : d / (max + min)
|
59
|
+
h = calculate_hue(max, red, green, blue, d)
|
60
|
+
h /= 6.0
|
61
|
+
end
|
62
|
+
[h, s, l]
|
63
|
+
end
|
64
|
+
|
65
|
+
def calculate_hue(max, red, green, blue, delta)
|
66
|
+
case max
|
67
|
+
when red
|
68
|
+
((green - blue) / delta) + (green < blue ? 6.0 : 0)
|
69
|
+
when green
|
70
|
+
((blue - red) / delta) + 2.0
|
71
|
+
when blue
|
72
|
+
((red - green) / delta) + 4.0
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TNS
|
4
|
+
module Color
|
5
|
+
# RGB is our base representation for color objects.
|
6
|
+
class RGB < Base
|
7
|
+
attr_reader :red, :green, :blue
|
8
|
+
|
9
|
+
def initialize(red = 0, green = 0, blue = 0)
|
10
|
+
@red, @green, @blue = [red, green, blue].map { |color| normalize(color) }
|
11
|
+
super()
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.from_hex(color, &)
|
15
|
+
hex = color.scan(/[0-9a-f]/i)
|
16
|
+
case hex.size
|
17
|
+
when 3
|
18
|
+
new(*hex.map { |v| (v * 2).to_i(16) }, &)
|
19
|
+
when 6
|
20
|
+
new(*hex.each_slice(2).map { |v| v.join.to_i(16) }, &)
|
21
|
+
else
|
22
|
+
raise ArgumentError, "Invalid color #{color}. Please provide a color in hex format."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Return a new instance of RGB that is tinted by step
|
27
|
+
def tint(step)
|
28
|
+
red = @red + ((255 - @red) * step * 0.2)
|
29
|
+
green = @green + ((255 - @green) * step * 0.2)
|
30
|
+
blue = @blue + ((255 - @blue) * step * 0.2)
|
31
|
+
Tint.new(RGB.new(red, green, blue), step)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Return a new instance of RGB that is shaded by step
|
35
|
+
def shade(step)
|
36
|
+
red = @red * (1 - (0.2 * step))
|
37
|
+
green = @green * (1 - (0.2 * step))
|
38
|
+
blue = @blue * (1 - (0.2 * step))
|
39
|
+
Shade.new(RGB.new(red, green, blue), step)
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_hex
|
43
|
+
Hex.new(self)
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_hsl
|
47
|
+
HSL.new(self)
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_css
|
51
|
+
"rgb(#{self})"
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
format("%<red>d %<green>d %<blue>d", red: @red, green: @green, blue: @blue)
|
56
|
+
end
|
57
|
+
|
58
|
+
def ==(other)
|
59
|
+
other.class == self.class && other.state == state
|
60
|
+
end
|
61
|
+
|
62
|
+
def state
|
63
|
+
instance_variables.map { |variable| instance_variable_get variable }
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
# Set color value between allowed range.
|
69
|
+
def normalize(value)
|
70
|
+
value.round.clamp(0, 255)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
|
5
|
+
module TNS
|
6
|
+
module Color
|
7
|
+
# A variant of a color, which could be either a tint or a shade.
|
8
|
+
class Variant < Base
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
attr_reader :color, :step
|
12
|
+
|
13
|
+
def_delegators :@color, :to_css, :to_s
|
14
|
+
|
15
|
+
def initialize(color, step)
|
16
|
+
@color = color
|
17
|
+
@step = step
|
18
|
+
super()
|
19
|
+
end
|
20
|
+
|
21
|
+
# Change the internal color representation to Hex
|
22
|
+
def to_hex
|
23
|
+
@color = @color.to_hex
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
# Change the internal color representation to HSL
|
28
|
+
def to_hsl
|
29
|
+
@color = @color.to_hsl
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
# Return the step relative to base color. Step 0 has in index of 5,
|
34
|
+
# tints and shades have indices relative to that.
|
35
|
+
def index
|
36
|
+
raise NotImplementedError("Implement this for shades or tints")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TNS
|
4
|
+
module Output
|
5
|
+
# Output a given color as CSS property (aka. variable).
|
6
|
+
class CSS
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def format(palette)
|
12
|
+
palette
|
13
|
+
.map { |variant| format_variant(variant) }
|
14
|
+
.map(&:to_s)
|
15
|
+
.map { |string| "#{string};" }
|
16
|
+
.join("\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
def format_variant(variant)
|
20
|
+
"--#{@name}-#{variant.index * 100}: #{variant.to_css}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TNS
|
4
|
+
module Output
|
5
|
+
def from_argument(arg, name)
|
6
|
+
case arg
|
7
|
+
when "css"
|
8
|
+
CSS.new(name)
|
9
|
+
when "sass"
|
10
|
+
SASS.new(name)
|
11
|
+
when "tailwind"
|
12
|
+
Tailwind.new(name)
|
13
|
+
else
|
14
|
+
raise ArgumentError, "Invalid output #{arg}."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
module_function :from_argument
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TNS
|
4
|
+
module Output
|
5
|
+
# Output a given color as SASS variable.
|
6
|
+
class SASS
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def format(palette)
|
12
|
+
palette
|
13
|
+
.map { |variant| format_variant(variant) }
|
14
|
+
.map { |string| "#{string};" }
|
15
|
+
.join("\n")
|
16
|
+
end
|
17
|
+
|
18
|
+
def format_variant(variant)
|
19
|
+
"$#{@name}-#{variant.index * 100}: #{variant.to_css}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module TNS
|
6
|
+
module Output
|
7
|
+
# Output a given color palette as Tailwind JSON.
|
8
|
+
class Tailwind
|
9
|
+
def initialize(name)
|
10
|
+
@name = name
|
11
|
+
end
|
12
|
+
|
13
|
+
def format(palette)
|
14
|
+
colors = palette.map { |variant| format_variant(variant) }
|
15
|
+
JSON.pretty_generate({ @name.to_s => colors.reduce({}, :merge) })
|
16
|
+
end
|
17
|
+
|
18
|
+
def format_variant(variant)
|
19
|
+
{ (variant.index * 100).to_s => variant.to_css.to_s }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/tns/palette.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TNS
|
4
|
+
# Represents a palette based on a color
|
5
|
+
class Palette
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
def initialize(color)
|
9
|
+
@color = color
|
10
|
+
end
|
11
|
+
|
12
|
+
def tints
|
13
|
+
(1..4).each_with_object([]) do |index, object|
|
14
|
+
object << @color.tint(index)
|
15
|
+
end.reverse
|
16
|
+
end
|
17
|
+
|
18
|
+
def shades
|
19
|
+
(1..4).each_with_object([]) do |index, object|
|
20
|
+
object << @color.shade(index)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def to(format)
|
25
|
+
case format
|
26
|
+
when "hex"
|
27
|
+
map(&:to_hex)
|
28
|
+
when "hsl"
|
29
|
+
map(&:to_hsl)
|
30
|
+
when "rgb"
|
31
|
+
palette
|
32
|
+
else
|
33
|
+
raise ArgumentError, "Invalid color format #{format}. Specify hex, hsl or rgb."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def each(&)
|
38
|
+
palette.each(&)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def palette
|
44
|
+
tints + [Color::Tint.new(@color, 0)] + shades
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/tns/version.rb
ADDED
data/lib/tns.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "tns/version"
|
4
|
+
|
5
|
+
require_relative "tns/color/base"
|
6
|
+
require_relative "tns/color/rgb"
|
7
|
+
require_relative "tns/color/hex"
|
8
|
+
require_relative "tns/color/hsl"
|
9
|
+
|
10
|
+
require_relative "tns/color/variant"
|
11
|
+
require_relative "tns/color/tint"
|
12
|
+
require_relative "tns/color/shade"
|
13
|
+
require_relative "tns/output/output"
|
14
|
+
require_relative "tns/output/css"
|
15
|
+
require_relative "tns/output/sass"
|
16
|
+
require_relative "tns/output/tailwind"
|
17
|
+
require_relative "tns/palette"
|
18
|
+
|
19
|
+
module TNS
|
20
|
+
class Error < StandardError; end
|
21
|
+
end
|
data/sig/tns.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tints-n-shades
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hans Schnedlidtz
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
description: The tints & shades generator for CLI lovers.
|
28
|
+
email:
|
29
|
+
- hello@hansschnedlitz.com
|
30
|
+
executables:
|
31
|
+
- tns
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".rubocop.yml"
|
36
|
+
- CHANGELOG.md
|
37
|
+
- CODE_OF_CONDUCT.md
|
38
|
+
- LICENSE.txt
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- assets/logo.svg
|
42
|
+
- assets/logo.webp
|
43
|
+
- exe/tns
|
44
|
+
- lib/tns.rb
|
45
|
+
- lib/tns/cli.rb
|
46
|
+
- lib/tns/color/base.rb
|
47
|
+
- lib/tns/color/hex.rb
|
48
|
+
- lib/tns/color/hsl.rb
|
49
|
+
- lib/tns/color/rgb.rb
|
50
|
+
- lib/tns/color/shade.rb
|
51
|
+
- lib/tns/color/tint.rb
|
52
|
+
- lib/tns/color/variant.rb
|
53
|
+
- lib/tns/output/css.rb
|
54
|
+
- lib/tns/output/output.rb
|
55
|
+
- lib/tns/output/sass.rb
|
56
|
+
- lib/tns/output/tailwind.rb
|
57
|
+
- lib/tns/palette.rb
|
58
|
+
- lib/tns/version.rb
|
59
|
+
- sig/tns.rbs
|
60
|
+
homepage: https://github.com/hschne/tints-n-shades
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata:
|
64
|
+
allowed_push_host: https://rubygems.org
|
65
|
+
homepage_uri: https://github.com/hschne/tints-n-shades
|
66
|
+
source_code_uri: https://github.com/hschne/tints-n-shades
|
67
|
+
changelog_uri: https://github.com/hschne/tints-n-shades/CHANGELOG.md
|
68
|
+
rubygems_mfa_required: 'true'
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.2.2
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubygems_version: 3.4.10
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: The tints & shades generator for CLI lovers.
|
88
|
+
test_files: []
|