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 all commits
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
114 changes: 92 additions & 22 deletions app/client/packages/design-system/theming/src/color/DarkModeTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class DarkModeTheme implements ColorModeTheme {
private readonly seedHue: number;
private readonly seedIsAchromatic: boolean;
private readonly seedIsCold: boolean;
private readonly seedIsGreen: boolean;
private readonly seedIsRed: boolean;
private readonly seedIsVeryDark: boolean;

Expand All @@ -21,6 +22,7 @@ export class DarkModeTheme implements ColorModeTheme {
hue,
isAchromatic,
isCold,
isGreen,
isRed,
isVeryDark,
lightness,
Expand All @@ -31,6 +33,7 @@ export class DarkModeTheme implements ColorModeTheme {
this.seedHue = hue;
this.seedIsAchromatic = isAchromatic;
this.seedIsCold = isCold;
this.seedIsGreen = isGreen;
this.seedIsRed = isRed;
this.seedIsVeryDark = isVeryDark;
}
Expand All @@ -46,14 +49,15 @@ export class DarkModeTheme implements ColorModeTheme {
bgAccentSubtleActive: this.bgAccentSubtleActive.toString(),
bgAssistive: this.bgAssistive.toString(),
bgNegative: this.bgNegative.toString(),
bgPositive: this.bgPositive.toString(),
// fg
fg: this.fg.toString(),
fgAccent: this.fgAccent.toString(),
fgNegative: this.fgNegative.toString(),
fgNeutral: this.fgNeutral.toString(),
fgOnAccent: this.fgOnAccent.toString(),
fgOnAssistive: this.fgOnAssistive.toString(),
fgPositive: this.fgPositive,
fgPositive: this.fgPositive.toString(),
fgWarn: this.fgWarn,
// bd
bdAccent: this.bdAccent.toString(),
Expand All @@ -62,6 +66,8 @@ export class DarkModeTheme implements ColorModeTheme {
bdNegativeHover: this.bdNegativeHover.toString(),
bdNeutral: this.bdNeutral.toString(),
bdNeutralHover: this.bdNeutralHover.toString(),
bdPositive: this.bdPositive.toString(),
bdPositiveHover: this.bdPositiveHover.toString(),
};
};

Expand Down Expand Up @@ -222,6 +228,26 @@ export class DarkModeTheme implements ColorModeTheme {

return color;
}

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

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

if (this.seedIsGreen && this.seedColor.oklch.c > 0.09) {
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 @@ -256,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 @@ -275,40 +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() {
return "#4ade80";
}
const color = this.bgPositive.clone();

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 @@ -424,4 +463,35 @@ export class DarkModeTheme implements ColorModeTheme {

return color;
}

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

color.oklch.l = color.oklch.l + 0.05;
color.oklch.c = color.oklch.c + 0.05;

return color;
}

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

if (this.bdPositive.oklch.l < 0.06) {
color.oklch.l = color.oklch.l + 0.6;
}

if (this.bdPositive.oklch.l >= 0.06 && this.bdPositive.oklch.l < 0.25) {
color.oklch.l = color.oklch.l + 0.4;
}

if (this.bdPositive.oklch.l >= 0.25 && this.bdPositive.oklch.l < 0.5) {
color.oklch.l = color.oklch.l + 0.25;
}

if (this.bdPositive.oklch.l >= 0.5) {
color.oklch.l = color.oklch.l + 0.1;
}

return color;
}
}
Loading