Theme plugins (#231)

This commit is contained in:
Gregory Schier
2025-07-03 13:06:30 -07:00
committed by GitHub
parent a6979cf37e
commit 19c6ad9d97
64 changed files with 1754 additions and 1623 deletions

View File

@@ -143,6 +143,9 @@ pub enum InternalEventPayload {
FindHttpResponsesRequest(FindHttpResponsesRequest),
FindHttpResponsesResponse(FindHttpResponsesResponse),
GetThemesRequest(GetThemesRequest),
GetThemesResponse(GetThemesResponse),
/// Returned when a plugin doesn't get run, just so the server
/// has something to listen for
EmptyResponse(EmptyPayload),
@@ -284,6 +287,113 @@ pub struct RenderHttpRequestResponse {
pub http_request: HttpRequest,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
#[serde(default, rename_all = "camelCase")]
#[ts(export, export_to = "gen_events.ts")]
pub struct GetThemesRequest {}
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
#[serde(default, rename_all = "camelCase")]
#[ts(export, export_to = "gen_events.ts")]
pub struct ThemeComponents {
#[ts(optional)]
pub dialog: Option<ThemeComponentColors>,
#[ts(optional)]
pub menu: Option<ThemeComponentColors>,
#[ts(optional)]
pub toast: Option<ThemeComponentColors>,
#[ts(optional)]
pub sidebar: Option<ThemeComponentColors>,
#[ts(optional)]
pub response_pane: Option<ThemeComponentColors>,
#[ts(optional)]
pub app_header: Option<ThemeComponentColors>,
#[ts(optional)]
pub button: Option<ThemeComponentColors>,
#[ts(optional)]
pub banner: Option<ThemeComponentColors>,
#[ts(optional)]
pub template_tag: Option<ThemeComponentColors>,
#[ts(optional)]
pub url_bar: Option<ThemeComponentColors>,
#[ts(optional)]
pub editor: Option<ThemeComponentColors>,
#[ts(optional)]
pub input: Option<ThemeComponentColors>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
#[serde(default, rename_all = "camelCase")]
#[ts(export, export_to = "gen_events.ts")]
pub struct ThemeComponentColors {
#[ts(optional)]
pub surface: Option<String>,
#[ts(optional)]
pub surface_highlight: Option<String>,
#[ts(optional)]
pub surface_active: Option<String>,
#[ts(optional)]
pub text: Option<String>,
#[ts(optional)]
pub text_subtle: Option<String>,
#[ts(optional)]
pub text_subtlest: Option<String>,
#[ts(optional)]
pub border: Option<String>,
#[ts(optional)]
pub border_subtle: Option<String>,
#[ts(optional)]
pub border_focus: Option<String>,
#[ts(optional)]
pub shadow: Option<String>,
#[ts(optional)]
pub backdrop: Option<String>,
#[ts(optional)]
pub selection: Option<String>,
#[ts(optional)]
pub primary: Option<String>,
#[ts(optional)]
pub secondary: Option<String>,
#[ts(optional)]
pub info: Option<String>,
#[ts(optional)]
pub success: Option<String>,
#[ts(optional)]
pub notice: Option<String>,
#[ts(optional)]
pub warning: Option<String>,
#[ts(optional)]
pub danger: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
#[serde(default, rename_all = "camelCase")]
#[ts(export, export_to = "gen_events.ts")]
pub struct Theme {
/// How the theme is identified. This should never be changed
pub id: String,
/// The friendly name of the theme to be displayed to the user
pub label: String,
/// Whether the theme will be used for dark or light appearance
pub dark: bool,
/// The default top-level colors for the theme
pub base: ThemeComponentColors,
/// Optionally override theme for individual UI components for more control
#[ts(optional)]
pub components: Option<ThemeComponents>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
#[serde(default, rename_all = "camelCase")]
#[ts(export, export_to = "gen_events.ts")]
pub struct GetThemesResponse {
pub themes: Vec<Theme>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
#[serde(default, rename_all = "camelCase")]
#[ts(export, export_to = "gen_events.ts")]