mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-29 05:31:51 +02:00
Start on plugin ctx API (#64)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
|
||||
type Appearance = 'light' | 'dark';
|
||||
export type Appearance = 'light' | 'dark';
|
||||
|
||||
export function getCSSAppearance(): Appearance {
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
|
||||
@@ -310,7 +310,6 @@ export function completeTheme(theme: YaakTheme): YaakTheme {
|
||||
|
||||
theme.border = theme.border ?? theme.surface?.lift(0.12);
|
||||
theme.borderSubtle = theme.borderSubtle ?? theme.border?.lower(0.08);
|
||||
console.log('HELLO', { theme });
|
||||
|
||||
theme.text = theme.text ?? theme.border?.lift(1).lower(0.2);
|
||||
theme.textSubtle = theme.textSubtle ?? theme.text?.lower(0.3);
|
||||
|
||||
@@ -104,6 +104,15 @@ export class YaakColor {
|
||||
return rgbaToHex(r, g, b, a);
|
||||
}
|
||||
|
||||
hexNoAlpha(): string {
|
||||
const h = this.hue;
|
||||
const s = this.saturation;
|
||||
const l = this.lightness;
|
||||
|
||||
const [r, g, b] = parseColor(`hsl(${h},${s}%,${l}%)`).rgb;
|
||||
return rgbaToHexNoAlpha(r, g, b);
|
||||
}
|
||||
|
||||
private _lighten(mod: number): YaakColor {
|
||||
const c = this.clone();
|
||||
c.lightness = this.lightness + (100 - this.lightness) * mod;
|
||||
@@ -125,6 +134,14 @@ function rgbaToHex(r: number, g: number, b: number, a: number): string {
|
||||
return '#' + [toHex(r), toHex(g), toHex(b), toHex(a * 255)].join('').toUpperCase();
|
||||
}
|
||||
|
||||
function rgbaToHexNoAlpha(r: number, g: number, b: number): string {
|
||||
const toHex = (n: number): string => {
|
||||
const hex = Number(Math.round(n)).toString(16);
|
||||
return hex.length === 1 ? `0${hex}` : hex;
|
||||
};
|
||||
return '#' + [toHex(r), toHex(g), toHex(b)].join('').toUpperCase();
|
||||
}
|
||||
|
||||
function hexToRgba(hex: string): [number, number, number, number] {
|
||||
const fromHex = (h: string): number => {
|
||||
if (h === '') return 255;
|
||||
|
||||
Reference in New Issue
Block a user