Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color Module - First Draft #147

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cb13637
color: Init first draft
adekunleoduye Jun 21, 2022
e674eeb
fix: clean up format
adekunleoduye Jun 23, 2022
fd0e930
Markdown lobster party!
kaelig Sep 8, 2022
0e2cc98
Updates for future section and tables
ayeshakmaz Sep 26, 2022
055697c
Merge branch 'main' into color-first-draft
ayeshakmaz Sep 26, 2022
bc0f325
More updates
ayeshakmaz Oct 19, 2022
0f02b4c
Merge branch 'color-first-draft' of https://github.com/design-tokens/…
ayeshakmaz Oct 19, 2022
ec0079e
prettier
ayeshakmaz Oct 19, 2022
b688a40
formatting
ayeshakmaz Nov 30, 2022
8ce0869
Update technical-reports/color/index.html
ayeshakmaz May 30, 2023
e4283bc
Update technical-reports/color/index.html
ayeshakmaz May 30, 2023
b938bb9
Update technical-reports/color/color-type.md
ayeshakmaz May 30, 2023
2f4349c
Update technical-reports/color/color-type.md
ayeshakmaz May 30, 2023
f4728eb
Update technical-reports/color/color-type.md
ayeshakmaz May 30, 2023
d25486c
Update technical-reports/color/color-type.md
ayeshakmaz May 30, 2023
f76ef65
Update technical-reports/color/token-naming.md
ayeshakmaz May 30, 2023
a618f5f
Update technical-reports/color/token-naming.md
ayeshakmaz May 30, 2023
3bb8998
Update technical-reports/color/token-naming.md
ayeshakmaz May 30, 2023
70c7212
Update technical-reports/color/color-type.md
ayeshakmaz May 30, 2023
d707312
Merge branch 'main' into color-first-draft
ayeshakmaz May 30, 2023
c5eeb7e
Update to new format with Hex fallback and Colorspace
ayeshakmaz Aug 2, 2023
f34cd40
add: Gradient sections
adekunleoduye Aug 2, 2023
1b18504
format: ran prettier
adekunleoduye Aug 2, 2023
15d896a
format updates
adekunleoduye Aug 2, 2023
5b65608
More format changes
adekunleoduye Aug 3, 2023
e47765b
Merge branch 'main' into color-first-draft
resource11 Aug 20, 2024
e7a9c30
fix format errors
adekunleoduye Aug 20, 2024
62b7771
revert change
adekunleoduye Aug 20, 2024
c61fab2
test verification
adekunleoduye Aug 20, 2024
c58ca34
Sync color-format color type verbiage
resource11 Aug 22, 2024
1226b98
Merge branch 'main' into color-first-draft
resource11 Aug 22, 2024
1195a2f
Merge branch 'main' into color-first-draft
resource11 Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 184 additions & 5 deletions technical-reports/color/color-type.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# The color type
# Color type

Represents a 24bit RGB or 24+8bit RGBA color in the sRGB color space. The `$type` property MUST be set to the string `color`. The value MUST be a string containing a hex triplet/quartet including the preceding `#` character. To support other color spaces, such as HSL, translation tools SHOULD convert color tokens to the equivalent value as needed.
## Hex - required support
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Rename to ensure this is now optional
Suggested change
## Hex - required support
## `hex` fallback


For example, initially the color tokens MAY be defined as such:
Colors can be represented through various formats. For color tokens, the `$type` property MUST be set to the string `color`. For the value, the most common format to represent color through design tokens is a hex triplet. A hex triplet is a 6-digit, 24 bit, hexadecimal number that represents Red, Green, and Blue values as `#RRGGBB`. For the initial version of this spec, we expect tools to support Hex values, at minimum. The value MUST be a string containing a hex triplet, including the preceding `#` character. To support other color spaces, such as HSL, translation tools SHOULD convert color tokens to the equivalent value as needed.

| Pros | Cons |
| ------------------------------------------ | -------------------------------------- |
| Easily recognized among tools and browsers | Cannot specify alpha value for opacity |

For example, initially color tokens may be defined as such:

<aside class="example">

Expand All @@ -12,11 +18,184 @@ For example, initially the color tokens MAY be defined as such:
"$value": "#ff00ff",
"$type": "color"
},
"Translucent shadow": {
"$value": "#00000088",
"Simple sage": {
"$value": "#abcabc",
"$type": "color"
}
}
```

</aside>

Then, the output from a tool’s conversion to HSL may look something like:

<aside class="example">

```scss
// colors-hex.scss
$majestic-magenta: #ff00ff;
$simple-sage: #abcabc;

// colors-hsl.scss
$majestic-magenta: ​hsl(300, 100%, 50%);
$translucent-shadow: ​hsl(153, 23%, 73%);
```

</aside>

## Other value options

### RGBA

Formatted in R (red), G (green), B (blue) and (A) alpha. Red, green, and blue values can range from 0 to 255 and alpha values can range from 0 and 1 (i.e 0.5) or a percentage (i.e 50%) where 1 or %100 is full opacity.
ayeshakmaz marked this conversation as resolved.
Show resolved Hide resolved

| Pros | Cons |
| --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Can define alpha value with color directly | It is not perceptually uniform, and is difficult to create variants (lighter or darker, more or less vivid etc) by tweaking its parameters. [Learn more about RGBA issues.](https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/) |
| Alpha value is easy to comprehend at a glance | |

For example, initially color tokens may be defined as such:

<aside class="example">

```json
{
"Majestic magenta": {
"$value": {
"red": 255,
"green": 0,
"blue": 255,
"alpha": 1
},
"$type": "color"
},
"Simple sage": {
"$value": {
"red": 171,
"green": 202,
"blue": 188,
"alpha": "50%"
},
"$type": "color"
}
}
```

</aside>

Then, the output from a tool’s conversion to RGBA may look something like:

<aside class="example">

```scss
// colors-rgba.scss
$majestic-magenta: rgba(255, 0, 255, 1);
$translucent-shadow: rgba(171, 202, 188, 50%);
```

</aside>

### HSL

Formatted in H (hue), S (saturation), L (lightness) and an optional (A) alpha. Hue values range from 0 to 360, saturation and lightness are percentage values that go from 0% to 100%, and alpha value can range from 0 and 1 (i.e 0.5) or a percentage (i.e 50%) where 1 or 100% is full opacity (which is the default value if a value isn’t provided).
ayeshakmaz marked this conversation as resolved.
Show resolved Hide resolved

| Pros | Cons |
| ----------------------------------------------------- | ------------------------------------- |
| It is easy to understand and compare to other formats | Not supported in all browsers (IE 11) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not supported in all browsers (IE 11)

Source?


<aside class="example">

```json
{
"Majestic magenta": {
"h": 300,
"s": "100%",
"l": "50%",
"a": "100%",
"$type": "color"
},
"Simple sage": {
"h": 100,
"s": "27%",
"l": "57%",
"a": "100%",
"$type": "color"
}
}
```

</aside>

Then, the output variables may look like:

<aside class="example">

```scss
// colors-rgba.scss
$majestic-magenta: hsl(300, 100%, 50%, 1);
$simple-sage: hsl(100, 27%, 57%);
```

</aside>

### Hex8

Hex8 uses two extra digits, known as the alpha value, to change the transparency of the color. The format follows `#RRGGBBAA`. [Learn more about alpha values in hex.](https://www.digitalocean.com/community/tutorials/css-hex-code-colors-alpha-values#adding-an-alpha-value-to-css-hex-codes)
ayeshakmaz marked this conversation as resolved.
Show resolved Hide resolved

| Pros | Cons |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Can define alpha value with color | Less commonly used |
| | Alpha value is not immediately obvious (needs calculation) |
| | Not available in older versions of Internet Explorer ([caniuse reference](https://caniuse.com/css-rrggbbaa)) |

<aside class="example">

```json
{
"Majestic magenta": {
"$value": "#ff00ff80",
"$type": "color"
},
"Simple sage": {
"$value": "#abcabc80",
"$type": "color"
}
}
```

</aside>

Then, the output variables may look like:

<aside class="example">

```scss
// colors-hex.scss
$majestic-magenta: #ff00ff80;
$simple-sage: #abcabc80;

// colors-rgba.scss
$majestic-magenta: rgba(255, 0, 255, 0.5);
$simple-sage: rgba(171, 202, 188, 0.5);
```

</aside>

### LCH (Lightness Chroma Hue)

Formatted in L (lightness), C (chroma), H (hue) and an optional (A) alpha. Hue values range from 0 to 360, saturation and lightness are percentage values that go from 0% to 100%, and alpha value can range from 0 and 1 (i.e., 0.5) or a percentage (i.e., 50%) where 1 or %100 is full opacity (which is the default value if a value isn’t provided).
ayeshakmaz marked this conversation as resolved.
Show resolved Hide resolved

| Pros | Cons |
| ------------------------------------------ | --------------------------------------------------------------------------- |
| Access to 50% more colors (P3 color space) | Colors more perceptually uniform, so it can be harder to distinguish values |
| | Limited browser support (Safari only) |
Copy link
Member

@kaelig kaelig Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Limited browser support (Safari only)

Now supported in Chrome, Edge, Safari, and Firefox behind a flag.

https://caniuse.com/mdn-css_types_color_oklch


---

## Future color type support

The initial version of the Design Token format will focus on widely-supported color spaces (i.e., Hex, RGB, HSL and Hex8). Support for Hex is required, while other format options are optional.
ayeshakmaz marked this conversation as resolved.
Show resolved Hide resolved

### Backwards compatibility

While future versions of this spec may add support for color spaces like OKLCH, OKLAB, CAM16, Display P-3, etc., using these color spaces may result in a lack of support from tools. We plan to rely on a Hex back-up when colors need to be downgraded due to lack of support. Please keep this in mind when defining tokens in these more experimental color spaces.
10 changes: 9 additions & 1 deletion technical-reports/color/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,17 @@ <h1>Introduction</h1>
<em>This section is non normative</em>
ayeshakmaz marked this conversation as resolved.
Show resolved Hide resolved
</p>

<p>Work in progress.</p>
<section
data-include="./overview.md"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overview.md is missing in this PR. Is this an old link that needs to be removed, or does this file just need to be added to git?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • (This comment is still valid and needs addressing)

data-include-format="markdown"
></section>
</section>

<section
data-include="./token-naming.md"
data-include-format="markdown"
ayeshakmaz marked this conversation as resolved.
Show resolved Hide resolved
></section>

<section
data-include="./color-type.md"
data-include-format="markdown"
Expand Down
7 changes: 7 additions & 0 deletions technical-reports/color/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Color module
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may need to move this section directly into the technical-reports/color/index.html file like we do with the format:

<section id="introduction">
<h1>Introduction</h1>
<p>
<em>This section is non normative</em>
</p>
<p>
Design tokens are a methodology for expressing design decisions in a
platform-agnostic way so that they can be shared across different
disciplines, tools, and technologies. They help establish a common
vocabulary across organisations.
</p>

And we can probably remove the Color module title.


Color tokens allow teams to manage color decisions at scale, streamline product consistency, reduce technical debt, and optimize the software development lifecycle.

The goal is to manage color at scale for a product, thereby reducing complexity and communicating the value to stakeholders.

This module describes best practices in regards to naming color tokens, defining color token values, and supporting multiple themes or brands. It also details future plans for the color module and extended value support.
Loading