Skip to content

Commit

Permalink
feat(background): Color order close to og hue, tilted
Browse files Browse the repository at this point in the history
  • Loading branch information
Gh61 committed Nov 26, 2023
1 parent b59c149 commit 54ab3b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/core/colors/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ export class Background {
throw new Error('Only array of Colors or Backgrounds is supported for new Background(...).');
}
});
// sort the colors from the brightest
this._colors.sort((a, b) => a.getLuminance() - b.getLuminance());
// sort the colors based on hue (starting from around 195 - light blue)
// the Official app is olso showing only 5 colors, so every color gets wide enough stripe in card
// I think it's like cheating, so we don't do this (at least not now)
const getSortValue = (c: Color) => {
let result = c.getHue() - 195; // this hue value should be first
if (result < 0) {
result += 360;
}
return result;
}

Check failure on line 35 in src/core/colors/background.ts

View workflow job for this annotation

GitHub Actions / validate

Missing semicolon
this._colors.sort((a, b) => getSortValue(a) - getSortValue(b));
}

/**
Expand Down Expand Up @@ -66,6 +75,6 @@ export class Background {
colors += `, ${this._colors[i]} ${Math.round(currentStep)}%`;
}

return `linear-gradient(90deg, ${colors})`;
return `linear-gradient(100deg, ${colors})`;
}
}
2 changes: 1 addition & 1 deletion src/types/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Consts {
public static readonly DialogBgColor = '#171717';
public static readonly DialogFgLightColor = new Color('#aaa');
public static readonly DialogOffColor = '#363636';
public static readonly GradientOffset = 10; // percent
public static readonly GradientOffset = 7; // percent
public static readonly TransitionDefault = 'all 0.3s ease-out 0s';
public static readonly TimeCacheInterval = 1500; // ms

Expand Down

0 comments on commit 54ab3b2

Please sign in to comment.