snake_case icons and better toast styles

This commit is contained in:
Gregory Schier
2024-09-20 07:30:11 -07:00
parent a18271d306
commit 93633875ac
55 changed files with 309 additions and 262 deletions

View File

@@ -1,6 +1,6 @@
import { readFile } from '@tauri-apps/plugin-fs';
import type { HttpResponse } from '@yaakapp/api';
import { getCharsetFromContentType } from './models';
import { getCharsetFromContentType } from './model_util';
export async function getResponseBodyText(response: HttpResponse): Promise<string | null> {
if (response.bodyPath) {

View File

@@ -98,14 +98,23 @@ function templateTagColorVariables(color: YaakColor): Partial<CSSVariables> {
};
}
function toastColorVariables(color: YaakColor): Partial<CSSVariables> {
return {
text: color.lift(0.8),
textSubtle: color,
surface: color.translucify(0.9),
surfaceHighlight: color.translucify(0.8),
border: color.lift(0.3).translucify(0.6),
};
}
function bannerColorVariables(color: YaakColor): Partial<CSSVariables> {
return {
text: color.lift(0.8),
textSubtle: color.translucify(0.3),
textSubtlest: color,
surface: color,
surface: color.translucify(0.9),
border: color.lift(0.3).translucify(0.4),
surfaceHighlight: color.translucify(0.9),
};
}
@@ -201,6 +210,15 @@ function bannerCSS(color: YaakColorKey, colors?: Partial<YaakColors>): string |
);
}
function toastCSS(color: YaakColorKey, colors?: Partial<YaakColors>): string | null {
const yaakColor = colors?.[color];
if (yaakColor == null) {
return null;
}
return [variablesToCSS(`.x-theme-toast--${color}`, toastColorVariables(yaakColor))].join('\n\n');
}
function templateTagCSS(color: YaakColorKey, colors?: Partial<YaakColors>): string | null {
const yaakColor = colors?.[color];
if (yaakColor == null) {
@@ -253,6 +271,9 @@ export function getThemeCSS(theme: YaakTheme): string {
...Object.keys(colors ?? {}).map((key) =>
bannerCSS(key as YaakColorKey, theme.components?.banner ?? colors),
),
...Object.keys(colors ?? {}).map((key) =>
toastCSS(key as YaakColorKey, theme.components?.banner ?? colors),
),
...Object.keys(colors ?? {}).map((key) =>
templateTagCSS(key as YaakColorKey, theme.components?.templateTag ?? colors),
),