mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-18 23:09:47 +02:00
Theme analytics and Moonlight
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
use log::warn;
|
use log::{debug, warn};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use sqlx::types::JsonValue;
|
use sqlx::types::JsonValue;
|
||||||
@@ -19,6 +19,7 @@ const NUM_LAUNCHES_KEY: &str = "num_launches";
|
|||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum AnalyticsResource {
|
pub enum AnalyticsResource {
|
||||||
App,
|
App,
|
||||||
|
Appearance,
|
||||||
CookieJar,
|
CookieJar,
|
||||||
Dialog,
|
Dialog,
|
||||||
Environment,
|
Environment,
|
||||||
@@ -29,9 +30,10 @@ pub enum AnalyticsResource {
|
|||||||
HttpRequest,
|
HttpRequest,
|
||||||
HttpResponse,
|
HttpResponse,
|
||||||
KeyValue,
|
KeyValue,
|
||||||
Sidebar,
|
|
||||||
Workspace,
|
|
||||||
Setting,
|
Setting,
|
||||||
|
Sidebar,
|
||||||
|
Theme,
|
||||||
|
Workspace,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AnalyticsResource {
|
impl AnalyticsResource {
|
||||||
@@ -187,7 +189,7 @@ pub async fn track_event(
|
|||||||
|
|
||||||
// Disable analytics actual sending in dev
|
// Disable analytics actual sending in dev
|
||||||
if is_dev() {
|
if is_dev() {
|
||||||
// debug!("track: {} {} {:?}", event, attributes_json, params);
|
debug!("track: {}", event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,4 +249,4 @@ async fn get_id(app_handle: &AppHandle) -> String {
|
|||||||
|
|
||||||
pub async fn get_num_launches(app: &AppHandle) -> i32 {
|
pub async fn get_num_launches(app: &AppHandle) -> i32 {
|
||||||
get_key_value_int(app, NAMESPACE, NUM_LAUNCHES_KEY, 0).await
|
get_key_value_int(app, NAMESPACE, NUM_LAUNCHES_KEY, 0).await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,17 +62,17 @@ export function BinaryFileEditor({
|
|||||||
<InlineCode>{mimeType}</InlineCode> for current request?
|
<InlineCode>{mimeType}</InlineCode> for current request?
|
||||||
</div>
|
</div>
|
||||||
<HStack space={1.5} justifyContent="center">
|
<HStack space={1.5} justifyContent="center">
|
||||||
|
<Button size="sm" variant="border" onClick={() => ignoreContentType.set(true)}>
|
||||||
|
Ignore
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
variant="solid"
|
||||||
color="secondary"
|
color="primary"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => onChangeContentType(mimeType)}
|
onClick={() => onChangeContentType(mimeType)}
|
||||||
>
|
>
|
||||||
Set Header
|
Set Header
|
||||||
</Button>
|
</Button>
|
||||||
<Button size="sm" variant="border" onClick={() => ignoreContentType.set(true)}>
|
|
||||||
Ignore
|
|
||||||
</Button>
|
|
||||||
</HStack>
|
</HStack>
|
||||||
</Banner>
|
</Banner>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const Settings = () => {
|
|||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
data-tauri-drag-region
|
data-tauri-drag-region
|
||||||
className="h-[27px] bg-background-highlight-secondary flex items-center justify-center border-b border-background-highlight"
|
className="x-theme-appHeader h-[27px] bg-background text-fg-subtle flex items-center justify-center border-b border-background-highlight text-sm font-semibold"
|
||||||
>
|
>
|
||||||
Settings
|
Settings
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useResolvedTheme } from '../../hooks/useResolvedTheme';
|
|||||||
import { useSettings } from '../../hooks/useSettings';
|
import { useSettings } from '../../hooks/useSettings';
|
||||||
import { useThemes } from '../../hooks/useThemes';
|
import { useThemes } from '../../hooks/useThemes';
|
||||||
import { useUpdateSettings } from '../../hooks/useUpdateSettings';
|
import { useUpdateSettings } from '../../hooks/useUpdateSettings';
|
||||||
|
import { trackEvent } from '../../lib/analytics';
|
||||||
import { clamp } from '../../lib/clamp';
|
import { clamp } from '../../lib/clamp';
|
||||||
import { isThemeDark } from '../../lib/theme/window';
|
import { isThemeDark } from '../../lib/theme/window';
|
||||||
import type { ButtonProps } from '../core/Button';
|
import type { ButtonProps } from '../core/Button';
|
||||||
@@ -112,6 +113,7 @@ export function SettingsAppearance() {
|
|||||||
size="sm"
|
size="sm"
|
||||||
value={settings.appearance}
|
value={settings.appearance}
|
||||||
onChange={(appearance) => {
|
onChange={(appearance) => {
|
||||||
|
trackEvent('appearance', 'update', { appearance });
|
||||||
updateSettings.mutateAsync({ appearance });
|
updateSettings.mutateAsync({ appearance });
|
||||||
}}
|
}}
|
||||||
options={[
|
options={[
|
||||||
@@ -130,7 +132,10 @@ export function SettingsAppearance() {
|
|||||||
size="sm"
|
size="sm"
|
||||||
value={activeTheme.light.id}
|
value={activeTheme.light.id}
|
||||||
options={lightThemes}
|
options={lightThemes}
|
||||||
onChange={(themeLight) => updateSettings.mutateAsync({ ...settings, themeLight })}
|
onChange={(themeLight) => {
|
||||||
|
trackEvent('theme', 'update', { theme: themeLight, appearance: 'light' });
|
||||||
|
updateSettings.mutateAsync({ ...settings, themeLight });
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{(settings.appearance === 'system' || settings.appearance === 'dark') && (
|
{(settings.appearance === 'system' || settings.appearance === 'dark') && (
|
||||||
@@ -142,7 +147,10 @@ export function SettingsAppearance() {
|
|||||||
size="sm"
|
size="sm"
|
||||||
value={activeTheme.dark.id}
|
value={activeTheme.dark.id}
|
||||||
options={darkThemes}
|
options={darkThemes}
|
||||||
onChange={(themeDark) => updateSettings.mutateAsync({ ...settings, themeDark })}
|
onChange={(themeDark) => {
|
||||||
|
trackEvent('theme', 'update', { theme: themeDark, appearance: 'dark' });
|
||||||
|
updateSettings.mutateAsync({ ...settings, themeDark });
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</HStack>
|
</HStack>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export function Select<T extends string>({
|
|||||||
className={classNames(
|
className={classNames(
|
||||||
'w-full rounded-md text-fg text-sm font-mono',
|
'w-full rounded-md text-fg text-sm font-mono',
|
||||||
'pl-2',
|
'pl-2',
|
||||||
'bg-background-highlight-secondary border',
|
'border',
|
||||||
focused ? 'border-border-focus' : 'border-background-highlight',
|
focused ? 'border-border-focus' : 'border-background-highlight',
|
||||||
size === 'xs' && 'h-xs',
|
size === 'xs' && 'h-xs',
|
||||||
size === 'sm' && 'h-sm',
|
size === 'sm' && 'h-sm',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
|
|
||||||
export type TrackResource =
|
export type TrackResource =
|
||||||
|
| 'appearance'
|
||||||
| 'app'
|
| 'app'
|
||||||
| 'cookie_jar'
|
| 'cookie_jar'
|
||||||
| 'dialog'
|
| 'dialog'
|
||||||
@@ -14,7 +15,7 @@ export type TrackResource =
|
|||||||
| 'key_value'
|
| 'key_value'
|
||||||
| 'setting'
|
| 'setting'
|
||||||
| 'sidebar'
|
| 'sidebar'
|
||||||
| 'toast'
|
| 'theme'
|
||||||
| 'workspace';
|
| 'workspace';
|
||||||
|
|
||||||
export type TrackAction =
|
export type TrackAction =
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { catppuccin } from './themes/catppuccin';
|
|||||||
import { github } from './themes/github';
|
import { github } from './themes/github';
|
||||||
import { hotdogStand } from './themes/hotdog-stand';
|
import { hotdogStand } from './themes/hotdog-stand';
|
||||||
import { monokaiPro } from './themes/monokai-pro';
|
import { monokaiPro } from './themes/monokai-pro';
|
||||||
|
import { moonlight } from './themes/moonlight';
|
||||||
import { rosePine } from './themes/rose-pine';
|
import { rosePine } from './themes/rose-pine';
|
||||||
import { yaak, yaakDark, yaakLight } from './themes/yaak';
|
import { yaak, yaakDark, yaakLight } from './themes/yaak';
|
||||||
|
|
||||||
@@ -12,7 +13,8 @@ export const yaakThemes = [
|
|||||||
...yaak,
|
...yaak,
|
||||||
...catppuccin,
|
...catppuccin,
|
||||||
...rosePine,
|
...rosePine,
|
||||||
...github,
|
|
||||||
...monokaiPro,
|
...monokaiPro,
|
||||||
|
...github,
|
||||||
|
...moonlight,
|
||||||
...hotdogStand,
|
...hotdogStand,
|
||||||
];
|
];
|
||||||
|
|||||||
72
src-web/lib/theme/themes/moonlight.ts
Normal file
72
src-web/lib/theme/themes/moonlight.ts
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import { Color } from '../color';
|
||||||
|
import type { YaakTheme } from '../window';
|
||||||
|
|
||||||
|
export const colors = {
|
||||||
|
lightRed: '#ff98a4',
|
||||||
|
red: '#ff757f',
|
||||||
|
darkRed: '#ff5370',
|
||||||
|
lightOrange: '#f8b576',
|
||||||
|
orange: '#ff966c',
|
||||||
|
darkOrange: '#fc7b7b',
|
||||||
|
yellow: '#ffc777',
|
||||||
|
green: '#c3e88d',
|
||||||
|
lightTeal: '#7af8ca',
|
||||||
|
teal: '#3ad7c7',
|
||||||
|
lightCyan: '#b4f9f8',
|
||||||
|
cyan: '#78dbff',
|
||||||
|
sky: '#60bdff',
|
||||||
|
blue: '#7cafff',
|
||||||
|
darkBlue: '#3d6fe0',
|
||||||
|
darkestBlue: '#3b63cf',
|
||||||
|
indigo: '#af9fff',
|
||||||
|
purple: '#c4a2ff',
|
||||||
|
pink: '#fca7ea',
|
||||||
|
darkPink: '#fd8aca',
|
||||||
|
saturatedGray: '#7a88cf',
|
||||||
|
desaturatedGray: '#979bb6',
|
||||||
|
gray11: '#d5def8',
|
||||||
|
gray10: '#c8d3f5',
|
||||||
|
gray9: '#b4c2f0',
|
||||||
|
gray8: '#a9b8e8',
|
||||||
|
gray7: '#828bb8',
|
||||||
|
gray6: '#444a73',
|
||||||
|
gray5: '#2f334d',
|
||||||
|
gray4: '#222436',
|
||||||
|
gray3: '#1e2030',
|
||||||
|
gray2: '#191a2a',
|
||||||
|
gray1: '#131421',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
const moonlightDefault: YaakTheme = {
|
||||||
|
id: 'moonlight',
|
||||||
|
name: 'Moonlight',
|
||||||
|
background: new Color(colors.gray4, 'dark'),
|
||||||
|
backgroundHighlight: new Color(colors.gray5, 'dark'),
|
||||||
|
backgroundHighlightSecondary: new Color(colors.gray5, 'dark'),
|
||||||
|
foreground: new Color(colors.gray11, 'dark'),
|
||||||
|
foregroundSubtle: new Color(colors.gray7, 'dark'),
|
||||||
|
foregroundSubtler: new Color(colors.gray6, 'dark'),
|
||||||
|
colors: {
|
||||||
|
primary: new Color(colors.purple, 'dark'),
|
||||||
|
secondary: new Color(colors.desaturatedGray, 'dark'),
|
||||||
|
info: new Color(colors.blue, 'dark'),
|
||||||
|
success: new Color(colors.teal, 'dark'),
|
||||||
|
notice: new Color(colors.yellow, 'dark'),
|
||||||
|
warning: new Color(colors.orange, 'dark'),
|
||||||
|
danger: new Color(colors.red, 'dark'),
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
appHeader: {
|
||||||
|
background: new Color(colors.gray3, 'dark'),
|
||||||
|
backgroundHighlight: new Color(colors.gray5, 'dark'),
|
||||||
|
backgroundHighlightSecondary: new Color(colors.gray4, 'dark'),
|
||||||
|
},
|
||||||
|
sidebar: {
|
||||||
|
background: new Color(colors.gray3, 'dark'),
|
||||||
|
backgroundHighlight: new Color(colors.gray5, 'dark'),
|
||||||
|
backgroundHighlightSecondary: new Color(colors.gray4, 'dark'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const moonlight = [moonlightDefault];
|
||||||
Reference in New Issue
Block a user