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

feat: WDS color positive #24086

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Algorithmic positive color
  • Loading branch information
ichik committed Jun 14, 2023
commit 84c995365cf96decd65de9949137386f305637b5
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,19 @@ export class DarkModeTheme implements ColorModeTheme {
private get bgPositive() {
const color = this.bgAccent.clone();

color.oklch.h = 140;
color.oklch.l = 0.62;
color.oklch.c = 0.17;
color.oklch.h = 145;

if (this.seedIsGreen) {
if (this.seedColor.oklch.h < 139) {
color.oklch.h = 165;
if (this.seedIsGreen && this.seedColor.oklch.c > 0.09) {
if (this.seedColor.oklch.h < 145) {
color.oklch.h = 155;
}
if (this.seedColor.oklch.h >= 139) {
color.oklch.h = 116;
if (this.seedColor.oklch.h >= 145) {
color.oklch.h = 135;
}
}

if (color.oklch.c < 0.15) {
color.oklch.c = 0.15;
}

return color;
}

Expand Down Expand Up @@ -284,6 +282,30 @@ export class DarkModeTheme implements ColorModeTheme {
return color;
}

private get fgNegative() {
const color = this.bgNegative.clone();
color.oklch.l = color.oklch.l + 0.05;
color.oklch.c = color.oklch.c + 0.1;
color.oklch.h = color.oklch.h - 10;

if (
this.seedIsRed &&
!this.seedIsAchromatic &&
this.fgAccent.oklch.l < 0.5 &&
this.fgAccent.oklch.h < 28
) {
color.oklch.l = color.oklch.l + 0.05;
color.oklch.c = color.oklch.c + 0.05;
color.oklch.h = color.oklch.h - 15;
}

return color;
}

private get fgNeutral() {
return this.bdNeutral.clone();
}

private get fgOnAccent() {
const tint = this.seedColor.clone();
const shade = this.seedColor.clone();
Expand All @@ -303,46 +325,29 @@ export class DarkModeTheme implements ColorModeTheme {
return tint;
}

private get fgNeutral() {
return this.bdNeutral.clone();
private get fgOnAssistive() {
return this.bg.clone();
}

private get fgPositive() {
const color = this.bgPositive.clone();

if (this.bg.contrastAPCA(color) > -60) {
color.oklch.l = 50;
}

return color;
}

private get fgWarn() {
return "#facc15";
}

private get fgNegative() {
const color = this.bgNegative.clone();
color.oklch.l = color.oklch.l + 0.05;
color.oklch.c = color.oklch.c + 0.1;
color.oklch.h = color.oklch.h - 10;
color.oklch.l = color.oklch.l + 0.08;

if (
this.seedIsRed &&
this.seedIsGreen &&
!this.seedIsAchromatic &&
this.fgAccent.oklch.l < 0.5 &&
this.fgAccent.oklch.h < 28
this.fgAccent.oklch.l > 0.5 &&
this.fgAccent.oklch.h < 145
) {
color.oklch.l = color.oklch.l + 0.05;
color.oklch.c = color.oklch.c + 0.05;
color.oklch.h = color.oklch.h - 15;
color.oklch.h = color.oklch.h - 5;
}

return color;
}

private get fgOnAssistive() {
return this.bg.clone();
private get fgWarn() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
private get fgWarn() {
private get fgWarning() {

return "#facc15";
}

/*
Expand Down Expand Up @@ -460,13 +465,10 @@ export class DarkModeTheme implements ColorModeTheme {
}

private get bdPositive() {
const color = this.bdAccent.clone();

color.oklch.h = this.bgPositive.oklch.h;
const color = this.bgPositive.clone();

if (color.oklch.c < 0.15) {
color.oklch.c = 0.15;
}
color.oklch.l = color.oklch.l + 0.05;
color.oklch.c = color.oklch.c + 0.05;

return color;
}
Expand Down
121 changes: 70 additions & 51 deletions app/client/packages/design-system/theming/src/color/LightModeTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,6 @@ export class LightModeTheme implements ColorModeTheme {
return color;
}

private get bgPositive() {
const color = this.bgAccent.clone();

color.oklch.h = 140;

if (this.seedIsGreen) {
if (this.seedColor.oklch.h < 139) {
color.oklch.h = 165;
}
if (this.seedColor.oklch.h >= 139) {
color.oklch.h = 116;
}
}

if (color.oklch.c < 0.15) {
color.oklch.c = 0.15;
}

return color;
}

// used only for generating child colors, not used as a token
private get bgAccentSubtle() {
const color = this.seedColor.clone();
Expand Down Expand Up @@ -266,6 +245,25 @@ export class LightModeTheme implements ColorModeTheme {
return color;
}

private get bgPositive() {
const color = this.bgAccent.clone();

color.oklch.l = 0.62;
color.oklch.c = 0.19;
color.oklch.h = 145;

if (this.seedIsGreen && this.seedColor.oklch.c > 0.11) {
if (this.seedColor.oklch.h < 145) {
color.oklch.h = 155;
}
if (this.seedColor.oklch.h >= 145) {
color.oklch.h = 135;
}
}

return color;
}

/*
* Foreground colors
*/
Expand Down Expand Up @@ -301,6 +299,30 @@ export class LightModeTheme implements ColorModeTheme {
return color;
}

private get fgNegative() {
const color = this.bgNegative.clone();

color.oklch.l = color.oklch.l + 0.1;
color.oklch.c = color.oklch.c + 0.1;
color.oklch.h = color.oklch.h - 10;

if (
this.seedIsRed &&
!this.seedIsAchromatic &&
this.fgAccent.oklch.l > 0.5 &&
this.fgAccent.oklch.h < 28
) {
color.oklch.c = color.oklch.c + 0.05;
color.oklch.h = color.oklch.h - 15;
}

return color;
}

private get fgNeutral() {
return this.bdNeutral.clone();
}

private get fgOnAccent() {
const tint = this.seedColor.clone();
const shade = this.seedColor.clone();
Expand All @@ -322,47 +344,30 @@ export class LightModeTheme implements ColorModeTheme {
return shade;
}

private get fgNeutral() {
return this.bdNeutral.clone();
}

private get fgWarn() {
return "#facc15";
private get fgOnAssistive() {
return this.bg.clone();
}

private get fgNegative() {
const color = this.bgNegative.clone();

color.oklch.l = color.oklch.l + 0.1;
color.oklch.c = color.oklch.c + 0.1;
color.oklch.h = color.oklch.h - 10;
private get fgPositive() {
const color = this.bgPositive.clone();

if (
this.seedIsRed &&
this.seedIsGreen &&
!this.seedIsAchromatic &&
this.fgAccent.oklch.l > 0.5 &&
this.fgAccent.oklch.h < 28
this.fgAccent.oklch.h < 145
) {
color.oklch.c = color.oklch.c + 0.05;
color.oklch.h = color.oklch.h - 15;
color.oklch.h = color.oklch.h - 10;
}

return color;
}

private get fgOnAssistive() {
return this.bg.clone();
private get fgWarn() {
return "#facc15";
}

private get fgPositive() {
const color = this.bgPositive.clone();

if (this.bg.contrastAPCA(color) < 60) {
color.oklch.l = 50;
}

return color;
}
/*
* Border colors
*/
Expand Down Expand Up @@ -483,12 +488,26 @@ export class LightModeTheme implements ColorModeTheme {
}

private get bdPositive() {
const color = this.bdAccent.clone();
const color = this.bgPositive.clone();

color.oklch.h = this.bgPositive.oklch.h;
if (
this.bdAccent.oklch.l > 0.5 &&
this.bdAccent.oklch.c > 0.11 &&
this.bdAccent.oklch.h < 145 &&
this.bdAccent.oklch.h >= 116
) {
color.oklch.h = color.oklch.h + 5;
color.oklch.l = color.oklch.l + 0.1;
}

if (color.oklch.c < 0.15) {
color.oklch.c = 0.15;
if (
this.bdAccent.oklch.l > 0.5 &&
this.bdAccent.oklch.c > 0.11 &&
this.bdAccent.oklch.h >= 145 &&
this.bdAccent.oklch.h < 166
) {
color.oklch.h = color.oklch.h - 5;
color.oklch.l = color.oklch.l + 0.05;
}

return color;
Expand Down