From e92015b12fde6a0ab7c9d0a4dc5723d3312321d0 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 14 Jun 2023 14:02:32 +0200 Subject: [PATCH 01/26] Split out Interactive into Toggle and Interactive --- crates/ai/src/assistant.rs | 8 +- crates/auto_update/src/update_notification.rs | 4 +- crates/breadcrumbs/src/breadcrumbs.rs | 2 +- crates/collab_ui/src/collab_titlebar_item.rs | 29 +++-- crates/collab_ui/src/contact_finder.rs | 3 +- crates/collab_ui/src/contact_list.rs | 41 ++++--- crates/collab_ui/src/notifications.rs | 4 +- crates/command_palette/src/command_palette.rs | 8 +- crates/context_menu/src/context_menu.rs | 32 ++++-- crates/copilot/src/sign_in.rs | 6 +- crates/copilot_button/src/copilot_button.rs | 5 +- crates/diagnostics/src/items.rs | 4 +- crates/editor/src/editor.rs | 18 +-- crates/editor/src/element.rs | 2 +- crates/feedback/src/deploy_feedback_button.rs | 3 +- crates/feedback/src/submit_feedback_button.rs | 2 +- crates/file_finder/src/file_finder.rs | 2 +- .../src/active_buffer_language.rs | 2 +- .../src/language_selector.rs | 2 +- crates/language_tools/src/lsp_log.rs | 8 +- crates/language_tools/src/syntax_tree_view.rs | 5 +- crates/outline/src/outline.rs | 2 +- crates/project_panel/src/project_panel.rs | 11 +- crates/project_symbols/src/project_symbols.rs | 4 +- crates/recent_projects/src/recent_projects.rs | 2 +- crates/search/src/buffer_search.rs | 10 +- crates/search/src/project_search.rs | 8 +- crates/theme/src/theme.rs | 105 ++++++++++-------- crates/theme/src/ui.rs | 6 +- crates/theme_selector/src/theme_selector.rs | 2 +- crates/welcome/src/base_keymap_picker.rs | 2 +- crates/workspace/src/dock.rs | 11 +- crates/workspace/src/notifications.rs | 4 +- crates/workspace/src/pane.rs | 4 +- crates/workspace/src/toolbar.rs | 6 +- 35 files changed, 223 insertions(+), 144 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index ce816f147bac15db7a12ac2dbc7666303ff098b5..5b254fac4bedc049a012869b3b78b410be7656e8 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -1233,19 +1233,19 @@ impl AssistantEditor { cx, |state, _| match message.role { Role::User => { - let style = style.user_sender.style_for(state, false); + let style = style.user_sender.style_for(state); Label::new("You", style.text.clone()) .contained() .with_style(style.container) } Role::Assistant => { - let style = style.assistant_sender.style_for(state, false); + let style = style.assistant_sender.style_for(state); Label::new("Assistant", style.text.clone()) .contained() .with_style(style.container) } Role::System => { - let style = style.system_sender.style_for(state, false); + let style = style.system_sender.style_for(state); Label::new("System", style.text.clone()) .contained() .with_style(style.container) @@ -1484,7 +1484,7 @@ impl View for AssistantEditor { Flex::row() .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.model.style_for(state, false); + let style = theme.model.style_for(state); Label::new(model, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/auto_update/src/update_notification.rs b/crates/auto_update/src/update_notification.rs index 6f31df614dbbd0f0761c93487d988ae9168f3d9d..cd2e53905d1ec58347b47e528178206f608e784a 100644 --- a/crates/auto_update/src/update_notification.rs +++ b/crates/auto_update/src/update_notification.rs @@ -49,7 +49,7 @@ impl View for UpdateNotification { ) .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.dismiss_button.style_for(state, false); + let style = theme.dismiss_button.style_for(state); Svg::new("icons/x_mark_8.svg") .with_color(style.color) .constrained() @@ -74,7 +74,7 @@ impl View for UpdateNotification { ), ) .with_child({ - let style = theme.action_message.style_for(state, false); + let style = theme.action_message.style_for(state); Text::new("View the release notes", style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/breadcrumbs/src/breadcrumbs.rs b/crates/breadcrumbs/src/breadcrumbs.rs index 906d70abb738e7267d35a59f501be96809fbf5b1..433dbed29b53d670f92e6cff0e222966c5bc85dd 100644 --- a/crates/breadcrumbs/src/breadcrumbs.rs +++ b/crates/breadcrumbs/src/breadcrumbs.rs @@ -83,7 +83,7 @@ impl View for Breadcrumbs { } MouseEventHandler::::new(0, cx, |state, _| { - let style = style.style_for(state, false); + let style = style.style_for(state); crumbs.with_style(style.container) }) .on_click(MouseButton::Left, |_, this, cx| { diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 720a73f477e1c5ceb4e8888de95afefe937f1589..aa643f4416dbdd066cc1fd24a0851ac4409e4b38 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -299,7 +299,7 @@ impl CollabTitlebarItem { pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext) { let theme = theme::current(cx).clone(); let avatar_style = theme.workspace.titlebar.leader_avatar.clone(); - let item_style = theme.context_menu.item.disabled_style().clone(); + let item_style = theme.context_menu.item.off_state().disabled_style().clone(); self.user_menu.update(cx, |user_menu, cx| { let items = if let Some(user) = self.user_store.read(cx).current_user() { vec![ @@ -361,8 +361,20 @@ impl CollabTitlebarItem { .contained() .with_style(titlebar.toggle_contacts_badge) .contained() - .with_margin_left(titlebar.toggle_contacts_button.default.icon_width) - .with_margin_top(titlebar.toggle_contacts_button.default.icon_width) + .with_margin_left( + titlebar + .toggle_contacts_button + .off_state() + .default + .icon_width, + ) + .with_margin_top( + titlebar + .toggle_contacts_button + .off_state() + .default + .icon_width, + ) .aligned(), ) }; @@ -372,7 +384,8 @@ impl CollabTitlebarItem { MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar .toggle_contacts_button - .style_for(state, self.contacts_popover.is_some()); + .in_state(self.contacts_popover.is_some()) + .style_for(state); Svg::new("icons/user_plus_16.svg") .with_color(style.color) .constrained() @@ -419,7 +432,7 @@ impl CollabTitlebarItem { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.call_control.style_for(state, false); + let style = titlebar.call_control.style_for(state); Svg::new(icon) .with_color(style.color) .constrained() @@ -473,7 +486,7 @@ impl CollabTitlebarItem { .with_child( MouseEventHandler::::new(0, cx, |state, _| { //TODO: Ensure this button has consistent width for both text variations - let style = titlebar.share_button.style_for(state, false); + let style = titlebar.share_button.style_for(state); Label::new(label, style.text.clone()) .contained() .with_style(style.container) @@ -511,7 +524,7 @@ impl CollabTitlebarItem { Stack::new() .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.call_control.style_for(state, false); + let style = titlebar.call_control.style_for(state); Svg::new("icons/ellipsis_14.svg") .with_color(style.color) .constrained() @@ -549,7 +562,7 @@ impl CollabTitlebarItem { fn render_sign_in_button(&self, theme: &Theme, cx: &mut ViewContext) -> AnyElement { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.sign_in_prompt.style_for(state, false); + let style = titlebar.sign_in_prompt.style_for(state); Label::new("Sign In", style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/collab_ui/src/contact_finder.rs b/crates/collab_ui/src/contact_finder.rs index b5f2416a5bc51e1d4bbe763082f77ff80b75922d..af59817ece40ab0fc3c15adb35c78b4d8aa84898 100644 --- a/crates/collab_ui/src/contact_finder.rs +++ b/crates/collab_ui/src/contact_finder.rs @@ -117,7 +117,8 @@ impl PickerDelegate for ContactFinderDelegate { .contact_finder .picker .item - .style_for(mouse_state, selected); + .in_state(selected) + .style_for(mouse_state); Flex::row() .with_children(user.avatar.clone().map(|avatar| { Image::from_data(avatar) diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs index e8dae210c4c5ed196207fefb285c21c5a25bd1e1..c0839249f2574d8f77a34689c5ffbc3c2463a0b4 100644 --- a/crates/collab_ui/src/contact_list.rs +++ b/crates/collab_ui/src/contact_list.rs @@ -774,7 +774,8 @@ impl ContactList { .with_style( *theme .contact_row - .style_for(&mut Default::default(), is_selected), + .in_state(is_selected) + .style_for(&mut Default::default()), ) .into_any() } @@ -797,7 +798,7 @@ impl ContactList { .width .or(theme.contact_avatar.height) .unwrap_or(0.); - let row = &theme.project_row.default; + let row = &theme.project_row.off_state().default; let tree_branch = theme.tree_branch; let line_height = row.name.text.line_height(font_cache); let cap_height = row.name.text.cap_height(font_cache); @@ -810,8 +811,11 @@ impl ContactList { }; MouseEventHandler::::new(project_id as usize, cx, |mouse_state, _| { - let tree_branch = *tree_branch.style_for(mouse_state, is_selected); - let row = theme.project_row.style_for(mouse_state, is_selected); + let tree_branch = *tree_branch.in_state(is_selected).style_for(mouse_state); + let row = theme + .project_row + .in_state(is_selected) + .style_for(mouse_state); Flex::row() .with_child( @@ -893,7 +897,7 @@ impl ContactList { .width .or(theme.contact_avatar.height) .unwrap_or(0.); - let row = &theme.project_row.default; + let row = &theme.project_row.off_state().default; let tree_branch = theme.tree_branch; let line_height = row.name.text.line_height(font_cache); let cap_height = row.name.text.cap_height(font_cache); @@ -904,8 +908,11 @@ impl ContactList { peer_id.as_u64() as usize, cx, |mouse_state, _| { - let tree_branch = *tree_branch.style_for(mouse_state, is_selected); - let row = theme.project_row.style_for(mouse_state, is_selected); + let tree_branch = *tree_branch.in_state(is_selected).style_for(mouse_state); + let row = theme + .project_row + .in_state(is_selected) + .style_for(mouse_state); Flex::row() .with_child( @@ -989,7 +996,8 @@ impl ContactList { let header_style = theme .header_row - .style_for(&mut Default::default(), is_selected); + .in_state(is_selected) + .style_for(&mut Default::default()); let text = match section { Section::ActiveCall => "Collaborators", Section::Requests => "Contact Requests", @@ -999,7 +1007,7 @@ impl ContactList { let leave_call = if section == Section::ActiveCall { Some( MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.leave_call.style_for(state, false); + let style = theme.leave_call.style_for(state); Label::new("Leave Call", style.text.clone()) .contained() .with_style(style.container) @@ -1110,8 +1118,7 @@ impl ContactList { contact.user.id as usize, cx, |mouse_state, _| { - let button_style = - theme.contact_button.style_for(mouse_state, false); + let button_style = theme.contact_button.style_for(mouse_state); render_icon_button(button_style, "icons/x_mark_8.svg") .aligned() .flex_float() @@ -1146,7 +1153,8 @@ impl ContactList { .with_style( *theme .contact_row - .style_for(&mut Default::default(), is_selected), + .in_state(is_selected) + .style_for(&mut Default::default()), ) }) .on_click(MouseButton::Left, move |_, this, cx| { @@ -1204,7 +1212,7 @@ impl ContactList { let button_style = if is_contact_request_pending { &theme.disabled_button } else { - theme.contact_button.style_for(mouse_state, false) + theme.contact_button.style_for(mouse_state) }; render_icon_button(button_style, "icons/x_mark_8.svg").aligned() }) @@ -1227,7 +1235,7 @@ impl ContactList { let button_style = if is_contact_request_pending { &theme.disabled_button } else { - theme.contact_button.style_for(mouse_state, false) + theme.contact_button.style_for(mouse_state) }; render_icon_button(button_style, "icons/check_8.svg") .aligned() @@ -1250,7 +1258,7 @@ impl ContactList { let button_style = if is_contact_request_pending { &theme.disabled_button } else { - theme.contact_button.style_for(mouse_state, false) + theme.contact_button.style_for(mouse_state) }; render_icon_button(button_style, "icons/x_mark_8.svg") .aligned() @@ -1277,7 +1285,8 @@ impl ContactList { .with_style( *theme .contact_row - .style_for(&mut Default::default(), is_selected), + .in_state(is_selected) + .style_for(&mut Default::default()), ) .into_any() } diff --git a/crates/collab_ui/src/notifications.rs b/crates/collab_ui/src/notifications.rs index abeb65b1dcc2d876e45dfa1d69fc3fb86b9d406d..cbd072fe8906dcfb49e8d7220b9b2d9657d4e894 100644 --- a/crates/collab_ui/src/notifications.rs +++ b/crates/collab_ui/src/notifications.rs @@ -53,7 +53,7 @@ where ) .with_child( MouseEventHandler::::new(user.id as usize, cx, |state, _| { - let style = theme.dismiss_button.style_for(state, false); + let style = theme.dismiss_button.style_for(state); Svg::new("icons/x_mark_8.svg") .with_color(style.color) .constrained() @@ -93,7 +93,7 @@ where .with_children(buttons.into_iter().enumerate().map( |(ix, (message, handler))| { MouseEventHandler::::new(ix, cx, |state, _| { - let button = theme.button.style_for(state, false); + let button = theme.button.style_for(state); Label::new(message, button.text.clone()) .contained() .with_style(button.container) diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index 2ee93a0734dd9b88aae34f07ebda21a8572af513..e7e7462fd9c27c07b5490609c3c7cb77636c021f 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -185,8 +185,12 @@ impl PickerDelegate for CommandPaletteDelegate { let mat = &self.matches[ix]; let command = &self.actions[mat.candidate_id]; let theme = theme::current(cx); - let style = theme.picker.item.style_for(mouse_state, selected); - let key_style = &theme.command_palette.key.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); + let key_style = &theme + .command_palette + .key + .in_state(selected) + .style_for(mouse_state); let keystroke_spacing = theme.command_palette.keystroke_spacing; Flex::row() diff --git a/crates/context_menu/src/context_menu.rs b/crates/context_menu/src/context_menu.rs index fb455fe1d0a76cfe2c0fdcc3fff0ec295fb89df8..e9ab24f06e09b2e8bfd3cf92cac8218c1c4d5f70 100644 --- a/crates/context_menu/src/context_menu.rs +++ b/crates/context_menu/src/context_menu.rs @@ -9,6 +9,7 @@ use gpui::{ }; use menu::*; use std::{any::TypeId, borrow::Cow, sync::Arc, time::Duration}; +use theme::ToggleState; pub fn init(cx: &mut AppContext) { cx.add_action(ContextMenu::select_first); @@ -328,10 +329,13 @@ impl ContextMenu { Flex::column().with_children(self.items.iter().enumerate().map(|(ix, item)| { match item { ContextMenuItem::Item { label, .. } => { - let style = style.item.style_for( - &mut Default::default(), - Some(ix) == self.selected_index, - ); + let toggle_state = if Some(ix) == self.selected_index { + ToggleState::On + } else { + ToggleState::Off + }; + let style = style.item.in_state(toggle_state); + let style = style.style_for(&mut Default::default()); match label { ContextMenuItemLabel::String(label) => { @@ -363,10 +367,13 @@ impl ContextMenu { .with_children(self.items.iter().enumerate().map(|(ix, item)| { match item { ContextMenuItem::Item { action, .. } => { - let style = style.item.style_for( - &mut Default::default(), - Some(ix) == self.selected_index, - ); + let toggle_state = if Some(ix) == self.selected_index { + ToggleState::On + } else { + ToggleState::Off + }; + let style = style.item.in_state(toggle_state); + let style = style.style_for(&mut Default::default()); match action { ContextMenuItemAction::Action(action) => KeystrokeLabel::new( @@ -412,8 +419,13 @@ impl ContextMenu { let action = action.clone(); let view_id = self.parent_view_id; MouseEventHandler::::new(ix, cx, |state, _| { - let style = - style.item.style_for(state, Some(ix) == self.selected_index); + let toggle_state = if Some(ix) == self.selected_index { + ToggleState::On + } else { + ToggleState::Off + }; + let style = style.item.in_state(toggle_state); + let style = style.style_for(state); let keystroke = match &action { ContextMenuItemAction::Action(action) => Some( KeystrokeLabel::new( diff --git a/crates/copilot/src/sign_in.rs b/crates/copilot/src/sign_in.rs index 0993a33e6c886323586c21620520440ca4bcd68c..803cb5cc85636d45946446b4e059a5e7d9aeae30 100644 --- a/crates/copilot/src/sign_in.rs +++ b/crates/copilot/src/sign_in.rs @@ -127,16 +127,16 @@ impl CopilotCodeVerification { .with_child( Label::new( if copied { "Copied!" } else { "Copy" }, - device_code_style.cta.style_for(state, false).text.clone(), + device_code_style.cta.style_for(state).text.clone(), ) .aligned() .contained() - .with_style(*device_code_style.right_container.style_for(state, false)) + .with_style(*device_code_style.right_container.style_for(state)) .constrained() .with_width(device_code_style.right), ) .contained() - .with_style(device_code_style.cta.style_for(state, false).container) + .with_style(device_code_style.cta.style_for(state).container) }) .on_click(gpui::platform::MouseButton::Left, { let user_code = data.user_code.clone(); diff --git a/crates/copilot_button/src/copilot_button.rs b/crates/copilot_button/src/copilot_button.rs index 2454074d459b4938cbeebadb5cf7cf73589b5d99..9b0581492f470a7d97988dc2c90b48ac63ddbc6d 100644 --- a/crates/copilot_button/src/copilot_button.rs +++ b/crates/copilot_button/src/copilot_button.rs @@ -71,7 +71,8 @@ impl View for CopilotButton { .status_bar .panel_buttons .button - .style_for(state, active); + .in_state(active) + .style_for(state); Flex::row() .with_child( @@ -255,7 +256,7 @@ impl CopilotButton { move |state: &mut MouseState, style: &theme::ContextMenuItem| { Flex::row() .with_child(Label::new("Copilot Settings", style.label.clone())) - .with_child(theme::ui::icon(icon_style.style_for(state, false))) + .with_child(theme::ui::icon(icon_style.style_for(state))) .align_children_center() .into_any() }, diff --git a/crates/diagnostics/src/items.rs b/crates/diagnostics/src/items.rs index f84846eae1e28d4a1dcd89172000983a6219f268..c106f042b5cf9328724eb72415cf8bea3fcceeff 100644 --- a/crates/diagnostics/src/items.rs +++ b/crates/diagnostics/src/items.rs @@ -100,7 +100,7 @@ impl View for DiagnosticIndicator { .workspace .status_bar .diagnostic_summary - .style_for(state, false); + .style_for(state); let mut summary_row = Flex::row(); if self.summary.error_count > 0 { @@ -198,7 +198,7 @@ impl View for DiagnosticIndicator { MouseEventHandler::::new(1, cx, |state, _| { Label::new( diagnostic.message.split('\n').next().unwrap().to_string(), - message_style.style_for(state, false).text.clone(), + message_style.style_for(state).text.clone(), ) .aligned() .contained() diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 2e0d444e0473b4b4cfe2b79f712797c2e8e799f5..e438d0dc2e7246baa764405d4fd7d7cb08f57684 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3320,15 +3320,21 @@ impl Editor { pub fn render_code_actions_indicator( &self, style: &EditorStyle, - active: bool, + is_active: bool, cx: &mut ViewContext, ) -> Option> { if self.available_code_actions.is_some() { enum CodeActions {} Some( MouseEventHandler::::new(0, cx, |state, _| { - Svg::new("icons/bolt_8.svg") - .with_color(style.code_actions.indicator.style_for(state, active).color) + Svg::new("icons/bolt_8.svg").with_color( + style + .code_actions + .indicator + .in_state(is_active) + .style_for(state) + .color, + ) }) .with_cursor_style(CursorStyle::PointingHand) .with_padding(Padding::uniform(3.)) @@ -3378,10 +3384,8 @@ impl Editor { .with_color( style .indicator - .style_for( - mouse_state, - fold_status == FoldStatus::Folded, - ) + .in_state(fold_status == FoldStatus::Folded) + .style_for(mouse_state) .color, ) .constrained() diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index d6f9a2e90682f72d33d06ee1b37d813e35764094..835d53bc8c27e2357fd3b228891b817370d4a44d 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2090,7 +2090,7 @@ impl Element for EditorElement { .folds .ellipses .background - .style_for(&mut cx.mouse_state::(id as usize), false) + .style_for(&mut cx.mouse_state::(id as usize)) .color; (id, fold, color) diff --git a/crates/feedback/src/deploy_feedback_button.rs b/crates/feedback/src/deploy_feedback_button.rs index d32a3e5b4c863be333ca3077d0988bdbd34dce9c..beb5284031fc82e157b06240b7dadc04be08be93 100644 --- a/crates/feedback/src/deploy_feedback_button.rs +++ b/crates/feedback/src/deploy_feedback_button.rs @@ -41,7 +41,8 @@ impl View for DeployFeedbackButton { .status_bar .panel_buttons .button - .style_for(state, active); + .in_state(active) + .style_for(state); Svg::new("icons/feedback_16.svg") .with_color(style.icon_color) diff --git a/crates/feedback/src/submit_feedback_button.rs b/crates/feedback/src/submit_feedback_button.rs index 56bc235570742d90850886b2460322035fa3c2fa..15f77bd561eb900bbdeb213f4fb37adc3be22697 100644 --- a/crates/feedback/src/submit_feedback_button.rs +++ b/crates/feedback/src/submit_feedback_button.rs @@ -48,7 +48,7 @@ impl View for SubmitFeedbackButton { let theme = theme::current(cx).clone(); enum SubmitFeedbackButton {} MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.feedback.submit_button.style_for(state, false); + let style = theme.feedback.submit_button.style_for(state); Label::new("Submit as Markdown", style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 73e7ca6eaa1cf56f98115a6607632f10da422fd4..3f6bd83760f855c1b5dd0d3225eec6b9b8ecfa98 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -546,7 +546,7 @@ impl PickerDelegate for FileFinderDelegate { .get(ix) .expect("Invalid matches state: no element for index {ix}"); let theme = theme::current(cx); - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); let (file_name, file_name_positions, full_path, full_path_positions) = self.labels_for_match(path_match, cx, ix); Flex::column() diff --git a/crates/language_selector/src/active_buffer_language.rs b/crates/language_selector/src/active_buffer_language.rs index 2c78b89f31c61fd7193aaf15eb1b90c15b39fdd4..b97417580fb645b8051d1f3cb030bf914c0ca067 100644 --- a/crates/language_selector/src/active_buffer_language.rs +++ b/crates/language_selector/src/active_buffer_language.rs @@ -55,7 +55,7 @@ impl View for ActiveBufferLanguage { MouseEventHandler::::new(0, cx, |state, cx| { let theme = &theme::current(cx).workspace.status_bar; - let style = theme.active_language.style_for(state, false); + let style = theme.active_language.style_for(state); Label::new(active_language_text, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/language_selector/src/language_selector.rs b/crates/language_selector/src/language_selector.rs index 817901cd3a6a3f480a19ba5fb34d11e6c20074ae..6362b8247d39b3d6dd86f339d5f72b56c94da984 100644 --- a/crates/language_selector/src/language_selector.rs +++ b/crates/language_selector/src/language_selector.rs @@ -180,7 +180,7 @@ impl PickerDelegate for LanguageSelectorDelegate { ) -> AnyElement> { let theme = theme::current(cx); let mat = &self.matches[ix]; - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); let buffer_language_name = self.buffer.read(cx).language().map(|l| l.name()); let mut label = mat.string.clone(); if buffer_language_name.as_deref() == Some(mat.string.as_str()) { diff --git a/crates/language_tools/src/lsp_log.rs b/crates/language_tools/src/lsp_log.rs index 04f47885c0e084a9eb86cb529896624f34c8d536..12d8c6b34d3abd93e25e1b18e03656de477d417a 100644 --- a/crates/language_tools/src/lsp_log.rs +++ b/crates/language_tools/src/lsp_log.rs @@ -681,7 +681,7 @@ impl LspLogToolbarItemView { ) }) .unwrap_or_else(|| "No server selected".into()); - let style = theme.toolbar_dropdown_menu.header.style_for(state, false); + let style = theme.toolbar_dropdown_menu.header.style_for(state); Label::new(label, style.text.clone()) .contained() .with_style(style.container) @@ -722,7 +722,8 @@ impl LspLogToolbarItemView { let style = theme .toolbar_dropdown_menu .item - .style_for(state, logs_selected); + .in_state(logs_selected) + .style_for(state); Label::new(SERVER_LOGS, style.text.clone()) .contained() .with_style(style.container) @@ -739,7 +740,8 @@ impl LspLogToolbarItemView { let style = theme .toolbar_dropdown_menu .item - .style_for(state, rpc_trace_selected); + .in_state(rpc_trace_selected) + .style_for(state); Flex::row() .with_child( Label::new(RPC_MESSAGES, style.text.clone()) diff --git a/crates/language_tools/src/syntax_tree_view.rs b/crates/language_tools/src/syntax_tree_view.rs index 075df766532a634d06e9c558f86009516ae9d435..3e6727bbf4794eba1dc81d363c2b56a23c5e6a95 100644 --- a/crates/language_tools/src/syntax_tree_view.rs +++ b/crates/language_tools/src/syntax_tree_view.rs @@ -565,7 +565,7 @@ impl SyntaxTreeToolbarItemView { ) -> impl Element { enum ToggleMenu {} MouseEventHandler::::new(0, cx, move |state, _| { - let style = theme.toolbar_dropdown_menu.header.style_for(state, false); + let style = theme.toolbar_dropdown_menu.header.style_for(state); Flex::row() .with_child( Label::new(active_layer.language.name().to_string(), style.text.clone()) @@ -601,7 +601,8 @@ impl SyntaxTreeToolbarItemView { let style = theme .toolbar_dropdown_menu .item - .style_for(state, is_selected); + .in_state(is_selected) + .style_for(state); Flex::row() .with_child( Label::new(layer.language.name().to_string(), style.text.clone()) diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rs index 1e364f5fc8f6d9198fba71b6d11429e11e13d3e0..f93fa100524b8371238dbe880f9519205c9c82cf 100644 --- a/crates/outline/src/outline.rs +++ b/crates/outline/src/outline.rs @@ -204,7 +204,7 @@ impl PickerDelegate for OutlineViewDelegate { cx: &AppContext, ) -> AnyElement> { let theme = theme::current(cx); - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); let string_match = &self.matches[ix]; let outline_item = &self.outline.items[string_match.candidate_id]; diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 9563d54be8b05233ed3df121efb2de9a37b0d5b7..a4ac8a5743dd08c39cc5b38fc1d2b91d3b6a9e87 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1253,7 +1253,10 @@ impl ProjectPanel { let show_editor = details.is_editing && !details.is_processing; MouseEventHandler::::new(entry_id.to_usize(), cx, |state, cx| { - let mut style = entry_style.style_for(state, details.is_selected).clone(); + let mut style = entry_style + .in_state(details.is_selected) + .style_for(state) + .clone(); if cx .global::>() @@ -1264,7 +1267,7 @@ impl ProjectPanel { .filter(|destination| details.path.starts_with(destination)) .is_some() { - style = entry_style.active.clone().unwrap(); + style = entry_style.on_state().default.clone(); } let row_container_style = if show_editor { @@ -1405,9 +1408,9 @@ impl View for ProjectPanel { let button_style = theme.open_project_button.clone(); let context_menu_item_style = theme::current(cx).context_menu.item.clone(); move |state, cx| { - let button_style = button_style.style_for(state, false).clone(); + let button_style = button_style.style_for(state).clone(); let context_menu_item = - context_menu_item_style.style_for(state, true).clone(); + context_menu_item_style.on_state().style_for(state).clone(); theme::ui::keystroke_label( "Open a project", diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index 0dc5dad3bf8d43edf3cb4c18507a7389ca65c2e1..dbfad48e87cc33415933dd4dca82400e346796a0 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -196,7 +196,7 @@ impl PickerDelegate for ProjectSymbolsDelegate { ) -> AnyElement> { let theme = theme::current(cx); let style = &theme.picker.item; - let current_style = style.style_for(mouse_state, selected); + let current_style = style.in_state(selected).style_for(mouse_state); let string_match = &self.matches[ix]; let symbol = &self.symbols[string_match.candidate_id]; @@ -229,7 +229,7 @@ impl PickerDelegate for ProjectSymbolsDelegate { .with_child( // Avoid styling the path differently when it is selected, since // the symbol's syntax highlighting doesn't change when selected. - Label::new(path.to_string(), style.default.label.clone()), + Label::new(path.to_string(), style.off_state().default.label.clone()), ) .contained() .with_style(current_style.container) diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index a1dc8982c79fcedd36447f5bf116f068701b238f..b13f72da0b247a4947b8bae505a2fe3b9e09cb67 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -173,7 +173,7 @@ impl PickerDelegate for RecentProjectsDelegate { cx: &gpui::AppContext, ) -> AnyElement> { let theme = theme::current(cx); - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); let string_match = &self.matches[ix]; diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 87a8b265fb2f774135e5db267a269c3890eaae21..1a059f5df78eb684ece9f0ba9f417a1d4ac41dae 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -328,7 +328,11 @@ impl BufferSearchBar { Some( MouseEventHandler::::new(option as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.style_for(state, is_active); + let style = theme + .search + .option_button + .in_state(is_active) + .style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) @@ -371,7 +375,7 @@ impl BufferSearchBar { enum NavButton {} MouseEventHandler::::new(direction as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.style_for(state, false); + let style = theme.search.option_button.off_state().style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) @@ -403,7 +407,7 @@ impl BufferSearchBar { enum CloseButton {} MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.dismiss_button.style_for(state, false); + let style = theme.dismiss_button.style_for(state); Svg::new("icons/x_mark_8.svg") .with_color(style.color) .constrained() diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 27aac1762bec9f37389e0cba1a47d4e5a11016e0..a379fa80e132b5ebd0cf73d5cab2e7b934ce7171 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -896,7 +896,7 @@ impl ProjectSearchBar { enum NavButton {} MouseEventHandler::::new(direction as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.style_for(state, false); + let style = theme.search.option_button.off_state().style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) @@ -927,7 +927,11 @@ impl ProjectSearchBar { let is_active = self.is_option_enabled(option, cx); MouseEventHandler::::new(option as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.style_for(state, is_active); + let style = theme + .search + .option_button + .in_state(is_active) + .style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index c7563ec87a3dfd20f3f2682a2a6e9848cecf5279..812659078f1220cd75a92948b85925ead23ac2b4 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -132,7 +132,7 @@ pub struct Titlebar { pub outdated_warning: ContainedText, pub share_button: Interactive, pub call_control: Interactive, - pub toggle_contacts_button: Interactive, + pub toggle_contacts_button: Toggleable>, pub user_menu_button: Interactive, pub toggle_contacts_badge: ContainerStyle, } @@ -204,12 +204,12 @@ pub struct ContactList { pub user_query_editor: FieldEditor, pub user_query_editor_height: f32, pub add_contact_button: IconButton, - pub header_row: Interactive, + pub header_row: Toggleable>, pub leave_call: Interactive, - pub contact_row: Interactive, + pub contact_row: Toggleable>, pub row_height: f32, - pub project_row: Interactive, - pub tree_branch: Interactive, + pub project_row: Toggleable>, + pub tree_branch: Toggleable>, pub contact_avatar: ImageStyle, pub contact_status_free: ContainerStyle, pub contact_status_busy: ContainerStyle, @@ -251,7 +251,7 @@ pub struct DropdownMenu { pub container: ContainerStyle, pub header: Interactive, pub section_header: ContainedText, - pub item: Interactive, + pub item: Toggleable>, pub row_height: f32, } @@ -270,7 +270,7 @@ pub struct DropdownMenuItem { pub struct TabBar { #[serde(flatten)] pub container: ContainerStyle, - pub pane_button: Interactive, + pub pane_button: Toggleable>, pub pane_button_container: ContainerStyle, pub active_pane: TabStyles, pub inactive_pane: TabStyles, @@ -339,7 +339,7 @@ pub struct Toolbar { pub container: ContainerStyle, pub height: f32, pub item_spacing: f32, - pub nav_button: Interactive, + pub nav_button: Toggleable>, } #[derive(Clone, Deserialize, Default)] @@ -359,7 +359,7 @@ pub struct Search { pub include_exclude_editor: FindEditor, pub invalid_include_exclude_editor: ContainerStyle, pub include_exclude_inputs: ContainedText, - pub option_button: Interactive, + pub option_button: Toggleable>, pub match_background: Color, pub match_index: ContainedText, pub results_status: TextStyle, @@ -395,7 +395,7 @@ pub struct StatusBarPanelButtons { pub group_left: ContainerStyle, pub group_bottom: ContainerStyle, pub group_right: ContainerStyle, - pub button: Interactive, + pub button: Toggleable>, } #[derive(Deserialize, Default)] @@ -444,10 +444,10 @@ pub struct PanelButton { pub struct ProjectPanel { #[serde(flatten)] pub container: ContainerStyle, - pub entry: Interactive, + pub entry: Toggleable>, pub dragged_entry: ProjectPanelEntry, - pub ignored_entry: Interactive, - pub cut_entry: Interactive, + pub ignored_entry: Toggleable>, + pub cut_entry: Toggleable>, pub filename_editor: FieldEditor, pub indent_width: f32, pub open_project_button: Interactive, @@ -481,7 +481,7 @@ pub struct GitProjectStatus { pub struct ContextMenu { #[serde(flatten)] pub container: ContainerStyle, - pub item: Interactive, + pub item: Toggleable>, pub keystroke_margin: f32, pub separator: ContainerStyle, } @@ -498,7 +498,7 @@ pub struct ContextMenuItem { #[derive(Debug, Deserialize, Default)] pub struct CommandPalette { - pub key: Interactive, + pub key: Toggleable>, pub keystroke_spacing: f32, } @@ -565,7 +565,7 @@ pub struct Picker { pub input_editor: FieldEditor, pub empty_input_editor: FieldEditor, pub no_matches: ContainedLabel, - pub item: Interactive, + pub item: Toggleable>, } #[derive(Clone, Debug, Deserialize, Default)] @@ -771,13 +771,13 @@ pub struct InteractiveColor { #[derive(Clone, Deserialize, Default)] pub struct CodeActions { #[serde(default)] - pub indicator: Interactive, + pub indicator: Toggleable>, pub vertical_scale: f32, } #[derive(Clone, Deserialize, Default)] pub struct Folds { - pub indicator: Interactive, + pub indicator: Toggleable>, pub ellipses: FoldEllipses, pub fold_background: Color, pub icon_margin_scale: f32, @@ -806,29 +806,52 @@ pub struct DiffStyle { pub struct Interactive { pub default: T, pub hover: Option, - pub hover_and_active: Option, pub clicked: Option, - pub click_and_active: Option, - pub active: Option, pub disabled: Option, } +#[derive(Clone, Copy, Debug, Default, Deserialize)] +pub struct Toggleable { + on: T, + off: T, +} + +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +pub enum ToggleState { + Off, + On, +} + +impl> From for ToggleState { + fn from(item: T) -> Self { + match *item.borrow() { + true => Self::On, + false => Self::Off, + } + } +} + +impl Toggleable { + pub fn new(on: T, off: T) -> Self { + Self { on, off } + } + pub fn in_state(&self, state: impl Into) -> &T { + match state.into() { + ToggleState::Off => &self.off, + ToggleState::On => &self.on, + } + } + pub fn on_state(&self) -> &T { + self.in_state(ToggleState::On) + } + pub fn off_state(&self) -> &T { + self.in_state(ToggleState::Off) + } +} + impl Interactive { - pub fn style_for(&self, state: &mut MouseState, active: bool) -> &T { - if active { - if state.hovered() { - self.hover_and_active - .as_ref() - .unwrap_or(self.active.as_ref().unwrap_or(&self.default)) - } else if state.clicked() == Some(platform::MouseButton::Left) && self.clicked.is_some() - { - self.click_and_active - .as_ref() - .unwrap_or(self.active.as_ref().unwrap_or(&self.default)) - } else { - self.active.as_ref().unwrap_or(&self.default) - } - } else if state.clicked() == Some(platform::MouseButton::Left) && self.clicked.is_some() { + pub fn style_for(&self, state: &mut MouseState) -> &T { + if state.clicked() == Some(platform::MouseButton::Left) && self.clicked.is_some() { self.clicked.as_ref().unwrap() } else if state.hovered() { self.hover.as_ref().unwrap_or(&self.default) @@ -836,7 +859,6 @@ impl Interactive { &self.default } } - pub fn disabled_style(&self) -> &T { self.disabled.as_ref().unwrap_or(&self.default) } @@ -852,10 +874,7 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { #[serde(flatten)] default: Value, hover: Option, - hover_and_active: Option, clicked: Option, - click_and_active: Option, - active: Option, disabled: Option, } @@ -881,20 +900,14 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { }; let hover = deserialize_state(json.hover)?; - let hover_and_active = deserialize_state(json.hover_and_active)?; let clicked = deserialize_state(json.clicked)?; - let click_and_active = deserialize_state(json.click_and_active)?; - let active = deserialize_state(json.active)?; let disabled = deserialize_state(json.disabled)?; let default = serde_json::from_value(json.default).map_err(serde::de::Error::custom)?; Ok(Interactive { default, hover, - hover_and_active, clicked, - click_and_active, - active, disabled, }) } diff --git a/crates/theme/src/ui.rs b/crates/theme/src/ui.rs index b86bfca8c42ae05900d76d86e19544531c245899..a0fd741d1d65e3e18bb4e83f876086f39cf4c0ae 100644 --- a/crates/theme/src/ui.rs +++ b/crates/theme/src/ui.rs @@ -170,7 +170,7 @@ where F: Fn(MouseClick, &mut V, &mut EventContext) + 'static, { MouseEventHandler::::new(0, cx, |state, _| { - let style = style.style_for(state, false); + let style = style.style_for(state); Label::new(label, style.text.to_owned()) .aligned() .contained() @@ -220,13 +220,13 @@ where title, style .title_text - .style_for(&mut MouseState::default(), false) + .style_for(&mut MouseState::default()) .clone(), )) .with_child( // FIXME: Get a better tag type MouseEventHandler::::new(999999, cx, |state, _cx| { - let style = style.close_icon.style_for(state, false); + let style = style.close_icon.style_for(state); icon(style) }) .on_click(platform::MouseButton::Left, move |_, _, cx| { diff --git a/crates/theme_selector/src/theme_selector.rs b/crates/theme_selector/src/theme_selector.rs index a6c84d1d91a6b149b3ed4950c2127f194040fc4a..5775f1b3e75fe3f80e5b0dd488b95f57724364cb 100644 --- a/crates/theme_selector/src/theme_selector.rs +++ b/crates/theme_selector/src/theme_selector.rs @@ -208,7 +208,7 @@ impl PickerDelegate for ThemeSelectorDelegate { cx: &AppContext, ) -> AnyElement> { let theme = theme::current(cx); - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); let theme_match = &self.matches[ix]; Label::new(theme_match.string.clone(), style.label.clone()) diff --git a/crates/welcome/src/base_keymap_picker.rs b/crates/welcome/src/base_keymap_picker.rs index e44b391d84b3f46d96e84c8e97589b6ecbde699e..cf24a9127e980b21241ab16e20119041b7447a9c 100644 --- a/crates/welcome/src/base_keymap_picker.rs +++ b/crates/welcome/src/base_keymap_picker.rs @@ -141,7 +141,7 @@ impl PickerDelegate for BaseKeymapSelectorDelegate { ) -> gpui::AnyElement> { let theme = &theme::current(cx); let keymap_match = &self.matches[ix]; - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); Label::new(keymap_match.string.clone(), style.label.clone()) .with_highlights(keymap_match.positions.clone()) diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index c174b8d3a5682b16c2b0b049389f5101afdde458..376fb85b21ff45f5c62a72a33939b584c6bdb0db 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -6,7 +6,7 @@ use gpui::{ }; use serde::Deserialize; use std::rc::Rc; -use theme::ThemeSettings; +use theme::{ThemeSettings, ToggleState}; pub trait Panel: View { fn position(&self, cx: &WindowContext) -> DockPosition; @@ -498,7 +498,14 @@ impl View for PanelButtons { Stack::new() .with_child( MouseEventHandler::::new(panel_ix, cx, |state, cx| { - let style = button_style.style_for(state, is_active); + let toggle_state = if is_active { + ToggleState::On + } else { + ToggleState::Off + }; + let style = button_style.in_state(toggle_state); + + let style = style.style_for(state); Flex::row() .with_child( Svg::new(view.icon_path(cx)) diff --git a/crates/workspace/src/notifications.rs b/crates/workspace/src/notifications.rs index 1e3c6044a1651101939453d2ee2e5c6b90df3564..09cfb4d5d805561bd4b7593fc08355bd64badf9e 100644 --- a/crates/workspace/src/notifications.rs +++ b/crates/workspace/src/notifications.rs @@ -291,7 +291,7 @@ pub mod simple_message_notification { ) .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.dismiss_button.style_for(state, false); + let style = theme.dismiss_button.style_for(state); Svg::new("icons/x_mark_8.svg") .with_color(style.color) .constrained() @@ -323,7 +323,7 @@ pub mod simple_message_notification { 0, cx, |state, _| { - let style = theme.action_message.style_for(state, false); + let style = theme.action_message.style_for(state); Flex::row() .with_child( diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 551bc831d3cc074a95cef62479b26407c6fe65bf..5136db1d18b7aea794bbdcad87a851228fadd8ab 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1410,7 +1410,7 @@ impl Pane { pub fn render_tab_bar_button)>( index: usize, icon: &'static str, - active: bool, + is_active: bool, tooltip: Option<(String, Option>)>, cx: &mut ViewContext, on_click: F, @@ -1420,7 +1420,7 @@ impl Pane { let mut button = MouseEventHandler::::new(index, cx, |mouse_state, cx| { let theme = &settings::get::(cx).theme.workspace.tab_bar; - let style = theme.pane_button.style_for(mouse_state, active); + let style = theme.pane_button.in_state(is_active).style_for(mouse_state); Svg::new(icon) .with_color(style.color) .constrained() diff --git a/crates/workspace/src/toolbar.rs b/crates/workspace/src/toolbar.rs index 8b26b1181bca243d38cc915455cbe0df9403de5b..59f39f1d9357bf62f036473d6f71b10ca0cabd47 100644 --- a/crates/workspace/src/toolbar.rs +++ b/crates/workspace/src/toolbar.rs @@ -219,7 +219,7 @@ impl View for Toolbar { #[allow(clippy::too_many_arguments)] fn nav_button)>( svg_path: &'static str, - style: theme::Interactive, + style: theme::Toggleable>, nav_button_height: f32, tooltip_style: TooltipStyle, enabled: bool, @@ -231,9 +231,9 @@ fn nav_button ) -> AnyElement { MouseEventHandler::::new(0, cx, |state, _| { let style = if enabled { - style.style_for(state, false) + style.off_state().style_for(state) } else { - style.disabled_style() + style.off_state().disabled_style() }; Svg::new(svg_path) .with_color(style.color) From 0256f89dd66c693523d8fa19aefa5cdd7ddd34b2 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 14 Jun 2023 15:12:38 +0200 Subject: [PATCH 02/26] Rename on/off states to active/inactive --- crates/collab_ui/src/collab_titlebar_item.rs | 11 +++++-- crates/collab_ui/src/contact_list.rs | 4 +-- crates/context_menu/src/context_menu.rs | 12 +++---- crates/project_panel/src/project_panel.rs | 8 +++-- crates/project_symbols/src/project_symbols.rs | 5 ++- crates/search/src/buffer_search.rs | 2 +- crates/search/src/project_search.rs | 2 +- crates/theme/src/theme.rs | 31 ++++++++++--------- crates/workspace/src/dock.rs | 4 +-- crates/workspace/src/toolbar.rs | 4 +-- 10 files changed, 47 insertions(+), 36 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index aa643f4416dbdd066cc1fd24a0851ac4409e4b38..cf699d19889c66d62c2efe63b842f05196a3c0d2 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -299,7 +299,12 @@ impl CollabTitlebarItem { pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext) { let theme = theme::current(cx).clone(); let avatar_style = theme.workspace.titlebar.leader_avatar.clone(); - let item_style = theme.context_menu.item.off_state().disabled_style().clone(); + let item_style = theme + .context_menu + .item + .inactive_state() + .disabled_style() + .clone(); self.user_menu.update(cx, |user_menu, cx| { let items = if let Some(user) = self.user_store.read(cx).current_user() { vec![ @@ -364,14 +369,14 @@ impl CollabTitlebarItem { .with_margin_left( titlebar .toggle_contacts_button - .off_state() + .inactive_state() .default .icon_width, ) .with_margin_top( titlebar .toggle_contacts_button - .off_state() + .inactive_state() .default .icon_width, ) diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs index c0839249f2574d8f77a34689c5ffbc3c2463a0b4..0c8b27a1511e075aa734d62001392beb64da56b4 100644 --- a/crates/collab_ui/src/contact_list.rs +++ b/crates/collab_ui/src/contact_list.rs @@ -798,7 +798,7 @@ impl ContactList { .width .or(theme.contact_avatar.height) .unwrap_or(0.); - let row = &theme.project_row.off_state().default; + let row = &theme.project_row.inactive_state().default; let tree_branch = theme.tree_branch; let line_height = row.name.text.line_height(font_cache); let cap_height = row.name.text.cap_height(font_cache); @@ -897,7 +897,7 @@ impl ContactList { .width .or(theme.contact_avatar.height) .unwrap_or(0.); - let row = &theme.project_row.off_state().default; + let row = &theme.project_row.inactive_state().default; let tree_branch = theme.tree_branch; let line_height = row.name.text.line_height(font_cache); let cap_height = row.name.text.cap_height(font_cache); diff --git a/crates/context_menu/src/context_menu.rs b/crates/context_menu/src/context_menu.rs index e9ab24f06e09b2e8bfd3cf92cac8218c1c4d5f70..e140177c5c13cda2645184fb71e16ef8b5461894 100644 --- a/crates/context_menu/src/context_menu.rs +++ b/crates/context_menu/src/context_menu.rs @@ -330,9 +330,9 @@ impl ContextMenu { match item { ContextMenuItem::Item { label, .. } => { let toggle_state = if Some(ix) == self.selected_index { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = style.item.in_state(toggle_state); let style = style.style_for(&mut Default::default()); @@ -368,9 +368,9 @@ impl ContextMenu { match item { ContextMenuItem::Item { action, .. } => { let toggle_state = if Some(ix) == self.selected_index { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = style.item.in_state(toggle_state); let style = style.style_for(&mut Default::default()); @@ -420,9 +420,9 @@ impl ContextMenu { let view_id = self.parent_view_id; MouseEventHandler::::new(ix, cx, |state, _| { let toggle_state = if Some(ix) == self.selected_index { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = style.item.in_state(toggle_state); let style = style.style_for(state); diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index a4ac8a5743dd08c39cc5b38fc1d2b91d3b6a9e87..dc592b758880601dec6bb63d22d73fb0a9e4e289 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1267,7 +1267,7 @@ impl ProjectPanel { .filter(|destination| details.path.starts_with(destination)) .is_some() { - style = entry_style.on_state().default.clone(); + style = entry_style.active_state().default.clone(); } let row_container_style = if show_editor { @@ -1409,8 +1409,10 @@ impl View for ProjectPanel { let context_menu_item_style = theme::current(cx).context_menu.item.clone(); move |state, cx| { let button_style = button_style.style_for(state).clone(); - let context_menu_item = - context_menu_item_style.on_state().style_for(state).clone(); + let context_menu_item = context_menu_item_style + .active_state() + .style_for(state) + .clone(); theme::ui::keystroke_label( "Open a project", diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index dbfad48e87cc33415933dd4dca82400e346796a0..fc17b57c6dbf92eee74874f9cb1577f495ba8704 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -229,7 +229,10 @@ impl PickerDelegate for ProjectSymbolsDelegate { .with_child( // Avoid styling the path differently when it is selected, since // the symbol's syntax highlighting doesn't change when selected. - Label::new(path.to_string(), style.off_state().default.label.clone()), + Label::new( + path.to_string(), + style.inactive_state().default.label.clone(), + ), ) .contained() .with_style(current_style.container) diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 1a059f5df78eb684ece9f0ba9f417a1d4ac41dae..c6a86b2f6a209f89de05f80f6fa314120e074297 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -375,7 +375,7 @@ impl BufferSearchBar { enum NavButton {} MouseEventHandler::::new(direction as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.off_state().style_for(state); + let style = theme.search.option_button.inactive_state().style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index a379fa80e132b5ebd0cf73d5cab2e7b934ce7171..135194df6a2f5a22c1ed001a725488ae2c003437 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -896,7 +896,7 @@ impl ProjectSearchBar { enum NavButton {} MouseEventHandler::::new(direction as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.off_state().style_for(state); + let style = theme.search.option_button.inactive_state().style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 812659078f1220cd75a92948b85925ead23ac2b4..7c4c8c1ce27d91da90fbde07398a413647f87d47 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -812,40 +812,41 @@ pub struct Interactive { #[derive(Clone, Copy, Debug, Default, Deserialize)] pub struct Toggleable { - on: T, - off: T, + active: T, + inactive: T, } -#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Default, Hash, PartialEq, Eq)] pub enum ToggleState { - Off, - On, + #[default] + Inactive, + Active, } impl> From for ToggleState { fn from(item: T) -> Self { match *item.borrow() { - true => Self::On, - false => Self::Off, + true => Self::Active, + false => Self::Inactive, } } } impl Toggleable { - pub fn new(on: T, off: T) -> Self { - Self { on, off } + pub fn new(active: T, inactive: T) -> Self { + Self { active, inactive } } pub fn in_state(&self, state: impl Into) -> &T { match state.into() { - ToggleState::Off => &self.off, - ToggleState::On => &self.on, + ToggleState::Inactive => &self.inactive, + ToggleState::Active => &self.active, } } - pub fn on_state(&self) -> &T { - self.in_state(ToggleState::On) + pub fn active_state(&self) -> &T { + self.in_state(ToggleState::Active) } - pub fn off_state(&self) -> &T { - self.in_state(ToggleState::Off) + pub fn inactive_state(&self) -> &T { + self.in_state(ToggleState::Inactive) } } diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 376fb85b21ff45f5c62a72a33939b584c6bdb0db..ec00ddece8f9a2ee8231df5c4b9123a70d49cbfa 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -499,9 +499,9 @@ impl View for PanelButtons { .with_child( MouseEventHandler::::new(panel_ix, cx, |state, cx| { let toggle_state = if is_active { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = button_style.in_state(toggle_state); diff --git a/crates/workspace/src/toolbar.rs b/crates/workspace/src/toolbar.rs index 59f39f1d9357bf62f036473d6f71b10ca0cabd47..d74e7f046abadbda21b9407f0570d4e09b6ef1c6 100644 --- a/crates/workspace/src/toolbar.rs +++ b/crates/workspace/src/toolbar.rs @@ -231,9 +231,9 @@ fn nav_button ) -> AnyElement { MouseEventHandler::::new(0, cx, |state, _| { let style = if enabled { - style.off_state().style_for(state) + style.inactive_state().style_for(state) } else { - style.off_state().disabled_style() + style.inactive_state().disabled_style() }; Svg::new(svg_path) .with_color(style.color) From b9959ffdc0811e01fb6b87a18c3f61741000bce0 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:26:47 +0200 Subject: [PATCH 03/26] Do not flatten Interactive::default --- crates/theme/src/theme.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 7c4c8c1ce27d91da90fbde07398a413647f87d47..a82bb18cf140fef6b1f8b9340d6a5ec82cb78380 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -872,7 +872,6 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { { #[derive(Deserialize)] struct Helper { - #[serde(flatten)] default: Value, hover: Option, clicked: Option, From c47d1e9f5178d1a14122405f0872e305c6da562e Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:26:58 +0200 Subject: [PATCH 04/26] Add toggle.ts and interactive.ts --- styles/src/styleTree/interactive.ts | 26 ++++++++++++++++++++++++++ styles/src/styleTree/toggle.ts | 17 +++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 styles/src/styleTree/interactive.ts create mode 100644 styles/src/styleTree/toggle.ts diff --git a/styles/src/styleTree/interactive.ts b/styles/src/styleTree/interactive.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f7181900cf97bf776fbc2a85c578e0ddbdc59dc --- /dev/null +++ b/styles/src/styleTree/interactive.ts @@ -0,0 +1,26 @@ +interface Interactive { + default: T, + hover?: T, + clicked?: T, + disabled?: T, +} + +export function interactive(base: T, modifications: Partial>): Interactive { + const interactiveObj: Interactive = { + default: base, + }; + + if (modifications.hover !== undefined) { + interactiveObj.hover = { ...base, ...modifications.hover }; + } + + if (modifications.clicked !== undefined) { + interactiveObj.clicked = { ...base, ...modifications.clicked }; + } + + if (modifications.disabled !== undefined) { + interactiveObj.disabled = { ...base, ...modifications.disabled }; + } + + return interactiveObj; +} diff --git a/styles/src/styleTree/toggle.ts b/styles/src/styleTree/toggle.ts new file mode 100644 index 0000000000000000000000000000000000000000..0602ae6b598712719b5bf91cf18bf60a5b024bd5 --- /dev/null +++ b/styles/src/styleTree/toggle.ts @@ -0,0 +1,17 @@ +interface Toggleable { + inactive: T + active: T, +} + +export function toggleable(inactive: T, modifications: Partial>): Toggleable { + let active: T = inactive; + if (modifications.active !== undefined) { + active = { ...inactive, ...modifications.active }; + } + return { + inactive: inactive, + active: active + }; + + d +} From 198a446b03a168fc96f68f8de2e0ebf96068c1ac Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 15 Jun 2023 13:09:22 +0200 Subject: [PATCH 05/26] Implement Toggleable and Interactive properly --- styles/package-lock.json | 30 ++++++++++++++- styles/package.json | 4 +- styles/src/styleTree/commandPalette.ts | 53 +++++++++++++++----------- styles/src/styleTree/interactive.ts | 19 ++++++--- styles/src/styleTree/toggle.ts | 40 +++++++++++++------ 5 files changed, 104 insertions(+), 42 deletions(-) diff --git a/styles/package-lock.json b/styles/package-lock.json index d1d0ed0eb8f810cea84e6efbc3e7aa7aa6e3f899..b4bdd52c66463b020f0798a03494920f9206d874 100644 --- a/styles/package-lock.json +++ b/styles/package-lock.json @@ -18,7 +18,9 @@ "chroma-js": "^2.4.2", "deepmerge": "^4.3.0", "toml": "^3.0.0", - "ts-node": "^10.9.1" + "ts-deepmerge": "^6.0.3", + "ts-node": "^10.9.1", + "utility-types": "^3.10.0" } }, "node_modules/@cspotcode/source-map-support": { @@ -180,6 +182,14 @@ "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" }, + "node_modules/ts-deepmerge": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/ts-deepmerge/-/ts-deepmerge-6.0.3.tgz", + "integrity": "sha512-MBBJL0UK/mMnZRONMz4J1CRu5NsGtsh+gR1nkn8KLE9LXo/PCzeHhQduhNary8m5/m9ryOOyFwVKxq81cPlaow==", + "engines": { + "node": ">=14.13.1" + } + }, "node_modules/ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", @@ -235,6 +245,14 @@ "node": ">=4.2.0" } }, + "node_modules/utility-types": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", + "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==", + "engines": { + "node": ">= 4" + } + }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", @@ -382,6 +400,11 @@ "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" }, + "ts-deepmerge": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/ts-deepmerge/-/ts-deepmerge-6.0.3.tgz", + "integrity": "sha512-MBBJL0UK/mMnZRONMz4J1CRu5NsGtsh+gR1nkn8KLE9LXo/PCzeHhQduhNary8m5/m9ryOOyFwVKxq81cPlaow==" + }, "ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", @@ -408,6 +431,11 @@ "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "peer": true }, + "utility-types": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", + "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==" + }, "v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", diff --git a/styles/package.json b/styles/package.json index 2a0881863b588e2f26424e380173d2fa2de16533..30336d5c519a30ba68aef0be7541d86d8f7b6bc3 100644 --- a/styles/package.json +++ b/styles/package.json @@ -20,7 +20,9 @@ "chroma-js": "^2.4.2", "deepmerge": "^4.3.0", "toml": "^3.0.0", - "ts-node": "^10.9.1" + "ts-deepmerge": "^6.0.3", + "ts-node": "^10.9.1", + "utility-types": "^3.10.0" }, "prettier": { "semi": false, diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index c49e1f194c7fbcd16a4f1ac0a5bc7f996fd53dcc..5fe7b74f92352f1d2f311d5b3f93af9c22e6fc35 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -1,30 +1,37 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" +import { toggleable } from "./toggle" +import { interactive } from "./interactive" export default function commandPalette(colorScheme: ColorScheme) { - let layer = colorScheme.highest - return { - keystrokeSpacing: 8, - key: { - text: text(layer, "mono", "variant", "default", { size: "xs" }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - active: { - text: text(layer, "mono", "on", "default", { size: "xs" }), - background: withOpacity(background(layer, "on"), 0.2), - }, + let layer = colorScheme.highest + return { + keystrokeSpacing: 8, + key: + toggleable(interactive({ + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, }, - } + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, { hover: { cornerRadius: 4, padding: { top: 17 } } }), { + default: { + text: text(layer, "mono", "on", "default", { size: "xs" }), + background: withOpacity(background(layer, "on"), 0.2), + } + + }) + , + + } } diff --git a/styles/src/styleTree/interactive.ts b/styles/src/styleTree/interactive.ts index 2f7181900cf97bf776fbc2a85c578e0ddbdc59dc..7135cecd906952889f37e580b932ffb96efa6689 100644 --- a/styles/src/styleTree/interactive.ts +++ b/styles/src/styleTree/interactive.ts @@ -1,3 +1,5 @@ +import { DeepPartial } from "utility-types"; +import merge from "ts-deepmerge" interface Interactive { default: T, hover?: T, @@ -5,21 +7,26 @@ interface Interactive { disabled?: T, } -export function interactive(base: T, modifications: Partial>): Interactive { - const interactiveObj: Interactive = { +// Helper function for creating Interactive objects that works pretty much like Toggle. +// It takes a object to be used as a value for `default` field and then fills out other fields +// with fields from either `base` or `modifications`. Notably, it does not touch `hover`, `clicked` and `disabled` if there are no modifications for it. +export function interactive(base: T, modifications: DeepPartial>): Interactive { + let interactiveObj: Interactive = { default: base, }; - + if (modifications.default !== undefined) { + interactiveObj.default = merge(interactiveObj.default, modifications.default) as T; + } if (modifications.hover !== undefined) { - interactiveObj.hover = { ...base, ...modifications.hover }; + interactiveObj.hover = merge(interactiveObj.default, modifications.hover) as T; } if (modifications.clicked !== undefined) { - interactiveObj.clicked = { ...base, ...modifications.clicked }; + interactiveObj.clicked = merge(interactiveObj.default, modifications.clicked) as T; } if (modifications.disabled !== undefined) { - interactiveObj.disabled = { ...base, ...modifications.disabled }; + interactiveObj.disabled = merge(interactiveObj.default, modifications.disabled) as T; } return interactiveObj; diff --git a/styles/src/styleTree/toggle.ts b/styles/src/styleTree/toggle.ts index 0602ae6b598712719b5bf91cf18bf60a5b024bd5..9c35b8337c07a730c17d5bf5db3787446f615e88 100644 --- a/styles/src/styleTree/toggle.ts +++ b/styles/src/styleTree/toggle.ts @@ -1,17 +1,35 @@ +import { DeepPartial } from 'utility-types'; +import merge from 'ts-deepmerge'; + interface Toggleable { inactive: T active: T, } -export function toggleable(inactive: T, modifications: Partial>): Toggleable { - let active: T = inactive; - if (modifications.active !== undefined) { - active = { ...inactive, ...modifications.active }; - } - return { - inactive: inactive, - active: active - }; - - d +/// Helper function for creating Toggleable objects; it takes a object of type T that is used as +/// `inactive` member of result Toggleable. `active` member is created by applying `modifications` on top of `inactive` argument. +// Thus, the following call: +// ``` +// toggleable({day: 1, month: "January"}, {day: 3}) +// ``` +// To return the following object: +// ``` +// Toggleable<_>{ +// inactive: { day: 1, month: "January" }, +// active: { day: 3, month: "January" } +// } +// ``` +// Remarkably, it also works for nested structures: +// ``` +// toggleable({first_level: "foo", second_level: {nested_member: "nested"}}, {second_level: {nested_member: "another nested thing"}}) +// ``` +// ``` +// Toggleable<_> { +// inactive: {first_level: "foo", second_level: {nested_member: "nested"}}, +// active: { first_level: "foo", second_level: {nested_member: "another nested thing"}} +// } +// ``` +export function toggleable(inactive: T, modifications: DeepPartial): Toggleable { + let active: T = merge(inactive, modifications) as T; + return { active: active, inactive: inactive }; } From 31c1177737501b742e3522a52a4045a6c718e279 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:24:05 +0200 Subject: [PATCH 06/26] Adjust some of the styles to the new Toggleable format --- crates/collab_ui/src/collab_titlebar_item.rs | 4 +- crates/theme/src/theme.rs | 8 +- crates/workspace/src/toolbar.rs | 6 +- styles/src/styleTree/components.ts | 436 ++++++------ styles/src/styleTree/contactList.ts | 368 ++++++----- styles/src/styleTree/contactNotification.ts | 81 +-- styles/src/styleTree/contextMenu.ts | 91 +-- styles/src/styleTree/copilot.ts | 491 +++++++------- styles/src/styleTree/editor.ts | 517 ++++++++------- styles/src/styleTree/picker.ts | 154 ++--- styles/src/styleTree/projectPanel.ts | 204 +++--- styles/src/styleTree/statusBar.ts | 241 +++---- styles/src/styleTree/tabBar.ts | 191 +++--- styles/src/styleTree/welcome.ts | 240 +++---- styles/src/styleTree/workspace.ts | 658 ++++++++++--------- 15 files changed, 1907 insertions(+), 1783 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index cf699d19889c66d62c2efe63b842f05196a3c0d2..04fc9650eb82f1177b0290463b04e2601be9640c 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -491,7 +491,7 @@ impl CollabTitlebarItem { .with_child( MouseEventHandler::::new(0, cx, |state, _| { //TODO: Ensure this button has consistent width for both text variations - let style = titlebar.share_button.style_for(state); + let style = titlebar.share_button.inactive_state().style_for(state); Label::new(label, style.text.clone()) .contained() .with_style(style.container) @@ -567,7 +567,7 @@ impl CollabTitlebarItem { fn render_sign_in_button(&self, theme: &Theme, cx: &mut ViewContext) -> AnyElement { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.sign_in_prompt.style_for(state); + let style = titlebar.sign_in_prompt.inactive_state().style_for(state); Label::new("Sign In", style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index a82bb18cf140fef6b1f8b9340d6a5ec82cb78380..fd30387ad868782fb47c3c877a6e516fce47fcba 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -128,12 +128,12 @@ pub struct Titlebar { pub leader_avatar: AvatarStyle, pub follower_avatar: AvatarStyle, pub inactive_avatar_grayscale: bool, - pub sign_in_prompt: Interactive, + pub sign_in_prompt: Toggleable>, pub outdated_warning: ContainedText, - pub share_button: Interactive, + pub share_button: Toggleable>, pub call_control: Interactive, pub toggle_contacts_button: Toggleable>, - pub user_menu_button: Interactive, + pub user_menu_button: Toggleable>, pub toggle_contacts_badge: ContainerStyle, } @@ -339,7 +339,7 @@ pub struct Toolbar { pub container: ContainerStyle, pub height: f32, pub item_spacing: f32, - pub nav_button: Toggleable>, + pub nav_button: Interactive, } #[derive(Clone, Deserialize, Default)] diff --git a/crates/workspace/src/toolbar.rs b/crates/workspace/src/toolbar.rs index d74e7f046abadbda21b9407f0570d4e09b6ef1c6..49f9db12e6bb182976c5f4d76d55aed8b8d4688b 100644 --- a/crates/workspace/src/toolbar.rs +++ b/crates/workspace/src/toolbar.rs @@ -219,7 +219,7 @@ impl View for Toolbar { #[allow(clippy::too_many_arguments)] fn nav_button)>( svg_path: &'static str, - style: theme::Toggleable>, + style: theme::Interactive, nav_button_height: f32, tooltip_style: TooltipStyle, enabled: bool, @@ -231,9 +231,9 @@ fn nav_button ) -> AnyElement { MouseEventHandler::::new(0, cx, |state, _| { let style = if enabled { - style.inactive_state().style_for(state) + style.style_for(state) } else { - style.inactive_state().disabled_style() + style.disabled_style() }; Svg::new(svg_path) .with_color(style.color) diff --git a/styles/src/styleTree/components.ts b/styles/src/styleTree/components.ts index a575dad52725d77dff8951be97a4fb7eb0949449..3aa5d9176e26649c136befcee7aaf51ad412e918 100644 --- a/styles/src/styleTree/components.ts +++ b/styles/src/styleTree/components.ts @@ -2,297 +2,297 @@ import { fontFamilies, fontSizes, FontWeight } from "../common" import { Layer, Styles, StyleSets, Style } from "../theme/colorScheme" function isStyleSet(key: any): key is StyleSets { - return [ - "base", - "variant", - "on", - "accent", - "positive", - "warning", - "negative", - ].includes(key) + return [ + "base", + "variant", + "on", + "accent", + "positive", + "warning", + "negative", + ].includes(key) } function isStyle(key: any): key is Styles { - return [ - "default", - "active", - "disabled", - "hovered", - "pressed", - "inverted", - ].includes(key) + return [ + "default", + "active", + "disabled", + "hovered", + "pressed", + "inverted", + ].includes(key) } function getStyle( - layer: Layer, - possibleStyleSetOrStyle?: any, - possibleStyle?: any + layer: Layer, + possibleStyleSetOrStyle?: any, + possibleStyle?: any ): Style { - let styleSet: StyleSets = "base" - let style: Styles = "default" - if (isStyleSet(possibleStyleSetOrStyle)) { - styleSet = possibleStyleSetOrStyle - } else if (isStyle(possibleStyleSetOrStyle)) { - style = possibleStyleSetOrStyle - } + let styleSet: StyleSets = "base" + let style: Styles = "default" + if (isStyleSet(possibleStyleSetOrStyle)) { + styleSet = possibleStyleSetOrStyle + } else if (isStyle(possibleStyleSetOrStyle)) { + style = possibleStyleSetOrStyle + } - if (isStyle(possibleStyle)) { - style = possibleStyle - } + if (isStyle(possibleStyle)) { + style = possibleStyle + } - return layer[styleSet][style] + return layer[styleSet][style] } export function background(layer: Layer, style?: Styles): string export function background( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function background( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).background + return getStyle(layer, styleSetOrStyles, style).background } export function borderColor(layer: Layer, style?: Styles): string export function borderColor( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function borderColor( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).border + return getStyle(layer, styleSetOrStyles, style).border } export function foreground(layer: Layer, style?: Styles): string export function foreground( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function foreground( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).foreground + return getStyle(layer, styleSetOrStyles, style).foreground } -interface Text { - family: keyof typeof fontFamilies - color: string - size: number - weight?: FontWeight - underline?: boolean +interface Text extends Object { + family: keyof typeof fontFamilies + color: string + size: number + weight?: FontWeight + underline?: boolean } export interface TextProperties { - size?: keyof typeof fontSizes - weight?: FontWeight - underline?: boolean - color?: string - features?: FontFeatures + size?: keyof typeof fontSizes + weight?: FontWeight + underline?: boolean + color?: string + features?: FontFeatures } interface FontFeatures { - /** Contextual Alternates: Applies a second substitution feature based on a match of a character pattern within a context of surrounding patterns */ - calt?: boolean - /** Case-Sensitive Forms: Shifts various punctuation marks up to a position that works better with all-capital sequences */ - case?: boolean - /** Capital Spacing: Adjusts inter-glyph spacing for all-capital text */ - cpsp?: boolean - /** Fractions: Replaces figures separated by a slash with diagonal fractions */ - frac?: boolean - /** Standard Ligatures: Replaces a sequence of glyphs with a single glyph which is preferred for typographic purposes */ - liga?: boolean - /** Oldstyle Figures: Changes selected figures from the default or lining style to oldstyle form. */ - onum?: boolean - /** Ordinals: Replaces default alphabetic glyphs with the corresponding ordinal forms for use after figures */ - ordn?: boolean - /** Proportional Figures: Replaces figure glyphs set on uniform (tabular) widths with corresponding glyphs set on proportional widths */ - pnum?: boolean - /** Stylistic set 01 */ - ss01?: boolean - /** Stylistic set 02 */ - ss02?: boolean - /** Stylistic set 03 */ - ss03?: boolean - /** Stylistic set 04 */ - ss04?: boolean - /** Stylistic set 05 */ - ss05?: boolean - /** Stylistic set 06 */ - ss06?: boolean - /** Stylistic set 07 */ - ss07?: boolean - /** Stylistic set 08 */ - ss08?: boolean - /** Stylistic set 09 */ - ss09?: boolean - /** Stylistic set 10 */ - ss10?: boolean - /** Stylistic set 11 */ - ss11?: boolean - /** Stylistic set 12 */ - ss12?: boolean - /** Stylistic set 13 */ - ss13?: boolean - /** Stylistic set 14 */ - ss14?: boolean - /** Stylistic set 15 */ - ss15?: boolean - /** Stylistic set 16 */ - ss16?: boolean - /** Stylistic set 17 */ - ss17?: boolean - /** Stylistic set 18 */ - ss18?: boolean - /** Stylistic set 19 */ - ss19?: boolean - /** Stylistic set 20 */ - ss20?: boolean - /** Subscript: Replaces default glyphs with subscript glyphs */ - subs?: boolean - /** Superscript: Replaces default glyphs with superscript glyphs */ - sups?: boolean - /** Swash: Replaces default glyphs with swash glyphs for stylistic purposes */ - swsh?: boolean - /** Titling: Replaces default glyphs with titling glyphs for use in large-size settings */ - titl?: boolean - /** Tabular Figures: Replaces figure glyphs set on proportional widths with corresponding glyphs set on uniform (tabular) widths */ - tnum?: boolean - /** Slashed Zero: Replaces default zero with a slashed zero for better distinction between "0" and "O" */ - zero?: boolean + /** Contextual Alternates: Applies a second substitution feature based on a match of a character pattern within a context of surrounding patterns */ + calt?: boolean + /** Case-Sensitive Forms: Shifts various punctuation marks up to a position that works better with all-capital sequences */ + case?: boolean + /** Capital Spacing: Adjusts inter-glyph spacing for all-capital text */ + cpsp?: boolean + /** Fractions: Replaces figures separated by a slash with diagonal fractions */ + frac?: boolean + /** Standard Ligatures: Replaces a sequence of glyphs with a single glyph which is preferred for typographic purposes */ + liga?: boolean + /** Oldstyle Figures: Changes selected figures from the default or lining style to oldstyle form. */ + onum?: boolean + /** Ordinals: Replaces default alphabetic glyphs with the corresponding ordinal forms for use after figures */ + ordn?: boolean + /** Proportional Figures: Replaces figure glyphs set on uniform (tabular) widths with corresponding glyphs set on proportional widths */ + pnum?: boolean + /** Stylistic set 01 */ + ss01?: boolean + /** Stylistic set 02 */ + ss02?: boolean + /** Stylistic set 03 */ + ss03?: boolean + /** Stylistic set 04 */ + ss04?: boolean + /** Stylistic set 05 */ + ss05?: boolean + /** Stylistic set 06 */ + ss06?: boolean + /** Stylistic set 07 */ + ss07?: boolean + /** Stylistic set 08 */ + ss08?: boolean + /** Stylistic set 09 */ + ss09?: boolean + /** Stylistic set 10 */ + ss10?: boolean + /** Stylistic set 11 */ + ss11?: boolean + /** Stylistic set 12 */ + ss12?: boolean + /** Stylistic set 13 */ + ss13?: boolean + /** Stylistic set 14 */ + ss14?: boolean + /** Stylistic set 15 */ + ss15?: boolean + /** Stylistic set 16 */ + ss16?: boolean + /** Stylistic set 17 */ + ss17?: boolean + /** Stylistic set 18 */ + ss18?: boolean + /** Stylistic set 19 */ + ss19?: boolean + /** Stylistic set 20 */ + ss20?: boolean + /** Subscript: Replaces default glyphs with subscript glyphs */ + subs?: boolean + /** Superscript: Replaces default glyphs with superscript glyphs */ + sups?: boolean + /** Swash: Replaces default glyphs with swash glyphs for stylistic purposes */ + swsh?: boolean + /** Titling: Replaces default glyphs with titling glyphs for use in large-size settings */ + titl?: boolean + /** Tabular Figures: Replaces figure glyphs set on proportional widths with corresponding glyphs set on uniform (tabular) widths */ + tnum?: boolean + /** Slashed Zero: Replaces default zero with a slashed zero for better distinction between "0" and "O" */ + zero?: boolean } export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSet: StyleSets, - style: Styles, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSet: StyleSets, + style: Styles, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSet: StyleSets, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSet: StyleSets, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - style: Styles, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + style: Styles, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSetStyleOrProperties?: StyleSets | Styles | TextProperties, - styleOrProperties?: Styles | TextProperties, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSetStyleOrProperties?: StyleSets | Styles | TextProperties, + styleOrProperties?: Styles | TextProperties, + properties?: TextProperties ) { - let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) + let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) - if (typeof styleSetStyleOrProperties === "object") { - properties = styleSetStyleOrProperties - } - if (typeof styleOrProperties === "object") { - properties = styleOrProperties - } + if (typeof styleSetStyleOrProperties === "object") { + properties = styleSetStyleOrProperties + } + if (typeof styleOrProperties === "object") { + properties = styleOrProperties + } - let size = fontSizes[properties?.size || "sm"] - let color = properties?.color || style.foreground + let size = fontSizes[properties?.size || "sm"] + let color = properties?.color || style.foreground - return { - family: fontFamilies[fontFamily], - ...properties, - color, - size, - } + return { + family: fontFamilies[fontFamily], + ...properties, + color, + size, + } } export interface Border { - color: string - width: number - top?: boolean - bottom?: boolean - left?: boolean - right?: boolean - overlay?: boolean + color: string + width: number + top?: boolean + bottom?: boolean + left?: boolean + right?: boolean + overlay?: boolean } export interface BorderProperties { - width?: number - top?: boolean - bottom?: boolean - left?: boolean - right?: boolean - overlay?: boolean + width?: number + top?: boolean + bottom?: boolean + left?: boolean + right?: boolean + overlay?: boolean } export function border( - layer: Layer, - styleSet: StyleSets, - style: Styles, - properties?: BorderProperties + layer: Layer, + styleSet: StyleSets, + style: Styles, + properties?: BorderProperties ): Border export function border( - layer: Layer, - styleSet: StyleSets, - properties?: BorderProperties + layer: Layer, + styleSet: StyleSets, + properties?: BorderProperties ): Border export function border( - layer: Layer, - style: Styles, - properties?: BorderProperties + layer: Layer, + style: Styles, + properties?: BorderProperties ): Border export function border(layer: Layer, properties?: BorderProperties): Border export function border( - layer: Layer, - styleSetStyleOrProperties?: StyleSets | Styles | BorderProperties, - styleOrProperties?: Styles | BorderProperties, - properties?: BorderProperties + layer: Layer, + styleSetStyleOrProperties?: StyleSets | Styles | BorderProperties, + styleOrProperties?: Styles | BorderProperties, + properties?: BorderProperties ): Border { - let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) + let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) - if (typeof styleSetStyleOrProperties === "object") { - properties = styleSetStyleOrProperties - } - if (typeof styleOrProperties === "object") { - properties = styleOrProperties - } + if (typeof styleSetStyleOrProperties === "object") { + properties = styleSetStyleOrProperties + } + if (typeof styleOrProperties === "object") { + properties = styleOrProperties + } - return { - color: style.border, - width: 1, - ...properties, - } + return { + color: style.border, + width: 1, + ...properties, + } } export function svg( - color: string, - asset: String, - width: Number, - height: Number + color: string, + asset: String, + width: Number, + height: Number ) { - return { - color, - asset, - dimensions: { - width, - height, - }, - } + return { + color, + asset, + dimensions: { + width, + height, + }, + } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index a597e44d9f38ba54cc5ae706c0d61ab7822cb5c8..b3e30f4aa78ba172aae5022e16a7b65f916c25b6 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -1,182 +1,206 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" - +import { toggleable } from "./toggle" +import { interactive } from "./interactive" export default function contactsPanel(colorScheme: ColorScheme) { - const nameMargin = 8 - const sidePadding = 12 + const nameMargin = 8 + const sidePadding = 12 - let layer = colorScheme.middle + let layer = colorScheme.middle - const contactButton = { - background: background(layer, "on"), - color: foreground(layer, "on"), - iconWidth: 8, - buttonWidth: 16, - cornerRadius: 8, - } - const projectRow = { - guestAvatarSpacing: 4, - height: 24, - guestAvatar: { - cornerRadius: 8, - width: 14, - }, - name: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - right: 6, - }, - }, - guests: { - margin: { - left: nameMargin, - right: nameMargin, - }, - }, - padding: { + const contactButton = { + background: background(layer, "on"), + color: foreground(layer, "on"), + iconWidth: 8, + buttonWidth: 16, + cornerRadius: 8, + } + const projectRow = { + guestAvatarSpacing: 4, + height: 24, + guestAvatar: { + cornerRadius: 8, + width: 14, + }, + name: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + right: 6, + }, + }, + guests: { + margin: { + left: nameMargin, + right: nameMargin, + }, + }, + padding: { + left: sidePadding, + right: sidePadding, + }, + } + + return { + background: background(layer), + padding: { top: 12 }, + userQueryEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + margin: { + left: 6, + }, + }, + userQueryEditorHeight: 33, + addContactButton: { + margin: { left: 6, right: 12 }, + color: foreground(layer, "on"), + buttonWidth: 28, + iconWidth: 16, + }, + rowHeight: 28, + sectionIconSize: 8, + headerRow: toggleable(interactive({ + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"),// posiewic: breaking change + }, {}), + { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), + }, + }), + leaveCall: interactive({ + background: background(layer), + border: border(layer), + cornerRadius: 6, + margin: { + top: 1, + }, + padding: { + top: 1, + bottom: 1, + left: 7, + right: 7, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + }, + { + hover: { + ...text(layer, "sans", "hovered", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "hovered"), + } + } + ), + contactRow: { + inactive: { + default: { + padding: { left: sidePadding, right: sidePadding, + } }, - } + }, + active: { + default: { + background: background(layer, "active"), + padding: { + left: sidePadding, + right: sidePadding, + } + } + }, + }, - return { - background: background(layer), - padding: { top: 12 }, - userQueryEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - margin: { - left: 6, - }, - }, - userQueryEditorHeight: 33, - addContactButton: { - margin: { left: 6, right: 12 }, - color: foreground(layer, "on"), - buttonWidth: 28, - iconWidth: 16, - }, - rowHeight: 28, - sectionIconSize: 8, - headerRow: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, - }, - active: { - ...text(layer, "mono", "active", { size: "sm" }), - background: background(layer, "active"), - }, - }, - leaveCall: { - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, - }, - padding: { - top: 1, - bottom: 1, - left: 7, - right: 7, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - hover: { - ...text(layer, "sans", "hovered", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "hovered"), - }, - }, - contactRow: { - padding: { - left: sidePadding, - right: sidePadding, - }, - active: { - background: background(layer, "active"), - }, - }, - contactAvatar: { - cornerRadius: 10, - width: 18, - }, - contactStatusFree: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "positive"), - }, - contactStatusBusy: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "negative"), - }, - contactUsername: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - }, - }, - contactButtonSpacing: nameMargin, - contactButton: { - ...contactButton, - hover: { - background: background(layer, "hovered"), - }, - }, - disabledButton: { - ...contactButton, - background: background(layer, "on"), - color: foreground(layer, "on"), - }, - callingIndicator: { - ...text(layer, "mono", "variant", { size: "xs" }), - }, - treeBranch: { - color: borderColor(layer), - width: 1, - hover: { - color: borderColor(layer), - }, - active: { - color: borderColor(layer), - }, - }, - projectRow: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, - }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), - }, - hover: { - background: background(layer, "hovered"), - }, - active: { - background: background(layer, "active"), - }, - }, - } + contactAvatar: { + cornerRadius: 10, + width: 18, + }, + contactStatusFree: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "positive"), + }, + contactStatusBusy: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "negative"), + }, + contactUsername: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + }, + }, + contactButtonSpacing: nameMargin, + contactButton: interactive( + contactButton, + { + hover: { + background: background(layer, "hovered"), + }, + }), + disabledButton: { + ...contactButton, + background: background(layer, "on"), + color: foreground(layer, "on"), + }, + callingIndicator: { + ...text(layer, "mono", "variant", { size: "xs" }), + }, + treeBranch: toggleable(interactive({ + color: borderColor(layer), + width: 1, + }, + { + hover: { + color: borderColor(layer), + }, + }), + { + default: { + color: borderColor(layer), + }, + } + ), + projectRow: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, + hover: { + background: background(layer, "hovered"), + }, + active: { + background: background(layer, "active"), + }, + }, + } } diff --git a/styles/src/styleTree/contactNotification.ts b/styles/src/styleTree/contactNotification.ts index 85a0b9d0de1bb61f5d2f67a82da93a509ac4b9be..edef8dac20cd37aed08f8cec6e87c4af221f3e02 100644 --- a/styles/src/styleTree/contactNotification.ts +++ b/styles/src/styleTree/contactNotification.ts @@ -1,45 +1,52 @@ import { ColorScheme } from "../theme/colorScheme" import { background, foreground, text } from "./components" - +import { interactive } from "./interactive" const avatarSize = 12 const headerPadding = 8 export default function contactNotification(colorScheme: ColorScheme): Object { - let layer = colorScheme.lowest - return { - headerAvatar: { - height: avatarSize, - width: avatarSize, - cornerRadius: 6, - }, - headerMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, - }, - headerHeight: 18, - bodyMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: avatarSize + headerPadding, top: 6, bottom: 6 }, - }, - button: { - ...text(layer, "sans", "on", { size: "xs" }), - background: background(layer, "on"), - padding: 4, - cornerRadius: 6, - margin: { left: 6 }, - hover: { - background: background(layer, "on", "hovered"), - }, - }, - dismissButton: { - color: foreground(layer, "variant"), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), - }, + let layer = colorScheme.lowest + return { + headerAvatar: { + height: avatarSize, + width: avatarSize, + cornerRadius: 6, + }, + headerMessage: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, + }, + headerHeight: 18, + bodyMessage: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: avatarSize + headerPadding, top: 6, bottom: 6 }, + }, + button: + interactive({ + ...text(layer, "sans", "on", { size: "xs" }), + background: background(layer, "on"), + padding: 4, + cornerRadius: 6, + margin: { left: 6 } + }, + + { + hover: { + background: background(layer, "on", "hovered"), + } + }), + + dismissButton: { + default: { + color: foreground(layer, "variant"), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8, + hover: { + color: foreground(layer, "hovered"), }, - } + } + }, + } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index f14cd90219b5f5eddf5dd91fc64e01e120581f1f..b030d2797292fe745a7041fa17d0fb4e7d8127d1 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -1,49 +1,54 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, text } from "./components" +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function contextMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle - return { - background: background(layer), - cornerRadius: 10, - padding: 4, - shadow: colorScheme.popoverShadow, - border: border(layer), - keystrokeMargin: 30, - item: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - hover: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "hovered", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - }, - active: { - background: background(layer, "active"), - }, - activeHover: { - background: background(layer, "active"), - }, + let layer = colorScheme.middle + return { + background: background(layer), + cornerRadius: 10, + padding: 4, + shadow: colorScheme.popoverShadow, + border: border(layer), + keystrokeMargin: 30, + item: toggleable(interactive({ + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + } + }, { + hover: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, }, - separator: { - background: borderColor(layer), - margin: { top: 2, bottom: 2 }, - }, - } + } + }), { + default: { + background: background(layer, "active"), + }, + hover: { + background: background(layer, "active"), + }, + }), + + separator: { + background: borderColor(layer), + margin: { top: 2, bottom: 2 }, + }, + } } diff --git a/styles/src/styleTree/copilot.ts b/styles/src/styleTree/copilot.ts index 8614cb69764e06a3c64ac304ec028366a5315eeb..090d05eaee14af03b4cf1eb89958d884771937ec 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -1,267 +1,278 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, svg, text } from "./components" - +import { interactive } from "./interactive" export default function copilot(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - let content_width = 264 + let content_width = 264 - let ctaButton = { - // Copied from welcome screen. FIXME: Move this into a ZDS component - background: background(layer), - border: border(layer, "default"), - cornerRadius: 4, - margin: { - top: 4, - bottom: 4, - left: 8, - right: 8, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }), + let ctaButton = + // Copied from welcome screen. FIXME: Move this into a ZDS component + interactive({ + background: background(layer), + border: border(layer, "default"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + left: 8, + right: 8, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) + }, + { hover: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), }, - } + }); - return { - outLinkIcon: { - icon: svg( - foreground(layer, "variant"), - "icons/link_out_12.svg", - 12, - 12 - ), - container: { - cornerRadius: 6, - padding: { left: 6 }, - }, - hover: { - icon: svg( - foreground(layer, "hovered"), - "icons/link_out_12.svg", - 12, - 12 - ), - }, + return { + outLinkIcon: + interactive({ + icon: svg( + foreground(layer, "variant"), + "icons/link_out_12.svg", + 12, + 12 + ), + container: { + cornerRadius: 6, + padding: { left: 6 }, }, - modal: { - titleText: { - ...text(layer, "sans", { size: "xs", weight: "bold" }), - }, - titlebar: { - background: background(colorScheme.lowest), - border: border(layer, "active"), - padding: { - top: 4, - bottom: 4, - left: 8, - right: 8, - }, - }, - container: { - background: background(colorScheme.lowest), - padding: { - top: 0, - left: 0, - right: 0, - bottom: 8, - }, - }, - closeIcon: { - icon: svg( - foreground(layer, "variant"), - "icons/x_mark_8.svg", - 8, - 8 - ), - container: { - cornerRadius: 2, - padding: { - top: 4, - bottom: 4, - left: 4, - right: 4, - }, - margin: { - right: 0, - }, - }, - hover: { - icon: svg( - foreground(layer, "on"), - "icons/x_mark_8.svg", - 8, - 8 - ), - }, - clicked: { - icon: svg( - foreground(layer, "base"), - "icons/x_mark_8.svg", - 8, - 8 - ), - }, + }, + { + hover: { + icon: { + color: + foreground(layer, "hovered") + } + }, + }), + + modal: { + titleText: { + default: { + ...text(layer, "sans", { size: "xs", weight: "bold" }) + } + }, + titlebar: { + background: background(colorScheme.lowest), + border: border(layer, "active"), + padding: { + top: 4, + bottom: 4, + left: 8, + right: 8, + }, + }, + container: { + background: background(colorScheme.lowest), + padding: { + top: 0, + left: 0, + right: 0, + bottom: 8, + }, + }, + closeIcon: interactive( + { + icon: svg( + foreground(layer, "variant"), + "icons/x_mark_8.svg", + 8, + 8 + ), + container: { + cornerRadius: 2, + padding: { + top: 4, + bottom: 4, + left: 4, + right: 4, }, - dimensions: { - width: 280, - height: 280, + margin: { + right: 0, }, + } }, + { + hover: { + icon: svg( + foreground(layer, "on"), + "icons/x_mark_8.svg", + 8, + 8 + ), + }, + clicked: { + icon: svg( + foreground(layer, "base"), + "icons/x_mark_8.svg", + 8, + 8 + ), + }, + }), + dimensions: { + width: 280, + height: 280, + }, + }, - auth: { - content_width, + auth: { + content_width, - ctaButton, + ctaButton, - header: { - icon: svg( - foreground(layer, "default"), - "icons/zed_plus_copilot_32.svg", - 92, - 32 - ), - container: { - margin: { - top: 35, - bottom: 5, - left: 0, - right: 0, - }, - }, - }, + header: { + icon: svg( + foreground(layer, "default"), + "icons/zed_plus_copilot_32.svg", + 92, + 32 + ), + container: { + margin: { + top: 35, + bottom: 5, + left: 0, + right: 0, + }, + }, + }, - prompting: { - subheading: { - ...text(layer, "sans", { size: "xs" }), - margin: { - top: 6, - bottom: 12, - left: 0, - right: 0, - }, - }, + prompting: { + subheading: { + ...text(layer, "sans", { size: "xs" }), + margin: { + top: 6, + bottom: 12, + left: 0, + right: 0, + }, + }, - hint: { - ...text(layer, "sans", { size: "xs", color: "#838994" }), - margin: { - top: 6, - bottom: 2, - }, - }, + hint: { + ...text(layer, "sans", { size: "xs", color: "#838994" }), + margin: { + top: 6, + bottom: 2, + }, + }, - deviceCode: { - text: text(layer, "mono", { size: "sm" }), - cta: { - ...ctaButton, - background: background(colorScheme.lowest), - border: border(colorScheme.lowest, "inverted"), - padding: { - top: 0, - bottom: 0, - left: 16, - right: 16, - }, - margin: { - left: 16, - right: 16, - }, - }, - left: content_width / 2, - leftContainer: { - padding: { - top: 3, - bottom: 3, - left: 0, - right: 6, - }, - }, - right: (content_width * 1) / 3, - rightContainer: { - border: border(colorScheme.lowest, "inverted", { - bottom: false, - right: false, - top: false, - left: true, - }), - padding: { - top: 3, - bottom: 5, - left: 8, - right: 0, - }, - hover: { - border: border(layer, "active", { - bottom: false, - right: false, - top: false, - left: true, - }), - }, - }, - }, + deviceCode: { + text: text(layer, "mono", { size: "sm" }), + cta: { + ...ctaButton, + background: background(colorScheme.lowest), + border: border(colorScheme.lowest, "inverted"), + padding: { + top: 0, + bottom: 0, + left: 16, + right: 16, + }, + margin: { + left: 16, + right: 16, + }, + }, + left: content_width / 2, + leftContainer: { + padding: { + top: 3, + bottom: 3, + left: 0, + right: 6, + }, + }, + right: (content_width * 1) / 3, + rightContainer: interactive({ + border: border(colorScheme.lowest, "inverted", { + bottom: false, + right: false, + top: false, + left: true, + }), + padding: { + top: 3, + bottom: 5, + left: 8, + right: 0, + } + }, { + hover: { + border: border(layer, "active", { + bottom: false, + right: false, + top: false, + left: true, + }), }, + }) + }, + }, - notAuthorized: { - subheading: { - ...text(layer, "sans", { size: "xs" }), + notAuthorized: { + subheading: { + ...text(layer, "sans", { size: "xs" }), - margin: { - top: 16, - bottom: 16, - left: 0, - right: 0, - }, - }, + margin: { + top: 16, + bottom: 16, + left: 0, + right: 0, + }, + }, - warning: { - ...text(layer, "sans", { - size: "xs", - color: foreground(layer, "warning"), - }), - border: border(layer, "warning"), - background: background(layer, "warning"), - cornerRadius: 2, - padding: { - top: 4, - left: 4, - bottom: 4, - right: 4, - }, - margin: { - bottom: 16, - left: 8, - right: 8, - }, - }, - }, + warning: { + ...text(layer, "sans", { + size: "xs", + color: foreground(layer, "warning"), + }), + border: border(layer, "warning"), + background: background(layer, "warning"), + cornerRadius: 2, + padding: { + top: 4, + left: 4, + bottom: 4, + right: 4, + }, + margin: { + bottom: 16, + left: 8, + right: 8, + }, + }, + }, - authorized: { - subheading: { - ...text(layer, "sans", { size: "xs" }), + authorized: { + subheading: { + ...text(layer, "sans", { size: "xs" }), - margin: { - top: 16, - bottom: 16, - }, - }, + margin: { + top: 16, + bottom: 16, + }, + }, - hint: { - ...text(layer, "sans", { size: "xs", color: "#838994" }), - margin: { - top: 24, - bottom: 4, - }, - }, - }, + hint: { + ...text(layer, "sans", { size: "xs", color: "#838994" }), + margin: { + top: 24, + bottom: 4, + }, }, - } + }, + }, + } } diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 55f3da6e900f79a0f02f936b73dde9c376043027..ac7447de42dac543361c3a216cd1dcf23ea9107c 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -4,275 +4,284 @@ import { background, border, borderColor, foreground, text } from "./components" import hoverPopover from "./hoverPopover" import { buildSyntax } from "../theme/syntax" +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function editor(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.highest + let layer = colorScheme.highest - const autocompleteItem = { - cornerRadius: 6, - padding: { - bottom: 2, - left: 6, - right: 6, - top: 2, - }, - } + const autocompleteItem = { + cornerRadius: 6, + padding: { + bottom: 2, + left: 6, + right: 6, + top: 2, + }, + } - function diagnostic(layer: Layer, styleSet: StyleSets) { - return { - textScaleFactor: 0.857, - header: { - border: border(layer, { - top: true, - }), - }, - message: { - text: text(layer, "sans", styleSet, "default", { size: "sm" }), - highlightText: text(layer, "sans", styleSet, "default", { - size: "sm", - weight: "bold", - }), - }, - } + function diagnostic(layer: Layer, styleSet: StyleSets) { + return { + textScaleFactor: 0.857, + header: { + border: border(layer, { + top: true, + }), + }, + message: { + text: text(layer, "sans", styleSet, "default", { size: "sm" }), + highlightText: text(layer, "sans", styleSet, "default", { + size: "sm", + weight: "bold", + }), + }, } + } - const syntax = buildSyntax(colorScheme) - - return { - textColor: syntax.primary.color, - background: background(layer), - activeLineBackground: withOpacity(background(layer, "on"), 0.75), - highlightedLineBackground: background(layer, "on"), - // Inline autocomplete suggestions, Co-pilot suggestions, etc. - suggestion: syntax.predictive, - codeActions: { - indicator: { - color: foreground(layer, "variant"), + const syntax = buildSyntax(colorScheme) - clicked: { - color: foreground(layer, "base"), - }, - hover: { - color: foreground(layer, "on"), - }, - active: { - color: foreground(layer, "on"), - }, - }, - verticalScale: 0.55, + return { + textColor: syntax.primary.color, + background: background(layer), + activeLineBackground: withOpacity(background(layer, "on"), 0.75), + highlightedLineBackground: background(layer, "on"), + // Inline autocomplete suggestions, Co-pilot suggestions, etc. + suggestion: syntax.predictive, + codeActions: { + indicator: toggleable(interactive({ + color: foreground(layer, "variant"), + }, { + clicked: { + color: foreground(layer, "base"), }, - folds: { - iconMarginScale: 2.5, - foldedIcon: "icons/chevron_right_8.svg", - foldableIcon: "icons/chevron_down_8.svg", - indicator: { - color: foreground(layer, "variant"), + hover: { + color: foreground(layer, "on"), + }, + }), + { + default: { + color: foreground(layer, "on"), + } + }), - clicked: { - color: foreground(layer, "base"), - }, - hover: { - color: foreground(layer, "on"), - }, - active: { - color: foreground(layer, "on"), - }, - }, - ellipses: { - textColor: colorScheme.ramps.neutral(0.71).hex(), - cornerRadiusFactor: 0.15, - background: { - // Copied from hover_popover highlight - color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), + verticalScale: 0.55, + }, + folds: { + iconMarginScale: 2.5, + foldedIcon: "icons/chevron_right_8.svg", + foldableIcon: "icons/chevron_down_8.svg", + indicator: toggleable(interactive({ + color: foreground(layer, "variant"), + }, { + clicked: { + color: foreground(layer, "base"), + }, + hover: { + color: foreground(layer, "on"), + }, + }), + { + default: { + color: foreground(layer, "on"), + } + }), + ellipses: { + textColor: colorScheme.ramps.neutral(0.71).hex(), + cornerRadiusFactor: 0.15, + background: { + // Copied from hover_popover highlight + default: { color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex() }, - hover: { - color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), - }, + hover: { + color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), + }, - clicked: { - color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), - }, - }, - }, - foldBackground: foreground(layer, "variant"), + clicked: { + color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), + }, }, - diff: { - deleted: isLight - ? colorScheme.ramps.red(0.5).hex() - : colorScheme.ramps.red(0.4).hex(), - modified: isLight - ? colorScheme.ramps.yellow(0.5).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.4).hex() - : colorScheme.ramps.green(0.5).hex(), - removedWidthEm: 0.275, - widthEm: 0.15, - cornerRadius: 0.05, - }, - /** Highlights matching occurrences of what is under the cursor - * as well as matched brackets - */ - documentHighlightReadBackground: withOpacity( - foreground(layer, "accent"), - 0.1 + }, + foldBackground: foreground(layer, "variant"), + }, + diff: { + deleted: isLight + ? colorScheme.ramps.red(0.5).hex() + : colorScheme.ramps.red(0.4).hex(), + modified: isLight + ? colorScheme.ramps.yellow(0.5).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.4).hex() + : colorScheme.ramps.green(0.5).hex(), + removedWidthEm: 0.275, + widthEm: 0.15, + cornerRadius: 0.05, + }, + /** Highlights matching occurrences of what is under the cursor + * as well as matched brackets + */ + documentHighlightReadBackground: withOpacity( + foreground(layer, "accent"), + 0.1 + ), + documentHighlightWriteBackground: colorScheme.ramps + .neutral(0.5) + .alpha(0.4) + .hex(), // TODO: This was blend * 2 + errorColor: background(layer, "negative"), + gutterBackground: background(layer), + gutterPaddingFactor: 3.5, + lineNumber: withOpacity(foreground(layer), 0.35), + lineNumberActive: foreground(layer), + renameFade: 0.6, + unnecessaryCodeFade: 0.5, + selection: colorScheme.players[0], + whitespace: colorScheme.ramps.neutral(0.5).hex(), + guestSelections: [ + colorScheme.players[1], + colorScheme.players[2], + colorScheme.players[3], + colorScheme.players[4], + colorScheme.players[5], + colorScheme.players[6], + colorScheme.players[7], + ], + autocomplete: { + background: background(colorScheme.middle), + cornerRadius: 8, + padding: 4, + margin: { + left: -14, + }, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + matchHighlight: foreground(colorScheme.middle, "accent"), + item: autocompleteItem, + hoveredItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "hovered" ), - documentHighlightWriteBackground: colorScheme.ramps - .neutral(0.5) - .alpha(0.4) - .hex(), // TODO: This was blend * 2 - errorColor: background(layer, "negative"), - gutterBackground: background(layer), - gutterPaddingFactor: 3.5, - lineNumber: withOpacity(foreground(layer), 0.35), - lineNumberActive: foreground(layer), - renameFade: 0.6, - unnecessaryCodeFade: 0.5, - selection: colorScheme.players[0], - whitespace: colorScheme.ramps.neutral(0.5).hex(), - guestSelections: [ - colorScheme.players[1], - colorScheme.players[2], - colorScheme.players[3], - colorScheme.players[4], - colorScheme.players[5], - colorScheme.players[6], - colorScheme.players[7], - ], - autocomplete: { - background: background(colorScheme.middle), - cornerRadius: 8, - padding: 4, - margin: { - left: -14, - }, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - matchHighlight: foreground(colorScheme.middle, "accent"), - item: autocompleteItem, - hoveredItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "hovered" - ), - background: background(colorScheme.middle, "hovered"), - }, - selectedItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "active" - ), - background: background(colorScheme.middle, "active"), - }, - }, - diagnosticHeader: { - background: background(colorScheme.middle), - iconWidthFactor: 1.5, - textScaleFactor: 0.857, - border: border(colorScheme.middle, { - bottom: true, - top: true, - }), - code: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 10, - }, - }, - source: { - text: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - }, - message: { - highlightText: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - text: text(colorScheme.middle, "sans", { size: "sm" }), - }, - }, - diagnosticPathHeader: { - background: background(colorScheme.middle), - textScaleFactor: 0.857, - filename: text(colorScheme.middle, "mono", { size: "sm" }), - path: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 12, - }, - }, - }, - errorDiagnostic: diagnostic(colorScheme.middle, "negative"), - warningDiagnostic: diagnostic(colorScheme.middle, "warning"), - informationDiagnostic: diagnostic(colorScheme.middle, "accent"), - hintDiagnostic: diagnostic(colorScheme.middle, "warning"), - invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), - hoverPopover: hoverPopover(colorScheme), - linkDefinition: { - color: syntax.linkUri.color, - underline: syntax.linkUri.underline, - }, - jumpIcon: { - color: foreground(layer, "on"), - iconWidth: 20, - buttonWidth: 20, - cornerRadius: 6, - padding: { - top: 6, - bottom: 6, - left: 6, - right: 6, - }, - hover: { - background: background(layer, "on", "hovered"), - }, + background: background(colorScheme.middle, "hovered"), + }, + selectedItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "active" + ), + background: background(colorScheme.middle, "active"), + }, + }, + diagnosticHeader: { + background: background(colorScheme.middle), + iconWidthFactor: 1.5, + textScaleFactor: 0.857, + border: border(colorScheme.middle, { + bottom: true, + top: true, + }), + code: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 10, }, - scrollbar: { - width: 12, - minHeightFactor: 1.0, - track: { - border: border(layer, "variant", { left: true }), - }, - thumb: { - background: withOpacity(background(layer, "inverted"), 0.3), - border: { - width: 1, - color: borderColor(layer, "variant"), - top: false, - right: true, - left: true, - bottom: false, - }, - }, - git: { - deleted: isLight - ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), - modified: isLight - ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), - inserted: isLight - ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), - }, + }, + source: { + text: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + }, + message: { + highlightText: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + text: text(colorScheme.middle, "sans", { size: "sm" }), + }, + }, + diagnosticPathHeader: { + background: background(colorScheme.middle), + textScaleFactor: 0.857, + filename: text(colorScheme.middle, "mono", { size: "sm" }), + path: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 12, }, - compositionMark: { - underline: { - thickness: 1.0, - color: borderColor(layer), - }, + }, + }, + errorDiagnostic: diagnostic(colorScheme.middle, "negative"), + warningDiagnostic: diagnostic(colorScheme.middle, "warning"), + informationDiagnostic: diagnostic(colorScheme.middle, "accent"), + hintDiagnostic: diagnostic(colorScheme.middle, "warning"), + invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), + hoverPopover: hoverPopover(colorScheme), + linkDefinition: { + color: syntax.linkUri.color, + underline: syntax.linkUri.underline, + }, + jumpIcon: interactive({ + color: foreground(layer, "on"), + iconWidth: 20, + buttonWidth: 20, + cornerRadius: 6, + padding: { + top: 6, + bottom: 6, + left: 6, + right: 6, + } + }, { + hover: { + background: background(layer, "on", "hovered"), + } + }), + + scrollbar: { + width: 12, + minHeightFactor: 1.0, + track: { + border: border(layer, "variant", { left: true }), + }, + thumb: { + background: withOpacity(background(layer, "inverted"), 0.3), + border: { + width: 1, + color: borderColor(layer, "variant"), + top: false, + right: true, + left: true, + bottom: false, }, - syntax, - } + }, + git: { + deleted: isLight + ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), + modified: isLight + ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), + inserted: isLight + ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), + }, + }, + compositionMark: { + underline: { + thickness: 1.0, + color: borderColor(layer), + }, + }, + syntax, + } } diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index d84bd6fc7a2cec4a818f920bfc62040c638e4b71..ecf34a9927146920f0355696d86b6ab93b32c6a0 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -1,82 +1,86 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, text } from "./components" +import { toggleable } from "./toggle" +import { interactive } from "./interactive" export default function picker(colorScheme: ColorScheme): any { - let layer = colorScheme.lowest - const container = { - background: background(layer), - border: border(layer), - shadow: colorScheme.modalShadow, - cornerRadius: 12, - padding: { - bottom: 4, - }, - } - const inputEditor = { - placeholderText: text(layer, "sans", "on", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "on"), - border: border(layer, { bottom: true }), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - margin: { - bottom: 4, - }, - } - const emptyInputEditor: any = { ...inputEditor } - delete emptyInputEditor.border - delete emptyInputEditor.margin + let layer = colorScheme.lowest + const container = { + background: background(layer), + border: border(layer), + shadow: colorScheme.modalShadow, + cornerRadius: 12, + padding: { + bottom: 4, + }, + } + const inputEditor = { + placeholderText: text(layer, "sans", "on", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "on"), + border: border(layer, { bottom: true }), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + margin: { + bottom: 4, + }, + } + const emptyInputEditor: any = { ...inputEditor } + delete emptyInputEditor.border + delete emptyInputEditor.margin - return { - ...container, - emptyContainer: { - ...container, - padding: {}, - }, - item: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, - }, - margin: { - top: 1, - left: 4, - right: 4, - }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { weight: "bold" }), - active: { - background: withOpacity( - background(layer, "base", "active"), - 0.5 - ), - text: text(layer, "sans", "base", "active"), - highlightText: text(layer, "sans", "accent", { - weight: "bold", - }), - }, - hover: { - background: withOpacity(background(layer, "hovered"), 0.5), - }, - }, - inputEditor, - emptyInputEditor, - noMatches: { - text: text(layer, "sans", "variant"), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - }, - } + return { + ...container, + emptyContainer: { + ...container, + padding: {}, + }, + item: toggleable(interactive({ + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, + }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { weight: "bold" }), + }, { + hover: { + background: withOpacity(background(layer, "hovered"), 0.5), + } + }), + { + default: { + background: withOpacity( + background(layer, "base", "active"), + 0.5 + ), + //text: text(layer, "sans", "base", "active"), + } + }), + + + inputEditor, + emptyInputEditor, + noMatches: { + text: text(layer, "sans", "variant"), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + }, + } } diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index a86ae010b605fc26f206cdc4219d9594c496e079..57abd0dafce9adb4cd13bd4b42ea610656716c8e 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,107 +1,119 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" - +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function projectPanel(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.middle + let layer = colorScheme.middle - let baseEntry = { - height: 22, - iconColor: foreground(layer, "variant"), - iconSize: 7, - iconSpacing: 5, - } + let baseEntry = { + height: 22, + iconColor: foreground(layer, "variant"), + iconSize: 7, + iconSpacing: 5, + } - let status = { - git: { - modified: isLight - ? colorScheme.ramps.yellow(0.6).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.45).hex() - : colorScheme.ramps.green(0.5).hex(), - conflict: isLight - ? colorScheme.ramps.red(0.6).hex() - : colorScheme.ramps.red(0.5).hex(), - }, - } + let status = { + git: { + modified: isLight + ? colorScheme.ramps.yellow(0.6).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.45).hex() + : colorScheme.ramps.green(0.5).hex(), + conflict: isLight + ? colorScheme.ramps.red(0.6).hex() + : colorScheme.ramps.red(0.5).hex(), + }, + } - let entry = { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - hover: { - background: background(layer, "variant", "hovered"), - }, - active: { - background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - activeHover: { - background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - status, - } + let entry = toggleable(interactive({ + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, + { + hover: { + background: background(layer, "variant", "hovered"), + } + }), + { + default: { + /*background: colorScheme.isLight + ? withOpacity(background(layer, "active"), 0.5) + : background(layer, "active") ,*/ // todo posiewic + text: text(layer, "mono", "active", { size: "sm" }), + }, + hover: { + //background: background(layer, "active"), + text: text(layer, "mono", "active", { size: "sm" }), + }, - return { - openProjectButton: { - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 16, - left: 16, - right: 16, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }), - hover: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - background: background(layer), - padding: { left: 6, right: 6, top: 0, bottom: 6 }, - indentWidth: 12, - entry, - draggedEntry: { - ...baseEntry, - text: text(layer, "mono", "on", { size: "sm" }), - background: withOpacity(background(layer, "on"), 0.9), - border: border(layer), - status, - }, - ignoredEntry: { - ...entry, - iconColor: foreground(layer, "disabled"), - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - iconColor: foreground(layer, "variant"), - }, - }, - cutEntry: { - ...entry, - text: text(layer, "mono", "disabled"), - active: { - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), - }, - }, - filenameEditor: { - background: background(layer, "on"), - text: text(layer, "mono", "on", { size: "sm" }), - selection: colorScheme.players[0], + }); + + return { + openProjectButton: interactive({ + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 16, + left: 16, + right: 16, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) + }, { + hover: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + }), + background: background(layer), + padding: { left: 6, right: 6, top: 0, bottom: 6 }, + indentWidth: 12, + entry, + draggedEntry: { + ...baseEntry, + text: text(layer, "mono", "on", { size: "sm" }), + background: withOpacity(background(layer, "on"), 0.9), + border: border(layer), + status, + }, + ignoredEntry: { + ...entry, + iconColor: foreground(layer, "disabled"), + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + iconColor: foreground(layer, "variant"), + }, + }, + cutEntry: { + ...entry, + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + default: { + ...entry.active.default, + background: background(layer, "active"), + text: text(layer, "mono", "disabled", { size: "sm" }), }, - } + + }, + }, + filenameEditor: { + background: background(layer, "on"), + text: text(layer, "mono", "on", { size: "sm" }), + selection: colorScheme.players[0], + }, + } } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index a8d926f40e44d0f372278fae7961e70693bf605e..66643dbde1ae4e6783a365ea65d3ad88c91f645a 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -1,126 +1,135 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" - +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function statusBar(colorScheme: ColorScheme) { - let layer = colorScheme.lowest + let layer = colorScheme.lowest - const statusContainer = { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 6, right: 6 }, - } + const statusContainer = { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 6, right: 6 }, + } - const diagnosticStatusContainer = { - cornerRadius: 6, - padding: { top: 1, bottom: 1, left: 6, right: 6 }, - } + const diagnosticStatusContainer = { + cornerRadius: 6, + padding: { top: 1, bottom: 1, left: 6, right: 6 }, + } - return { - height: 30, - itemSpacing: 8, - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - border: border(layer, { top: true, overlay: true }), - cursorPosition: text(layer, "sans", "variant"), - activeLanguage: { - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant"), - hover: { - ...text(layer, "sans", "on"), - }, - }, - autoUpdateProgressMessage: text(layer, "sans", "variant"), - autoUpdateDoneMessage: text(layer, "sans", "variant"), - lspStatus: { - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer), - hover: { - message: text(layer, "sans"), - iconColor: foreground(layer), - background: background(layer, "hovered"), - }, - }, - diagnosticMessage: { - ...text(layer, "sans"), - hover: text(layer, "sans", "hovered"), + return { + height: 30, + itemSpacing: 8, + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + border: border(layer, { top: true, overlay: true }), + cursorPosition: text(layer, "sans", "variant"), + activeLanguage: interactive({ + padding: { left: 6, right: 6 }, + ...text(layer, "sans", "variant") + }, + { + hover: { + ...text(layer, "sans", "on"), + } + }, + ), + autoUpdateProgressMessage: text(layer, "sans", "variant"), + autoUpdateDoneMessage: text(layer, "sans", "variant"), + lspStatus: interactive({ + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, + message: text(layer, "sans"), + iconColor: foreground(layer) + }, + { + hover: { + message: text(layer, "sans"), + iconColor: foreground(layer), + background: background(layer, "hovered"), + } + }), + diagnosticMessage: interactive({ + ...text(layer, "sans") + }, + { hover: text(layer, "sans", "hovered") }, + ), + diagnosticSummary: + interactive({ + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), + containerOk: { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, }, - diagnosticSummary: { - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - }, - hover: { - iconColorOk: foreground(layer, "on"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - background: background(layer, "on", "hovered"), - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), - }, - }, + containerWarning: { + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), }, - panelButtons: { - groupLeft: {}, - groupBottom: {}, - groupRight: {}, - button: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, - hover: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - }, - active: { - iconColor: foreground(layer, "active"), - background: background(layer, "active"), - }, - }, - badge: { - cornerRadius: 3, - padding: 2, - margin: { bottom: -1, right: -1 }, - border: border(layer), - background: background(layer, "accent"), - }, + containerError: { + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + } + }, { + hover: { + iconColorOk: foreground(layer, "on"), + containerOk: { + background: background(layer, "on", "hovered"), + }, + containerWarning: { + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), + }, + containerError: { + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + } + } + } + ), + panelButtons: { + groupLeft: {}, + groupBottom: {}, + groupRight: {}, + button: toggleable(interactive({ + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), }, - } + }, { + hover: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + } + }), + { + default: { + iconColor: foreground(layer, "active"), + background: background(layer, "active"), + } + }), + badge: { + cornerRadius: 3, + padding: 2, + margin: { bottom: -1, right: -1 }, + border: border(layer), + background: background(layer, "accent"), + }, + }, + } } diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index c5b397b34a3e176207b75f965aadbceeb4611e37..6799b0a9e3272da327fa19b14fd02f2acb77375b 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -1,109 +1,116 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, border, background, foreground } from "./components" +import { toggleable } from "./toggle" +import { interactive } from "./interactive" export default function tabBar(colorScheme: ColorScheme) { - const height = 32 + const height = 32 - let activeLayer = colorScheme.highest - let layer = colorScheme.middle + let activeLayer = colorScheme.highest + let layer = colorScheme.middle - const tab = { - height, - text: text(layer, "sans", "variant", { size: "sm" }), - background: background(layer), - border: border(layer, { - right: true, - bottom: true, - overlay: true, - }), - padding: { - left: 8, - right: 12, - }, - spacing: 8, + const tab = { + height, + text: text(layer, "sans", "variant", { size: "sm" }), + background: background(layer), + border: border(layer, { + right: true, + bottom: true, + overlay: true, + }), + padding: { + left: 8, + right: 12, + }, + spacing: 8, - // Tab type icons (e.g. Project Search) - typeIconWidth: 14, + // Tab type icons (e.g. Project Search) + typeIconWidth: 14, - // Close icons - closeIconWidth: 8, - iconClose: foreground(layer, "variant"), - iconCloseActive: foreground(layer, "hovered"), + // Close icons + closeIconWidth: 8, + iconClose: foreground(layer, "variant"), + iconCloseActive: foreground(layer, "hovered"), - // Indicators - iconConflict: foreground(layer, "warning"), - iconDirty: foreground(layer, "accent"), + // Indicators + iconConflict: foreground(layer, "warning"), + iconDirty: foreground(layer, "accent"), - // When two tabs of the same name are open, a label appears next to them - description: { - margin: { left: 8 }, - ...text(layer, "sans", "disabled", { size: "2xs" }), - }, - } + // When two tabs of the same name are open, a label appears next to them + description: { + margin: { left: 8 }, + ...text(layer, "sans", "disabled", { size: "2xs" }), + }, + } - const activePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(activeLayer, "sans", "active", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const activePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(activeLayer, "sans", "active", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const inactivePaneInactiveTab = { - ...tab, - background: background(layer), - text: text(layer, "sans", "variant", { size: "sm" }), - } + const inactivePaneInactiveTab = { + ...tab, + background: background(layer), + text: text(layer, "sans", "variant", { size: "sm" }), + } - const inactivePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(layer, "sans", "variant", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const inactivePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(layer, "sans", "variant", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const draggedTab = { - ...activePaneActiveTab, - background: withOpacity(tab.background, 0.9), - border: undefined as any, - shadow: colorScheme.popoverShadow, - } + const draggedTab = { + ...activePaneActiveTab, + background: withOpacity(tab.background, 0.9), + border: undefined as any, + shadow: colorScheme.popoverShadow, + } - return { - height, - background: background(layer), - activePane: { - activeTab: activePaneActiveTab, - inactiveTab: tab, - }, - inactivePane: { - activeTab: inactivePaneActiveTab, - inactiveTab: inactivePaneInactiveTab, - }, - draggedTab, - paneButton: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - hover: { - color: foreground(layer, "hovered"), - }, - active: { - color: foreground(layer, "accent"), - }, - }, - paneButtonContainer: { - background: tab.background, - border: { - ...tab.border, - right: false, - }, - }, - } + return { + height, + background: background(layer), + activePane: { + activeTab: activePaneActiveTab, + inactiveTab: tab, + }, + inactivePane: { + activeTab: inactivePaneActiveTab, + inactiveTab: inactivePaneInactiveTab, + }, + draggedTab, + paneButton: toggleable(interactive({ + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + { + hover: { + color: foreground(layer, "hovered"), + } + }), + { + default: { + color: foreground(layer, "accent"), + } + }, + ), + paneButtonContainer: { + background: tab.background, + border: { + ...tab.border, + right: false, + }, + }, + } } diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index 10e6e02b953addb6e44165b1a387eb284e852d1c..dbabc553830eac93a887a254e3632b617118dd8f 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -1,129 +1,131 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { - border, - background, - foreground, - text, - TextProperties, - svg, + border, + background, + foreground, + text, + TextProperties, + svg, } from "./components" +import { interactive } from "./interactive" export default function welcome(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - let checkboxBase = { - cornerRadius: 4, - padding: { - left: 3, - right: 3, - top: 3, - bottom: 3, - }, - // shadow: colorScheme.popoverShadow, - border: border(layer), - margin: { - right: 8, - top: 5, - bottom: 5, - }, - } + let checkboxBase = { + cornerRadius: 4, + padding: { + left: 3, + right: 3, + top: 3, + bottom: 3, + }, + // shadow: colorScheme.popoverShadow, + border: border(layer), + margin: { + right: 8, + top: 5, + bottom: 5, + }, + } - let interactive_text_size: TextProperties = { size: "sm" } + let interactive_text_size: TextProperties = { size: "sm" } - return { - pageWidth: 320, - logo: svg(foreground(layer, "default"), "icons/logo_96.svg", 64, 64), - logoSubheading: { - ...text(layer, "sans", "variant", { size: "md" }), - margin: { - top: 10, - bottom: 7, - }, - }, - buttonGroup: { - margin: { - top: 8, - bottom: 16, - }, - }, - headingGroup: { - margin: { - top: 8, - bottom: 12, - }, - }, - checkboxGroup: { - border: border(layer, "variant"), - background: withOpacity(background(layer, "hovered"), 0.25), - cornerRadius: 4, - padding: { - left: 12, - top: 2, - bottom: 2, - }, - }, - button: { - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 4, - bottom: 4, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", interactive_text_size), - hover: { - ...text(layer, "sans", "default", interactive_text_size), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - usageNote: { - ...text(layer, "sans", "variant", { size: "2xs" }), - padding: { - top: -4, - }, - }, - checkboxContainer: { - margin: { - top: 4, - }, - padding: { - bottom: 8, - }, - }, - checkbox: { - label: { - ...text(layer, "sans", interactive_text_size), - // Also supports margin, container, border, etc. - }, - icon: svg(foreground(layer, "on"), "icons/check_12.svg", 12, 12), - default: { - ...checkboxBase, - background: background(layer, "default"), - border: border(layer, "active"), - }, - checked: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - hovered: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - hoveredAndChecked: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - } + return { + pageWidth: 320, + logo: svg(foreground(layer, "default"), "icons/logo_96.svg", 64, 64), + logoSubheading: { + ...text(layer, "sans", "variant", { size: "md" }), + margin: { + top: 10, + bottom: 7, + }, + }, + buttonGroup: { + margin: { + top: 8, + bottom: 16, + }, + }, + headingGroup: { + margin: { + top: 8, + bottom: 12, + }, + }, + checkboxGroup: { + border: border(layer, "variant"), + background: withOpacity(background(layer, "hovered"), 0.25), + cornerRadius: 4, + padding: { + left: 12, + top: 2, + bottom: 2, + }, + }, + button: interactive({ + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", interactive_text_size) + }, { + hover: { + ...text(layer, "sans", "default", interactive_text_size), + background: background(layer, "hovered"), + } + }), + + usageNote: { + ...text(layer, "sans", "variant", { size: "2xs" }), + padding: { + top: -4, + }, + }, + checkboxContainer: { + margin: { + top: 4, + }, + padding: { + bottom: 8, + }, + }, + checkbox: { + label: { + ...text(layer, "sans", interactive_text_size), + // Also supports margin, container, border, etc. + }, + icon: svg(foreground(layer, "on"), "icons/check_12.svg", 12, 12), + default: { + ...checkboxBase, + background: background(layer, "default"), + border: border(layer, "active"), + }, + checked: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + hovered: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + hoveredAndChecked: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + }, + } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index ae8de178f88c5abfb3fb76af4cda4e386ff748d1..18341fc51e08ced69b82a594116cc792de0e5706 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -1,338 +1,372 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" +import { toggleable } from "./toggle" import { - background, - border, - borderColor, - foreground, - svg, - text, + background, + border, + borderColor, + foreground, + svg, + text, } from "./components" import statusBar from "./statusBar" import tabBar from "./tabBar" - +import { interactive } from "./interactive" +import merge from 'ts-deepmerge'; export default function workspace(colorScheme: ColorScheme) { - const layer = colorScheme.lowest - const isLight = colorScheme.isLight - const itemSpacing = 8 - const titlebarButton = { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - hover: { - ...text(layer, "sans", "variant", "hovered", { size: "xs" }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { size: "xs" }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - }, - active: { - ...text(layer, "sans", "variant", "active", { size: "xs" }), - background: background(layer, "variant", "active"), - border: border(layer, "variant", "active"), - }, + const layer = colorScheme.lowest + const isLight = colorScheme.isLight + const itemSpacing = 8 + const titlebarButton = toggleable(interactive({ + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, { + hover: { + ...text(layer, "sans", "variant", "hovered", { size: "xs" }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { size: "xs" }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), } - const avatarWidth = 18 - const avatarOuterWidth = avatarWidth + 4 - const followerAvatarWidth = 14 - const followerAvatarOuterWidth = followerAvatarWidth + 4 + }), + { + default: { + ...text(layer, "sans", "variant", "active", { size: "xs" }), + background: background(layer, "variant", "active"), + border: border(layer, "variant", "active"), + } + }, + ); + const avatarWidth = 18 + const avatarOuterWidth = avatarWidth + 4 + const followerAvatarWidth = 14 + const followerAvatarOuterWidth = followerAvatarWidth + 4 - return { - background: background(colorScheme.lowest), - blankPane: { - logoContainer: { - width: 256, - height: 256, - }, - logo: svg( - withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), - "icons/logo_96.svg", - 256, - 256 - ), + return { + background: background(colorScheme.lowest), + blankPane: { + logoContainer: { + width: 256, + height: 256, + }, + logo: svg( + withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), + "icons/logo_96.svg", + 256, + 256 + ), - logoShadow: svg( - withOpacity( - colorScheme.isLight - ? "#FFFFFF" - : colorScheme.lowest.base.default.background, - colorScheme.isLight ? 1 : 0.6 - ), - "icons/logo_96.svg", - 256, - 256 - ), - keyboardHints: { - margin: { - top: 96, - }, - cornerRadius: 4, - }, - keyboardHint: { - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8, - hover: { - ...text(layer, "sans", "active", { size: "sm" }), - }, - }, - keyboardHintWidth: 320, - }, - joiningProjectAvatar: { - cornerRadius: 40, - width: 80, - }, - joiningProjectMessage: { - padding: 12, - ...text(layer, "sans", { size: "lg" }), - }, - externalLocationMessage: { - background: background(colorScheme.middle, "accent"), - border: border(colorScheme.middle, "accent"), - cornerRadius: 6, - padding: 12, - margin: { bottom: 8, right: 8 }, - ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), - }, - leaderBorderOpacity: 0.7, - leaderBorderWidth: 2.0, - tabBar: tabBar(colorScheme), - modal: { - margin: { - bottom: 52, - top: 52, - }, - cursor: "Arrow", - }, - zoomedBackground: { - cursor: "Arrow", - background: isLight - ? withOpacity(background(colorScheme.lowest), 0.8) - : withOpacity(background(colorScheme.highest), 0.6), - }, - zoomedPaneForeground: { - margin: 16, - shadow: colorScheme.modalShadow, - border: border(colorScheme.lowest, { overlay: true }), - }, - zoomedPanelForeground: { - margin: 16, - border: border(colorScheme.lowest, { overlay: true }), + logoShadow: svg( + withOpacity( + colorScheme.isLight + ? "#FFFFFF" + : colorScheme.lowest.base.default.background, + colorScheme.isLight ? 1 : 0.6 + ), + "icons/logo_96.svg", + 256, + 256 + ), + keyboardHints: { + margin: { + top: 96, }, - dock: { - left: { - border: border(layer, { right: true }), - }, - bottom: { - border: border(layer, { top: true }), - }, - right: { - border: border(layer, { left: true }), - }, - }, - paneDivider: { - color: borderColor(layer), - width: 1, - }, - statusBar: statusBar(colorScheme), - titlebar: { - itemSpacing, - facePileSpacing: 2, - height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. - background: background(layer), - border: border(layer, { bottom: true }), - padding: { - left: 80, - right: itemSpacing, - }, + cornerRadius: 4, + }, + keyboardHint: + interactive({ + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8 + }, { + hover: { + ...text(layer, "sans", "active", { size: "sm" }), + } + }), - // Project - title: text(layer, "sans", "variant"), - highlight_color: text(layer, "sans", "active").color, + keyboardHintWidth: 320, + }, + joiningProjectAvatar: { + cornerRadius: 40, + width: 80, + }, + joiningProjectMessage: { + padding: 12, + ...text(layer, "sans", { size: "lg" }), + }, + externalLocationMessage: { + background: background(colorScheme.middle, "accent"), + border: border(colorScheme.middle, "accent"), + cornerRadius: 6, + padding: 12, + margin: { bottom: 8, right: 8 }, + ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), + }, + leaderBorderOpacity: 0.7, + leaderBorderWidth: 2.0, + tabBar: tabBar(colorScheme), + modal: { + margin: { + bottom: 52, + top: 52, + }, + cursor: "Arrow", + }, + zoomedBackground: { + cursor: "Arrow", + background: isLight + ? withOpacity(background(colorScheme.lowest), 0.8) + : withOpacity(background(colorScheme.highest), 0.6), + }, + zoomedPaneForeground: { + margin: 16, + shadow: colorScheme.modalShadow, + border: border(colorScheme.lowest, { overlay: true }), + }, + zoomedPanelForeground: { + margin: 16, + border: border(colorScheme.lowest, { overlay: true }), + }, + dock: { + left: { + border: border(layer, { right: true }), + }, + bottom: { + border: border(layer, { top: true }), + }, + right: { + border: border(layer, { left: true }), + }, + }, + paneDivider: { + color: borderColor(layer), + width: 1, + }, + statusBar: statusBar(colorScheme), + titlebar: { + itemSpacing, + facePileSpacing: 2, + height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. + background: background(layer), + border: border(layer, { bottom: true }), + padding: { + left: 80, + right: itemSpacing, + }, - // Collaborators - leaderAvatar: { - width: avatarWidth, - outerWidth: avatarOuterWidth, - cornerRadius: avatarWidth / 2, - outerCornerRadius: avatarOuterWidth / 2, - }, - followerAvatar: { - width: followerAvatarWidth, - outerWidth: followerAvatarOuterWidth, - cornerRadius: followerAvatarWidth / 2, - outerCornerRadius: followerAvatarOuterWidth / 2, - }, - inactiveAvatarGrayscale: true, - followerAvatarOverlap: 8, - leaderSelection: { - margin: { - top: 4, - bottom: 4, - }, - padding: { - left: 2, - right: 2, - top: 2, - bottom: 2, - }, - cornerRadius: 6, - }, - avatarRibbon: { - height: 3, - width: 12, - // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. - }, + // Project + title: text(layer, "sans", "variant"), + highlight_color: text(layer, "sans", "active").color, - // Sign in buttom - // FlatButton, Variant - signInPrompt: { - margin: { - left: itemSpacing, - }, - ...titlebarButton, - }, + // Collaborators + leaderAvatar: { + width: avatarWidth, + outerWidth: avatarOuterWidth, + cornerRadius: avatarWidth / 2, + outerCornerRadius: avatarOuterWidth / 2, + }, + followerAvatar: { + width: followerAvatarWidth, + outerWidth: followerAvatarOuterWidth, + cornerRadius: followerAvatarWidth / 2, + outerCornerRadius: followerAvatarOuterWidth / 2, + }, + inactiveAvatarGrayscale: true, + followerAvatarOverlap: 8, + leaderSelection: { + margin: { + top: 4, + bottom: 4, + }, + padding: { + left: 2, + right: 2, + top: 2, + bottom: 2, + }, + cornerRadius: 6, + }, + avatarRibbon: { + height: 3, + width: 12, + // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. + }, - // Offline Indicator - offlineIcon: { - color: foreground(layer, "variant"), - width: 16, + // Sign in buttom + // FlatButton, Variant + signInPrompt: + merge(titlebarButton, + { + inactive: { + default: { margin: { - left: itemSpacing, + left: itemSpacing, }, - padding: { - right: 4, - }, - }, + } + } + }), - // Notice that the collaboration server is out of date - outdatedWarning: { - ...text(layer, "sans", "warning", { size: "xs" }), - background: withOpacity(background(layer, "warning"), 0.3), - border: border(layer, "warning"), - margin: { - left: itemSpacing, - }, - padding: { - left: 8, - right: 8, - }, - cornerRadius: 6, - }, - callControl: { - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - hover: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - }, - toggleContactsButton: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - active: { - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active"), - }, - clicked: { - background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), - }, - hover: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - }, - userMenuButton: { - buttonWidth: 20, - iconWidth: 12, - ...titlebarButton, - }, - toggleContactsBadge: { - cornerRadius: 3, - padding: 2, - margin: { top: 3, left: 3 }, - border: border(layer), - background: foreground(layer, "accent"), - }, - shareButton: { - ...titlebarButton, - }, + + // Offline Indicator + offlineIcon: { + color: foreground(layer, "variant"), + width: 16, + margin: { + left: itemSpacing, + }, + padding: { + right: 4, }, + }, - toolbar: { - height: 34, - background: background(colorScheme.highest), - border: border(colorScheme.highest, { bottom: true }), - itemSpacing: 8, - navButton: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, - hover: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - disabled: { - color: foreground(colorScheme.highest, "on", "disabled"), - }, - }, - padding: { left: 8, right: 8, top: 4, bottom: 4 }, + // Notice that the collaboration server is out of date + outdatedWarning: { + ...text(layer, "sans", "warning", { size: "xs" }), + background: withOpacity(background(layer, "warning"), 0.3), + border: border(layer, "warning"), + margin: { + left: itemSpacing, + }, + padding: { + left: 8, + right: 8, }, - breadcrumbHeight: 24, - breadcrumbs: { - ...text(colorScheme.highest, "sans", "variant"), - cornerRadius: 6, - padding: { - left: 6, - right: 6, - }, - hover: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background(colorScheme.highest, "on", "hovered"), - }, + cornerRadius: 6, + }, + callControl: interactive({ + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 20, + }, { + hover: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), }, - disconnectedOverlay: { - ...text(layer, "sans"), - background: withOpacity(background(layer), 0.8), + }), + toggleContactsButton: toggleable(interactive({ + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + { + clicked: { + background: background(layer, "variant", "pressed"), + color: foreground(layer, "variant", "pressed"), + }, + hover: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + } + }), + { + default: { + background: background(layer, "variant", "active"), + color: foreground(layer, "variant", "active") + } }, - notification: { - margin: { top: 10 }, - background: background(colorScheme.middle), - cornerRadius: 6, - padding: 12, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, + ), + userMenuButton: merge(titlebarButton, { + inactive: { + default: { + buttonWidth: 20, + iconWidth: 12 + } + }, active: { // posiewic: these properties are not currently set on main + default: { + iconWidth: 12, + button_width: 20, + } + } + }), + + + toggleContactsBadge: { + cornerRadius: 3, + padding: 2, + margin: { top: 3, left: 3 }, + border: border(layer), + background: foreground(layer, "accent"), + }, + shareButton: { + ...titlebarButton, + }, + }, + + toolbar: { + height: 34, + background: background(colorScheme.highest), + border: border(colorScheme.highest, { bottom: true }), + itemSpacing: 8, + navButton: interactive( + { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, { + hover: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), }, - notifications: { - width: 400, - margin: { right: 10, bottom: 10 }, + disabled: { + color: foreground(colorScheme.highest, "on", "disabled"), }, - dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), - } + }), + padding: { left: 8, right: 8, top: 4, bottom: 4 }, + }, + breadcrumbHeight: 24, + breadcrumbs: interactive({ + ...text(colorScheme.highest, "sans", "variant"), + cornerRadius: 6, + padding: { + left: 6, + right: 6, + } + }, { + hover: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background(colorScheme.highest, "on", "hovered"), + }, + }), + disconnectedOverlay: { + ...text(layer, "sans"), + background: withOpacity(background(layer), 0.8), + }, + notification: { + margin: { top: 10 }, + background: background(colorScheme.middle), + cornerRadius: 6, + padding: 12, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + }, + notifications: { + width: 400, + margin: { right: 10, bottom: 10 }, + }, + dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), + } } From 16564707df836c12fe785dc6aa51999bdded0b4b Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 15 Jun 2023 11:10:37 -0400 Subject: [PATCH 07/26] Use TS-flavored doc comments --- styles/src/styleTree/interactive.ts | 54 +++++++++++++++----------- styles/src/styleTree/toggle.ts | 60 ++++++++++++++++------------- 2 files changed, 64 insertions(+), 50 deletions(-) diff --git a/styles/src/styleTree/interactive.ts b/styles/src/styleTree/interactive.ts index 7135cecd906952889f37e580b932ffb96efa6689..230a05515d7926c5cae1ee096f7912d026338c26 100644 --- a/styles/src/styleTree/interactive.ts +++ b/styles/src/styleTree/interactive.ts @@ -1,33 +1,41 @@ import { DeepPartial } from "utility-types"; import merge from "ts-deepmerge" interface Interactive { - default: T, - hover?: T, - clicked?: T, - disabled?: T, + default: T, + hover?: T, + clicked?: T, + disabled?: T, } -// Helper function for creating Interactive objects that works pretty much like Toggle. -// It takes a object to be used as a value for `default` field and then fills out other fields -// with fields from either `base` or `modifications`. Notably, it does not touch `hover`, `clicked` and `disabled` if there are no modifications for it. +/** + * Helper function for creating Interactive objects that works pretty much like Toggle. + * It takes a object to be used as a value for `default` field and then fills out other fields + * with fields from either `base` or `modifications`. + * Notably, it does not touch `hover`, `clicked` and `disabled` if there are no modifications for it. + * + * @param defaultObj Object to be used as the value for `default` field. + * @param base Object containing base fields to be included in the resulting object. + * @param modifications Object containing modified fields to be included in the resulting object. + * @returns Interactive object with fields from `base` and `modifications`. + */ export function interactive(base: T, modifications: DeepPartial>): Interactive { - let interactiveObj: Interactive = { - default: base, - }; - if (modifications.default !== undefined) { - interactiveObj.default = merge(interactiveObj.default, modifications.default) as T; - } - if (modifications.hover !== undefined) { - interactiveObj.hover = merge(interactiveObj.default, modifications.hover) as T; - } + let interactiveObj: Interactive = { + default: base, + }; + if (modifications.default !== undefined) { + interactiveObj.default = merge(interactiveObj.default, modifications.default) as T; + } + if (modifications.hover !== undefined) { + interactiveObj.hover = merge(interactiveObj.default, modifications.hover) as T; + } - if (modifications.clicked !== undefined) { - interactiveObj.clicked = merge(interactiveObj.default, modifications.clicked) as T; - } + if (modifications.clicked !== undefined) { + interactiveObj.clicked = merge(interactiveObj.default, modifications.clicked) as T; + } - if (modifications.disabled !== undefined) { - interactiveObj.disabled = merge(interactiveObj.default, modifications.disabled) as T; - } + if (modifications.disabled !== undefined) { + interactiveObj.disabled = merge(interactiveObj.default, modifications.disabled) as T; + } - return interactiveObj; + return interactiveObj; } diff --git a/styles/src/styleTree/toggle.ts b/styles/src/styleTree/toggle.ts index 9c35b8337c07a730c17d5bf5db3787446f615e88..d6b37dde9e22ac697540b2ea4304e3cbedf6fbfe 100644 --- a/styles/src/styleTree/toggle.ts +++ b/styles/src/styleTree/toggle.ts @@ -2,34 +2,40 @@ import { DeepPartial } from 'utility-types'; import merge from 'ts-deepmerge'; interface Toggleable { - inactive: T - active: T, + inactive: T + active: T, } -/// Helper function for creating Toggleable objects; it takes a object of type T that is used as -/// `inactive` member of result Toggleable. `active` member is created by applying `modifications` on top of `inactive` argument. -// Thus, the following call: -// ``` -// toggleable({day: 1, month: "January"}, {day: 3}) -// ``` -// To return the following object: -// ``` -// Toggleable<_>{ -// inactive: { day: 1, month: "January" }, -// active: { day: 3, month: "January" } -// } -// ``` -// Remarkably, it also works for nested structures: -// ``` -// toggleable({first_level: "foo", second_level: {nested_member: "nested"}}, {second_level: {nested_member: "another nested thing"}}) -// ``` -// ``` -// Toggleable<_> { -// inactive: {first_level: "foo", second_level: {nested_member: "nested"}}, -// active: { first_level: "foo", second_level: {nested_member: "another nested thing"}} -// } -// ``` +/** + * Helper function for creating Toggleable objects. + * @template T The type of the object being toggled. + * @param inactive The initial state of the toggleable object. + * @param modifications The modifications to be applied to the initial state to create the active state. + * @returns A Toggleable object containing both the inactive and active states. + * @example + * ``` + * toggleable({day: 1, month: "January"}, {day: 3}) + * ``` + * This returns the following object: + * ``` + * Toggleable<_>{ + * inactive: { day: 1, month: "January" }, + * active: { day: 3, month: "January" } + * } + * ``` + * The function also works for nested structures: + * ``` + * toggleable({first_level: "foo", second_level: {nested_member: "nested"}}, {second_level: {nested_member: "another nested thing"}}) + * ``` + * Which returns: + * ``` + * Toggleable<_> { + * inactive: {first_level: "foo", second_level: {nested_member: "nested"}}, + * active: { first_level: "foo", second_level: {nested_member: "another nested thing"}} + * } + * ``` + */ export function toggleable(inactive: T, modifications: DeepPartial): Toggleable { - let active: T = merge(inactive, modifications) as T; - return { active: active, inactive: inactive }; + let active: T = merge(inactive, modifications) as T; + return { active: active, inactive: inactive }; } From 247f618d4f5419acacf86e4ac3b276437a755990 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 15 Jun 2023 15:33:02 -0400 Subject: [PATCH 08/26] Update the interactive function --- styles/src/styleTree/interactive.ts | 56 ++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/styles/src/styleTree/interactive.ts b/styles/src/styleTree/interactive.ts index 230a05515d7926c5cae1ee096f7912d026338c26..6bc6ca048be6f3619c0d76facc5a729b4a4d91f7 100644 --- a/styles/src/styleTree/interactive.ts +++ b/styles/src/styleTree/interactive.ts @@ -1,10 +1,18 @@ -import { DeepPartial } from "utility-types"; import merge from "ts-deepmerge" -interface Interactive { + +type InteractiveState = "default" | "hovered" | "clicked" | "selected" | "disabled"; + +type Interactive = { default: T, - hover?: T, + hovered?: T, clicked?: T, + selected?: T, disabled?: T, +}; + +interface InteractiveProps { + base?: T, + state: Partial> } /** @@ -18,23 +26,45 @@ interface Interactive { * @param modifications Object containing modified fields to be included in the resulting object. * @returns Interactive object with fields from `base` and `modifications`. */ -export function interactive(base: T, modifications: DeepPartial>): Interactive { +export function interactive({ base, state }: InteractiveProps): Interactive { + if (!base && !state.default) throw new Error("An interactive object must have a default state, or a base property."); + + let defaultState: T; + + if (state.default && base) { + defaultState = merge(base, state.default) as T; + } else { + defaultState = base ? base : state.default as T; + } + let interactiveObj: Interactive = { - default: base, + default: defaultState, }; - if (modifications.default !== undefined) { - interactiveObj.default = merge(interactiveObj.default, modifications.default) as T; + + let stateCount = 0; + + if (state.hovered !== undefined) { + interactiveObj.hovered = merge(interactiveObj.default, state.hovered) as T; + stateCount++; } - if (modifications.hover !== undefined) { - interactiveObj.hover = merge(interactiveObj.default, modifications.hover) as T; + + if (state.clicked !== undefined) { + interactiveObj.clicked = merge(interactiveObj.default, state.clicked) as T; + stateCount++; + } + + if (state.selected !== undefined) { + interactiveObj.selected = merge(interactiveObj.default, state.selected) as T; + stateCount++; } - if (modifications.clicked !== undefined) { - interactiveObj.clicked = merge(interactiveObj.default, modifications.clicked) as T; + if (state.disabled !== undefined) { + interactiveObj.disabled = merge(interactiveObj.default, state.disabled) as T; + stateCount++; } - if (modifications.disabled !== undefined) { - interactiveObj.disabled = merge(interactiveObj.default, modifications.disabled) as T; + if (stateCount < 1) { + throw new Error("An interactive object must have a default and at least one other state."); } return interactiveObj; From 63630949ba96ef6b0b36aafad7558d31774e92b1 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 15 Jun 2023 21:58:08 +0200 Subject: [PATCH 09/26] Fix up uses of interactive --- styles/src/styleTree/commandPalette.ts | 32 ++-- styles/src/styleTree/contactList.ts | 79 +++++----- styles/src/styleTree/contactNotification.ts | 20 +-- styles/src/styleTree/contextMenu.ts | 40 ++--- styles/src/styleTree/copilot.ts | 112 ++++++------- styles/src/styleTree/editor.ts | 64 ++++---- styles/src/styleTree/picker.ts | 37 +++-- styles/src/styleTree/projectPanel.ts | 58 +++---- styles/src/styleTree/statusBar.ts | 128 ++++++++------- styles/src/styleTree/tabBar.ts | 16 +- styles/src/styleTree/welcome.ts | 38 ++--- styles/src/styleTree/workspace.ts | 164 +++++++++++--------- 12 files changed, 425 insertions(+), 363 deletions(-) diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 5fe7b74f92352f1d2f311d5b3f93af9c22e6fc35..d6cb196770058ee267c3914e065a94ac7aa4e138 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -10,21 +10,23 @@ export default function commandPalette(colorScheme: ColorScheme) { keystrokeSpacing: 8, key: toggleable(interactive({ - text: text(layer, "mono", "variant", "default", { size: "xs" }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - }, { hover: { cornerRadius: 4, padding: { top: 17 } } }), { + base: { + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, state: { hovered: { cornerRadius: 4, padding: { top: 17 } } } + }), { default: { text: text(layer, "mono", "on", "default", { size: "xs" }), background: withOpacity(background(layer, "on"), 0.2), diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index b3e30f4aa78ba172aae5022e16a7b65f916c25b6..5837720401bc40a7e991b0c16f2cee8cdc02154a 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -73,14 +73,17 @@ export default function contactsPanel(colorScheme: ColorScheme) { rowHeight: 28, sectionIconSize: 8, headerRow: toggleable(interactive({ - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, - }, - background: background(layer, "default"),// posiewic: breaking change - }, {}), + base: { + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"),// posiewic: breaking change + } + , state: { hovered: { background: background(layer, "default") } } // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. + }), { default: { ...text(layer, "mono", "active", { size: "sm" }), @@ -88,27 +91,30 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, }), leaveCall: interactive({ - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, - }, - padding: { - top: 1, - bottom: 1, - left: 7, - right: 7, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - }, - { - hover: { + base: { + background: background(layer), + border: border(layer), + cornerRadius: 6, + margin: { + top: 1, + }, + padding: { + top: 1, + bottom: 1, + left: 7, + right: 7, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + } + , + state: { + hovered: { ...text(layer, "sans", "hovered", { size: "xs" }), background: background(layer, "hovered"), border: border(layer, "hovered"), } } + } ), contactRow: { inactive: { @@ -153,13 +159,14 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, }, contactButtonSpacing: nameMargin, - contactButton: interactive( - contactButton, - { - hover: { + contactButton: interactive({ + base: { ...contactButton }, + state: { + hovered: { background: background(layer, "hovered"), }, - }), + } + }), disabledButton: { ...contactButton, background: background(layer, "on"), @@ -169,14 +176,16 @@ export default function contactsPanel(colorScheme: ColorScheme) { ...text(layer, "mono", "variant", { size: "xs" }), }, treeBranch: toggleable(interactive({ - color: borderColor(layer), - width: 1, - }, - { - hover: { + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { color: borderColor(layer), }, - }), + } + }), { default: { color: borderColor(layer), diff --git a/styles/src/styleTree/contactNotification.ts b/styles/src/styleTree/contactNotification.ts index edef8dac20cd37aed08f8cec6e87c4af221f3e02..5b29e15e6bdb60bc2f5743123b09f9e9fe1a35da 100644 --- a/styles/src/styleTree/contactNotification.ts +++ b/styles/src/styleTree/contactNotification.ts @@ -23,18 +23,20 @@ export default function contactNotification(colorScheme: ColorScheme): Object { }, button: interactive({ - ...text(layer, "sans", "on", { size: "xs" }), - background: background(layer, "on"), - padding: 4, - cornerRadius: 6, - margin: { left: 6 } - }, + base: { + ...text(layer, "sans", "on", { size: "xs" }), + background: background(layer, "on"), + padding: 4, + cornerRadius: 6, + margin: { left: 6 } + }, - { - hover: { + state: { + hovered: { background: background(layer, "on", "hovered"), } - }), + } + }), dismissButton: { default: { diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index b030d2797292fe745a7041fa17d0fb4e7d8127d1..2d5e84dcf0aa6633730172ef7b10ab1e8f3435f3 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -13,35 +13,37 @@ export default function contextMenu(colorScheme: ColorScheme) { border: border(layer), keystrokeMargin: 30, item: toggleable(interactive({ - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - } - }, { - hover: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), keystroke: { - ...text(layer, "sans", "hovered", { + ...text(layer, "sans", "variant", { size: "sm", weight: "bold", }), padding: { left: 3, right: 3 }, - }, + } + }, state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + } } }), { default: { background: background(layer, "active"), }, - hover: { + hovered: { background: background(layer, "active"), }, }), diff --git a/styles/src/styleTree/copilot.ts b/styles/src/styleTree/copilot.ts index 090d05eaee14af03b4cf1eb89958d884771937ec..6440941e64eb9678e9ab24430edd13f6922e5105 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -9,53 +9,57 @@ export default function copilot(colorScheme: ColorScheme) { let ctaButton = // Copied from welcome screen. FIXME: Move this into a ZDS component interactive({ - background: background(layer), - border: border(layer, "default"), - cornerRadius: 4, - margin: { - top: 4, - bottom: 4, - left: 8, - right: 8, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, + base: { + background: background(layer), + border: border(layer, "default"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + left: 8, + right: 8, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) }, - ...text(layer, "sans", "default", { size: "sm" }) - }, - { - hover: { + state: { + hovered: { ...text(layer, "sans", "default", { size: "sm" }), background: background(layer, "hovered"), border: border(layer, "active"), }, - }); + } + }); return { outLinkIcon: interactive({ - icon: svg( - foreground(layer, "variant"), - "icons/link_out_12.svg", - 12, - 12 - ), - container: { - cornerRadius: 6, - padding: { left: 6 }, + base: { + icon: svg( + foreground(layer, "variant"), + "icons/link_out_12.svg", + 12, + 12 + ), + container: { + cornerRadius: 6, + padding: { left: 6 }, + }, }, - }, - { - hover: { + state: { + hovered: { icon: { color: foreground(layer, "hovered") } }, - }), + } + }), modal: { titleText: { @@ -82,7 +86,8 @@ export default function copilot(colorScheme: ColorScheme) { bottom: 8, }, }, - closeIcon: interactive( + closeIcon: interactive({ + base: { icon: svg( foreground(layer, "variant"), @@ -103,8 +108,8 @@ export default function copilot(colorScheme: ColorScheme) { }, } }, - { - hover: { + state: { + hovered: { icon: svg( foreground(layer, "on"), "icons/x_mark_8.svg", @@ -120,7 +125,8 @@ export default function copilot(colorScheme: ColorScheme) { 8 ), }, - }), + } + }), dimensions: { width: 280, height: 280, @@ -196,27 +202,29 @@ export default function copilot(colorScheme: ColorScheme) { }, right: (content_width * 1) / 3, rightContainer: interactive({ - border: border(colorScheme.lowest, "inverted", { - bottom: false, - right: false, - top: false, - left: true, - }), - padding: { - top: 3, - bottom: 5, - left: 8, - right: 0, - } - }, { - hover: { - border: border(layer, "active", { + base: { + border: border(colorScheme.lowest, "inverted", { bottom: false, right: false, top: false, left: true, }), - }, + padding: { + top: 3, + bottom: 5, + left: 8, + right: 0, + } + }, state: { + hovered: { + border: border(layer, "active", { + bottom: false, + right: false, + top: false, + left: true, + }), + }, + } }) }, }, diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index ac7447de42dac543361c3a216cd1dcf23ea9107c..b3b22f3c8bc98dccec725645454d9ab7e95b4de1 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -51,14 +51,16 @@ export default function editor(colorScheme: ColorScheme) { suggestion: syntax.predictive, codeActions: { indicator: toggleable(interactive({ - color: foreground(layer, "variant"), - }, { - clicked: { - color: foreground(layer, "base"), - }, - hover: { - color: foreground(layer, "on"), - }, + base: { + color: foreground(layer, "variant"), + }, state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + } }), { default: { @@ -73,14 +75,16 @@ export default function editor(colorScheme: ColorScheme) { foldedIcon: "icons/chevron_right_8.svg", foldableIcon: "icons/chevron_down_8.svg", indicator: toggleable(interactive({ - color: foreground(layer, "variant"), - }, { - clicked: { - color: foreground(layer, "base"), - }, - hover: { - color: foreground(layer, "on"), - }, + base: { + color: foreground(layer, "variant"), + }, state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + } }), { default: { @@ -231,19 +235,21 @@ export default function editor(colorScheme: ColorScheme) { underline: syntax.linkUri.underline, }, jumpIcon: interactive({ - color: foreground(layer, "on"), - iconWidth: 20, - buttonWidth: 20, - cornerRadius: 6, - padding: { - top: 6, - bottom: 6, - left: 6, - right: 6, - } - }, { - hover: { - background: background(layer, "on", "hovered"), + base: { + color: foreground(layer, "on"), + iconWidth: 20, + buttonWidth: 20, + cornerRadius: 6, + padding: { + top: 6, + bottom: 6, + left: 6, + right: 6, + } + }, state: { + hovered: { + background: background(layer, "on", "hovered"), + } } }), diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index ecf34a9927146920f0355696d86b6ab93b32c6a0..89b6cd0614924fd4cf6c4f8f47a07a89b4a247c5 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -41,23 +41,26 @@ export default function picker(colorScheme: ColorScheme): any { padding: {}, }, item: toggleable(interactive({ - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, - }, - margin: { - top: 1, - left: 4, - right: 4, - }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { weight: "bold" }), - }, { - hover: { - background: withOpacity(background(layer, "hovered"), 0.5), + base: { + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, + }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { weight: "bold" }), + } + , state: { + hovered: { + background: withOpacity(background(layer, "hovered"), 0.5), + } } }), { diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 57abd0dafce9adb4cd13bd4b42ea610656716c8e..782c781156a7cd643f81424c666b5dd34a2f4cb1 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -30,15 +30,17 @@ export default function projectPanel(colorScheme: ColorScheme) { } let entry = toggleable(interactive({ - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, - }, + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, state: { - hover: { + hovered: { background: background(layer, "variant", "hovered"), } - }), + } + }), { default: { /*background: colorScheme.isLight @@ -46,7 +48,7 @@ export default function projectPanel(colorScheme: ColorScheme) { : background(layer, "active") ,*/ // todo posiewic text: text(layer, "mono", "active", { size: "sm" }), }, - hover: { + hovered: { //background: background(layer, "active"), text: text(layer, "mono", "active", { size: "sm" }), }, @@ -55,27 +57,29 @@ export default function projectPanel(colorScheme: ColorScheme) { return { openProjectButton: interactive({ - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 16, - left: 16, - right: 16, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }) - }, { - hover: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), + base: { + background: background(layer), border: border(layer, "active"), - }, + cornerRadius: 4, + margin: { + top: 16, + left: 16, + right: 16, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) + }, state: { + hovered: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + } }), background: background(layer), padding: { left: 6, right: 6, top: 0, bottom: 6 }, diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 66643dbde1ae4e6783a365ea65d3ad88c91f645a..754703c2b9c431892e9a71000d621e8f4f24a8a1 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -27,74 +27,82 @@ export default function statusBar(colorScheme: ColorScheme) { border: border(layer, { top: true, overlay: true }), cursorPosition: text(layer, "sans", "variant"), activeLanguage: interactive({ - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant") - }, - { - hover: { + base: { + padding: { left: 6, right: 6 }, + ...text(layer, "sans", "variant") + }, + state: { + hovered: { ...text(layer, "sans", "on"), } - }, + } + }, ), autoUpdateProgressMessage: text(layer, "sans", "variant"), autoUpdateDoneMessage: text(layer, "sans", "variant"), lspStatus: interactive({ - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer) - }, - { - hover: { + base: { + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, + message: text(layer, "sans"), + iconColor: foreground(layer) + }, + state: { + hovered: { message: text(layer, "sans"), iconColor: foreground(layer), background: background(layer, "hovered"), } - }), + } + }), diagnosticMessage: interactive({ - ...text(layer, "sans") + base: { + ...text(layer, "sans") + }, + state: { hovered: text(layer, "sans", "hovered") } }, - { hover: text(layer, "sans", "hovered") }, ), diagnosticSummary: interactive({ - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - } - }, { - hover: { - iconColorOk: foreground(layer, "on"), + base: { + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), containerOk: { - background: background(layer, "on", "hovered"), + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, }, containerWarning: { - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), }, containerError: { - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + } + }, state: { + hovered: { + iconColorOk: foreground(layer, "on"), + containerOk: { + background: background(layer, "on", "hovered"), + }, + containerWarning: { + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), + }, + containerError: { + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + } } } } @@ -104,17 +112,19 @@ export default function statusBar(colorScheme: ColorScheme) { groupBottom: {}, groupRight: {}, button: toggleable(interactive({ - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, - }, { - hover: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, + }, state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + } } }), { diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index 6799b0a9e3272da327fa19b14fd02f2acb77375b..9da63b95187e9edd718715a4296782e4ac799373 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -90,15 +90,17 @@ export default function tabBar(colorScheme: ColorScheme) { }, draggedTab, paneButton: toggleable(interactive({ - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - }, - { - hover: { + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { color: foreground(layer, "hovered"), } - }), + } + }), { default: { color: foreground(layer, "accent"), diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index dbabc553830eac93a887a254e3632b617118dd8f..7ba7b304300c64fd9ddcd645b36f23c4c2065c29 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -65,24 +65,26 @@ export default function welcome(colorScheme: ColorScheme) { }, }, button: interactive({ - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 4, - bottom: 4, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", interactive_text_size) - }, { - hover: { - ...text(layer, "sans", "default", interactive_text_size), - background: background(layer, "hovered"), + base: { + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", interactive_text_size) + }, state: { + hovered: { + ...text(layer, "sans", "default", interactive_text_size), + background: background(layer, "hovered"), + } } }), diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 18341fc51e08ced69b82a594116cc792de0e5706..fcada68a282b4c41d0bdf31c0e2585837c7219f1 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -18,26 +18,28 @@ export default function workspace(colorScheme: ColorScheme) { const isLight = colorScheme.isLight const itemSpacing = 8 const titlebarButton = toggleable(interactive({ - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, { - hover: { - ...text(layer, "sans", "variant", "hovered", { size: "xs" }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { size: "xs" }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), + base: { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, state: { + hovered: { + ...text(layer, "sans", "variant", "hovered", { size: "xs" }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { size: "xs" }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + } } }), { @@ -86,17 +88,19 @@ export default function workspace(colorScheme: ColorScheme) { }, keyboardHint: interactive({ - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8 - }, { - hover: { - ...text(layer, "sans", "active", { size: "sm" }), + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8 + }, state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + } } }), @@ -250,33 +254,37 @@ export default function workspace(colorScheme: ColorScheme) { cornerRadius: 6, }, callControl: interactive({ - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - }, { - hover: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, + base: { + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 20, + }, state: { + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + } }), toggleContactsButton: toggleable(interactive({ - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - }, - { + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { clicked: { background: background(layer, "variant", "pressed"), color: foreground(layer, "variant", "pressed"), }, - hover: { + hovered: { background: background(layer, "variant", "hovered"), color: foreground(layer, "variant", "hovered"), } - }), + } + }), { default: { background: background(layer, "variant", "active"), @@ -318,38 +326,42 @@ export default function workspace(colorScheme: ColorScheme) { itemSpacing: 8, navButton: interactive( { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, - }, { - hover: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - disabled: { - color: foreground(colorScheme.highest, "on", "disabled"), - }, - }), + base: { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + disabled: { + color: foreground(colorScheme.highest, "on", "disabled"), + }, + } + }), padding: { left: 8, right: 8, top: 4, bottom: 4 }, }, breadcrumbHeight: 24, breadcrumbs: interactive({ - ...text(colorScheme.highest, "sans", "variant"), - cornerRadius: 6, - padding: { - left: 6, - right: 6, + base: { + ...text(colorScheme.highest, "sans", "variant"), + cornerRadius: 6, + padding: { + left: 6, + right: 6, + } + }, state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background(colorScheme.highest, "on", "hovered"), + }, } - }, { - hover: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background(colorScheme.highest, "on", "hovered"), - }, }), disconnectedOverlay: { ...text(layer, "sans"), From 4bd89c4c8c8b6860050c09d8457fac1baebfee65 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 15 Jun 2023 22:39:51 +0200 Subject: [PATCH 10/26] further style adjustments; cargo-run works --- styles/src/styleTree/assistant.ts | 167 +++++++------- styles/src/styleTree/contactList.ts | 41 ++-- styles/src/styleTree/feedback.ts | 78 +++---- styles/src/styleTree/search.ts | 208 +++++++++--------- .../styleTree/simpleMessageNotification.ts | 71 +++--- styles/src/styleTree/toolbarDropdownMenu.ts | 92 ++++---- styles/src/styleTree/updateNotification.ts | 54 +++-- 7 files changed, 381 insertions(+), 330 deletions(-) diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index bbb4aae5e1b9d35f21f2d78897f368691c006e72..d501237721fcb5196ed1c3082ee4522548e5cd50 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -1,85 +1,94 @@ import { ColorScheme } from "../theme/colorScheme" import { text, border, background, foreground } from "./components" import editor from "./editor" +import { interactive } from "./interactive" export default function assistant(colorScheme: ColorScheme) { - const layer = colorScheme.highest - return { - container: { - background: editor(colorScheme).background, - padding: { left: 12 }, - }, - header: { - border: border(layer, "default", { bottom: true, top: true }), - margin: { bottom: 6, top: 6 }, - background: editor(colorScheme).background, - }, - userSender: { - ...text(layer, "sans", "default", { size: "sm", weight: "bold" }), - }, - assistantSender: { - ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }), - }, - systemSender: { - ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }), - }, - sentAt: { - margin: { top: 2, left: 8 }, - ...text(layer, "sans", "default", { size: "2xs" }), - }, - modelInfoContainer: { - margin: { right: 16, top: 4 }, - }, - model: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - cornerRadius: 4, - ...text(layer, "sans", "default", { size: "xs" }), - hover: { - background: background(layer, "on", "hovered"), - }, - }, - remainingTokens: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - margin: { left: 4 }, - cornerRadius: 4, - ...text(layer, "sans", "positive", { size: "xs" }), - }, - noRemainingTokens: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - margin: { left: 4 }, - cornerRadius: 4, - ...text(layer, "sans", "negative", { size: "xs" }), - }, - errorIcon: { - margin: { left: 8 }, - color: foreground(layer, "negative"), - width: 12, - }, - apiKeyEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - }, - apiKeyPrompt: { - padding: 10, - ...text(layer, "sans", "default", { size: "xs" }), - }, - } + const layer = colorScheme.highest + return { + container: { + background: editor(colorScheme).background, + padding: { left: 12 }, + }, + header: { + border: border(layer, "default", { bottom: true, top: true }), + margin: { bottom: 6, top: 6 }, + background: editor(colorScheme).background, + }, + userSender: { + default: + { ...text(layer, "sans", "default", { size: "sm", weight: "bold" }) }, + }, + assistantSender: { + default: { + ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }) + }, + }, + systemSender: { + default: { + ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }) + }, + }, + sentAt: { + margin: { top: 2, left: 8 }, + ...text(layer, "sans", "default", { size: "2xs" }), + }, + modelInfoContainer: { + margin: { right: 16, top: 4 }, + }, + model: interactive({ + base: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + cornerRadius: 4, + ...text(layer, "sans", "default", { size: "xs" }), + }, state: { + hovered: { + background: background(layer, "on", "hovered"), + } + } + }), + remainingTokens: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + margin: { left: 4 }, + cornerRadius: 4, + ...text(layer, "sans", "positive", { size: "xs" }), + }, + noRemainingTokens: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + margin: { left: 4 }, + cornerRadius: 4, + ...text(layer, "sans", "negative", { size: "xs" }), + }, + errorIcon: { + margin: { left: 8 }, + color: foreground(layer, "negative"), + width: 12, + }, + apiKeyEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + }, + apiKeyPrompt: { + padding: 10, + ...text(layer, "sans", "default", { size: "xs" }), + }, + } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 5837720401bc40a7e991b0c16f2cee8cdc02154a..4309343ed257bad38b40b56767bef46bed57625d 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -192,24 +192,27 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, } ), - projectRow: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, - }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), - }, - hover: { - background: background(layer, "hovered"), - }, - active: { - background: background(layer, "active"), - }, - }, + projectRow: toggleable(interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, + }, state: { + hovered: { + background: background(layer, "hovered"), + }, + } + }), + { + default: { background: background(layer, "active") } + }) } } diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 5eef4b42792131b9b4de128c708d5e17dd28dc14..4b5a4de89fb2c97765c279d1716abda2e8424bbd 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -1,44 +1,48 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" +import { interactive } from "./interactive" export default function feedback(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - return { - submit_button: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - }, - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hover: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, + return { + submit_button: interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, }, - button_margin: 8, - info_text_default: text(layer, "sans", "default", { size: "xs" }), - link_text_default: text(layer, "sans", "default", { - size: "xs", - underline: true, - }), - link_text_hover: text(layer, "sans", "hovered", { - size: "xs", - underline: true, - }), - } + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, + } + }, state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + } + }), + button_margin: 8, + info_text_default: text(layer, "sans", "default", { size: "xs" }), + link_text_default: text(layer, "sans", "default", { + size: "xs", + underline: true, + }), + link_text_hover: text(layer, "sans", "hovered", { + size: "xs", + underline: true, + }), + } } diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index d69c4bb2d919d2b70054deba22f16e3db9eb39f6..e278f69ff084d53bec79a0d22f20ad503cdfa38c 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -1,113 +1,123 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function search(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - // Search input - const editor = { - background: background(layer), - cornerRadius: 8, - minWidth: 200, - maxWidth: 500, - placeholderText: text(layer, "mono", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "default"), - border: border(layer), - margin: { - right: 12, - }, - padding: { - top: 3, - bottom: 3, - left: 12, - right: 8, - }, - } + // Search input + const editor = { + background: background(layer), + cornerRadius: 8, + minWidth: 200, + maxWidth: 500, + placeholderText: text(layer, "mono", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "default"), + border: border(layer), + margin: { + right: 12, + }, + padding: { + top: 3, + bottom: 3, + left: 12, + right: 8, + }, + } - const includeExcludeEditor = { - ...editor, - minWidth: 100, - maxWidth: 250, - } + const includeExcludeEditor = { + ...editor, + minWidth: 100, + maxWidth: 250, + } - return { - // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive - matchBackground: withOpacity(foreground(layer, "accent"), 0.4), - optionButton: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - }, - active: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), - }, - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hover: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, - }, - editor, - invalidEditor: { - ...editor, - border: border(layer, "negative"), - }, - includeExcludeEditor, - invalidIncludeExcludeEditor: { - ...includeExcludeEditor, - border: border(layer, "negative"), - }, - matchIndex: { - ...text(layer, "mono", "variant"), - padding: { - left: 6, - }, + return { + // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive + matchBackground: withOpacity(foreground(layer, "accent"), 0.4), + optionButton: toggleable(interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, }, - optionButtonGroup: { - padding: { - left: 12, - right: 12, - }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, }, - includeExcludeInputs: { - ...text(layer, "mono", "variant"), - padding: { - right: 6, - }, + }, state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), }, - resultsStatus: { - ...text(layer, "mono", "on"), - size: 18, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), }, - dismissButton: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 14, - padding: { - left: 10, - right: 10, - }, - hover: { - color: foreground(layer, "hovered"), - }, + } + }), { + default: { + ...text(layer, "mono", "on", "inverted"), + background: background(layer, "on", "inverted"), + border: border(layer, "on", "inverted"), + }, + + }), + editor, + invalidEditor: { + ...editor, + border: border(layer, "negative"), + }, + includeExcludeEditor, + invalidIncludeExcludeEditor: { + ...includeExcludeEditor, + border: border(layer, "negative"), + }, + matchIndex: { + ...text(layer, "mono", "variant"), + padding: { + left: 6, + }, + }, + optionButtonGroup: { + padding: { + left: 12, + right: 12, + }, + }, + includeExcludeInputs: { + ...text(layer, "mono", "variant"), + padding: { + right: 6, + }, + }, + resultsStatus: { + ...text(layer, "mono", "on"), + size: 18, + }, + dismissButton: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 14, + padding: { + left: 10, + right: 10, }, - } + }, state: { + hovered: { + color: foreground(layer, "hovered"), + } + } + }), + } } diff --git a/styles/src/styleTree/simpleMessageNotification.ts b/styles/src/styleTree/simpleMessageNotification.ts index 8d88f05c53466b718d5efd189cfdf6a321499ba2..70219d7a1029d9500facaf8d3e15baa7d20db152 100644 --- a/styles/src/styleTree/simpleMessageNotification.ts +++ b/styles/src/styleTree/simpleMessageNotification.ts @@ -1,44 +1,51 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" +import { interactive } from "./interactive" const headerPadding = 8 export default function simpleMessageNotification( - colorScheme: ColorScheme + colorScheme: ColorScheme ): Object { - let layer = colorScheme.middle - return { - message: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, + let layer = colorScheme.middle + return { + message: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, + }, + actionMessage: interactive({ + base: { + ...text(layer, "sans", { size: "xs" }), + border: border(layer, "active"), + cornerRadius: 4, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, }, - actionMessage: { - ...text(layer, "sans", { size: "xs" }), - border: border(layer, "active"), - cornerRadius: 4, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - margin: { left: headerPadding, top: 6, bottom: 6 }, - hover: { - ...text(layer, "sans", "default", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, + margin: { left: headerPadding, top: 6, bottom: 6 }, + }, state: { + hovered: { + ...text(layer, "sans", "default", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "active"), }, - dismissButton: { - color: foreground(layer), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), - }, + } + }), + dismissButton: interactive({ + base: { + color: foreground(layer), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8, + }, state: { + hovered: { + color: foreground(layer, "hovered"), }, - } + } + }) + } } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 92616eb0223781deae3162bfd7d429a3f896e6eb..0cfcb921efc352bcfbcc74e43727167936332a85 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -1,46 +1,56 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" - +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function dropdownMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - return { - rowHeight: 30, - background: background(layer), - border: border(layer), - shadow: colorScheme.popoverShadow, - header: { - ...text(layer, "sans", { size: "sm" }), - secondaryText: text(layer, "sans", { size: "sm", color: "#aaaaaa" }), - secondaryTextSpacing: 10, - padding: { left: 8, right: 8, top: 2, bottom: 2 }, - cornerRadius: 6, - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - hover: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - } - }, - sectionHeader: { - ...text(layer, "sans", { size: "sm" }), - padding: { left: 8, right: 8, top: 8, bottom: 8 }, - }, - item: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 }, - hover: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - }, - active: { - background: background(layer, "active"), - }, - activeHover: { - background: background(layer, "active"), - }, - }, - } + return { + rowHeight: 30, + background: background(layer), + border: border(layer), + shadow: colorScheme.popoverShadow, + header: interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryText: text(layer, "sans", { size: "sm", color: "#aaaaaa" }), + secondaryTextSpacing: 10, + padding: { left: 8, right: 8, top: 2, bottom: 2 }, + cornerRadius: 6, + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }) + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + } + } + }) + , + sectionHeader: { + ...text(layer, "sans", { size: "sm" }), + padding: { left: 8, right: 8, top: 8, bottom: 8 }, + }, + item: toggleable(interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 } + }, state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + } + } + }), { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + }) + } } diff --git a/styles/src/styleTree/updateNotification.ts b/styles/src/styleTree/updateNotification.ts index 281012e62f562ac721ab17c4c72afb458e1d59f1..aa8db916ea08a4625e2a218a4fead51d61552847 100644 --- a/styles/src/styleTree/updateNotification.ts +++ b/styles/src/styleTree/updateNotification.ts @@ -1,31 +1,39 @@ import { ColorScheme } from "../theme/colorScheme" import { foreground, text } from "./components" +import { interactive } from "./interactive" const headerPadding = 8 export default function updateNotification(colorScheme: ColorScheme): Object { - let layer = colorScheme.middle - return { - message: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, + let layer = colorScheme.middle + return { + message: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, + }, + actionMessage: interactive({ + base: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, top: 6, bottom: 6 } + }, state: { + hovered: { + color: foreground(layer, "hovered"), + } + } + }), + dismissButton: interactive({ + base: { + color: foreground(layer), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8 + }, state: { + hovered: { + color: foreground(layer, "hovered"), }, - actionMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, top: 6, bottom: 6 }, - hover: { - color: foreground(layer, "hovered"), - }, - }, - dismissButton: { - color: foreground(layer), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), - }, - }, - } + }, + }) + + } } From 5369f2c25a98217bd8a6d35f67687a84147af7c2 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 15 Jun 2023 18:42:48 -0400 Subject: [PATCH 11/26] Set up vitest and add tests for `interactive` --- styles/.gitignore | 1 + styles/package-lock.json | 2346 ++++++++++++++++- styles/package.json | 9 +- styles/src/element/interactive/index.ts | 3 + .../element/interactive/interactive.test.ts | 59 + .../interactive}/interactive.ts | 23 +- styles/src/styleTree/assistant.ts | 176 +- styles/src/styleTree/commandPalette.ts | 60 +- styles/src/styleTree/contactList.ts | 392 +-- styles/src/styleTree/contactNotification.ts | 86 +- styles/src/styleTree/contextMenu.ts | 98 +- styles/src/styleTree/copilot.ts | 522 ++-- styles/src/styleTree/editor.ts | 536 ++-- styles/src/styleTree/feedback.ts | 84 +- styles/src/styleTree/picker.ts | 152 +- styles/src/styleTree/projectPanel.ts | 212 +- styles/src/styleTree/search.ts | 216 +- .../styleTree/simpleMessageNotification.ts | 82 +- styles/src/styleTree/statusBar.ts | 266 +- styles/src/styleTree/tabBar.ts | 200 +- styles/src/styleTree/toolbarDropdownMenu.ts | 100 +- styles/src/styleTree/updateNotification.ts | 60 +- styles/src/styleTree/welcome.ts | 240 +- styles/src/styleTree/workspace.ts | 704 ++--- styles/vitest.config.ts | 8 + 25 files changed, 4509 insertions(+), 2126 deletions(-) create mode 100644 styles/src/element/interactive/index.ts create mode 100644 styles/src/element/interactive/interactive.test.ts rename styles/src/{styleTree => element/interactive}/interactive.ts (58%) create mode 100644 styles/vitest.config.ts diff --git a/styles/.gitignore b/styles/.gitignore index c2658d7d1b31848c3b71960543cb0368e56cd4c7..25fbf5a1c42c82c0f45aa74514722b67863ba17d 100644 --- a/styles/.gitignore +++ b/styles/.gitignore @@ -1 +1,2 @@ node_modules/ +coverage/ diff --git a/styles/package-lock.json b/styles/package-lock.json index b4bdd52c66463b020f0798a03494920f9206d874..faa64043b6fc5fe9febb4dd6f73a918da94fd0d7 100644 --- a/styles/package-lock.json +++ b/styles/package-lock.json @@ -20,9 +20,32 @@ "toml": "^3.0.0", "ts-deepmerge": "^6.0.3", "ts-node": "^10.9.1", - "utility-types": "^3.10.0" + "utility-types": "^3.10.0", + "vitest": "^0.32.0" + }, + "devDependencies": { + "@vitest/coverage-v8": "^0.32.0" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" } }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -34,6 +57,359 @@ "node": ">=12" } }, + "node_modules/@esbuild/android-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", + "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", + "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", + "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", + "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", + "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", + "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", + "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", + "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", + "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", + "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", + "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", + "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", + "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", + "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", + "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", + "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", + "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", + "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", + "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", + "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", + "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", + "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", @@ -42,6 +418,15 @@ "node": ">=6.0.0" } }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.14", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", @@ -81,16 +466,124 @@ "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" }, + "node_modules/@types/chai": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.5.tgz", + "integrity": "sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==" + }, + "node_modules/@types/chai-subset": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@types/chai-subset/-/chai-subset-1.3.3.tgz", + "integrity": "sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==", + "dependencies": { + "@types/chai": "*" + } + }, "node_modules/@types/chroma-js": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/@types/chroma-js/-/chroma-js-2.4.0.tgz", "integrity": "sha512-JklMxityrwjBTjGY2anH8JaTx3yjRU3/sEHSblLH1ba5lqcSh1LnImXJZO5peJfXyqKYWjHTGy4s5Wz++hARrw==" }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", + "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "dev": true + }, "node_modules/@types/node": { "version": "18.14.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.1.tgz", "integrity": "sha512-QH+37Qds3E0eDlReeboBxfHbX9omAcBCXEzswCu6jySP642jiM3cYSIkU/REqwhCUqXdonHFuBfJDiAJxMNhaQ==" }, + "node_modules/@vitest/coverage-v8": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-0.32.0.tgz", + "integrity": "sha512-VXXlWq9X/NbsoP/l/CHLBjutsFFww1UY1qEhzGjn/DY7Tqe+z0Nu8XKc8im/XUAmjiWsh2XV7sy/F0IKAl4eaw==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.1", + "@bcoe/v8-coverage": "^0.2.3", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.1", + "istanbul-reports": "^3.1.5", + "magic-string": "^0.30.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "test-exclude": "^6.0.0", + "v8-to-istanbul": "^9.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "vitest": ">=0.32.0 <1" + } + }, + "node_modules/@vitest/expect": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.32.0.tgz", + "integrity": "sha512-VxVHhIxKw9Lux+O9bwLEEk2gzOUe93xuFHy9SzYWnnoYZFYg1NfBtnfnYWiJN7yooJ7KNElCK5YtA7DTZvtXtg==", + "dependencies": { + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "chai": "^4.3.7" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.32.0.tgz", + "integrity": "sha512-QpCmRxftHkr72xt5A08xTEs9I4iWEXIOCHWhQQguWOKE4QH7DXSKZSOFibuwEIMAD7G0ERvtUyQn7iPWIqSwmw==", + "dependencies": { + "@vitest/utils": "0.32.0", + "concordance": "^5.0.4", + "p-limit": "^4.0.0", + "pathe": "^1.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-0.32.0.tgz", + "integrity": "sha512-yCKorPWjEnzpUxQpGlxulujTcSPgkblwGzAUEL+z01FTUg/YuCDZ8dxr9sHA08oO2EwxzHXNLjQKWJ2zc2a19Q==", + "dependencies": { + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "pretty-format": "^27.5.1" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.32.0.tgz", + "integrity": "sha512-MruAPlM0uyiq3d53BkwTeShXY0rYEfhNGQzVO5GHBmmX3clsxcWp79mMnkOVcV244sNTeDcHbcPFWIjOI4tZvw==", + "dependencies": { + "tinyspy": "^2.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.32.0.tgz", + "integrity": "sha512-53yXunzx47MmbuvcOPpLaVljHaeSu1G2dHdmy7+9ngMnQIkBQcvwOcoclWFnxDMxFbnq8exAfh3aKSZaK71J5A==", + "dependencies": { + "concordance": "^5.0.4", + "loupe": "^2.3.6", + "pretty-format": "^27.5.1" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/acorn": { "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", @@ -110,11 +603,38 @@ "node": ">=0.4.0" } }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "engines": { + "node": "*" + } + }, "node_modules/ayu": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/ayu/-/ayu-8.0.1.tgz", @@ -125,11 +645,40 @@ "nonenumerable": "^1.1.1" } }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, "node_modules/bezier-easing": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz", "integrity": "sha512-gbIqZ/eslnUFC1tjEvtz0sgx+xTK20wDnYMIA27VA04R7w6xxXQPZDbibjA9DTWZRA2CXtwHykkVzlCaAJAZig==" }, + "node_modules/blueimp-md5": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", + "integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "engines": { + "node": ">=8" + } + }, "node_modules/case-anything": { "version": "2.1.10", "resolved": "https://registry.npmjs.org/case-anything/-/case-anything-2.1.10.tgz", @@ -141,16 +690,109 @@ "url": "https://github.com/sponsors/mesqueeb" } }, + "node_modules/chai": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", + "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^4.1.2", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", + "engines": { + "node": "*" + } + }, "node_modules/chroma-js": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chroma-js/-/chroma-js-2.4.2.tgz", "integrity": "sha512-U9eDw6+wt7V8z5NncY2jJfZa+hUH8XEj8FQHgFJTrUFnJfXYf4Ml4adI2vXZOjqRDpFWtYVWypDfZwnJ+HIR4A==" }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/concordance": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/concordance/-/concordance-5.0.4.tgz", + "integrity": "sha512-OAcsnTEYu1ARJqWVGwf4zh4JDfHZEaSNlNccFmt8YjB2l/n19/PF2viLINHc57vO4FKIAFl2FWASIGZZWZ2Kxw==", + "dependencies": { + "date-time": "^3.1.0", + "esutils": "^2.0.3", + "fast-diff": "^1.2.0", + "js-string-escape": "^1.0.1", + "lodash": "^4.17.15", + "md5-hex": "^3.0.1", + "semver": "^7.3.2", + "well-known-symbols": "^2.0.0" + }, + "engines": { + "node": ">=10.18.0 <11 || >=12.14.0 <13 || >=14" + } + }, + "node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" }, + "node_modules/date-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz", + "integrity": "sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg==", + "dependencies": { + "time-zone": "^1.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/deepmerge": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", @@ -167,16 +809,564 @@ "node": ">=0.3.1" } }, + "node_modules/esbuild": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", + "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.17.19", + "@esbuild/android-arm64": "0.17.19", + "@esbuild/android-x64": "0.17.19", + "@esbuild/darwin-arm64": "0.17.19", + "@esbuild/darwin-x64": "0.17.19", + "@esbuild/freebsd-arm64": "0.17.19", + "@esbuild/freebsd-x64": "0.17.19", + "@esbuild/linux-arm": "0.17.19", + "@esbuild/linux-arm64": "0.17.19", + "@esbuild/linux-ia32": "0.17.19", + "@esbuild/linux-loong64": "0.17.19", + "@esbuild/linux-mips64el": "0.17.19", + "@esbuild/linux-ppc64": "0.17.19", + "@esbuild/linux-riscv64": "0.17.19", + "@esbuild/linux-s390x": "0.17.19", + "@esbuild/linux-x64": "0.17.19", + "@esbuild/netbsd-x64": "0.17.19", + "@esbuild/openbsd-x64": "0.17.19", + "@esbuild/sunos-x64": "0.17.19", + "@esbuild/win32-arm64": "0.17.19", + "@esbuild/win32-ia32": "0.17.19", + "@esbuild/win32-x64": "0.17.19" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", + "engines": { + "node": "*" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/js-string-escape": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", + "integrity": "sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" + }, + "node_modules/local-pkg": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.3.tgz", + "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/loupe": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "dependencies": { + "get-func-name": "^2.0.0" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/magic-string": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz", + "integrity": "sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.13" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, + "node_modules/md5-hex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz", + "integrity": "sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw==", + "dependencies": { + "blueimp-md5": "^2.10.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mlly": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.3.0.tgz", + "integrity": "sha512-HT5mcgIQKkOrZecOjOX3DJorTikWXwsBfpcr/MGBkhfWcjiqvnaL/9ppxvIUXfjT6xt4DVIAsN9fMUz1ev4bIw==", + "dependencies": { + "acorn": "^8.8.2", + "pathe": "^1.1.0", + "pkg-types": "^1.0.3", + "ufo": "^1.1.2" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/nonenumerable": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/nonenumerable/-/nonenumerable-1.1.1.tgz", "integrity": "sha512-ptUD9w9D8WqW6fuJJkZNCImkf+0vdbgUTbRK3i7jsy3olqtH96hYE6Q/S3Tx9NWbcB/ocAjYshXCAUP0lZ9B4Q==" }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", + "dependencies": { + "yocto-queue": "^1.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathe": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.1.tgz", + "integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==" + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "engines": { + "node": "*" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "node_modules/pkg-types": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.3.tgz", + "integrity": "sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==", + "dependencies": { + "jsonc-parser": "^3.2.0", + "mlly": "^1.2.0", + "pathe": "^1.1.0" + } + }, + "node_modules/postcss": { + "version": "8.4.24", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz", + "integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" + }, + "node_modules/rollup": { + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz", + "integrity": "sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==", + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/semver": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz", + "integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==" + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==" + }, + "node_modules/std-env": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.3.3.tgz", + "integrity": "sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==" + }, + "node_modules/strip-literal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.1.tgz", + "integrity": "sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==", + "dependencies": { + "acorn": "^8.8.2" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/time-zone": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", + "integrity": "sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/tinybench": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.5.0.tgz", + "integrity": "sha512-kRwSG8Zx4tjF9ZiyH4bhaebu+EDz1BOx9hOigYHlUW4xxI/wKIUQUqo018UlU4ar6ATPBsaMrdbKZ+tmPdohFA==" + }, + "node_modules/tinypool": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.5.0.tgz", + "integrity": "sha512-paHQtnrlS1QZYKF/GnLoOM/DN9fqaGOFbCbxzAhwniySnzl9Ebk8w73/dd34DAhe/obUbPAOldTyYXQZxnPBPQ==", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-2.1.1.tgz", + "integrity": "sha512-XPJL2uSzcOyBMky6OFrusqWlzfFrXtE0hPuMgW8A2HmaqrPo4ZQHRN/V0QXN3FSjKxpsbRrFc5LI7KOwBsT1/w==", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/toml": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", @@ -227,36 +1417,253 @@ "@swc/core": { "optional": true }, - "@swc/wasm": { + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "engines": { + "node": ">=4" + } + }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/ufo": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.1.2.tgz", + "integrity": "sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==" + }, + "node_modules/utility-types": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", + "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==", + "engines": { + "node": ">= 4" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" + }, + "node_modules/v8-to-istanbul": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", + "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/v8-to-istanbul/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.18", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", + "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + }, + "node_modules/vite": { + "version": "4.3.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz", + "integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==", + "dependencies": { + "esbuild": "^0.17.5", + "postcss": "^8.4.23", + "rollup": "^3.21.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@types/node": ">= 14", + "less": "*", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.32.0.tgz", + "integrity": "sha512-220P/y8YacYAU+daOAqiGEFXx2A8AwjadDzQqos6wSukjvvTWNqleJSwoUn0ckyNdjHIKoxn93Nh1vWBqEKr3Q==", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "mlly": "^1.2.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "vite": "^3.0.0 || ^4.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": ">=v14.18.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.32.0.tgz", + "integrity": "sha512-SW83o629gCqnV3BqBnTxhB10DAwzwEx3z+rqYZESehUB+eWsJxwcBQx7CKy0otuGMJTYh7qCVuUX23HkftGl/Q==", + "dependencies": { + "@types/chai": "^4.3.5", + "@types/chai-subset": "^1.3.3", + "@types/node": "*", + "@vitest/expect": "0.32.0", + "@vitest/runner": "0.32.0", + "@vitest/snapshot": "0.32.0", + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "acorn": "^8.8.2", + "acorn-walk": "^8.2.0", + "cac": "^6.7.14", + "chai": "^4.3.7", + "concordance": "^5.0.4", + "debug": "^4.3.4", + "local-pkg": "^0.4.3", + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "strip-literal": "^1.0.1", + "tinybench": "^2.5.0", + "tinypool": "^0.5.0", + "vite": "^3.0.0 || ^4.0.0", + "vite-node": "0.32.0", + "why-is-node-running": "^2.2.2" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": ">=v14.18.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@vitest/browser": "*", + "@vitest/ui": "*", + "happy-dom": "*", + "jsdom": "*", + "playwright": "*", + "safaridriver": "*", + "webdriverio": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "playwright": { + "optional": true + }, + "safaridriver": { + "optional": true + }, + "webdriverio": { "optional": true } } }, - "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, + "node_modules/well-known-symbols": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz", + "integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==", "engines": { - "node": ">=4.2.0" + "node": ">=6" } }, - "node_modules/utility-types": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", - "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==", + "node_modules/why-is-node-running": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", + "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, "engines": { - "node": ">= 4" + "node": ">=8" } }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/yn": { "version": "3.1.1", @@ -265,9 +1672,36 @@ "engines": { "node": ">=6" } + }, + "node_modules/yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } }, "dependencies": { + "@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, + "requires": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, "@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -276,11 +1710,166 @@ "@jridgewell/trace-mapping": "0.3.9" } }, + "@esbuild/android-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", + "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", + "optional": true + }, + "@esbuild/android-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", + "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", + "optional": true + }, + "@esbuild/android-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", + "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", + "optional": true + }, + "@esbuild/darwin-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", + "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", + "optional": true + }, + "@esbuild/darwin-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", + "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", + "optional": true + }, + "@esbuild/freebsd-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", + "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", + "optional": true + }, + "@esbuild/freebsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", + "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", + "optional": true + }, + "@esbuild/linux-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", + "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", + "optional": true + }, + "@esbuild/linux-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", + "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", + "optional": true + }, + "@esbuild/linux-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", + "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", + "optional": true + }, + "@esbuild/linux-loong64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", + "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", + "optional": true + }, + "@esbuild/linux-mips64el": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", + "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", + "optional": true + }, + "@esbuild/linux-ppc64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", + "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", + "optional": true + }, + "@esbuild/linux-riscv64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", + "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", + "optional": true + }, + "@esbuild/linux-s390x": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", + "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", + "optional": true + }, + "@esbuild/linux-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", + "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", + "optional": true + }, + "@esbuild/netbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", + "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", + "optional": true + }, + "@esbuild/openbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", + "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", + "optional": true + }, + "@esbuild/sunos-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", + "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", + "optional": true + }, + "@esbuild/win32-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", + "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", + "optional": true + }, + "@esbuild/win32-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", + "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", + "optional": true + }, + "@esbuild/win32-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", + "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", + "optional": true + }, + "@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true + }, + "@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, "@jridgewell/resolve-uri": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==" }, + "@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true + }, "@jridgewell/sourcemap-codec": { "version": "1.4.14", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", @@ -320,16 +1909,103 @@ "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" }, + "@types/chai": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.5.tgz", + "integrity": "sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==" + }, + "@types/chai-subset": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@types/chai-subset/-/chai-subset-1.3.3.tgz", + "integrity": "sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==", + "requires": { + "@types/chai": "*" + } + }, "@types/chroma-js": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/@types/chroma-js/-/chroma-js-2.4.0.tgz", "integrity": "sha512-JklMxityrwjBTjGY2anH8JaTx3yjRU3/sEHSblLH1ba5lqcSh1LnImXJZO5peJfXyqKYWjHTGy4s5Wz++hARrw==" }, + "@types/istanbul-lib-coverage": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", + "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "dev": true + }, "@types/node": { "version": "18.14.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.1.tgz", "integrity": "sha512-QH+37Qds3E0eDlReeboBxfHbX9omAcBCXEzswCu6jySP642jiM3cYSIkU/REqwhCUqXdonHFuBfJDiAJxMNhaQ==" }, + "@vitest/coverage-v8": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-0.32.0.tgz", + "integrity": "sha512-VXXlWq9X/NbsoP/l/CHLBjutsFFww1UY1qEhzGjn/DY7Tqe+z0Nu8XKc8im/XUAmjiWsh2XV7sy/F0IKAl4eaw==", + "dev": true, + "requires": { + "@ampproject/remapping": "^2.2.1", + "@bcoe/v8-coverage": "^0.2.3", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.1", + "istanbul-reports": "^3.1.5", + "magic-string": "^0.30.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "test-exclude": "^6.0.0", + "v8-to-istanbul": "^9.1.0" + } + }, + "@vitest/expect": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.32.0.tgz", + "integrity": "sha512-VxVHhIxKw9Lux+O9bwLEEk2gzOUe93xuFHy9SzYWnnoYZFYg1NfBtnfnYWiJN7yooJ7KNElCK5YtA7DTZvtXtg==", + "requires": { + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "chai": "^4.3.7" + } + }, + "@vitest/runner": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.32.0.tgz", + "integrity": "sha512-QpCmRxftHkr72xt5A08xTEs9I4iWEXIOCHWhQQguWOKE4QH7DXSKZSOFibuwEIMAD7G0ERvtUyQn7iPWIqSwmw==", + "requires": { + "@vitest/utils": "0.32.0", + "concordance": "^5.0.4", + "p-limit": "^4.0.0", + "pathe": "^1.1.0" + } + }, + "@vitest/snapshot": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-0.32.0.tgz", + "integrity": "sha512-yCKorPWjEnzpUxQpGlxulujTcSPgkblwGzAUEL+z01FTUg/YuCDZ8dxr9sHA08oO2EwxzHXNLjQKWJ2zc2a19Q==", + "requires": { + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "pretty-format": "^27.5.1" + } + }, + "@vitest/spy": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.32.0.tgz", + "integrity": "sha512-MruAPlM0uyiq3d53BkwTeShXY0rYEfhNGQzVO5GHBmmX3clsxcWp79mMnkOVcV244sNTeDcHbcPFWIjOI4tZvw==", + "requires": { + "tinyspy": "^2.1.0" + } + }, + "@vitest/utils": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.32.0.tgz", + "integrity": "sha512-53yXunzx47MmbuvcOPpLaVljHaeSu1G2dHdmy7+9ngMnQIkBQcvwOcoclWFnxDMxFbnq8exAfh3aKSZaK71J5A==", + "requires": { + "concordance": "^5.0.4", + "loupe": "^2.3.6", + "pretty-format": "^27.5.1" + } + }, "acorn": { "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", @@ -340,11 +2016,26 @@ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==" + }, "arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" + }, "ayu": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/ayu/-/ayu-8.0.1.tgz", @@ -355,26 +2046,122 @@ "nonenumerable": "^1.1.1" } }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, "bezier-easing": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz", "integrity": "sha512-gbIqZ/eslnUFC1tjEvtz0sgx+xTK20wDnYMIA27VA04R7w6xxXQPZDbibjA9DTWZRA2CXtwHykkVzlCaAJAZig==" }, + "blueimp-md5": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", + "integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==" + }, "case-anything": { "version": "2.1.10", "resolved": "https://registry.npmjs.org/case-anything/-/case-anything-2.1.10.tgz", "integrity": "sha512-JczJwVrCP0jPKh05McyVsuOg6AYosrB9XWZKbQzXeDAm2ClE/PJE/BcrrQrVyGYH7Jg8V/LDupmyL4kFlVsVFQ==" }, + "chai": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", + "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^4.1.2", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==" + }, "chroma-js": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chroma-js/-/chroma-js-2.4.2.tgz", "integrity": "sha512-U9eDw6+wt7V8z5NncY2jJfZa+hUH8XEj8FQHgFJTrUFnJfXYf4Ml4adI2vXZOjqRDpFWtYVWypDfZwnJ+HIR4A==" }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "concordance": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/concordance/-/concordance-5.0.4.tgz", + "integrity": "sha512-OAcsnTEYu1ARJqWVGwf4zh4JDfHZEaSNlNccFmt8YjB2l/n19/PF2viLINHc57vO4FKIAFl2FWASIGZZWZ2Kxw==", + "requires": { + "date-time": "^3.1.0", + "esutils": "^2.0.3", + "fast-diff": "^1.2.0", + "js-string-escape": "^1.0.1", + "lodash": "^4.17.15", + "md5-hex": "^3.0.1", + "semver": "^7.3.2", + "well-known-symbols": "^2.0.0" + } + }, + "convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, "create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" }, + "date-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz", + "integrity": "sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg==", + "requires": { + "time-zone": "^1.0.0" + } + }, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "requires": { + "type-detect": "^4.0.0" + } + }, "deepmerge": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", @@ -385,16 +2172,414 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" }, + "esbuild": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", + "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", + "requires": { + "@esbuild/android-arm": "0.17.19", + "@esbuild/android-arm64": "0.17.19", + "@esbuild/android-x64": "0.17.19", + "@esbuild/darwin-arm64": "0.17.19", + "@esbuild/darwin-x64": "0.17.19", + "@esbuild/freebsd-arm64": "0.17.19", + "@esbuild/freebsd-x64": "0.17.19", + "@esbuild/linux-arm": "0.17.19", + "@esbuild/linux-arm64": "0.17.19", + "@esbuild/linux-ia32": "0.17.19", + "@esbuild/linux-loong64": "0.17.19", + "@esbuild/linux-mips64el": "0.17.19", + "@esbuild/linux-ppc64": "0.17.19", + "@esbuild/linux-riscv64": "0.17.19", + "@esbuild/linux-s390x": "0.17.19", + "@esbuild/linux-x64": "0.17.19", + "@esbuild/netbsd-x64": "0.17.19", + "@esbuild/openbsd-x64": "0.17.19", + "@esbuild/sunos-x64": "0.17.19", + "@esbuild/win32-arm64": "0.17.19", + "@esbuild/win32-ia32": "0.17.19", + "@esbuild/win32-x64": "0.17.19" + } + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==" + }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true + }, + "istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + } + }, + "istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + } + }, + "istanbul-reports": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "dev": true, + "requires": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + } + }, + "js-string-escape": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", + "integrity": "sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==" + }, + "jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" + }, + "local-pkg": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.3.tgz", + "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==" + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "loupe": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "requires": { + "get-func-name": "^2.0.0" + } + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "magic-string": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz", + "integrity": "sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==", + "requires": { + "@jridgewell/sourcemap-codec": "^1.4.13" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, + "md5-hex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz", + "integrity": "sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw==", + "requires": { + "blueimp-md5": "^2.10.0" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "mlly": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.3.0.tgz", + "integrity": "sha512-HT5mcgIQKkOrZecOjOX3DJorTikWXwsBfpcr/MGBkhfWcjiqvnaL/9ppxvIUXfjT6xt4DVIAsN9fMUz1ev4bIw==", + "requires": { + "acorn": "^8.8.2", + "pathe": "^1.1.0", + "pkg-types": "^1.0.3", + "ufo": "^1.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==" + }, "nonenumerable": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/nonenumerable/-/nonenumerable-1.1.1.tgz", "integrity": "sha512-ptUD9w9D8WqW6fuJJkZNCImkf+0vdbgUTbRK3i7jsy3olqtH96hYE6Q/S3Tx9NWbcB/ocAjYshXCAUP0lZ9B4Q==" }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "p-limit": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", + "requires": { + "yocto-queue": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true + }, + "pathe": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.1.tgz", + "integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==" + }, + "pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==" + }, + "picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "pkg-types": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.3.tgz", + "integrity": "sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==", + "requires": { + "jsonc-parser": "^3.2.0", + "mlly": "^1.2.0", + "pathe": "^1.1.0" + } + }, + "postcss": { + "version": "8.4.24", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz", + "integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==", + "requires": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + } + }, + "pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "requires": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + } + }, + "react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" + }, + "rollup": { + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz", + "integrity": "sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==", + "requires": { + "fsevents": "~2.3.2" + } + }, + "semver": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz", + "integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==", + "requires": { + "lru-cache": "^6.0.0" + } + }, + "siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==" + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" + }, + "stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==" + }, + "std-env": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.3.3.tgz", + "integrity": "sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==" + }, + "strip-literal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.1.tgz", + "integrity": "sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==", + "requires": { + "acorn": "^8.8.2" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + } + }, + "time-zone": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", + "integrity": "sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==" + }, + "tinybench": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.5.0.tgz", + "integrity": "sha512-kRwSG8Zx4tjF9ZiyH4bhaebu+EDz1BOx9hOigYHlUW4xxI/wKIUQUqo018UlU4ar6ATPBsaMrdbKZ+tmPdohFA==" + }, + "tinypool": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.5.0.tgz", + "integrity": "sha512-paHQtnrlS1QZYKF/GnLoOM/DN9fqaGOFbCbxzAhwniySnzl9Ebk8w73/dd34DAhe/obUbPAOldTyYXQZxnPBPQ==" + }, + "tinyspy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-2.1.1.tgz", + "integrity": "sha512-XPJL2uSzcOyBMky6OFrusqWlzfFrXtE0hPuMgW8A2HmaqrPo4ZQHRN/V0QXN3FSjKxpsbRrFc5LI7KOwBsT1/w==" + }, "toml": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", @@ -425,12 +2610,22 @@ "yn": "3.1.1" } }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + }, "typescript": { "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "peer": true }, + "ufo": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.1.2.tgz", + "integrity": "sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==" + }, "utility-types": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", @@ -441,10 +2636,119 @@ "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" }, + "v8-to-istanbul": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", + "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0" + }, + "dependencies": { + "@jridgewell/trace-mapping": { + "version": "0.3.18", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", + "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + } + } + }, + "vite": { + "version": "4.3.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz", + "integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==", + "requires": { + "esbuild": "^0.17.5", + "fsevents": "~2.3.2", + "postcss": "^8.4.23", + "rollup": "^3.21.0" + } + }, + "vite-node": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.32.0.tgz", + "integrity": "sha512-220P/y8YacYAU+daOAqiGEFXx2A8AwjadDzQqos6wSukjvvTWNqleJSwoUn0ckyNdjHIKoxn93Nh1vWBqEKr3Q==", + "requires": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "mlly": "^1.2.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "vite": "^3.0.0 || ^4.0.0" + } + }, + "vitest": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.32.0.tgz", + "integrity": "sha512-SW83o629gCqnV3BqBnTxhB10DAwzwEx3z+rqYZESehUB+eWsJxwcBQx7CKy0otuGMJTYh7qCVuUX23HkftGl/Q==", + "requires": { + "@types/chai": "^4.3.5", + "@types/chai-subset": "^1.3.3", + "@types/node": "*", + "@vitest/expect": "0.32.0", + "@vitest/runner": "0.32.0", + "@vitest/snapshot": "0.32.0", + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "acorn": "^8.8.2", + "acorn-walk": "^8.2.0", + "cac": "^6.7.14", + "chai": "^4.3.7", + "concordance": "^5.0.4", + "debug": "^4.3.4", + "local-pkg": "^0.4.3", + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "strip-literal": "^1.0.1", + "tinybench": "^2.5.0", + "tinypool": "^0.5.0", + "vite": "^3.0.0 || ^4.0.0", + "vite-node": "0.32.0", + "why-is-node-running": "^2.2.2" + } + }, + "well-known-symbols": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz", + "integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==" + }, + "why-is-node-running": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", + "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==", + "requires": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==" + }, + "yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==" } } } diff --git a/styles/package.json b/styles/package.json index 30336d5c519a30ba68aef0be7541d86d8f7b6bc3..9907b0cbff0281653bdb3817fc04c62cd4dffa53 100644 --- a/styles/package.json +++ b/styles/package.json @@ -6,7 +6,8 @@ "scripts": { "build": "ts-node ./src/buildThemes.ts", "build-licenses": "ts-node ./src/buildLicenses.ts", - "build-tokens": "ts-node ./src/buildTokens.ts" + "build-tokens": "ts-node ./src/buildTokens.ts", + "test": "vitest" }, "author": "", "license": "ISC", @@ -22,12 +23,16 @@ "toml": "^3.0.0", "ts-deepmerge": "^6.0.3", "ts-node": "^10.9.1", - "utility-types": "^3.10.0" + "utility-types": "^3.10.0", + "vitest": "^0.32.0" }, "prettier": { "semi": false, "printWidth": 80, "htmlWhitespaceSensitivity": "strict", "tabWidth": 4 + }, + "devDependencies": { + "@vitest/coverage-v8": "^0.32.0" } } diff --git a/styles/src/element/interactive/index.ts b/styles/src/element/interactive/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..0ead902eb94c12f11c1cf076a599c10762f4d514 --- /dev/null +++ b/styles/src/element/interactive/index.ts @@ -0,0 +1,3 @@ +import { interactive } from "./interactive"; + +export { interactive } diff --git a/styles/src/element/interactive/interactive.test.ts b/styles/src/element/interactive/interactive.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa716e998ec3db8a042af72cc911925726a58f53 --- /dev/null +++ b/styles/src/element/interactive/interactive.test.ts @@ -0,0 +1,59 @@ +import { NOT_ENOUGH_STATES_ERROR, NO_DEFAULT_OR_BASE_ERROR, interactive } from './interactive' +import { describe, it, expect } from 'vitest' + +describe('interactive', () => { + + it('creates an Interactive with base properties and states', () => { + + const result = interactive({ + base: { fontSize: 10, color: '#FFFFFF' }, + state: { + hovered: { color: '#EEEEEE' }, + clicked: { color: '#CCCCCC' }, + } + }) + + expect(result).toEqual({ + default: { color: '#FFFFFF', fontSize: 10 }, + hovered: { color: '#EEEEEE', fontSize: 10 }, + clicked: { color: '#CCCCCC', fontSize: 10 }, + }) + }) + + it('creates an Interactive with no base properties', () => { + + const result = interactive({ + state: { + default: { color: '#FFFFFF', fontSize: 10 }, + hovered: { color: '#EEEEEE' }, + clicked: { color: '#CCCCCC' }, + } + }) + + expect(result).toEqual({ + default: { color: '#FFFFFF', fontSize: 10 }, + hovered: { color: '#EEEEEE', fontSize: 10 }, + clicked: { color: '#CCCCCC', fontSize: 10 }, + }) + }) + + it('throws error when both default and base are missing', () => { + const state = { + hovered: { color: 'blue' }, + } + + expect(() => interactive({ state })).toThrow( + NO_DEFAULT_OR_BASE_ERROR + ) + }) + + it('throws error when no other state besides default is present', () => { + const state = { + default: { fontSize: 10 }, + } + + expect(() => interactive({ state })).toThrow( + NOT_ENOUGH_STATES_ERROR + ) + }) +}) diff --git a/styles/src/styleTree/interactive.ts b/styles/src/element/interactive/interactive.ts similarity index 58% rename from styles/src/styleTree/interactive.ts rename to styles/src/element/interactive/interactive.ts index 6bc6ca048be6f3619c0d76facc5a729b4a4d91f7..23cd2a8c15a0cdf95b31f6fbb670edef717559d0 100644 --- a/styles/src/styleTree/interactive.ts +++ b/styles/src/element/interactive/interactive.ts @@ -10,24 +10,27 @@ type Interactive = { disabled?: T, }; +export const NO_DEFAULT_OR_BASE_ERROR = "An interactive object must have a default state, or a base property." +export const NOT_ENOUGH_STATES_ERROR = "An interactive object must have a default and at least one other state." + interface InteractiveProps { base?: T, state: Partial> } /** - * Helper function for creating Interactive objects that works pretty much like Toggle. - * It takes a object to be used as a value for `default` field and then fills out other fields - * with fields from either `base` or `modifications`. - * Notably, it does not touch `hover`, `clicked` and `disabled` if there are no modifications for it. + * Helper function for creating Interactive objects that works with Toggle-like behavior. + * It takes a default object to be used as the value for `default` field and fills out other fields + * with fields from either `base` or from the `state` object which contains values for specific states. + * Notably, it does not touch `hover`, `clicked`, `selected` and `disabled` states if there are no modifications for them. * - * @param defaultObj Object to be used as the value for `default` field. - * @param base Object containing base fields to be included in the resulting object. - * @param modifications Object containing modified fields to be included in the resulting object. - * @returns Interactive object with fields from `base` and `modifications`. + * @param defaultObj Object to be used as the value for the `default` field. + * @param base Optional object containing base fields to be included in the resulting object. + * @param state Object containing optional modified fields to be included in the resulting object for each state. + * @returns Interactive object with fields from `base` and `state`. */ export function interactive({ base, state }: InteractiveProps): Interactive { - if (!base && !state.default) throw new Error("An interactive object must have a default state, or a base property."); + if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR); let defaultState: T; @@ -64,7 +67,7 @@ export function interactive({ base, state }: InteractiveProps< } if (stateCount < 1) { - throw new Error("An interactive object must have a default and at least one other state."); + throw new Error(NOT_ENOUGH_STATES_ERROR); } return interactiveObj; diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index d501237721fcb5196ed1c3082ee4522548e5cd50..b31fe8169eb0693077a4ef59671bdddce13ec408 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -1,94 +1,94 @@ import { ColorScheme } from "../theme/colorScheme" import { text, border, background, foreground } from "./components" import editor from "./editor" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function assistant(colorScheme: ColorScheme) { - const layer = colorScheme.highest - return { - container: { - background: editor(colorScheme).background, - padding: { left: 12 }, - }, - header: { - border: border(layer, "default", { bottom: true, top: true }), - margin: { bottom: 6, top: 6 }, - background: editor(colorScheme).background, - }, - userSender: { - default: - { ...text(layer, "sans", "default", { size: "sm", weight: "bold" }) }, - }, - assistantSender: { - default: { - ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }) - }, - }, - systemSender: { - default: { - ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }) - }, - }, - sentAt: { - margin: { top: 2, left: 8 }, - ...text(layer, "sans", "default", { size: "2xs" }), - }, - modelInfoContainer: { - margin: { right: 16, top: 4 }, - }, - model: interactive({ - base: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - cornerRadius: 4, - ...text(layer, "sans", "default", { size: "xs" }), - }, state: { - hovered: { - background: background(layer, "on", "hovered"), - } - } - }), - remainingTokens: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - margin: { left: 4 }, - cornerRadius: 4, - ...text(layer, "sans", "positive", { size: "xs" }), - }, - noRemainingTokens: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - margin: { left: 4 }, - cornerRadius: 4, - ...text(layer, "sans", "negative", { size: "xs" }), - }, - errorIcon: { - margin: { left: 8 }, - color: foreground(layer, "negative"), - width: 12, - }, - apiKeyEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - }, - apiKeyPrompt: { - padding: 10, - ...text(layer, "sans", "default", { size: "xs" }), - }, - } + const layer = colorScheme.highest + return { + container: { + background: editor(colorScheme).background, + padding: { left: 12 }, + }, + header: { + border: border(layer, "default", { bottom: true, top: true }), + margin: { bottom: 6, top: 6 }, + background: editor(colorScheme).background, + }, + userSender: { + default: + { ...text(layer, "sans", "default", { size: "sm", weight: "bold" }) }, + }, + assistantSender: { + default: { + ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }) + }, + }, + systemSender: { + default: { + ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }) + }, + }, + sentAt: { + margin: { top: 2, left: 8 }, + ...text(layer, "sans", "default", { size: "2xs" }), + }, + modelInfoContainer: { + margin: { right: 16, top: 4 }, + }, + model: interactive({ + base: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + cornerRadius: 4, + ...text(layer, "sans", "default", { size: "xs" }), + }, state: { + hovered: { + background: background(layer, "on", "hovered"), + } + } + }), + remainingTokens: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + margin: { left: 4 }, + cornerRadius: 4, + ...text(layer, "sans", "positive", { size: "xs" }), + }, + noRemainingTokens: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + margin: { left: 4 }, + cornerRadius: 4, + ...text(layer, "sans", "negative", { size: "xs" }), + }, + errorIcon: { + margin: { left: 8 }, + color: foreground(layer, "negative"), + width: 12, + }, + apiKeyEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + }, + apiKeyPrompt: { + padding: 10, + ...text(layer, "sans", "default", { size: "xs" }), + }, + } } diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index d6cb196770058ee267c3914e065a94ac7aa4e138..081a0ba68c1dce191c6fc6b6f5d9bcc7243f3c11 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -2,38 +2,38 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" import { toggleable } from "./toggle" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function commandPalette(colorScheme: ColorScheme) { - let layer = colorScheme.highest - return { - keystrokeSpacing: 8, - key: - toggleable(interactive({ - base: { - text: text(layer, "mono", "variant", "default", { size: "xs" }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - }, state: { hovered: { cornerRadius: 4, padding: { top: 17 } } } - }), { - default: { - text: text(layer, "mono", "on", "default", { size: "xs" }), - background: withOpacity(background(layer, "on"), 0.2), - } + let layer = colorScheme.highest + return { + keystrokeSpacing: 8, + key: + toggleable(interactive({ + base: { + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, state: { hovered: { cornerRadius: 4, padding: { top: 17 } } } + }), { + default: { + text: text(layer, "mono", "on", "default", { size: "xs" }), + background: withOpacity(background(layer, "on"), 0.2), + } - }) - , + }) + , - } + } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 4309343ed257bad38b40b56767bef46bed57625d..3b95a3c885f24d11d210c0c5c288811be39b57d5 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -1,218 +1,218 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" import { toggleable } from "./toggle" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function contactsPanel(colorScheme: ColorScheme) { - const nameMargin = 8 - const sidePadding = 12 + const nameMargin = 8 + const sidePadding = 12 - let layer = colorScheme.middle + let layer = colorScheme.middle - const contactButton = { - background: background(layer, "on"), - color: foreground(layer, "on"), - iconWidth: 8, - buttonWidth: 16, - cornerRadius: 8, - } - const projectRow = { - guestAvatarSpacing: 4, - height: 24, - guestAvatar: { - cornerRadius: 8, - width: 14, - }, - name: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - right: 6, - }, - }, - guests: { - margin: { - left: nameMargin, - right: nameMargin, - }, - }, - padding: { - left: sidePadding, - right: sidePadding, - }, - } - - return { - background: background(layer), - padding: { top: 12 }, - userQueryEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - margin: { - left: 6, - }, - }, - userQueryEditorHeight: 33, - addContactButton: { - margin: { left: 6, right: 12 }, - color: foreground(layer, "on"), - buttonWidth: 28, - iconWidth: 16, - }, - rowHeight: 28, - sectionIconSize: 8, - headerRow: toggleable(interactive({ - base: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, + const contactButton = { + background: background(layer, "on"), + color: foreground(layer, "on"), + iconWidth: 8, + buttonWidth: 16, + cornerRadius: 8, + } + const projectRow = { + guestAvatarSpacing: 4, + height: 24, + guestAvatar: { + cornerRadius: 8, + width: 14, }, - background: background(layer, "default"),// posiewic: breaking change - } - , state: { hovered: { background: background(layer, "default") } } // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. - }), - { - default: { - ...text(layer, "mono", "active", { size: "sm" }), - background: background(layer, "active"), + name: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + right: 6, + }, }, - }), - leaveCall: interactive({ - base: { - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, + guests: { + margin: { + left: nameMargin, + right: nameMargin, + }, }, padding: { - top: 1, - bottom: 1, - left: 7, - right: 7, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - } - , - state: { - hovered: { - ...text(layer, "sans", "hovered", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "hovered"), - } - } - } - ), - contactRow: { - inactive: { - default: { - padding: { left: sidePadding, right: sidePadding, - } }, - }, - active: { - default: { - background: background(layer, "active"), - padding: { - left: sidePadding, - right: sidePadding, - } + } + + return { + background: background(layer), + padding: { top: 12 }, + userQueryEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + margin: { + left: 6, + }, + }, + userQueryEditorHeight: 33, + addContactButton: { + margin: { left: 6, right: 12 }, + color: foreground(layer, "on"), + buttonWidth: 28, + iconWidth: 16, + }, + rowHeight: 28, + sectionIconSize: 8, + headerRow: toggleable(interactive({ + base: { + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"),// posiewic: breaking change + } + , state: { hovered: { background: background(layer, "default") } } // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. + }), + { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), + }, + }), + leaveCall: interactive({ + base: { + background: background(layer), + border: border(layer), + cornerRadius: 6, + margin: { + top: 1, + }, + padding: { + top: 1, + bottom: 1, + left: 7, + right: 7, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + } + , + state: { + hovered: { + ...text(layer, "sans", "hovered", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "hovered"), + } + } } - }, - }, + ), + contactRow: { + inactive: { + default: { + padding: { + left: sidePadding, + right: sidePadding, + } + }, + }, + active: { + default: { + background: background(layer, "active"), + padding: { + left: sidePadding, + right: sidePadding, + } + } + }, + }, - contactAvatar: { - cornerRadius: 10, - width: 18, - }, - contactStatusFree: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "positive"), - }, - contactStatusBusy: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "negative"), - }, - contactUsername: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - }, - }, - contactButtonSpacing: nameMargin, - contactButton: interactive({ - base: { ...contactButton }, - state: { - hovered: { - background: background(layer, "hovered"), + contactAvatar: { + cornerRadius: 10, + width: 18, }, - } - }), - disabledButton: { - ...contactButton, - background: background(layer, "on"), - color: foreground(layer, "on"), - }, - callingIndicator: { - ...text(layer, "mono", "variant", { size: "xs" }), - }, - treeBranch: toggleable(interactive({ - base: { - color: borderColor(layer), - width: 1, - }, - state: { - hovered: { - color: borderColor(layer), + contactStatusFree: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "positive"), }, - } - }), - { - default: { - color: borderColor(layer), + contactStatusBusy: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "negative"), }, - } - ), - projectRow: toggleable(interactive({ - base: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, + contactUsername: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + }, }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), + contactButtonSpacing: nameMargin, + contactButton: interactive({ + base: { ...contactButton }, + state: { + hovered: { + background: background(layer, "hovered"), + }, + } + }), + disabledButton: { + ...contactButton, + background: background(layer, "on"), + color: foreground(layer, "on"), }, - }, state: { - hovered: { - background: background(layer, "hovered"), + callingIndicator: { + ...text(layer, "mono", "variant", { size: "xs" }), }, - } - }), - { - default: { background: background(layer, "active") } - }) - } + treeBranch: toggleable(interactive({ + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { + color: borderColor(layer), + }, + } + }), + { + default: { + color: borderColor(layer), + }, + } + ), + projectRow: toggleable(interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, + }, state: { + hovered: { + background: background(layer, "hovered"), + }, + } + }), + { + default: { background: background(layer, "active") } + }) + } } diff --git a/styles/src/styleTree/contactNotification.ts b/styles/src/styleTree/contactNotification.ts index 5b29e15e6bdb60bc2f5743123b09f9e9fe1a35da..4d572390052b11a97ad59d47a3320eac1ee0b921 100644 --- a/styles/src/styleTree/contactNotification.ts +++ b/styles/src/styleTree/contactNotification.ts @@ -1,54 +1,54 @@ import { ColorScheme } from "../theme/colorScheme" import { background, foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" const avatarSize = 12 const headerPadding = 8 export default function contactNotification(colorScheme: ColorScheme): Object { - let layer = colorScheme.lowest - return { - headerAvatar: { - height: avatarSize, - width: avatarSize, - cornerRadius: 6, - }, - headerMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, - }, - headerHeight: 18, - bodyMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: avatarSize + headerPadding, top: 6, bottom: 6 }, - }, - button: - interactive({ - base: { - ...text(layer, "sans", "on", { size: "xs" }), - background: background(layer, "on"), - padding: 4, - cornerRadius: 6, - margin: { left: 6 } + let layer = colorScheme.lowest + return { + headerAvatar: { + height: avatarSize, + width: avatarSize, + cornerRadius: 6, }, + headerMessage: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, + }, + headerHeight: 18, + bodyMessage: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: avatarSize + headerPadding, top: 6, bottom: 6 }, + }, + button: + interactive({ + base: { + ...text(layer, "sans", "on", { size: "xs" }), + background: background(layer, "on"), + padding: 4, + cornerRadius: 6, + margin: { left: 6 } + }, - state: { - hovered: { - background: background(layer, "on", "hovered"), - } - } - }), + state: { + hovered: { + background: background(layer, "on", "hovered"), + } + } + }), - dismissButton: { - default: { - color: foreground(layer, "variant"), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), + dismissButton: { + default: { + color: foreground(layer, "variant"), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8, + hover: { + color: foreground(layer, "hovered"), + }, + } }, - } - }, - } + } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 2d5e84dcf0aa6633730172ef7b10ab1e8f3435f3..51bff9de7fed6e83ffd2486003bb8aa73fa2cc47 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -1,56 +1,56 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function contextMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle - return { - background: background(layer), - cornerRadius: 10, - padding: 4, - shadow: colorScheme.popoverShadow, - border: border(layer), - keystrokeMargin: 30, - item: toggleable(interactive({ - base: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - } - }, state: { - hovered: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "hovered", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - } - } - }), { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - }), + let layer = colorScheme.middle + return { + background: background(layer), + cornerRadius: 10, + padding: 4, + shadow: colorScheme.popoverShadow, + border: border(layer), + keystrokeMargin: 30, + item: toggleable(interactive({ + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + } + }, state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + } + } + }), { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + }), - separator: { - background: borderColor(layer), - margin: { top: 2, bottom: 2 }, - }, - } + separator: { + background: borderColor(layer), + margin: { top: 2, bottom: 2 }, + }, + } } diff --git a/styles/src/styleTree/copilot.ts b/styles/src/styleTree/copilot.ts index 6440941e64eb9678e9ab24430edd13f6922e5105..27ef5ec11c49548adb8c6d22823e713126a16d36 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -1,286 +1,286 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, svg, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function copilot(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - let content_width = 264 + let content_width = 264 - let ctaButton = - // Copied from welcome screen. FIXME: Move this into a ZDS component - interactive({ - base: { - background: background(layer), - border: border(layer, "default"), - cornerRadius: 4, - margin: { - top: 4, - bottom: 4, - left: 8, - right: 8, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }) - }, - state: { - hovered: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - } - }); - - return { - outLinkIcon: - interactive({ - base: { - icon: svg( - foreground(layer, "variant"), - "icons/link_out_12.svg", - 12, - 12 - ), - container: { - cornerRadius: 6, - padding: { left: 6 }, - }, - }, - state: { - hovered: { - icon: { - color: - foreground(layer, "hovered") + let ctaButton = + // Copied from welcome screen. FIXME: Move this into a ZDS component + interactive({ + base: { + background: background(layer), + border: border(layer, "default"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + left: 8, + right: 8, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) + }, + state: { + hovered: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, } - }, - } - }), + }); - modal: { - titleText: { - default: { - ...text(layer, "sans", { size: "xs", weight: "bold" }) - } - }, - titlebar: { - background: background(colorScheme.lowest), - border: border(layer, "active"), - padding: { - top: 4, - bottom: 4, - left: 8, - right: 8, - }, - }, - container: { - background: background(colorScheme.lowest), - padding: { - top: 0, - left: 0, - right: 0, - bottom: 8, - }, - }, - closeIcon: interactive({ - base: - { - icon: svg( - foreground(layer, "variant"), - "icons/x_mark_8.svg", - 8, - 8 - ), - container: { - cornerRadius: 2, - padding: { - top: 4, - bottom: 4, - left: 4, - right: 4, + return { + outLinkIcon: + interactive({ + base: { + icon: svg( + foreground(layer, "variant"), + "icons/link_out_12.svg", + 12, + 12 + ), + container: { + cornerRadius: 6, + padding: { left: 6 }, + }, + }, + state: { + hovered: { + icon: { + color: + foreground(layer, "hovered") + } + }, + } + }), + + modal: { + titleText: { + default: { + ...text(layer, "sans", { size: "xs", weight: "bold" }) + } }, - margin: { - right: 0, + titlebar: { + background: background(colorScheme.lowest), + border: border(layer, "active"), + padding: { + top: 4, + bottom: 4, + left: 8, + right: 8, + }, + }, + container: { + background: background(colorScheme.lowest), + padding: { + top: 0, + left: 0, + right: 0, + bottom: 8, + }, + }, + closeIcon: interactive({ + base: + { + icon: svg( + foreground(layer, "variant"), + "icons/x_mark_8.svg", + 8, + 8 + ), + container: { + cornerRadius: 2, + padding: { + top: 4, + bottom: 4, + left: 4, + right: 4, + }, + margin: { + right: 0, + }, + } + }, + state: { + hovered: { + icon: svg( + foreground(layer, "on"), + "icons/x_mark_8.svg", + 8, + 8 + ), + }, + clicked: { + icon: svg( + foreground(layer, "base"), + "icons/x_mark_8.svg", + 8, + 8 + ), + }, + } + }), + dimensions: { + width: 280, + height: 280, }, - } }, - state: { - hovered: { - icon: svg( - foreground(layer, "on"), - "icons/x_mark_8.svg", - 8, - 8 - ), - }, - clicked: { - icon: svg( - foreground(layer, "base"), - "icons/x_mark_8.svg", - 8, - 8 - ), - }, - } - }), - dimensions: { - width: 280, - height: 280, - }, - }, - auth: { - content_width, + auth: { + content_width, - ctaButton, + ctaButton, - header: { - icon: svg( - foreground(layer, "default"), - "icons/zed_plus_copilot_32.svg", - 92, - 32 - ), - container: { - margin: { - top: 35, - bottom: 5, - left: 0, - right: 0, - }, - }, - }, + header: { + icon: svg( + foreground(layer, "default"), + "icons/zed_plus_copilot_32.svg", + 92, + 32 + ), + container: { + margin: { + top: 35, + bottom: 5, + left: 0, + right: 0, + }, + }, + }, - prompting: { - subheading: { - ...text(layer, "sans", { size: "xs" }), - margin: { - top: 6, - bottom: 12, - left: 0, - right: 0, - }, - }, + prompting: { + subheading: { + ...text(layer, "sans", { size: "xs" }), + margin: { + top: 6, + bottom: 12, + left: 0, + right: 0, + }, + }, - hint: { - ...text(layer, "sans", { size: "xs", color: "#838994" }), - margin: { - top: 6, - bottom: 2, - }, - }, + hint: { + ...text(layer, "sans", { size: "xs", color: "#838994" }), + margin: { + top: 6, + bottom: 2, + }, + }, - deviceCode: { - text: text(layer, "mono", { size: "sm" }), - cta: { - ...ctaButton, - background: background(colorScheme.lowest), - border: border(colorScheme.lowest, "inverted"), - padding: { - top: 0, - bottom: 0, - left: 16, - right: 16, - }, - margin: { - left: 16, - right: 16, + deviceCode: { + text: text(layer, "mono", { size: "sm" }), + cta: { + ...ctaButton, + background: background(colorScheme.lowest), + border: border(colorScheme.lowest, "inverted"), + padding: { + top: 0, + bottom: 0, + left: 16, + right: 16, + }, + margin: { + left: 16, + right: 16, + }, + }, + left: content_width / 2, + leftContainer: { + padding: { + top: 3, + bottom: 3, + left: 0, + right: 6, + }, + }, + right: (content_width * 1) / 3, + rightContainer: interactive({ + base: { + border: border(colorScheme.lowest, "inverted", { + bottom: false, + right: false, + top: false, + left: true, + }), + padding: { + top: 3, + bottom: 5, + left: 8, + right: 0, + } + }, state: { + hovered: { + border: border(layer, "active", { + bottom: false, + right: false, + top: false, + left: true, + }), + }, + } + }) + }, }, - }, - left: content_width / 2, - leftContainer: { - padding: { - top: 3, - bottom: 3, - left: 0, - right: 6, - }, - }, - right: (content_width * 1) / 3, - rightContainer: interactive({ - base: { - border: border(colorScheme.lowest, "inverted", { - bottom: false, - right: false, - top: false, - left: true, - }), - padding: { - top: 3, - bottom: 5, - left: 8, - right: 0, - } - }, state: { - hovered: { - border: border(layer, "active", { - bottom: false, - right: false, - top: false, - left: true, - }), - }, - } - }) - }, - }, - notAuthorized: { - subheading: { - ...text(layer, "sans", { size: "xs" }), + notAuthorized: { + subheading: { + ...text(layer, "sans", { size: "xs" }), - margin: { - top: 16, - bottom: 16, - left: 0, - right: 0, - }, - }, + margin: { + top: 16, + bottom: 16, + left: 0, + right: 0, + }, + }, - warning: { - ...text(layer, "sans", { - size: "xs", - color: foreground(layer, "warning"), - }), - border: border(layer, "warning"), - background: background(layer, "warning"), - cornerRadius: 2, - padding: { - top: 4, - left: 4, - bottom: 4, - right: 4, - }, - margin: { - bottom: 16, - left: 8, - right: 8, - }, - }, - }, + warning: { + ...text(layer, "sans", { + size: "xs", + color: foreground(layer, "warning"), + }), + border: border(layer, "warning"), + background: background(layer, "warning"), + cornerRadius: 2, + padding: { + top: 4, + left: 4, + bottom: 4, + right: 4, + }, + margin: { + bottom: 16, + left: 8, + right: 8, + }, + }, + }, - authorized: { - subheading: { - ...text(layer, "sans", { size: "xs" }), + authorized: { + subheading: { + ...text(layer, "sans", { size: "xs" }), - margin: { - top: 16, - bottom: 16, - }, - }, + margin: { + top: 16, + bottom: 16, + }, + }, - hint: { - ...text(layer, "sans", { size: "xs", color: "#838994" }), - margin: { - top: 24, - bottom: 4, - }, + hint: { + ...text(layer, "sans", { size: "xs", color: "#838994" }), + margin: { + top: 24, + bottom: 4, + }, + }, + }, }, - }, - }, - } + } } diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index b3b22f3c8bc98dccec725645454d9ab7e95b4de1..3612a0acd1fec92238c2c43f91e49f60db7bb2f7 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -4,290 +4,290 @@ import { background, border, borderColor, foreground, text } from "./components" import hoverPopover from "./hoverPopover" import { buildSyntax } from "../theme/syntax" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function editor(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.highest + let layer = colorScheme.highest - const autocompleteItem = { - cornerRadius: 6, - padding: { - bottom: 2, - left: 6, - right: 6, - top: 2, - }, - } + const autocompleteItem = { + cornerRadius: 6, + padding: { + bottom: 2, + left: 6, + right: 6, + top: 2, + }, + } - function diagnostic(layer: Layer, styleSet: StyleSets) { - return { - textScaleFactor: 0.857, - header: { - border: border(layer, { - top: true, - }), - }, - message: { - text: text(layer, "sans", styleSet, "default", { size: "sm" }), - highlightText: text(layer, "sans", styleSet, "default", { - size: "sm", - weight: "bold", - }), - }, + function diagnostic(layer: Layer, styleSet: StyleSets) { + return { + textScaleFactor: 0.857, + header: { + border: border(layer, { + top: true, + }), + }, + message: { + text: text(layer, "sans", styleSet, "default", { size: "sm" }), + highlightText: text(layer, "sans", styleSet, "default", { + size: "sm", + weight: "bold", + }), + }, + } } - } - const syntax = buildSyntax(colorScheme) + const syntax = buildSyntax(colorScheme) - return { - textColor: syntax.primary.color, - background: background(layer), - activeLineBackground: withOpacity(background(layer, "on"), 0.75), - highlightedLineBackground: background(layer, "on"), - // Inline autocomplete suggestions, Co-pilot suggestions, etc. - suggestion: syntax.predictive, - codeActions: { - indicator: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - }, state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - } - }), - { - default: { - color: foreground(layer, "on"), - } - }), + return { + textColor: syntax.primary.color, + background: background(layer), + activeLineBackground: withOpacity(background(layer, "on"), 0.75), + highlightedLineBackground: background(layer, "on"), + // Inline autocomplete suggestions, Co-pilot suggestions, etc. + suggestion: syntax.predictive, + codeActions: { + indicator: toggleable(interactive({ + base: { + color: foreground(layer, "variant"), + }, state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + } + }), + { + default: { + color: foreground(layer, "on"), + } + }), - verticalScale: 0.55, - }, - folds: { - iconMarginScale: 2.5, - foldedIcon: "icons/chevron_right_8.svg", - foldableIcon: "icons/chevron_down_8.svg", - indicator: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - }, state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - } - }), - { - default: { - color: foreground(layer, "on"), - } - }), - ellipses: { - textColor: colorScheme.ramps.neutral(0.71).hex(), - cornerRadiusFactor: 0.15, - background: { - // Copied from hover_popover highlight - default: { color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex() }, + verticalScale: 0.55, + }, + folds: { + iconMarginScale: 2.5, + foldedIcon: "icons/chevron_right_8.svg", + foldableIcon: "icons/chevron_down_8.svg", + indicator: toggleable(interactive({ + base: { + color: foreground(layer, "variant"), + }, state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + } + }), + { + default: { + color: foreground(layer, "on"), + } + }), + ellipses: { + textColor: colorScheme.ramps.neutral(0.71).hex(), + cornerRadiusFactor: 0.15, + background: { + // Copied from hover_popover highlight + default: { color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex() }, - hover: { - color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), - }, + hover: { + color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), + }, - clicked: { - color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), - }, + clicked: { + color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), + }, + }, + }, + foldBackground: foreground(layer, "variant"), }, - }, - foldBackground: foreground(layer, "variant"), - }, - diff: { - deleted: isLight - ? colorScheme.ramps.red(0.5).hex() - : colorScheme.ramps.red(0.4).hex(), - modified: isLight - ? colorScheme.ramps.yellow(0.5).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.4).hex() - : colorScheme.ramps.green(0.5).hex(), - removedWidthEm: 0.275, - widthEm: 0.15, - cornerRadius: 0.05, - }, - /** Highlights matching occurrences of what is under the cursor - * as well as matched brackets - */ - documentHighlightReadBackground: withOpacity( - foreground(layer, "accent"), - 0.1 - ), - documentHighlightWriteBackground: colorScheme.ramps - .neutral(0.5) - .alpha(0.4) - .hex(), // TODO: This was blend * 2 - errorColor: background(layer, "negative"), - gutterBackground: background(layer), - gutterPaddingFactor: 3.5, - lineNumber: withOpacity(foreground(layer), 0.35), - lineNumberActive: foreground(layer), - renameFade: 0.6, - unnecessaryCodeFade: 0.5, - selection: colorScheme.players[0], - whitespace: colorScheme.ramps.neutral(0.5).hex(), - guestSelections: [ - colorScheme.players[1], - colorScheme.players[2], - colorScheme.players[3], - colorScheme.players[4], - colorScheme.players[5], - colorScheme.players[6], - colorScheme.players[7], - ], - autocomplete: { - background: background(colorScheme.middle), - cornerRadius: 8, - padding: 4, - margin: { - left: -14, - }, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - matchHighlight: foreground(colorScheme.middle, "accent"), - item: autocompleteItem, - hoveredItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "hovered" - ), - background: background(colorScheme.middle, "hovered"), - }, - selectedItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "active" + diff: { + deleted: isLight + ? colorScheme.ramps.red(0.5).hex() + : colorScheme.ramps.red(0.4).hex(), + modified: isLight + ? colorScheme.ramps.yellow(0.5).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.4).hex() + : colorScheme.ramps.green(0.5).hex(), + removedWidthEm: 0.275, + widthEm: 0.15, + cornerRadius: 0.05, + }, + /** Highlights matching occurrences of what is under the cursor + * as well as matched brackets + */ + documentHighlightReadBackground: withOpacity( + foreground(layer, "accent"), + 0.1 ), - background: background(colorScheme.middle, "active"), - }, - }, - diagnosticHeader: { - background: background(colorScheme.middle), - iconWidthFactor: 1.5, - textScaleFactor: 0.857, - border: border(colorScheme.middle, { - bottom: true, - top: true, - }), - code: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 10, + documentHighlightWriteBackground: colorScheme.ramps + .neutral(0.5) + .alpha(0.4) + .hex(), // TODO: This was blend * 2 + errorColor: background(layer, "negative"), + gutterBackground: background(layer), + gutterPaddingFactor: 3.5, + lineNumber: withOpacity(foreground(layer), 0.35), + lineNumberActive: foreground(layer), + renameFade: 0.6, + unnecessaryCodeFade: 0.5, + selection: colorScheme.players[0], + whitespace: colorScheme.ramps.neutral(0.5).hex(), + guestSelections: [ + colorScheme.players[1], + colorScheme.players[2], + colorScheme.players[3], + colorScheme.players[4], + colorScheme.players[5], + colorScheme.players[6], + colorScheme.players[7], + ], + autocomplete: { + background: background(colorScheme.middle), + cornerRadius: 8, + padding: 4, + margin: { + left: -14, + }, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + matchHighlight: foreground(colorScheme.middle, "accent"), + item: autocompleteItem, + hoveredItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "hovered" + ), + background: background(colorScheme.middle, "hovered"), + }, + selectedItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "active" + ), + background: background(colorScheme.middle, "active"), + }, }, - }, - source: { - text: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - }, - message: { - highlightText: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - text: text(colorScheme.middle, "sans", { size: "sm" }), - }, - }, - diagnosticPathHeader: { - background: background(colorScheme.middle), - textScaleFactor: 0.857, - filename: text(colorScheme.middle, "mono", { size: "sm" }), - path: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 12, + diagnosticHeader: { + background: background(colorScheme.middle), + iconWidthFactor: 1.5, + textScaleFactor: 0.857, + border: border(colorScheme.middle, { + bottom: true, + top: true, + }), + code: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 10, + }, + }, + source: { + text: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + }, + message: { + highlightText: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + text: text(colorScheme.middle, "sans", { size: "sm" }), + }, }, - }, - }, - errorDiagnostic: diagnostic(colorScheme.middle, "negative"), - warningDiagnostic: diagnostic(colorScheme.middle, "warning"), - informationDiagnostic: diagnostic(colorScheme.middle, "accent"), - hintDiagnostic: diagnostic(colorScheme.middle, "warning"), - invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), - hoverPopover: hoverPopover(colorScheme), - linkDefinition: { - color: syntax.linkUri.color, - underline: syntax.linkUri.underline, - }, - jumpIcon: interactive({ - base: { - color: foreground(layer, "on"), - iconWidth: 20, - buttonWidth: 20, - cornerRadius: 6, - padding: { - top: 6, - bottom: 6, - left: 6, - right: 6, - } - }, state: { - hovered: { - background: background(layer, "on", "hovered"), - } - } - }), + diagnosticPathHeader: { + background: background(colorScheme.middle), + textScaleFactor: 0.857, + filename: text(colorScheme.middle, "mono", { size: "sm" }), + path: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 12, + }, + }, + }, + errorDiagnostic: diagnostic(colorScheme.middle, "negative"), + warningDiagnostic: diagnostic(colorScheme.middle, "warning"), + informationDiagnostic: diagnostic(colorScheme.middle, "accent"), + hintDiagnostic: diagnostic(colorScheme.middle, "warning"), + invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), + hoverPopover: hoverPopover(colorScheme), + linkDefinition: { + color: syntax.linkUri.color, + underline: syntax.linkUri.underline, + }, + jumpIcon: interactive({ + base: { + color: foreground(layer, "on"), + iconWidth: 20, + buttonWidth: 20, + cornerRadius: 6, + padding: { + top: 6, + bottom: 6, + left: 6, + right: 6, + } + }, state: { + hovered: { + background: background(layer, "on", "hovered"), + } + } + }), - scrollbar: { - width: 12, - minHeightFactor: 1.0, - track: { - border: border(layer, "variant", { left: true }), - }, - thumb: { - background: withOpacity(background(layer, "inverted"), 0.3), - border: { - width: 1, - color: borderColor(layer, "variant"), - top: false, - right: true, - left: true, - bottom: false, + scrollbar: { + width: 12, + minHeightFactor: 1.0, + track: { + border: border(layer, "variant", { left: true }), + }, + thumb: { + background: withOpacity(background(layer, "inverted"), 0.3), + border: { + width: 1, + color: borderColor(layer, "variant"), + top: false, + right: true, + left: true, + bottom: false, + }, + }, + git: { + deleted: isLight + ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), + modified: isLight + ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), + inserted: isLight + ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), + }, + }, + compositionMark: { + underline: { + thickness: 1.0, + color: borderColor(layer), + }, }, - }, - git: { - deleted: isLight - ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), - modified: isLight - ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), - inserted: isLight - ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), - }, - }, - compositionMark: { - underline: { - thickness: 1.0, - color: borderColor(layer), - }, - }, - syntax, - } + syntax, + } } diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 4b5a4de89fb2c97765c279d1716abda2e8424bbd..19a8f1e4c75911b4bc167d3227cab73c7a4ba2d5 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -1,48 +1,48 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function feedback(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - return { - submit_button: interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - } - }, state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, - } - }), - button_margin: 8, - info_text_default: text(layer, "sans", "default", { size: "xs" }), - link_text_default: text(layer, "sans", "default", { - size: "xs", - underline: true, - }), - link_text_hover: text(layer, "sans", "hovered", { - size: "xs", - underline: true, - }), - } + return { + submit_button: interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, + }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, + } + }, state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + } + }), + button_margin: 8, + info_text_default: text(layer, "sans", "default", { size: "xs" }), + link_text_default: text(layer, "sans", "default", { + size: "xs", + underline: true, + }), + link_text_hover: text(layer, "sans", "hovered", { + size: "xs", + underline: true, + }), + } } diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 89b6cd0614924fd4cf6c4f8f47a07a89b4a247c5..3bcdae584fddadc86ba637febdefb6411d96c10f 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -2,88 +2,88 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, text } from "./components" import { toggleable } from "./toggle" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function picker(colorScheme: ColorScheme): any { - let layer = colorScheme.lowest - const container = { - background: background(layer), - border: border(layer), - shadow: colorScheme.modalShadow, - cornerRadius: 12, - padding: { - bottom: 4, - }, - } - const inputEditor = { - placeholderText: text(layer, "sans", "on", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "on"), - border: border(layer, { bottom: true }), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - margin: { - bottom: 4, - }, - } - const emptyInputEditor: any = { ...inputEditor } - delete emptyInputEditor.border - delete emptyInputEditor.margin - - return { - ...container, - emptyContainer: { - ...container, - padding: {}, - }, - item: toggleable(interactive({ - base: { + let layer = colorScheme.lowest + const container = { + background: background(layer), + border: border(layer), + shadow: colorScheme.modalShadow, + cornerRadius: 12, + padding: { + bottom: 4, + }, + } + const inputEditor = { + placeholderText: text(layer, "sans", "on", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "on"), + border: border(layer, { bottom: true }), padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, + bottom: 8, + left: 16, + right: 16, + top: 8, }, margin: { - top: 1, - left: 4, - right: 4, + bottom: 4, }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { weight: "bold" }), - } - , state: { - hovered: { - background: withOpacity(background(layer, "hovered"), 0.5), - } - } - }), - { - default: { - background: withOpacity( - background(layer, "base", "active"), - 0.5 - ), - //text: text(layer, "sans", "base", "active"), - } - }), + } + const emptyInputEditor: any = { ...inputEditor } + delete emptyInputEditor.border + delete emptyInputEditor.margin + + return { + ...container, + emptyContainer: { + ...container, + padding: {}, + }, + item: toggleable(interactive({ + base: { + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, + }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { weight: "bold" }), + } + , state: { + hovered: { + background: withOpacity(background(layer, "hovered"), 0.5), + } + } + }), + { + default: { + background: withOpacity( + background(layer, "base", "active"), + 0.5 + ), + //text: text(layer, "sans", "base", "active"), + } + }), - inputEditor, - emptyInputEditor, - noMatches: { - text: text(layer, "sans", "variant"), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - }, - } + inputEditor, + emptyInputEditor, + noMatches: { + text: text(layer, "sans", "variant"), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + }, + } } diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 782c781156a7cd643f81424c666b5dd34a2f4cb1..132dfe102c14a26123cb82d694979a446ca1fb05 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,123 +1,123 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function projectPanel(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.middle + let layer = colorScheme.middle - let baseEntry = { - height: 22, - iconColor: foreground(layer, "variant"), - iconSize: 7, - iconSpacing: 5, - } - - let status = { - git: { - modified: isLight - ? colorScheme.ramps.yellow(0.6).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.45).hex() - : colorScheme.ramps.green(0.5).hex(), - conflict: isLight - ? colorScheme.ramps.red(0.6).hex() - : colorScheme.ramps.red(0.5).hex(), - }, - } + let baseEntry = { + height: 22, + iconColor: foreground(layer, "variant"), + iconSize: 7, + iconSpacing: 5, + } - let entry = toggleable(interactive({ - base: { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, - }, state: - { - hovered: { - background: background(layer, "variant", "hovered"), - } + let status = { + git: { + modified: isLight + ? colorScheme.ramps.yellow(0.6).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.45).hex() + : colorScheme.ramps.green(0.5).hex(), + conflict: isLight + ? colorScheme.ramps.red(0.6).hex() + : colorScheme.ramps.red(0.5).hex(), + }, } - }), - { - default: { - /*background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active") ,*/ // todo posiewic - text: text(layer, "mono", "active", { size: "sm" }), - }, - hovered: { - //background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - }); + let entry = toggleable(interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, state: + { + hovered: { + background: background(layer, "variant", "hovered"), + } + } + }), + { + default: { + /*background: colorScheme.isLight + ? withOpacity(background(layer, "active"), 0.5) + : background(layer, "active") ,*/ // todo posiewic + text: text(layer, "mono", "active", { size: "sm" }), + }, + hovered: { + //background: background(layer, "active"), + text: text(layer, "mono", "active", { size: "sm" }), + }, + + }); - return { - openProjectButton: interactive({ - base: { + return { + openProjectButton: interactive({ + base: { + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 16, + left: 16, + right: 16, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) + }, state: { + hovered: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + } + }), background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 16, - left: 16, - right: 16, + padding: { left: 6, right: 6, top: 0, bottom: 6 }, + indentWidth: 12, + entry, + draggedEntry: { + ...baseEntry, + text: text(layer, "mono", "on", { size: "sm" }), + background: withOpacity(background(layer, "on"), 0.9), + border: border(layer), + status, }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, + ignoredEntry: { + ...entry, + iconColor: foreground(layer, "disabled"), + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + iconColor: foreground(layer, "variant"), + }, }, - ...text(layer, "sans", "default", { size: "sm" }) - }, state: { - hovered: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), + cutEntry: { + ...entry, + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + default: { + ...entry.active.default, + background: background(layer, "active"), + text: text(layer, "mono", "disabled", { size: "sm" }), + }, + + }, }, - } - }), - background: background(layer), - padding: { left: 6, right: 6, top: 0, bottom: 6 }, - indentWidth: 12, - entry, - draggedEntry: { - ...baseEntry, - text: text(layer, "mono", "on", { size: "sm" }), - background: withOpacity(background(layer, "on"), 0.9), - border: border(layer), - status, - }, - ignoredEntry: { - ...entry, - iconColor: foreground(layer, "disabled"), - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - iconColor: foreground(layer, "variant"), - }, - }, - cutEntry: { - ...entry, - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - default: { - ...entry.active.default, - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), + filenameEditor: { + background: background(layer, "on"), + text: text(layer, "mono", "on", { size: "sm" }), + selection: colorScheme.players[0], }, - - }, - }, - filenameEditor: { - background: background(layer, "on"), - text: text(layer, "mono", "on", { size: "sm" }), - selection: colorScheme.players[0], - }, - } + } } diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index e278f69ff084d53bec79a0d22f20ad503cdfa38c..1f63d2740bada69aee3f5ebeb0d2fb82af5618d5 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -1,123 +1,123 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function search(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - // Search input - const editor = { - background: background(layer), - cornerRadius: 8, - minWidth: 200, - maxWidth: 500, - placeholderText: text(layer, "mono", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "default"), - border: border(layer), - margin: { - right: 12, - }, - padding: { - top: 3, - bottom: 3, - left: 12, - right: 8, - }, - } - - const includeExcludeEditor = { - ...editor, - minWidth: 100, - maxWidth: 250, - } - - return { - // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive - matchBackground: withOpacity(foreground(layer, "accent"), 0.4), - optionButton: toggleable(interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), + // Search input + const editor = { + background: background(layer), + cornerRadius: 8, + minWidth: 200, + maxWidth: 500, + placeholderText: text(layer, "mono", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "default"), + border: border(layer), margin: { - right: 4, + right: 12, }, padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, + top: 3, + bottom: 3, + left: 12, + right: 8, + }, + } + + const includeExcludeEditor = { + ...editor, + minWidth: 100, + maxWidth: 250, + } + + return { + // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive + matchBackground: withOpacity(foreground(layer, "accent"), 0.4), + optionButton: toggleable(interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, + }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, + }, + }, state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + } + }), { + default: { + ...text(layer, "mono", "on", "inverted"), + background: background(layer, "on", "inverted"), + border: border(layer, "on", "inverted"), + }, + + }), + editor, + invalidEditor: { + ...editor, + border: border(layer, "negative"), }, - }, state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), + includeExcludeEditor, + invalidIncludeExcludeEditor: { + ...includeExcludeEditor, + border: border(layer, "negative"), }, - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), + matchIndex: { + ...text(layer, "mono", "variant"), + padding: { + left: 6, + }, }, - } - }), { - default: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), - }, - - }), - editor, - invalidEditor: { - ...editor, - border: border(layer, "negative"), - }, - includeExcludeEditor, - invalidIncludeExcludeEditor: { - ...includeExcludeEditor, - border: border(layer, "negative"), - }, - matchIndex: { - ...text(layer, "mono", "variant"), - padding: { - left: 6, - }, - }, - optionButtonGroup: { - padding: { - left: 12, - right: 12, - }, - }, - includeExcludeInputs: { - ...text(layer, "mono", "variant"), - padding: { - right: 6, - }, - }, - resultsStatus: { - ...text(layer, "mono", "on"), - size: 18, - }, - dismissButton: interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 14, - padding: { - left: 10, - right: 10, + optionButtonGroup: { + padding: { + left: 12, + right: 12, + }, + }, + includeExcludeInputs: { + ...text(layer, "mono", "variant"), + padding: { + right: 6, + }, + }, + resultsStatus: { + ...text(layer, "mono", "on"), + size: 18, }, - }, state: { - hovered: { - color: foreground(layer, "hovered"), - } - } - }), - } + dismissButton: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 14, + padding: { + left: 10, + right: 10, + }, + }, state: { + hovered: { + color: foreground(layer, "hovered"), + } + } + }), + } } diff --git a/styles/src/styleTree/simpleMessageNotification.ts b/styles/src/styleTree/simpleMessageNotification.ts index 70219d7a1029d9500facaf8d3e15baa7d20db152..4c2abfcf9d6fac3575fa30c295cf1a6eaea1e6eb 100644 --- a/styles/src/styleTree/simpleMessageNotification.ts +++ b/styles/src/styleTree/simpleMessageNotification.ts @@ -1,51 +1,51 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" const headerPadding = 8 export default function simpleMessageNotification( - colorScheme: ColorScheme + colorScheme: ColorScheme ): Object { - let layer = colorScheme.middle - return { - message: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, - }, - actionMessage: interactive({ - base: { - ...text(layer, "sans", { size: "xs" }), - border: border(layer, "active"), - cornerRadius: 4, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, + let layer = colorScheme.middle + return { + message: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, }, + actionMessage: interactive({ + base: { + ...text(layer, "sans", { size: "xs" }), + border: border(layer, "active"), + cornerRadius: 4, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, - margin: { left: headerPadding, top: 6, bottom: 6 }, - }, state: { - hovered: { - ...text(layer, "sans", "default", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - } - }), - dismissButton: interactive({ - base: { - color: foreground(layer), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - }, state: { - hovered: { - color: foreground(layer, "hovered"), - }, - } - }) - } + margin: { left: headerPadding, top: 6, bottom: 6 }, + }, state: { + hovered: { + ...text(layer, "sans", "default", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + } + }), + dismissButton: interactive({ + base: { + color: foreground(layer), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8, + }, state: { + hovered: { + color: foreground(layer, "hovered"), + }, + } + }) + } } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 754703c2b9c431892e9a71000d621e8f4f24a8a1..ee78f5e6b311f74f229d6ff1d5c98f6d3c07d70e 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -1,145 +1,145 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function statusBar(colorScheme: ColorScheme) { - let layer = colorScheme.lowest + let layer = colorScheme.lowest - const statusContainer = { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 6, right: 6 }, - } + const statusContainer = { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 6, right: 6 }, + } - const diagnosticStatusContainer = { - cornerRadius: 6, - padding: { top: 1, bottom: 1, left: 6, right: 6 }, - } + const diagnosticStatusContainer = { + cornerRadius: 6, + padding: { top: 1, bottom: 1, left: 6, right: 6 }, + } - return { - height: 30, - itemSpacing: 8, - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - border: border(layer, { top: true, overlay: true }), - cursorPosition: text(layer, "sans", "variant"), - activeLanguage: interactive({ - base: { - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant") - }, - state: { - hovered: { - ...text(layer, "sans", "on"), - } - } - }, - ), - autoUpdateProgressMessage: text(layer, "sans", "variant"), - autoUpdateDoneMessage: text(layer, "sans", "variant"), - lspStatus: interactive({ - base: { - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer) - }, - state: { - hovered: { - message: text(layer, "sans"), - iconColor: foreground(layer), - background: background(layer, "hovered"), - } - } - }), - diagnosticMessage: interactive({ - base: { - ...text(layer, "sans") - }, - state: { hovered: text(layer, "sans", "hovered") } - }, - ), - diagnosticSummary: - interactive({ - base: { - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - } - }, state: { - hovered: { - iconColorOk: foreground(layer, "on"), - containerOk: { - background: background(layer, "on", "hovered"), + return { + height: 30, + itemSpacing: 8, + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + border: border(layer, { top: true, overlay: true }), + cursorPosition: text(layer, "sans", "variant"), + activeLanguage: interactive({ + base: { + padding: { left: 6, right: 6 }, + ...text(layer, "sans", "variant") }, - containerWarning: { - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), + state: { + hovered: { + ...text(layer, "sans", "on"), + } + } + }, + ), + autoUpdateProgressMessage: text(layer, "sans", "variant"), + autoUpdateDoneMessage: text(layer, "sans", "variant"), + lspStatus: interactive({ + base: { + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, + message: text(layer, "sans"), + iconColor: foreground(layer) }, - containerError: { - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), + state: { + hovered: { + message: text(layer, "sans"), + iconColor: foreground(layer), + background: background(layer, "hovered"), + } } - } - } - } - ), - panelButtons: { - groupLeft: {}, - groupBottom: {}, - groupRight: {}, - button: toggleable(interactive({ - base: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, - }, state: { - hovered: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - } - } - }), - { - default: { - iconColor: foreground(layer, "active"), - background: background(layer, "active"), - } }), - badge: { - cornerRadius: 3, - padding: 2, - margin: { bottom: -1, right: -1 }, - border: border(layer), - background: background(layer, "accent"), - }, - }, - } + diagnosticMessage: interactive({ + base: { + ...text(layer, "sans") + }, + state: { hovered: text(layer, "sans", "hovered") } + }, + ), + diagnosticSummary: + interactive({ + base: { + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), + containerOk: { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, + }, + containerWarning: { + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), + }, + containerError: { + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + } + }, state: { + hovered: { + iconColorOk: foreground(layer, "on"), + containerOk: { + background: background(layer, "on", "hovered"), + }, + containerWarning: { + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), + }, + containerError: { + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + } + } + } + } + ), + panelButtons: { + groupLeft: {}, + groupBottom: {}, + groupRight: {}, + button: toggleable(interactive({ + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, + }, state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + } + } + }), + { + default: { + iconColor: foreground(layer, "active"), + background: background(layer, "active"), + } + }), + badge: { + cornerRadius: 3, + padding: 2, + margin: { bottom: -1, right: -1 }, + border: border(layer), + background: background(layer, "accent"), + }, + }, + } } diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index 9da63b95187e9edd718715a4296782e4ac799373..8011a707727a14f031839e857664ebb4ccca599a 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -2,117 +2,117 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, border, background, foreground } from "./components" import { toggleable } from "./toggle" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function tabBar(colorScheme: ColorScheme) { - const height = 32 + const height = 32 - let activeLayer = colorScheme.highest - let layer = colorScheme.middle + let activeLayer = colorScheme.highest + let layer = colorScheme.middle - const tab = { - height, - text: text(layer, "sans", "variant", { size: "sm" }), - background: background(layer), - border: border(layer, { - right: true, - bottom: true, - overlay: true, - }), - padding: { - left: 8, - right: 12, - }, - spacing: 8, + const tab = { + height, + text: text(layer, "sans", "variant", { size: "sm" }), + background: background(layer), + border: border(layer, { + right: true, + bottom: true, + overlay: true, + }), + padding: { + left: 8, + right: 12, + }, + spacing: 8, - // Tab type icons (e.g. Project Search) - typeIconWidth: 14, + // Tab type icons (e.g. Project Search) + typeIconWidth: 14, - // Close icons - closeIconWidth: 8, - iconClose: foreground(layer, "variant"), - iconCloseActive: foreground(layer, "hovered"), + // Close icons + closeIconWidth: 8, + iconClose: foreground(layer, "variant"), + iconCloseActive: foreground(layer, "hovered"), - // Indicators - iconConflict: foreground(layer, "warning"), - iconDirty: foreground(layer, "accent"), + // Indicators + iconConflict: foreground(layer, "warning"), + iconDirty: foreground(layer, "accent"), - // When two tabs of the same name are open, a label appears next to them - description: { - margin: { left: 8 }, - ...text(layer, "sans", "disabled", { size: "2xs" }), - }, - } + // When two tabs of the same name are open, a label appears next to them + description: { + margin: { left: 8 }, + ...text(layer, "sans", "disabled", { size: "2xs" }), + }, + } - const activePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(activeLayer, "sans", "active", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const activePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(activeLayer, "sans", "active", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const inactivePaneInactiveTab = { - ...tab, - background: background(layer), - text: text(layer, "sans", "variant", { size: "sm" }), - } + const inactivePaneInactiveTab = { + ...tab, + background: background(layer), + text: text(layer, "sans", "variant", { size: "sm" }), + } - const inactivePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(layer, "sans", "variant", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const inactivePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(layer, "sans", "variant", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const draggedTab = { - ...activePaneActiveTab, - background: withOpacity(tab.background, 0.9), - border: undefined as any, - shadow: colorScheme.popoverShadow, - } + const draggedTab = { + ...activePaneActiveTab, + background: withOpacity(tab.background, 0.9), + border: undefined as any, + shadow: colorScheme.popoverShadow, + } - return { - height, - background: background(layer), - activePane: { - activeTab: activePaneActiveTab, - inactiveTab: tab, - }, - inactivePane: { - activeTab: inactivePaneActiveTab, - inactiveTab: inactivePaneInactiveTab, - }, - draggedTab, - paneButton: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - }, - state: { - hovered: { - color: foreground(layer, "hovered"), - } - } - }), - { - default: { - color: foreground(layer, "accent"), - } - }, - ), - paneButtonContainer: { - background: tab.background, - border: { - ...tab.border, - right: false, - }, - }, - } + return { + height, + background: background(layer), + activePane: { + activeTab: activePaneActiveTab, + inactiveTab: tab, + }, + inactivePane: { + activeTab: inactivePaneActiveTab, + inactiveTab: inactivePaneInactiveTab, + }, + draggedTab, + paneButton: toggleable(interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), + } + } + }), + { + default: { + color: foreground(layer, "accent"), + } + }, + ), + paneButtonContainer: { + background: tab.background, + border: { + ...tab.border, + right: false, + }, + }, + } } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 0cfcb921efc352bcfbcc74e43727167936332a85..0bb3958dc878dfd1206a663c1ceca7a6ad4389cc 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -1,56 +1,56 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function dropdownMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - return { - rowHeight: 30, - background: background(layer), - border: border(layer), - shadow: colorScheme.popoverShadow, - header: interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryText: text(layer, "sans", { size: "sm", color: "#aaaaaa" }), - secondaryTextSpacing: 10, - padding: { left: 8, right: 8, top: 2, bottom: 2 }, - cornerRadius: 6, - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }) - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - } - } - }) - , - sectionHeader: { - ...text(layer, "sans", { size: "sm" }), - padding: { left: 8, right: 8, top: 8, bottom: 8 }, - }, - item: toggleable(interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 } - }, state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - } - } - }), { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - }) - } + return { + rowHeight: 30, + background: background(layer), + border: border(layer), + shadow: colorScheme.popoverShadow, + header: interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryText: text(layer, "sans", { size: "sm", color: "#aaaaaa" }), + secondaryTextSpacing: 10, + padding: { left: 8, right: 8, top: 2, bottom: 2 }, + cornerRadius: 6, + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }) + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + } + } + }) + , + sectionHeader: { + ...text(layer, "sans", { size: "sm" }), + padding: { left: 8, right: 8, top: 8, bottom: 8 }, + }, + item: toggleable(interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 } + }, state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + } + } + }), { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + }) + } } diff --git a/styles/src/styleTree/updateNotification.ts b/styles/src/styleTree/updateNotification.ts index aa8db916ea08a4625e2a218a4fead51d61552847..a7a5aaabaa8c4881e0fd4ada5c049da45a458c80 100644 --- a/styles/src/styleTree/updateNotification.ts +++ b/styles/src/styleTree/updateNotification.ts @@ -1,39 +1,39 @@ import { ColorScheme } from "../theme/colorScheme" import { foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" const headerPadding = 8 export default function updateNotification(colorScheme: ColorScheme): Object { - let layer = colorScheme.middle - return { - message: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, - }, - actionMessage: interactive({ - base: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, top: 6, bottom: 6 } - }, state: { - hovered: { - color: foreground(layer, "hovered"), - } - } - }), - dismissButton: interactive({ - base: { - color: foreground(layer), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8 - }, state: { - hovered: { - color: foreground(layer, "hovered"), + let layer = colorScheme.middle + return { + message: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, }, - }, - }) + actionMessage: interactive({ + base: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, top: 6, bottom: 6 } + }, state: { + hovered: { + color: foreground(layer, "hovered"), + } + } + }), + dismissButton: interactive({ + base: { + color: foreground(layer), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8 + }, state: { + hovered: { + color: foreground(layer, "hovered"), + }, + }, + }) - } + } } diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index 7ba7b304300c64fd9ddcd645b36f23c4c2065c29..f0e4badf3f84f34f7a3501eb29d67afdfab0c6eb 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -1,133 +1,133 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { - border, - background, - foreground, - text, - TextProperties, - svg, + border, + background, + foreground, + text, + TextProperties, + svg, } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function welcome(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - let checkboxBase = { - cornerRadius: 4, - padding: { - left: 3, - right: 3, - top: 3, - bottom: 3, - }, - // shadow: colorScheme.popoverShadow, - border: border(layer), - margin: { - right: 8, - top: 5, - bottom: 5, - }, - } - - let interactive_text_size: TextProperties = { size: "sm" } - - return { - pageWidth: 320, - logo: svg(foreground(layer, "default"), "icons/logo_96.svg", 64, 64), - logoSubheading: { - ...text(layer, "sans", "variant", { size: "md" }), - margin: { - top: 10, - bottom: 7, - }, - }, - buttonGroup: { - margin: { - top: 8, - bottom: 16, - }, - }, - headingGroup: { - margin: { - top: 8, - bottom: 12, - }, - }, - checkboxGroup: { - border: border(layer, "variant"), - background: withOpacity(background(layer, "hovered"), 0.25), - cornerRadius: 4, - padding: { - left: 12, - top: 2, - bottom: 2, - }, - }, - button: interactive({ - base: { - background: background(layer), - border: border(layer, "active"), + let checkboxBase = { cornerRadius: 4, + padding: { + left: 3, + right: 3, + top: 3, + bottom: 3, + }, + // shadow: colorScheme.popoverShadow, + border: border(layer), margin: { - top: 4, - bottom: 4, + right: 8, + top: 5, + bottom: 5, }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, + } + + let interactive_text_size: TextProperties = { size: "sm" } + + return { + pageWidth: 320, + logo: svg(foreground(layer, "default"), "icons/logo_96.svg", 64, 64), + logoSubheading: { + ...text(layer, "sans", "variant", { size: "md" }), + margin: { + top: 10, + bottom: 7, + }, }, - ...text(layer, "sans", "default", interactive_text_size) - }, state: { - hovered: { - ...text(layer, "sans", "default", interactive_text_size), - background: background(layer, "hovered"), - } - } - }), + buttonGroup: { + margin: { + top: 8, + bottom: 16, + }, + }, + headingGroup: { + margin: { + top: 8, + bottom: 12, + }, + }, + checkboxGroup: { + border: border(layer, "variant"), + background: withOpacity(background(layer, "hovered"), 0.25), + cornerRadius: 4, + padding: { + left: 12, + top: 2, + bottom: 2, + }, + }, + button: interactive({ + base: { + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", interactive_text_size) + }, state: { + hovered: { + ...text(layer, "sans", "default", interactive_text_size), + background: background(layer, "hovered"), + } + } + }), - usageNote: { - ...text(layer, "sans", "variant", { size: "2xs" }), - padding: { - top: -4, - }, - }, - checkboxContainer: { - margin: { - top: 4, - }, - padding: { - bottom: 8, - }, - }, - checkbox: { - label: { - ...text(layer, "sans", interactive_text_size), - // Also supports margin, container, border, etc. - }, - icon: svg(foreground(layer, "on"), "icons/check_12.svg", 12, 12), - default: { - ...checkboxBase, - background: background(layer, "default"), - border: border(layer, "active"), - }, - checked: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - hovered: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - hoveredAndChecked: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - } + usageNote: { + ...text(layer, "sans", "variant", { size: "2xs" }), + padding: { + top: -4, + }, + }, + checkboxContainer: { + margin: { + top: 4, + }, + padding: { + bottom: 8, + }, + }, + checkbox: { + label: { + ...text(layer, "sans", interactive_text_size), + // Also supports margin, container, border, etc. + }, + icon: svg(foreground(layer, "on"), "icons/check_12.svg", 12, 12), + default: { + ...checkboxBase, + background: background(layer, "default"), + border: border(layer, "active"), + }, + checked: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + hovered: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + hoveredAndChecked: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + }, + } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index fcada68a282b4c41d0bdf31c0e2585837c7219f1..fa2d337592bca85fc58df563d8091ff723e9bfc6 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -2,383 +2,383 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { toggleable } from "./toggle" import { - background, - border, - borderColor, - foreground, - svg, - text, + background, + border, + borderColor, + foreground, + svg, + text, } from "./components" import statusBar from "./statusBar" import tabBar from "./tabBar" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import merge from 'ts-deepmerge'; export default function workspace(colorScheme: ColorScheme) { - const layer = colorScheme.lowest - const isLight = colorScheme.isLight - const itemSpacing = 8 - const titlebarButton = toggleable(interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { size: "xs" }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { size: "xs" }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - } - } - }), - { - default: { - ...text(layer, "sans", "variant", "active", { size: "xs" }), - background: background(layer, "variant", "active"), - border: border(layer, "variant", "active"), - } - }, - ); - const avatarWidth = 18 - const avatarOuterWidth = avatarWidth + 4 - const followerAvatarWidth = 14 - const followerAvatarOuterWidth = followerAvatarWidth + 4 - - return { - background: background(colorScheme.lowest), - blankPane: { - logoContainer: { - width: 256, - height: 256, - }, - logo: svg( - withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), - "icons/logo_96.svg", - 256, - 256 - ), - - logoShadow: svg( - withOpacity( - colorScheme.isLight - ? "#FFFFFF" - : colorScheme.lowest.base.default.background, - colorScheme.isLight ? 1 : 0.6 - ), - "icons/logo_96.svg", - 256, - 256 - ), - keyboardHints: { - margin: { - top: 96, - }, - cornerRadius: 4, - }, - keyboardHint: - interactive({ - base: { - ...text(layer, "sans", "variant", { size: "sm" }), + const layer = colorScheme.lowest + const isLight = colorScheme.isLight + const itemSpacing = 8 + const titlebarButton = toggleable(interactive({ + base: { + cornerRadius: 6, padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, + top: 1, + bottom: 1, + left: 8, + right: 8, }, - cornerRadius: 8 - }, state: { + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, state: { hovered: { - ...text(layer, "sans", "active", { size: "sm" }), + ...text(layer, "sans", "variant", "hovered", { size: "xs" }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { size: "xs" }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + } + } + }), + { + default: { + ...text(layer, "sans", "variant", "active", { size: "xs" }), + background: background(layer, "variant", "active"), + border: border(layer, "variant", "active"), } - } - }), - - keyboardHintWidth: 320, - }, - joiningProjectAvatar: { - cornerRadius: 40, - width: 80, - }, - joiningProjectMessage: { - padding: 12, - ...text(layer, "sans", { size: "lg" }), - }, - externalLocationMessage: { - background: background(colorScheme.middle, "accent"), - border: border(colorScheme.middle, "accent"), - cornerRadius: 6, - padding: 12, - margin: { bottom: 8, right: 8 }, - ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), - }, - leaderBorderOpacity: 0.7, - leaderBorderWidth: 2.0, - tabBar: tabBar(colorScheme), - modal: { - margin: { - bottom: 52, - top: 52, - }, - cursor: "Arrow", - }, - zoomedBackground: { - cursor: "Arrow", - background: isLight - ? withOpacity(background(colorScheme.lowest), 0.8) - : withOpacity(background(colorScheme.highest), 0.6), - }, - zoomedPaneForeground: { - margin: 16, - shadow: colorScheme.modalShadow, - border: border(colorScheme.lowest, { overlay: true }), - }, - zoomedPanelForeground: { - margin: 16, - border: border(colorScheme.lowest, { overlay: true }), - }, - dock: { - left: { - border: border(layer, { right: true }), - }, - bottom: { - border: border(layer, { top: true }), - }, - right: { - border: border(layer, { left: true }), - }, - }, - paneDivider: { - color: borderColor(layer), - width: 1, - }, - statusBar: statusBar(colorScheme), - titlebar: { - itemSpacing, - facePileSpacing: 2, - height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. - background: background(layer), - border: border(layer, { bottom: true }), - padding: { - left: 80, - right: itemSpacing, - }, - - // Project - title: text(layer, "sans", "variant"), - highlight_color: text(layer, "sans", "active").color, - - // Collaborators - leaderAvatar: { - width: avatarWidth, - outerWidth: avatarOuterWidth, - cornerRadius: avatarWidth / 2, - outerCornerRadius: avatarOuterWidth / 2, - }, - followerAvatar: { - width: followerAvatarWidth, - outerWidth: followerAvatarOuterWidth, - cornerRadius: followerAvatarWidth / 2, - outerCornerRadius: followerAvatarOuterWidth / 2, - }, - inactiveAvatarGrayscale: true, - followerAvatarOverlap: 8, - leaderSelection: { - margin: { - top: 4, - bottom: 4, - }, - padding: { - left: 2, - right: 2, - top: 2, - bottom: 2, }, - cornerRadius: 6, - }, - avatarRibbon: { - height: 3, - width: 12, - // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. - }, + ); + const avatarWidth = 18 + const avatarOuterWidth = avatarWidth + 4 + const followerAvatarWidth = 14 + const followerAvatarOuterWidth = followerAvatarWidth + 4 - // Sign in buttom - // FlatButton, Variant - signInPrompt: - merge(titlebarButton, - { - inactive: { - default: { + return { + background: background(colorScheme.lowest), + blankPane: { + logoContainer: { + width: 256, + height: 256, + }, + logo: svg( + withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), + "icons/logo_96.svg", + 256, + 256 + ), + + logoShadow: svg( + withOpacity( + colorScheme.isLight + ? "#FFFFFF" + : colorScheme.lowest.base.default.background, + colorScheme.isLight ? 1 : 0.6 + ), + "icons/logo_96.svg", + 256, + 256 + ), + keyboardHints: { margin: { - left: itemSpacing, + top: 96, }, - } - } - }), - + cornerRadius: 4, + }, + keyboardHint: + interactive({ + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8 + }, state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + } + } + }), - // Offline Indicator - offlineIcon: { - color: foreground(layer, "variant"), - width: 16, - margin: { - left: itemSpacing, + keyboardHintWidth: 320, }, - padding: { - right: 4, + joiningProjectAvatar: { + cornerRadius: 40, + width: 80, }, - }, - - // Notice that the collaboration server is out of date - outdatedWarning: { - ...text(layer, "sans", "warning", { size: "xs" }), - background: withOpacity(background(layer, "warning"), 0.3), - border: border(layer, "warning"), - margin: { - left: itemSpacing, + joiningProjectMessage: { + padding: 12, + ...text(layer, "sans", { size: "lg" }), }, - padding: { - left: 8, - right: 8, + externalLocationMessage: { + background: background(colorScheme.middle, "accent"), + border: border(colorScheme.middle, "accent"), + cornerRadius: 6, + padding: 12, + margin: { bottom: 8, right: 8 }, + ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), }, - cornerRadius: 6, - }, - callControl: interactive({ - base: { - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - }, state: { - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - } - }), - toggleContactsButton: toggleable(interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, + leaderBorderOpacity: 0.7, + leaderBorderWidth: 2.0, + tabBar: tabBar(colorScheme), + modal: { + margin: { + bottom: 52, + top: 52, + }, + cursor: "Arrow", }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - } - } - }), - { - default: { - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active") - } + zoomedBackground: { + cursor: "Arrow", + background: isLight + ? withOpacity(background(colorScheme.lowest), 0.8) + : withOpacity(background(colorScheme.highest), 0.6), }, - ), - userMenuButton: merge(titlebarButton, { - inactive: { - default: { - buttonWidth: 20, - iconWidth: 12 - } - }, active: { // posiewic: these properties are not currently set on main - default: { - iconWidth: 12, - button_width: 20, - } - } - }), + zoomedPaneForeground: { + margin: 16, + shadow: colorScheme.modalShadow, + border: border(colorScheme.lowest, { overlay: true }), + }, + zoomedPanelForeground: { + margin: 16, + border: border(colorScheme.lowest, { overlay: true }), + }, + dock: { + left: { + border: border(layer, { right: true }), + }, + bottom: { + border: border(layer, { top: true }), + }, + right: { + border: border(layer, { left: true }), + }, + }, + paneDivider: { + color: borderColor(layer), + width: 1, + }, + statusBar: statusBar(colorScheme), + titlebar: { + itemSpacing, + facePileSpacing: 2, + height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. + background: background(layer), + border: border(layer, { bottom: true }), + padding: { + left: 80, + right: itemSpacing, + }, + // Project + title: text(layer, "sans", "variant"), + highlight_color: text(layer, "sans", "active").color, - toggleContactsBadge: { - cornerRadius: 3, - padding: 2, - margin: { top: 3, left: 3 }, - border: border(layer), - background: foreground(layer, "accent"), - }, - shareButton: { - ...titlebarButton, - }, - }, + // Collaborators + leaderAvatar: { + width: avatarWidth, + outerWidth: avatarOuterWidth, + cornerRadius: avatarWidth / 2, + outerCornerRadius: avatarOuterWidth / 2, + }, + followerAvatar: { + width: followerAvatarWidth, + outerWidth: followerAvatarOuterWidth, + cornerRadius: followerAvatarWidth / 2, + outerCornerRadius: followerAvatarOuterWidth / 2, + }, + inactiveAvatarGrayscale: true, + followerAvatarOverlap: 8, + leaderSelection: { + margin: { + top: 4, + bottom: 4, + }, + padding: { + left: 2, + right: 2, + top: 2, + bottom: 2, + }, + cornerRadius: 6, + }, + avatarRibbon: { + height: 3, + width: 12, + // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. + }, - toolbar: { - height: 34, - background: background(colorScheme.highest), - border: border(colorScheme.highest, { bottom: true }), - itemSpacing: 8, - navButton: interactive( - { - base: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, - }, state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), + // Sign in buttom + // FlatButton, Variant + signInPrompt: + merge(titlebarButton, + { + inactive: { + default: { + margin: { + left: itemSpacing, + }, + } + } + }), + + + // Offline Indicator + offlineIcon: { + color: foreground(layer, "variant"), + width: 16, + margin: { + left: itemSpacing, + }, + padding: { + right: 4, + }, + }, + + // Notice that the collaboration server is out of date + outdatedWarning: { + ...text(layer, "sans", "warning", { size: "xs" }), + background: withOpacity(background(layer, "warning"), 0.3), + border: border(layer, "warning"), + margin: { + left: itemSpacing, + }, + padding: { + left: 8, + right: 8, + }, + cornerRadius: 6, + }, + callControl: interactive({ + base: { + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 20, + }, state: { + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + } + }), + toggleContactsButton: toggleable(interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), + color: foreground(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + } + } + }), + { + default: { + background: background(layer, "variant", "active"), + color: foreground(layer, "variant", "active") + } + }, + ), + userMenuButton: merge(titlebarButton, { + inactive: { + default: { + buttonWidth: 20, + iconWidth: 12 + } + }, active: { // posiewic: these properties are not currently set on main + default: { + iconWidth: 12, + button_width: 20, + } + } + }), + + + toggleContactsBadge: { + cornerRadius: 3, + padding: 2, + margin: { top: 3, left: 3 }, + border: border(layer), + background: foreground(layer, "accent"), }, - disabled: { - color: foreground(colorScheme.highest, "on", "disabled"), + shareButton: { + ...titlebarButton, }, - } + }, + + toolbar: { + height: 34, + background: background(colorScheme.highest), + border: border(colorScheme.highest, { bottom: true }), + itemSpacing: 8, + navButton: interactive( + { + base: { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + disabled: { + color: foreground(colorScheme.highest, "on", "disabled"), + }, + } + }), + padding: { left: 8, right: 8, top: 4, bottom: 4 }, + }, + breadcrumbHeight: 24, + breadcrumbs: interactive({ + base: { + ...text(colorScheme.highest, "sans", "variant"), + cornerRadius: 6, + padding: { + left: 6, + right: 6, + } + }, state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background(colorScheme.highest, "on", "hovered"), + }, + } }), - padding: { left: 8, right: 8, top: 4, bottom: 4 }, - }, - breadcrumbHeight: 24, - breadcrumbs: interactive({ - base: { - ...text(colorScheme.highest, "sans", "variant"), - cornerRadius: 6, - padding: { - left: 6, - right: 6, - } - }, state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background(colorScheme.highest, "on", "hovered"), + disconnectedOverlay: { + ...text(layer, "sans"), + background: withOpacity(background(layer), 0.8), }, - } - }), - disconnectedOverlay: { - ...text(layer, "sans"), - background: withOpacity(background(layer), 0.8), - }, - notification: { - margin: { top: 10 }, - background: background(colorScheme.middle), - cornerRadius: 6, - padding: 12, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - }, - notifications: { - width: 400, - margin: { right: 10, bottom: 10 }, - }, - dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), - } + notification: { + margin: { top: 10 }, + background: background(colorScheme.middle), + cornerRadius: 6, + padding: 12, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + }, + notifications: { + width: 400, + margin: { right: 10, bottom: 10 }, + }, + dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), + } } diff --git a/styles/vitest.config.ts b/styles/vitest.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..83bd50b9c65ed9a596e1574a767378a3e9bf7e68 --- /dev/null +++ b/styles/vitest.config.ts @@ -0,0 +1,8 @@ +import { configDefaults, defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + exclude: [...configDefaults.exclude, 'target/*'], + include: ['src/**/*.{spec,test}.ts'], + }, +}) From 1f3feacb2162db3a35699060727c43b062c882fb Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 00:37:08 -0400 Subject: [PATCH 12/26] Add path aliases --- styles/src/element/{interactive => }/index.ts | 0 .../{interactive => }/interactive.test.ts | 0 .../element/{interactive => }/interactive.ts | 0 styles/src/styleTree/assistant.ts | 2 +- styles/src/styleTree/commandPalette.ts | 2 +- styles/src/styleTree/contactList.ts | 2 +- styles/src/styleTree/contactNotification.ts | 2 +- styles/src/styleTree/contextMenu.ts | 2 +- styles/src/styleTree/copilot.ts | 2 +- styles/src/styleTree/editor.ts | 2 +- styles/src/styleTree/feedback.ts | 2 +- styles/src/styleTree/picker.ts | 2 +- styles/src/styleTree/projectPanel.ts | 2 +- styles/src/styleTree/search.ts | 2 +- .../styleTree/simpleMessageNotification.ts | 2 +- styles/src/styleTree/statusBar.ts | 2 +- styles/src/styleTree/tabBar.ts | 2 +- styles/src/styleTree/toolbarDropdownMenu.ts | 2 +- styles/src/styleTree/updateNotification.ts | 2 +- styles/src/styleTree/welcome.ts | 2 +- styles/src/styleTree/workspace.ts | 2 +- styles/tsconfig.json | 30 +++++++++++++++++-- 22 files changed, 46 insertions(+), 20 deletions(-) rename styles/src/element/{interactive => }/index.ts (100%) rename styles/src/element/{interactive => }/interactive.test.ts (100%) rename styles/src/element/{interactive => }/interactive.ts (100%) diff --git a/styles/src/element/interactive/index.ts b/styles/src/element/index.ts similarity index 100% rename from styles/src/element/interactive/index.ts rename to styles/src/element/index.ts diff --git a/styles/src/element/interactive/interactive.test.ts b/styles/src/element/interactive.test.ts similarity index 100% rename from styles/src/element/interactive/interactive.test.ts rename to styles/src/element/interactive.test.ts diff --git a/styles/src/element/interactive/interactive.ts b/styles/src/element/interactive.ts similarity index 100% rename from styles/src/element/interactive/interactive.ts rename to styles/src/element/interactive.ts diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index b31fe8169eb0693077a4ef59671bdddce13ec408..6ebf648481db46b845d33d712bd3b4d5b6f35d55 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -1,7 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { text, border, background, foreground } from "./components" import editor from "./editor" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function assistant(colorScheme: ColorScheme) { const layer = colorScheme.highest diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 081a0ba68c1dce191c6fc6b6f5d9bcc7243f3c11..8634d08a90e2c145a6273357b894140d0c659c99 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -2,7 +2,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" import { toggleable } from "./toggle" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function commandPalette(colorScheme: ColorScheme) { let layer = colorScheme.highest diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 3b95a3c885f24d11d210c0c5c288811be39b57d5..f038d7971688f110291fe785eec52bfc1aae5280 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -1,7 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" import { toggleable } from "./toggle" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function contactsPanel(colorScheme: ColorScheme) { const nameMargin = 8 const sidePadding = 12 diff --git a/styles/src/styleTree/contactNotification.ts b/styles/src/styleTree/contactNotification.ts index 4d572390052b11a97ad59d47a3320eac1ee0b921..7de3f2fe0c5ecd58b9bd20d61190ba88d55ad3e2 100644 --- a/styles/src/styleTree/contactNotification.ts +++ b/styles/src/styleTree/contactNotification.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" const avatarSize = 12 const headerPadding = 8 diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 51bff9de7fed6e83ffd2486003bb8aa73fa2cc47..21231ccac9d29ac8c98ff90c8760af310cb93097 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function contextMenu(colorScheme: ColorScheme) { diff --git a/styles/src/styleTree/copilot.ts b/styles/src/styleTree/copilot.ts index 27ef5ec11c49548adb8c6d22823e713126a16d36..9229761414a6bbfda40050a857bfdc7f74e4ac75 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, svg, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function copilot(colorScheme: ColorScheme) { let layer = colorScheme.middle diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 3612a0acd1fec92238c2c43f91e49f60db7bb2f7..5a55341933b74472ef0ce726f3e376beb4f4cbbf 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -4,7 +4,7 @@ import { background, border, borderColor, foreground, text } from "./components" import hoverPopover from "./hoverPopover" import { buildSyntax } from "../theme/syntax" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function editor(colorScheme: ColorScheme) { diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 19a8f1e4c75911b4bc167d3227cab73c7a4ba2d5..4f0e99844dfbc74075d2f8f8134b8bb146aa2b95 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function feedback(colorScheme: ColorScheme) { let layer = colorScheme.highest diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 3bcdae584fddadc86ba637febdefb6411d96c10f..940059eb438d8ff3e17748313e1dee5397f3c297 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -2,7 +2,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, text } from "./components" import { toggleable } from "./toggle" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function picker(colorScheme: ColorScheme): any { let layer = colorScheme.lowest diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 132dfe102c14a26123cb82d694979a446ca1fb05..5df3988be6ffd82fb08c0d8a0a0777c295774f7e 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,7 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function projectPanel(colorScheme: ColorScheme) { const { isLight } = colorScheme diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index 1f63d2740bada69aee3f5ebeb0d2fb82af5618d5..64f17e7d7407f0b94cb5f10135abe740dd1293a7 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -1,7 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function search(colorScheme: ColorScheme) { diff --git a/styles/src/styleTree/simpleMessageNotification.ts b/styles/src/styleTree/simpleMessageNotification.ts index 4c2abfcf9d6fac3575fa30c295cf1a6eaea1e6eb..404be2da7eaa0e860ab0b16427ce48dc75955ce7 100644 --- a/styles/src/styleTree/simpleMessageNotification.ts +++ b/styles/src/styleTree/simpleMessageNotification.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" const headerPadding = 8 diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index ee78f5e6b311f74f229d6ff1d5c98f6d3c07d70e..30f933de8c153eca7ae15562a3d4263e620238a7 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function statusBar(colorScheme: ColorScheme) { let layer = colorScheme.lowest diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index 8011a707727a14f031839e857664ebb4ccca599a..ae2d14bfd624ea52591f378e70c8c46798b71e37 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -2,7 +2,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, border, background, foreground } from "./components" import { toggleable } from "./toggle" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function tabBar(colorScheme: ColorScheme) { const height = 32 diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 0bb3958dc878dfd1206a663c1ceca7a6ad4389cc..bb3e8eda0c83ad9b1ca45ba0321440852ed9e61b 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function dropdownMenu(colorScheme: ColorScheme) { let layer = colorScheme.middle diff --git a/styles/src/styleTree/updateNotification.ts b/styles/src/styleTree/updateNotification.ts index a7a5aaabaa8c4881e0fd4ada5c049da45a458c80..0cef7fa805eb660f38cb50a13e8e189c1919075b 100644 --- a/styles/src/styleTree/updateNotification.ts +++ b/styles/src/styleTree/updateNotification.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" const headerPadding = 8 diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index f0e4badf3f84f34f7a3501eb29d67afdfab0c6eb..a0d599b7477058c7097f79f75cf2e0b31f1bcc7d 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -8,7 +8,7 @@ import { TextProperties, svg, } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function welcome(colorScheme: ColorScheme) { let layer = colorScheme.highest diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index fa2d337592bca85fc58df563d8091ff723e9bfc6..1045be1a9af1023aed9ce7ac681f0b4804e2b2ee 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -11,7 +11,7 @@ import { } from "./components" import statusBar from "./statusBar" import tabBar from "./tabBar" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import merge from 'ts-deepmerge'; export default function workspace(colorScheme: ColorScheme) { const layer = colorScheme.lowest diff --git a/styles/tsconfig.json b/styles/tsconfig.json index 6d24728a0a9f0e38b3a038c7c7bf3d0642e6e88f..051626adbc371db1b684db8f7e56e06421348153 100644 --- a/styles/tsconfig.json +++ b/styles/tsconfig.json @@ -20,7 +20,33 @@ "noFallthroughCasesInSwitch": false, "experimentalDecorators": true, "strictPropertyInitialization": false, - "skipLibCheck": true + "skipLibCheck": true, + "baseUrl": ".", + "paths": { + "@/*": [ + "./*" + ], + "@element/*": [ + "./src/element/*" + ], + "@component/*": [ + "./src/component/*" + ], + "@styleTree/*": [ + "./src/styleTree/*" + ], + "@theme/*": [ + "./src/theme/*" + ], + "@themes/*": [ + "./src/themes/*" + ], + "@util/*": [ + "./src/util/*" + ] + } }, - "exclude": ["node_modules"] + "exclude": [ + "node_modules" + ] } From 5c034ab63c2520e8fe0a6c27f9602dc0851662c6 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 01:01:51 -0400 Subject: [PATCH 13/26] Format --- styles/src/element/index.ts | 2 +- styles/src/element/interactive.test.ts | 61 ++- styles/src/element/interactive.ts | 76 +-- styles/src/styleTree/app.ts | 1 - styles/src/styleTree/assistant.ts | 25 +- styles/src/styleTree/commandPalette.ts | 22 +- styles/src/styleTree/components.ts | 434 +++++++++--------- styles/src/styleTree/contactList.ts | 106 +++-- styles/src/styleTree/contactNotification.ts | 31 +- styles/src/styleTree/contextMenu.ts | 60 +-- styles/src/styleTree/copilot.ts | 66 ++- styles/src/styleTree/editor.ts | 67 +-- styles/src/styleTree/feedback.ts | 7 +- styles/src/styleTree/picker.ts | 54 ++- styles/src/styleTree/projectPanel.ts | 37 +- styles/src/styleTree/search.ts | 72 +-- .../styleTree/simpleMessageNotification.ts | 12 +- styles/src/styleTree/statusBar.ts | 134 +++--- styles/src/styleTree/tabBar.ts | 29 +- styles/src/styleTree/toggle.ts | 64 +-- styles/src/styleTree/toolbarDropdownMenu.ts | 54 ++- styles/src/styleTree/updateNotification.ts | 17 +- styles/src/styleTree/welcome.ts | 9 +- styles/src/styleTree/workspace.ts | 235 +++++----- styles/src/theme/tokens/colorScheme.ts | 56 ++- styles/src/theme/tokens/layer.ts | 33 +- styles/src/theme/tokens/players.ts | 18 +- styles/src/theme/tokens/token.ts | 9 +- styles/src/utils/slugify.ts | 11 +- styles/tsconfig.json | 32 +- styles/vitest.config.ts | 6 +- 31 files changed, 979 insertions(+), 861 deletions(-) diff --git a/styles/src/element/index.ts b/styles/src/element/index.ts index 0ead902eb94c12f11c1cf076a599c10762f4d514..ad58b89e0e8217fc511d76183453b570a496fb39 100644 --- a/styles/src/element/index.ts +++ b/styles/src/element/index.ts @@ -1,3 +1,3 @@ -import { interactive } from "./interactive"; +import { interactive } from "./interactive" export { interactive } diff --git a/styles/src/element/interactive.test.ts b/styles/src/element/interactive.test.ts index aa716e998ec3db8a042af72cc911925726a58f53..b0cc57875f4249e0700cc4f28c7e93a34cec49dc 100644 --- a/styles/src/element/interactive.test.ts +++ b/styles/src/element/interactive.test.ts @@ -1,59 +1,56 @@ -import { NOT_ENOUGH_STATES_ERROR, NO_DEFAULT_OR_BASE_ERROR, interactive } from './interactive' -import { describe, it, expect } from 'vitest' - -describe('interactive', () => { - - it('creates an Interactive with base properties and states', () => { - +import { + NOT_ENOUGH_STATES_ERROR, + NO_DEFAULT_OR_BASE_ERROR, + interactive, +} from "./interactive" +import { describe, it, expect } from "vitest" + +describe("interactive", () => { + it("creates an Interactive with base properties and states", () => { const result = interactive({ - base: { fontSize: 10, color: '#FFFFFF' }, + base: { fontSize: 10, color: "#FFFFFF" }, state: { - hovered: { color: '#EEEEEE' }, - clicked: { color: '#CCCCCC' }, - } + hovered: { color: "#EEEEEE" }, + clicked: { color: "#CCCCCC" }, + }, }) expect(result).toEqual({ - default: { color: '#FFFFFF', fontSize: 10 }, - hovered: { color: '#EEEEEE', fontSize: 10 }, - clicked: { color: '#CCCCCC', fontSize: 10 }, + default: { color: "#FFFFFF", fontSize: 10 }, + hovered: { color: "#EEEEEE", fontSize: 10 }, + clicked: { color: "#CCCCCC", fontSize: 10 }, }) }) - it('creates an Interactive with no base properties', () => { - + it("creates an Interactive with no base properties", () => { const result = interactive({ state: { - default: { color: '#FFFFFF', fontSize: 10 }, - hovered: { color: '#EEEEEE' }, - clicked: { color: '#CCCCCC' }, - } + default: { color: "#FFFFFF", fontSize: 10 }, + hovered: { color: "#EEEEEE" }, + clicked: { color: "#CCCCCC" }, + }, }) expect(result).toEqual({ - default: { color: '#FFFFFF', fontSize: 10 }, - hovered: { color: '#EEEEEE', fontSize: 10 }, - clicked: { color: '#CCCCCC', fontSize: 10 }, + default: { color: "#FFFFFF", fontSize: 10 }, + hovered: { color: "#EEEEEE", fontSize: 10 }, + clicked: { color: "#CCCCCC", fontSize: 10 }, }) }) - it('throws error when both default and base are missing', () => { + it("throws error when both default and base are missing", () => { const state = { - hovered: { color: 'blue' }, + hovered: { color: "blue" }, } - expect(() => interactive({ state })).toThrow( - NO_DEFAULT_OR_BASE_ERROR - ) + expect(() => interactive({ state })).toThrow(NO_DEFAULT_OR_BASE_ERROR) }) - it('throws error when no other state besides default is present', () => { + it("throws error when no other state besides default is present", () => { const state = { default: { fontSize: 10 }, } - expect(() => interactive({ state })).toThrow( - NOT_ENOUGH_STATES_ERROR - ) + expect(() => interactive({ state })).toThrow(NOT_ENOUGH_STATES_ERROR) }) }) diff --git a/styles/src/element/interactive.ts b/styles/src/element/interactive.ts index 23cd2a8c15a0cdf95b31f6fbb670edef717559d0..5d9772d31343ffb4260a4908c82994200c7839a0 100644 --- a/styles/src/element/interactive.ts +++ b/styles/src/element/interactive.ts @@ -1,20 +1,27 @@ import merge from "ts-deepmerge" -type InteractiveState = "default" | "hovered" | "clicked" | "selected" | "disabled"; +type InteractiveState = + | "default" + | "hovered" + | "clicked" + | "selected" + | "disabled" type Interactive = { - default: T, - hovered?: T, - clicked?: T, - selected?: T, - disabled?: T, -}; + default: T + hovered?: T + clicked?: T + selected?: T + disabled?: T +} -export const NO_DEFAULT_OR_BASE_ERROR = "An interactive object must have a default state, or a base property." -export const NOT_ENOUGH_STATES_ERROR = "An interactive object must have a default and at least one other state." +export const NO_DEFAULT_OR_BASE_ERROR = + "An interactive object must have a default state, or a base property." +export const NOT_ENOUGH_STATES_ERROR = + "An interactive object must have a default and at least one other state." interface InteractiveProps { - base?: T, + base?: T state: Partial> } @@ -29,46 +36,61 @@ interface InteractiveProps { * @param state Object containing optional modified fields to be included in the resulting object for each state. * @returns Interactive object with fields from `base` and `state`. */ -export function interactive({ base, state }: InteractiveProps): Interactive { - if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR); +export function interactive({ + base, + state, +}: InteractiveProps): Interactive { + if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR) - let defaultState: T; + let defaultState: T if (state.default && base) { - defaultState = merge(base, state.default) as T; + defaultState = merge(base, state.default) as T } else { - defaultState = base ? base : state.default as T; + defaultState = base ? base : (state.default as T) } let interactiveObj: Interactive = { default: defaultState, - }; + } - let stateCount = 0; + let stateCount = 0 if (state.hovered !== undefined) { - interactiveObj.hovered = merge(interactiveObj.default, state.hovered) as T; - stateCount++; + interactiveObj.hovered = merge( + interactiveObj.default, + state.hovered + ) as T + stateCount++ } if (state.clicked !== undefined) { - interactiveObj.clicked = merge(interactiveObj.default, state.clicked) as T; - stateCount++; + interactiveObj.clicked = merge( + interactiveObj.default, + state.clicked + ) as T + stateCount++ } if (state.selected !== undefined) { - interactiveObj.selected = merge(interactiveObj.default, state.selected) as T; - stateCount++; + interactiveObj.selected = merge( + interactiveObj.default, + state.selected + ) as T + stateCount++ } if (state.disabled !== undefined) { - interactiveObj.disabled = merge(interactiveObj.default, state.disabled) as T; - stateCount++; + interactiveObj.disabled = merge( + interactiveObj.default, + state.disabled + ) as T + stateCount++ } if (stateCount < 1) { - throw new Error(NOT_ENOUGH_STATES_ERROR); + throw new Error(NOT_ENOUGH_STATES_ERROR) } - return interactiveObj; + return interactiveObj } diff --git a/styles/src/styleTree/app.ts b/styles/src/styleTree/app.ts index 6244cbae102b2a0d44d0494438182b07c1144f4a..754443cc5fb068c07df47f7672521dc68bc9ff17 100644 --- a/styles/src/styleTree/app.ts +++ b/styles/src/styleTree/app.ts @@ -1,4 +1,3 @@ -import { text } from "./components" import contactFinder from "./contactFinder" import contactsPopover from "./contactsPopover" import commandPalette from "./commandPalette" diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index 6ebf648481db46b845d33d712bd3b4d5b6f35d55..163584cd6db6b409112422398cde90adf21f9208 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -16,17 +16,27 @@ export default function assistant(colorScheme: ColorScheme) { background: editor(colorScheme).background, }, userSender: { - default: - { ...text(layer, "sans", "default", { size: "sm", weight: "bold" }) }, + default: { + ...text(layer, "sans", "default", { + size: "sm", + weight: "bold", + }), + }, }, assistantSender: { default: { - ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }) + ...text(layer, "sans", "accent", { + size: "sm", + weight: "bold", + }), }, }, systemSender: { default: { - ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }) + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), }, }, sentAt: { @@ -43,11 +53,12 @@ export default function assistant(colorScheme: ColorScheme) { padding: 4, cornerRadius: 4, ...text(layer, "sans", "default", { size: "xs" }), - }, state: { + }, + state: { hovered: { background: background(layer, "on", "hovered"), - } - } + }, + }, }), remainingTokens: { background: background(layer, "on"), diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 8634d08a90e2c145a6273357b894140d0c659c99..ae0aae2f81aee160fb6e094e005fd380f052ef89 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -8,10 +8,12 @@ export default function commandPalette(colorScheme: ColorScheme) { let layer = colorScheme.highest return { keystrokeSpacing: 8, - key: - toggleable(interactive({ + key: toggleable( + interactive({ base: { - text: text(layer, "mono", "variant", "default", { size: "xs" }), + text: text(layer, "mono", "variant", "default", { + size: "xs", + }), cornerRadius: 2, background: background(layer, "on"), padding: { @@ -25,15 +27,15 @@ export default function commandPalette(colorScheme: ColorScheme) { bottom: 1, left: 2, }, - }, state: { hovered: { cornerRadius: 4, padding: { top: 17 } } } - }), { + }, + state: { hovered: { cornerRadius: 4, padding: { top: 17 } } }, + }), + { default: { text: text(layer, "mono", "on", "default", { size: "xs" }), background: withOpacity(background(layer, "on"), 0.2), - } - - }) - , - + }, + } + ), } } diff --git a/styles/src/styleTree/components.ts b/styles/src/styleTree/components.ts index 3aa5d9176e26649c136befcee7aaf51ad412e918..bfd1f75cb07eae0e805eeb6632fdcb92a3f8354d 100644 --- a/styles/src/styleTree/components.ts +++ b/styles/src/styleTree/components.ts @@ -2,297 +2,297 @@ import { fontFamilies, fontSizes, FontWeight } from "../common" import { Layer, Styles, StyleSets, Style } from "../theme/colorScheme" function isStyleSet(key: any): key is StyleSets { - return [ - "base", - "variant", - "on", - "accent", - "positive", - "warning", - "negative", - ].includes(key) + return [ + "base", + "variant", + "on", + "accent", + "positive", + "warning", + "negative", + ].includes(key) } function isStyle(key: any): key is Styles { - return [ - "default", - "active", - "disabled", - "hovered", - "pressed", - "inverted", - ].includes(key) + return [ + "default", + "active", + "disabled", + "hovered", + "pressed", + "inverted", + ].includes(key) } function getStyle( - layer: Layer, - possibleStyleSetOrStyle?: any, - possibleStyle?: any + layer: Layer, + possibleStyleSetOrStyle?: any, + possibleStyle?: any ): Style { - let styleSet: StyleSets = "base" - let style: Styles = "default" - if (isStyleSet(possibleStyleSetOrStyle)) { - styleSet = possibleStyleSetOrStyle - } else if (isStyle(possibleStyleSetOrStyle)) { - style = possibleStyleSetOrStyle - } + let styleSet: StyleSets = "base" + let style: Styles = "default" + if (isStyleSet(possibleStyleSetOrStyle)) { + styleSet = possibleStyleSetOrStyle + } else if (isStyle(possibleStyleSetOrStyle)) { + style = possibleStyleSetOrStyle + } - if (isStyle(possibleStyle)) { - style = possibleStyle - } + if (isStyle(possibleStyle)) { + style = possibleStyle + } - return layer[styleSet][style] + return layer[styleSet][style] } export function background(layer: Layer, style?: Styles): string export function background( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function background( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).background + return getStyle(layer, styleSetOrStyles, style).background } export function borderColor(layer: Layer, style?: Styles): string export function borderColor( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function borderColor( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).border + return getStyle(layer, styleSetOrStyles, style).border } export function foreground(layer: Layer, style?: Styles): string export function foreground( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function foreground( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).foreground + return getStyle(layer, styleSetOrStyles, style).foreground } interface Text extends Object { - family: keyof typeof fontFamilies - color: string - size: number - weight?: FontWeight - underline?: boolean + family: keyof typeof fontFamilies + color: string + size: number + weight?: FontWeight + underline?: boolean } export interface TextProperties { - size?: keyof typeof fontSizes - weight?: FontWeight - underline?: boolean - color?: string - features?: FontFeatures + size?: keyof typeof fontSizes + weight?: FontWeight + underline?: boolean + color?: string + features?: FontFeatures } interface FontFeatures { - /** Contextual Alternates: Applies a second substitution feature based on a match of a character pattern within a context of surrounding patterns */ - calt?: boolean - /** Case-Sensitive Forms: Shifts various punctuation marks up to a position that works better with all-capital sequences */ - case?: boolean - /** Capital Spacing: Adjusts inter-glyph spacing for all-capital text */ - cpsp?: boolean - /** Fractions: Replaces figures separated by a slash with diagonal fractions */ - frac?: boolean - /** Standard Ligatures: Replaces a sequence of glyphs with a single glyph which is preferred for typographic purposes */ - liga?: boolean - /** Oldstyle Figures: Changes selected figures from the default or lining style to oldstyle form. */ - onum?: boolean - /** Ordinals: Replaces default alphabetic glyphs with the corresponding ordinal forms for use after figures */ - ordn?: boolean - /** Proportional Figures: Replaces figure glyphs set on uniform (tabular) widths with corresponding glyphs set on proportional widths */ - pnum?: boolean - /** Stylistic set 01 */ - ss01?: boolean - /** Stylistic set 02 */ - ss02?: boolean - /** Stylistic set 03 */ - ss03?: boolean - /** Stylistic set 04 */ - ss04?: boolean - /** Stylistic set 05 */ - ss05?: boolean - /** Stylistic set 06 */ - ss06?: boolean - /** Stylistic set 07 */ - ss07?: boolean - /** Stylistic set 08 */ - ss08?: boolean - /** Stylistic set 09 */ - ss09?: boolean - /** Stylistic set 10 */ - ss10?: boolean - /** Stylistic set 11 */ - ss11?: boolean - /** Stylistic set 12 */ - ss12?: boolean - /** Stylistic set 13 */ - ss13?: boolean - /** Stylistic set 14 */ - ss14?: boolean - /** Stylistic set 15 */ - ss15?: boolean - /** Stylistic set 16 */ - ss16?: boolean - /** Stylistic set 17 */ - ss17?: boolean - /** Stylistic set 18 */ - ss18?: boolean - /** Stylistic set 19 */ - ss19?: boolean - /** Stylistic set 20 */ - ss20?: boolean - /** Subscript: Replaces default glyphs with subscript glyphs */ - subs?: boolean - /** Superscript: Replaces default glyphs with superscript glyphs */ - sups?: boolean - /** Swash: Replaces default glyphs with swash glyphs for stylistic purposes */ - swsh?: boolean - /** Titling: Replaces default glyphs with titling glyphs for use in large-size settings */ - titl?: boolean - /** Tabular Figures: Replaces figure glyphs set on proportional widths with corresponding glyphs set on uniform (tabular) widths */ - tnum?: boolean - /** Slashed Zero: Replaces default zero with a slashed zero for better distinction between "0" and "O" */ - zero?: boolean + /** Contextual Alternates: Applies a second substitution feature based on a match of a character pattern within a context of surrounding patterns */ + calt?: boolean + /** Case-Sensitive Forms: Shifts various punctuation marks up to a position that works better with all-capital sequences */ + case?: boolean + /** Capital Spacing: Adjusts inter-glyph spacing for all-capital text */ + cpsp?: boolean + /** Fractions: Replaces figures separated by a slash with diagonal fractions */ + frac?: boolean + /** Standard Ligatures: Replaces a sequence of glyphs with a single glyph which is preferred for typographic purposes */ + liga?: boolean + /** Oldstyle Figures: Changes selected figures from the default or lining style to oldstyle form. */ + onum?: boolean + /** Ordinals: Replaces default alphabetic glyphs with the corresponding ordinal forms for use after figures */ + ordn?: boolean + /** Proportional Figures: Replaces figure glyphs set on uniform (tabular) widths with corresponding glyphs set on proportional widths */ + pnum?: boolean + /** Stylistic set 01 */ + ss01?: boolean + /** Stylistic set 02 */ + ss02?: boolean + /** Stylistic set 03 */ + ss03?: boolean + /** Stylistic set 04 */ + ss04?: boolean + /** Stylistic set 05 */ + ss05?: boolean + /** Stylistic set 06 */ + ss06?: boolean + /** Stylistic set 07 */ + ss07?: boolean + /** Stylistic set 08 */ + ss08?: boolean + /** Stylistic set 09 */ + ss09?: boolean + /** Stylistic set 10 */ + ss10?: boolean + /** Stylistic set 11 */ + ss11?: boolean + /** Stylistic set 12 */ + ss12?: boolean + /** Stylistic set 13 */ + ss13?: boolean + /** Stylistic set 14 */ + ss14?: boolean + /** Stylistic set 15 */ + ss15?: boolean + /** Stylistic set 16 */ + ss16?: boolean + /** Stylistic set 17 */ + ss17?: boolean + /** Stylistic set 18 */ + ss18?: boolean + /** Stylistic set 19 */ + ss19?: boolean + /** Stylistic set 20 */ + ss20?: boolean + /** Subscript: Replaces default glyphs with subscript glyphs */ + subs?: boolean + /** Superscript: Replaces default glyphs with superscript glyphs */ + sups?: boolean + /** Swash: Replaces default glyphs with swash glyphs for stylistic purposes */ + swsh?: boolean + /** Titling: Replaces default glyphs with titling glyphs for use in large-size settings */ + titl?: boolean + /** Tabular Figures: Replaces figure glyphs set on proportional widths with corresponding glyphs set on uniform (tabular) widths */ + tnum?: boolean + /** Slashed Zero: Replaces default zero with a slashed zero for better distinction between "0" and "O" */ + zero?: boolean } export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSet: StyleSets, - style: Styles, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSet: StyleSets, + style: Styles, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSet: StyleSets, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSet: StyleSets, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - style: Styles, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + style: Styles, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSetStyleOrProperties?: StyleSets | Styles | TextProperties, - styleOrProperties?: Styles | TextProperties, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSetStyleOrProperties?: StyleSets | Styles | TextProperties, + styleOrProperties?: Styles | TextProperties, + properties?: TextProperties ) { - let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) + let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) - if (typeof styleSetStyleOrProperties === "object") { - properties = styleSetStyleOrProperties - } - if (typeof styleOrProperties === "object") { - properties = styleOrProperties - } + if (typeof styleSetStyleOrProperties === "object") { + properties = styleSetStyleOrProperties + } + if (typeof styleOrProperties === "object") { + properties = styleOrProperties + } - let size = fontSizes[properties?.size || "sm"] - let color = properties?.color || style.foreground + let size = fontSizes[properties?.size || "sm"] + let color = properties?.color || style.foreground - return { - family: fontFamilies[fontFamily], - ...properties, - color, - size, - } + return { + family: fontFamilies[fontFamily], + ...properties, + color, + size, + } } export interface Border { - color: string - width: number - top?: boolean - bottom?: boolean - left?: boolean - right?: boolean - overlay?: boolean + color: string + width: number + top?: boolean + bottom?: boolean + left?: boolean + right?: boolean + overlay?: boolean } export interface BorderProperties { - width?: number - top?: boolean - bottom?: boolean - left?: boolean - right?: boolean - overlay?: boolean + width?: number + top?: boolean + bottom?: boolean + left?: boolean + right?: boolean + overlay?: boolean } export function border( - layer: Layer, - styleSet: StyleSets, - style: Styles, - properties?: BorderProperties + layer: Layer, + styleSet: StyleSets, + style: Styles, + properties?: BorderProperties ): Border export function border( - layer: Layer, - styleSet: StyleSets, - properties?: BorderProperties + layer: Layer, + styleSet: StyleSets, + properties?: BorderProperties ): Border export function border( - layer: Layer, - style: Styles, - properties?: BorderProperties + layer: Layer, + style: Styles, + properties?: BorderProperties ): Border export function border(layer: Layer, properties?: BorderProperties): Border export function border( - layer: Layer, - styleSetStyleOrProperties?: StyleSets | Styles | BorderProperties, - styleOrProperties?: Styles | BorderProperties, - properties?: BorderProperties + layer: Layer, + styleSetStyleOrProperties?: StyleSets | Styles | BorderProperties, + styleOrProperties?: Styles | BorderProperties, + properties?: BorderProperties ): Border { - let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) + let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) - if (typeof styleSetStyleOrProperties === "object") { - properties = styleSetStyleOrProperties - } - if (typeof styleOrProperties === "object") { - properties = styleOrProperties - } + if (typeof styleSetStyleOrProperties === "object") { + properties = styleSetStyleOrProperties + } + if (typeof styleOrProperties === "object") { + properties = styleOrProperties + } - return { - color: style.border, - width: 1, - ...properties, - } + return { + color: style.border, + width: 1, + ...properties, + } } export function svg( - color: string, - asset: String, - width: Number, - height: Number + color: string, + asset: String, + width: Number, + height: Number ) { - return { - color, - asset, - dimensions: { - width, - height, - }, - } + return { + color, + asset, + dimensions: { + width, + height, + }, + } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index f038d7971688f110291fe785eec52bfc1aae5280..5c6068408ecb0f06615a52f367520b0783fd5c21 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -72,24 +72,28 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, rowHeight: 28, sectionIconSize: 8, - headerRow: toggleable(interactive({ - base: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, + headerRow: toggleable( + interactive({ + base: { + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"), // posiewic: breaking change }, - background: background(layer, "default"),// posiewic: breaking change - } - , state: { hovered: { background: background(layer, "default") } } // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. - }), + state: { + hovered: { background: background(layer, "default") }, + }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. + }), { default: { ...text(layer, "mono", "active", { size: "sm" }), background: background(layer, "active"), }, - }), + } + ), leaveCall: interactive({ base: { background: background(layer), @@ -105,24 +109,22 @@ export default function contactsPanel(colorScheme: ColorScheme) { right: 7, }, ...text(layer, "sans", "variant", { size: "xs" }), - } - , + }, state: { hovered: { ...text(layer, "sans", "hovered", { size: "xs" }), background: background(layer, "hovered"), border: border(layer, "hovered"), - } - } - } - ), + }, + }, + }), contactRow: { inactive: { default: { padding: { left: sidePadding, right: sidePadding, - } + }, }, }, active: { @@ -131,8 +133,8 @@ export default function contactsPanel(colorScheme: ColorScheme) { padding: { left: sidePadding, right: sidePadding, - } - } + }, + }, }, }, @@ -165,7 +167,7 @@ export default function contactsPanel(colorScheme: ColorScheme) { hovered: { background: background(layer, "hovered"), }, - } + }, }), disabledButton: { ...contactButton, @@ -175,44 +177,48 @@ export default function contactsPanel(colorScheme: ColorScheme) { callingIndicator: { ...text(layer, "mono", "variant", { size: "xs" }), }, - treeBranch: toggleable(interactive({ - base: { - color: borderColor(layer), - width: 1, - }, - state: { - hovered: { + treeBranch: toggleable( + interactive({ + base: { color: borderColor(layer), + width: 1, }, - } - }), + state: { + hovered: { + color: borderColor(layer), + }, + }, + }), { default: { color: borderColor(layer), }, } ), - projectRow: toggleable(interactive({ - base: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, - }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), + projectRow: toggleable( + interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, }, - }, state: { - hovered: { - background: background(layer, "hovered"), + state: { + hovered: { + background: background(layer, "hovered"), + }, }, - } - }), + }), { - default: { background: background(layer, "active") } - }) + default: { background: background(layer, "active") }, + } + ), } } diff --git a/styles/src/styleTree/contactNotification.ts b/styles/src/styleTree/contactNotification.ts index 7de3f2fe0c5ecd58b9bd20d61190ba88d55ad3e2..825c5a389acf7bfd522e45557d4b775a3116ba60 100644 --- a/styles/src/styleTree/contactNotification.ts +++ b/styles/src/styleTree/contactNotification.ts @@ -21,22 +21,21 @@ export default function contactNotification(colorScheme: ColorScheme): Object { ...text(layer, "sans", { size: "xs" }), margin: { left: avatarSize + headerPadding, top: 6, bottom: 6 }, }, - button: - interactive({ - base: { - ...text(layer, "sans", "on", { size: "xs" }), - background: background(layer, "on"), - padding: 4, - cornerRadius: 6, - margin: { left: 6 } - }, + button: interactive({ + base: { + ...text(layer, "sans", "on", { size: "xs" }), + background: background(layer, "on"), + padding: 4, + cornerRadius: 6, + margin: { left: 6 }, + }, - state: { - hovered: { - background: background(layer, "on", "hovered"), - } - } - }), + state: { + hovered: { + background: background(layer, "on", "hovered"), + }, + }, + }), dismissButton: { default: { @@ -48,7 +47,7 @@ export default function contactNotification(colorScheme: ColorScheme): Object { hover: { color: foreground(layer, "hovered"), }, - } + }, }, } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 21231ccac9d29ac8c98ff90c8760af310cb93097..6f5eb5364058aa9b790c9b58f36bae8681385452 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -12,41 +12,45 @@ export default function contextMenu(colorScheme: ColorScheme) { shadow: colorScheme.popoverShadow, border: border(layer), keystrokeMargin: 30, - item: toggleable(interactive({ - base: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - } - }, state: { - hovered: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), + item: toggleable( + interactive({ + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), keystroke: { - ...text(layer, "sans", "hovered", { + ...text(layer, "sans", "variant", { size: "sm", weight: "bold", }), padding: { left: 3, right: 3 }, }, - } + }, + state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + }, + }), + { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, } - }), { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - }), + ), separator: { background: borderColor(layer), diff --git a/styles/src/styleTree/copilot.ts b/styles/src/styleTree/copilot.ts index 9229761414a6bbfda40050a857bfdc7f74e4ac75..1e09f4ff6b5f9c4c6a8ab9818cd16ede7d58a5e1 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -25,7 +25,7 @@ export default function copilot(colorScheme: ColorScheme) { left: 7, right: 7, }, - ...text(layer, "sans", "default", { size: "sm" }) + ...text(layer, "sans", "default", { size: "sm" }), }, state: { hovered: { @@ -33,39 +33,37 @@ export default function copilot(colorScheme: ColorScheme) { background: background(layer, "hovered"), border: border(layer, "active"), }, - } - }); + }, + }) return { - outLinkIcon: - interactive({ - base: { - icon: svg( - foreground(layer, "variant"), - "icons/link_out_12.svg", - 12, - 12 - ), - container: { - cornerRadius: 6, - padding: { left: 6 }, - }, + outLinkIcon: interactive({ + base: { + icon: svg( + foreground(layer, "variant"), + "icons/link_out_12.svg", + 12, + 12 + ), + container: { + cornerRadius: 6, + padding: { left: 6 }, }, - state: { - hovered: { - icon: { - color: - foreground(layer, "hovered") - } + }, + state: { + hovered: { + icon: { + color: foreground(layer, "hovered"), }, - } - }), + }, + }, + }), modal: { titleText: { default: { - ...text(layer, "sans", { size: "xs", weight: "bold" }) - } + ...text(layer, "sans", { size: "xs", weight: "bold" }), + }, }, titlebar: { background: background(colorScheme.lowest), @@ -87,8 +85,7 @@ export default function copilot(colorScheme: ColorScheme) { }, }, closeIcon: interactive({ - base: - { + base: { icon: svg( foreground(layer, "variant"), "icons/x_mark_8.svg", @@ -106,7 +103,7 @@ export default function copilot(colorScheme: ColorScheme) { margin: { right: 0, }, - } + }, }, state: { hovered: { @@ -125,7 +122,7 @@ export default function copilot(colorScheme: ColorScheme) { 8 ), }, - } + }, }), dimensions: { width: 280, @@ -214,8 +211,9 @@ export default function copilot(colorScheme: ColorScheme) { bottom: 5, left: 8, right: 0, - } - }, state: { + }, + }, + state: { hovered: { border: border(layer, "active", { bottom: false, @@ -224,8 +222,8 @@ export default function copilot(colorScheme: ColorScheme) { left: true, }), }, - } - }) + }, + }), }, }, diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 5a55341933b74472ef0ce726f3e376beb4f4cbbf..9dec64b0ced6218f41043bd48b7758d4fb54de51 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -50,23 +50,26 @@ export default function editor(colorScheme: ColorScheme) { // Inline autocomplete suggestions, Co-pilot suggestions, etc. suggestion: syntax.predictive, codeActions: { - indicator: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - }, state: { - clicked: { - color: foreground(layer, "base"), + indicator: toggleable( + interactive({ + base: { + color: foreground(layer, "variant"), }, - hovered: { - color: foreground(layer, "on"), + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, }, - } - }), + }), { default: { color: foreground(layer, "on"), - } - }), + }, + } + ), verticalScale: 0.55, }, @@ -74,29 +77,34 @@ export default function editor(colorScheme: ColorScheme) { iconMarginScale: 2.5, foldedIcon: "icons/chevron_right_8.svg", foldableIcon: "icons/chevron_down_8.svg", - indicator: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - }, state: { - clicked: { - color: foreground(layer, "base"), + indicator: toggleable( + interactive({ + base: { + color: foreground(layer, "variant"), }, - hovered: { - color: foreground(layer, "on"), + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, }, - } - }), + }), { default: { color: foreground(layer, "on"), - } - }), + }, + } + ), ellipses: { textColor: colorScheme.ramps.neutral(0.71).hex(), cornerRadiusFactor: 0.15, background: { // Copied from hover_popover highlight - default: { color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex() }, + default: { + color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), + }, hover: { color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), @@ -245,12 +253,13 @@ export default function editor(colorScheme: ColorScheme) { bottom: 6, left: 6, right: 6, - } - }, state: { + }, + }, + state: { hovered: { background: background(layer, "on", "hovered"), - } - } + }, + }, }), scrollbar: { diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 4f0e99844dfbc74075d2f8f8134b8bb146aa2b95..c98cbe768faa2495e5fde6099b685ce4103d0ecb 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -20,8 +20,9 @@ export default function feedback(colorScheme: ColorScheme) { left: 10, right: 10, top: 2, - } - }, state: { + }, + }, + state: { clicked: { ...text(layer, "mono", "on", "pressed"), background: background(layer, "on", "pressed"), @@ -32,7 +33,7 @@ export default function feedback(colorScheme: ColorScheme) { background: background(layer, "on", "hovered"), border: border(layer, "on", "hovered"), }, - } + }, }), button_margin: 8, info_text_default: text(layer, "sans", "default", { size: "xs" }), diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 940059eb438d8ff3e17748313e1dee5397f3c297..7730395ec9653f7661eae91eeee2f1703c4486a7 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -40,29 +40,35 @@ export default function picker(colorScheme: ColorScheme): any { ...container, padding: {}, }, - item: toggleable(interactive({ - base: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, + item: toggleable( + interactive({ + base: { + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, + }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { + weight: "bold", + }), }, - margin: { - top: 1, - left: 4, - right: 4, + state: { + hovered: { + background: withOpacity( + background(layer, "hovered"), + 0.5 + ), + }, }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { weight: "bold" }), - } - , state: { - hovered: { - background: withOpacity(background(layer, "hovered"), 0.5), - } - } - }), + }), { default: { background: withOpacity( @@ -70,9 +76,9 @@ export default function picker(colorScheme: ColorScheme): any { 0.5 ), //text: text(layer, "sans", "base", "active"), - } - }), - + }, + } + ), inputEditor, emptyInputEditor, diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 5df3988be6ffd82fb08c0d8a0a0777c295774f7e..23df2fbf58f60ada4cd9b36542e71728a398fca0 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -29,18 +29,19 @@ export default function projectPanel(colorScheme: ColorScheme) { }, } - let entry = toggleable(interactive({ - base: { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, - }, state: - { - hovered: { - background: background(layer, "variant", "hovered"), - } - } - }), + let entry = toggleable( + interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, + state: { + hovered: { + background: background(layer, "variant", "hovered"), + }, + }, + }), { default: { /*background: colorScheme.isLight @@ -52,8 +53,8 @@ export default function projectPanel(colorScheme: ColorScheme) { //background: background(layer, "active"), text: text(layer, "mono", "active", { size: "sm" }), }, - - }); + } + ) return { openProjectButton: interactive({ @@ -72,14 +73,15 @@ export default function projectPanel(colorScheme: ColorScheme) { left: 7, right: 7, }, - ...text(layer, "sans", "default", { size: "sm" }) - }, state: { + ...text(layer, "sans", "default", { size: "sm" }), + }, + state: { hovered: { ...text(layer, "sans", "default", { size: "sm" }), background: background(layer, "hovered"), border: border(layer, "active"), }, - } + }, }), background: background(layer), padding: { left: 6, right: 6, top: 0, bottom: 6 }, @@ -111,7 +113,6 @@ export default function projectPanel(colorScheme: ColorScheme) { background: background(layer, "active"), text: text(layer, "mono", "disabled", { size: "sm" }), }, - }, }, filenameEditor: { diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index 64f17e7d7407f0b94cb5f10135abe740dd1293a7..a95296971c1af14156f25f9e68d9e21e74e7a173 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -37,41 +37,44 @@ export default function search(colorScheme: ColorScheme) { return { // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive matchBackground: withOpacity(foreground(layer, "accent"), 0.4), - optionButton: toggleable(interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, + optionButton: toggleable( + interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, + }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, + }, }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, + state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, }, - }, state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), + }), + { + default: { + ...text(layer, "mono", "on", "inverted"), + background: background(layer, "on", "inverted"), + border: border(layer, "on", "inverted"), }, } - }), { - default: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), - }, - - }), + ), editor, invalidEditor: { ...editor, @@ -113,11 +116,12 @@ export default function search(colorScheme: ColorScheme) { left: 10, right: 10, }, - }, state: { + }, + state: { hovered: { color: foreground(layer, "hovered"), - } - } + }, + }, }), } } diff --git a/styles/src/styleTree/simpleMessageNotification.ts b/styles/src/styleTree/simpleMessageNotification.ts index 404be2da7eaa0e860ab0b16427ce48dc75955ce7..e894db3514ad19f70f24a0458c303b397f426f8a 100644 --- a/styles/src/styleTree/simpleMessageNotification.ts +++ b/styles/src/styleTree/simpleMessageNotification.ts @@ -26,13 +26,14 @@ export default function simpleMessageNotification( }, margin: { left: headerPadding, top: 6, bottom: 6 }, - }, state: { + }, + state: { hovered: { ...text(layer, "sans", "default", { size: "xs" }), background: background(layer, "hovered"), border: border(layer, "active"), }, - } + }, }), dismissButton: interactive({ base: { @@ -41,11 +42,12 @@ export default function simpleMessageNotification( iconHeight: 8, buttonWidth: 8, buttonHeight: 8, - }, state: { + }, + state: { hovered: { color: foreground(layer, "hovered"), }, - } - }) + }, + }), } } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 30f933de8c153eca7ae15562a3d4263e620238a7..8a91b7eaac434ac4b2c160320ee4ea22220ab956 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -29,15 +29,14 @@ export default function statusBar(colorScheme: ColorScheme) { activeLanguage: interactive({ base: { padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant") + ...text(layer, "sans", "variant"), }, state: { hovered: { ...text(layer, "sans", "on"), - } - } - }, - ), + }, + }, + }), autoUpdateProgressMessage: text(layer, "sans", "variant"), autoUpdateDoneMessage: text(layer, "sans", "variant"), lspStatus: interactive({ @@ -47,92 +46,93 @@ export default function statusBar(colorScheme: ColorScheme) { iconWidth: 14, height: 18, message: text(layer, "sans"), - iconColor: foreground(layer) + iconColor: foreground(layer), }, state: { hovered: { message: text(layer, "sans"), iconColor: foreground(layer), background: background(layer, "hovered"), - } - } + }, + }, }), diagnosticMessage: interactive({ base: { - ...text(layer, "sans") + ...text(layer, "sans"), }, - state: { hovered: text(layer, "sans", "hovered") } - }, - ), - diagnosticSummary: - interactive({ - base: { - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), + state: { hovered: text(layer, "sans", "hovered") }, + }), + diagnosticSummary: interactive({ + base: { + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), + containerOk: { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, + }, + containerWarning: { + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), + }, + containerError: { + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + }, + }, + state: { + hovered: { + iconColorOk: foreground(layer, "on"), containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, + background: background(layer, "on", "hovered"), }, containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), }, containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - } - }, state: { - hovered: { - iconColorOk: foreground(layer, "on"), - containerOk: { - background: background(layer, "on", "hovered"), - }, - containerWarning: { - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), - }, - containerError: { - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), - } - } - } - } - ), + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + }, + }, + }, + }), panelButtons: { groupLeft: {}, groupBottom: {}, groupRight: {}, - button: toggleable(interactive({ - base: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), + button: toggleable( + interactive({ + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, }, - }, state: { - hovered: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - } - } - }), + state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + }, + }, + }), { default: { iconColor: foreground(layer, "active"), background: background(layer, "active"), - } - }), + }, + } + ), badge: { cornerRadius: 3, padding: 2, diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index ae2d14bfd624ea52591f378e70c8c46798b71e37..c2b5de02159f34b9066594249dbbfdc1e1e270ca 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -89,23 +89,24 @@ export default function tabBar(colorScheme: ColorScheme) { inactiveTab: inactivePaneInactiveTab, }, draggedTab, - paneButton: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - }, - state: { - hovered: { - color: foreground(layer, "hovered"), - } - } - }), + paneButton: toggleable( + interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), + }, + }, + }), { default: { color: foreground(layer, "accent"), - } - }, + }, + } ), paneButtonContainer: { background: tab.background, diff --git a/styles/src/styleTree/toggle.ts b/styles/src/styleTree/toggle.ts index d6b37dde9e22ac697540b2ea4304e3cbedf6fbfe..2b6858e15be6c3db85232371ba38e0bc9127ea33 100644 --- a/styles/src/styleTree/toggle.ts +++ b/styles/src/styleTree/toggle.ts @@ -1,41 +1,47 @@ -import { DeepPartial } from 'utility-types'; -import merge from 'ts-deepmerge'; +import merge from "ts-deepmerge" -interface Toggleable { - inactive: T - active: T, +type ToggleState = "inactive" | "active" + +type Toggleable = Record + +const NO_INACTIVE_OR_BASE_ERROR = + "A toggleable object must have an inactive state, or a base property." +const NO_ACTIVE_ERROR = "A toggleable object must have an active state." + +interface ToggleableProps { + base?: T + state: Partial> } /** * Helper function for creating Toggleable objects. * @template T The type of the object being toggled. - * @param inactive The initial state of the toggleable object. - * @param modifications The modifications to be applied to the initial state to create the active state. + * @param props Object containing the base (inactive) state and state modifications to create the active state. * @returns A Toggleable object containing both the inactive and active states. * @example * ``` - * toggleable({day: 1, month: "January"}, {day: 3}) - * ``` - * This returns the following object: - * ``` - * Toggleable<_>{ - * inactive: { day: 1, month: "January" }, - * active: { day: 3, month: "January" } - * } - * ``` - * The function also works for nested structures: - * ``` - * toggleable({first_level: "foo", second_level: {nested_member: "nested"}}, {second_level: {nested_member: "another nested thing"}}) - * ``` - * Which returns: - * ``` - * Toggleable<_> { - * inactive: {first_level: "foo", second_level: {nested_member: "nested"}}, - * active: { first_level: "foo", second_level: {nested_member: "another nested thing"}} - * } + * toggleable({ + * base: { background: "#000000", text: "#CCCCCC" }, + * state: { active: { text: "#CCCCCC" } }, + * }) * ``` */ -export function toggleable(inactive: T, modifications: DeepPartial): Toggleable { - let active: T = merge(inactive, modifications) as T; - return { active: active, inactive: inactive }; +export function toggleable( + props: ToggleableProps +): Toggleable { + const { base, state } = props + + if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) + if (!state.active) throw new Error(NO_ACTIVE_ERROR) + + const inactiveState = base + ? ((state.inactive ? merge(base, state.inactive) : base) as T) + : (state.inactive as T) + + const toggleObj: Toggleable = { + inactive: inactiveState, + active: merge(base ?? {}, state.active) as T, + } + + return toggleObj } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index bb3e8eda0c83ad9b1ca45ba0321440852ed9e61b..1f47c85f4e7563b50577619e5747add669867c94 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -13,44 +13,50 @@ export default function dropdownMenu(colorScheme: ColorScheme) { header: interactive({ base: { ...text(layer, "sans", { size: "sm" }), - secondaryText: text(layer, "sans", { size: "sm", color: "#aaaaaa" }), + secondaryText: text(layer, "sans", { + size: "sm", + color: "#aaaaaa", + }), secondaryTextSpacing: 10, padding: { left: 8, right: 8, top: 2, bottom: 2 }, cornerRadius: 6, background: background(layer, "on"), - border: border(layer, "on", { overlay: true }) + border: border(layer, "on", { overlay: true }), }, state: { hovered: { background: background(layer, "hovered"), ...text(layer, "sans", "hovered", { size: "sm" }), - } - } - }) - , + }, + }, + }), sectionHeader: { ...text(layer, "sans", { size: "sm" }), padding: { left: 8, right: 8, top: 8, bottom: 8 }, }, - item: toggleable(interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 } - }, state: { + item: toggleable( + interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + }, + }, + }), + { + default: { + background: background(layer, "active"), + }, hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - } + background: background(layer, "active"), + }, } - }), { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - }) + ), } } diff --git a/styles/src/styleTree/updateNotification.ts b/styles/src/styleTree/updateNotification.ts index 0cef7fa805eb660f38cb50a13e8e189c1919075b..c6ef81c667c77a3235aece08e1f8f7256b012e6c 100644 --- a/styles/src/styleTree/updateNotification.ts +++ b/styles/src/styleTree/updateNotification.ts @@ -14,12 +14,13 @@ export default function updateNotification(colorScheme: ColorScheme): Object { actionMessage: interactive({ base: { ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, top: 6, bottom: 6 } - }, state: { + margin: { left: headerPadding, top: 6, bottom: 6 }, + }, + state: { hovered: { color: foreground(layer, "hovered"), - } - } + }, + }, }), dismissButton: interactive({ base: { @@ -27,13 +28,13 @@ export default function updateNotification(colorScheme: ColorScheme): Object { iconWidth: 8, iconHeight: 8, buttonWidth: 8, - buttonHeight: 8 - }, state: { + buttonHeight: 8, + }, + state: { hovered: { color: foreground(layer, "hovered"), }, }, - }) - + }), } } diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index a0d599b7477058c7097f79f75cf2e0b31f1bcc7d..311ff6daffa5ce468652ef0eb53dfa3d74c32eb2 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -79,13 +79,14 @@ export default function welcome(colorScheme: ColorScheme) { left: 7, right: 7, }, - ...text(layer, "sans", "default", interactive_text_size) - }, state: { + ...text(layer, "sans", "default", interactive_text_size), + }, + state: { hovered: { ...text(layer, "sans", "default", interactive_text_size), background: background(layer, "hovered"), - } - } + }, + }, }), usageNote: { diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 1045be1a9af1023aed9ce7ac681f0b4804e2b2ee..79e7830aec8e1ad46127516c33cb74892ad17943 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -12,44 +12,50 @@ import { import statusBar from "./statusBar" import tabBar from "./tabBar" import { interactive } from "../element" -import merge from 'ts-deepmerge'; +import merge from "ts-deepmerge" export default function workspace(colorScheme: ColorScheme) { const layer = colorScheme.lowest const isLight = colorScheme.isLight const itemSpacing = 8 - const titlebarButton = toggleable(interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, + const titlebarButton = toggleable( + interactive({ + base: { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { size: "xs" }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), + state: { + hovered: { + ...text(layer, "sans", "variant", "hovered", { + size: "xs", + }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { + size: "xs", + }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + }, }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { size: "xs" }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - } - } - }), + }), { default: { ...text(layer, "sans", "variant", "active", { size: "xs" }), background: background(layer, "variant", "active"), border: border(layer, "variant", "active"), - } - }, - ); + }, + } + ) const avatarWidth = 18 const avatarOuterWidth = avatarWidth + 4 const followerAvatarWidth = 14 @@ -86,23 +92,23 @@ export default function workspace(colorScheme: ColorScheme) { }, cornerRadius: 4, }, - keyboardHint: - interactive({ - base: { - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8 - }, state: { - hovered: { - ...text(layer, "sans", "active", { size: "sm" }), - } - } - }), + keyboardHint: interactive({ + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8, + }, + state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + }, + }, + }), keyboardHintWidth: 320, }, @@ -214,18 +220,15 @@ export default function workspace(colorScheme: ColorScheme) { // Sign in buttom // FlatButton, Variant - signInPrompt: - merge(titlebarButton, - { - inactive: { - default: { - margin: { - left: itemSpacing, - }, - } - } - }), - + signInPrompt: merge(titlebarButton, { + inactive: { + default: { + margin: { + left: itemSpacing, + }, + }, + }, + }), // Offline Indicator offlineIcon: { @@ -259,54 +262,57 @@ export default function workspace(colorScheme: ColorScheme) { color: foreground(layer, "variant"), iconWidth: 12, buttonWidth: 20, - }, state: { - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - } - }), - toggleContactsButton: toggleable(interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, }, state: { - clicked: { - background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), - }, hovered: { background: background(layer, "variant", "hovered"), color: foreground(layer, "variant", "hovered"), - } - } + }, + }, }), + toggleContactsButton: toggleable( + interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), + color: foreground(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + }, + }), { default: { background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active") - } - }, + color: foreground(layer, "variant", "active"), + }, + } ), userMenuButton: merge(titlebarButton, { inactive: { default: { buttonWidth: 20, - iconWidth: 12 - } - }, active: { // posiewic: these properties are not currently set on main + iconWidth: 12, + }, + }, + active: { + // posiewic: these properties are not currently set on main default: { iconWidth: 12, button_width: 20, - } - } + }, + }, }), - toggleContactsBadge: { cornerRadius: 3, padding: 2, @@ -324,27 +330,31 @@ export default function workspace(colorScheme: ColorScheme) { background: background(colorScheme.highest), border: border(colorScheme.highest, { bottom: true }), itemSpacing: 8, - navButton: interactive( - { - base: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, - }, state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - disabled: { - color: foreground(colorScheme.highest, "on", "disabled"), - }, - } - }), + navButton: interactive({ + base: { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, + state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + disabled: { + color: foreground( + colorScheme.highest, + "on", + "disabled" + ), + }, + }, + }), padding: { left: 8, right: 8, top: 4, bottom: 4 }, }, breadcrumbHeight: 24, @@ -355,13 +365,18 @@ export default function workspace(colorScheme: ColorScheme) { padding: { left: 6, right: 6, - } - }, state: { + }, + }, + state: { hovered: { color: foreground(colorScheme.highest, "on", "hovered"), - background: background(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), }, - } + }, }), disconnectedOverlay: { ...text(layer, "sans"), diff --git a/styles/src/theme/tokens/colorScheme.ts b/styles/src/theme/tokens/colorScheme.ts index 84b8db5ce00a0c1767c0b7326444176f594f56fa..bc53ca802a9a4f5cf39dd3345734674558170494 100644 --- a/styles/src/theme/tokens/colorScheme.ts +++ b/styles/src/theme/tokens/colorScheme.ts @@ -1,9 +1,19 @@ -import { SingleBoxShadowToken, SingleColorToken, SingleOtherToken, TokenTypes } from "@tokens-studio/types" -import { ColorScheme, Shadow, SyntaxHighlightStyle, ThemeSyntax } from "../colorScheme" +import { + SingleBoxShadowToken, + SingleColorToken, + SingleOtherToken, + TokenTypes, +} from "@tokens-studio/types" +import { + ColorScheme, + Shadow, + SyntaxHighlightStyle, + ThemeSyntax, +} from "../colorScheme" import { LayerToken, layerToken } from "./layer" import { PlayersToken, playersToken } from "./players" import { colorToken } from "./token" -import { Syntax } from "../syntax"; +import { Syntax } from "../syntax" import editor from "../../styleTree/editor" interface ColorSchemeTokens { @@ -18,27 +28,32 @@ interface ColorSchemeTokens { syntax?: Partial } -const createShadowToken = (shadow: Shadow, tokenName: string): SingleBoxShadowToken => { +const createShadowToken = ( + shadow: Shadow, + tokenName: string +): SingleBoxShadowToken => { return { name: tokenName, type: TokenTypes.BOX_SHADOW, - value: `${shadow.offset[0]}px ${shadow.offset[1]}px ${shadow.blur}px 0px ${shadow.color}` - }; -}; + value: `${shadow.offset[0]}px ${shadow.offset[1]}px ${shadow.blur}px 0px ${shadow.color}`, + } +} const popoverShadowToken = (colorScheme: ColorScheme): SingleBoxShadowToken => { - const shadow = colorScheme.popoverShadow; - return createShadowToken(shadow, "popoverShadow"); -}; + const shadow = colorScheme.popoverShadow + return createShadowToken(shadow, "popoverShadow") +} const modalShadowToken = (colorScheme: ColorScheme): SingleBoxShadowToken => { - const shadow = colorScheme.modalShadow; - return createShadowToken(shadow, "modalShadow"); -}; + const shadow = colorScheme.modalShadow + return createShadowToken(shadow, "modalShadow") +} type ThemeSyntaxColorTokens = Record -function syntaxHighlightStyleColorTokens(syntax: Syntax): ThemeSyntaxColorTokens { +function syntaxHighlightStyleColorTokens( + syntax: Syntax +): ThemeSyntaxColorTokens { const styleKeys = Object.keys(syntax) as (keyof Syntax)[] return styleKeys.reduce((acc, styleKey) => { @@ -46,13 +61,16 @@ function syntaxHighlightStyleColorTokens(syntax: Syntax): ThemeSyntaxColorTokens // This can happen because we have a "constructor" property on the syntax object // and a "constructor" property on the prototype of the syntax object // To work around this just assert that the type of the style is not a function - if (!syntax[styleKey] || typeof syntax[styleKey] === 'function') return acc; - const { color } = syntax[styleKey] as Required; - return { ...acc, [styleKey]: colorToken(styleKey, color) }; - }, {} as ThemeSyntaxColorTokens); + if (!syntax[styleKey] || typeof syntax[styleKey] === "function") + return acc + const { color } = syntax[styleKey] as Required + return { ...acc, [styleKey]: colorToken(styleKey, color) } + }, {} as ThemeSyntaxColorTokens) } -const syntaxTokens = (colorScheme: ColorScheme): ColorSchemeTokens['syntax'] => { +const syntaxTokens = ( + colorScheme: ColorScheme +): ColorSchemeTokens["syntax"] => { const syntax = editor(colorScheme).syntax return syntaxHighlightStyleColorTokens(syntax) diff --git a/styles/src/theme/tokens/layer.ts b/styles/src/theme/tokens/layer.ts index 3ee813b8c4917d733c3bd91de0728de084f81524..42a69b5a528161fac21fbb88f6778933772a32a4 100644 --- a/styles/src/theme/tokens/layer.ts +++ b/styles/src/theme/tokens/layer.ts @@ -1,11 +1,11 @@ -import { SingleColorToken } from "@tokens-studio/types"; -import { Layer, Style, StyleSet } from "../colorScheme"; -import { colorToken } from "./token"; +import { SingleColorToken } from "@tokens-studio/types" +import { Layer, Style, StyleSet } from "../colorScheme" +import { colorToken } from "./token" interface StyleToken { - background: SingleColorToken, - border: SingleColorToken, - foreground: SingleColorToken, + background: SingleColorToken + border: SingleColorToken + foreground: SingleColorToken } interface StyleSetToken { @@ -37,24 +37,27 @@ export const styleToken = (style: Style, name: string): StyleToken => { return token } -export const styleSetToken = (styleSet: StyleSet, name: string): StyleSetToken => { - const token: StyleSetToken = {} as StyleSetToken; +export const styleSetToken = ( + styleSet: StyleSet, + name: string +): StyleSetToken => { + const token: StyleSetToken = {} as StyleSetToken for (const style in styleSet) { - const s = style as keyof StyleSet; - token[s] = styleToken(styleSet[s], `${name}${style}`); + const s = style as keyof StyleSet + token[s] = styleToken(styleSet[s], `${name}${style}`) } - return token; + return token } export const layerToken = (layer: Layer, name: string): LayerToken => { - const token: LayerToken = {} as LayerToken; + const token: LayerToken = {} as LayerToken for (const styleSet in layer) { - const s = styleSet as keyof Layer; - token[s] = styleSetToken(layer[s], `${name}${styleSet}`); + const s = styleSet as keyof Layer + token[s] = styleSetToken(layer[s], `${name}${styleSet}`) } - return token; + return token } diff --git a/styles/src/theme/tokens/players.ts b/styles/src/theme/tokens/players.ts index b5f5538b2eae54c68ca2a49ac7a1e2523ed1251b..94d05cd827dbf8443d3f57e9008aa49da1333c8a 100644 --- a/styles/src/theme/tokens/players.ts +++ b/styles/src/theme/tokens/players.ts @@ -6,13 +6,21 @@ export type PlayerToken = Record<"selection" | "cursor", SingleColorToken> export type PlayersToken = Record -function buildPlayerToken(colorScheme: ColorScheme, index: number): PlayerToken { - +function buildPlayerToken( + colorScheme: ColorScheme, + index: number +): PlayerToken { const playerNumber = index.toString() as keyof Players return { - selection: colorToken(`player${index}Selection`, colorScheme.players[playerNumber].selection), - cursor: colorToken(`player${index}Cursor`, colorScheme.players[playerNumber].cursor), + selection: colorToken( + `player${index}Selection`, + colorScheme.players[playerNumber].selection + ), + cursor: colorToken( + `player${index}Cursor`, + colorScheme.players[playerNumber].cursor + ), } } @@ -24,5 +32,5 @@ export const playersToken = (colorScheme: ColorScheme): PlayersToken => ({ "4": buildPlayerToken(colorScheme, 4), "5": buildPlayerToken(colorScheme, 5), "6": buildPlayerToken(colorScheme, 6), - "7": buildPlayerToken(colorScheme, 7) + "7": buildPlayerToken(colorScheme, 7), }) diff --git a/styles/src/theme/tokens/token.ts b/styles/src/theme/tokens/token.ts index 3e5187dd64c3c9e8c5b57b39c9a4ac9a93f46250..2f1760778eaff686fdf26e03d05a0996e771ed2d 100644 --- a/styles/src/theme/tokens/token.ts +++ b/styles/src/theme/tokens/token.ts @@ -1,6 +1,10 @@ import { SingleColorToken, TokenTypes } from "@tokens-studio/types" -export function colorToken(name: string, value: string, description?: string): SingleColorToken { +export function colorToken( + name: string, + value: string, + description?: string +): SingleColorToken { const token: SingleColorToken = { name, type: TokenTypes.COLOR, @@ -8,7 +12,8 @@ export function colorToken(name: string, value: string, description?: string): S description, } - if (!token.value || token.value === '') throw new Error("Color token must have a value") + if (!token.value || token.value === "") + throw new Error("Color token must have a value") return token } diff --git a/styles/src/utils/slugify.ts b/styles/src/utils/slugify.ts index 62b226cd106876f106e159a1b5a3ffc79fda8d5c..b5c3b3c5196f51b29319a826b5e76785455be8b4 100644 --- a/styles/src/utils/slugify.ts +++ b/styles/src/utils/slugify.ts @@ -1 +1,10 @@ -export function slugify(t: string): string { return t.toString().toLowerCase().replace(/\s+/g, '-').replace(/[^\w\-]+/g, '').replace(/\-\-+/g, '-').replace(/^-+/, '').replace(/-+$/, '') } +export function slugify(t: string): string { + return t + .toString() + .toLowerCase() + .replace(/\s+/g, "-") + .replace(/[^\w\-]+/g, "") + .replace(/\-\-+/g, "-") + .replace(/^-+/, "") + .replace(/-+$/, "") +} diff --git a/styles/tsconfig.json b/styles/tsconfig.json index 051626adbc371db1b684db8f7e56e06421348153..7a8ec69927c92bc0a50981c75434336e393fa6d0 100644 --- a/styles/tsconfig.json +++ b/styles/tsconfig.json @@ -23,30 +23,14 @@ "skipLibCheck": true, "baseUrl": ".", "paths": { - "@/*": [ - "./*" - ], - "@element/*": [ - "./src/element/*" - ], - "@component/*": [ - "./src/component/*" - ], - "@styleTree/*": [ - "./src/styleTree/*" - ], - "@theme/*": [ - "./src/theme/*" - ], - "@themes/*": [ - "./src/themes/*" - ], - "@util/*": [ - "./src/util/*" - ] + "@/*": ["./*"], + "@element/*": ["./src/element/*"], + "@component/*": ["./src/component/*"], + "@styleTree/*": ["./src/styleTree/*"], + "@theme/*": ["./src/theme/*"], + "@themes/*": ["./src/themes/*"], + "@util/*": ["./src/util/*"] } }, - "exclude": [ - "node_modules" - ] + "exclude": ["node_modules"] } diff --git a/styles/vitest.config.ts b/styles/vitest.config.ts index 83bd50b9c65ed9a596e1574a767378a3e9bf7e68..00f3a9852db6b9a98a836e1c0abb78a4a08f354a 100644 --- a/styles/vitest.config.ts +++ b/styles/vitest.config.ts @@ -1,8 +1,8 @@ -import { configDefaults, defineConfig } from 'vitest/config' +import { configDefaults, defineConfig } from "vitest/config" export default defineConfig({ test: { - exclude: [...configDefaults.exclude, 'target/*'], - include: ['src/**/*.{spec,test}.ts'], + exclude: [...configDefaults.exclude, "target/*"], + include: ["src/**/*.{spec,test}.ts"], }, }) From 040881df3f584036570f7e07ee3fee7002e5e81f Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 01:02:00 -0400 Subject: [PATCH 14/26] Update toggle --- styles/src/element/toggle.ts | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 styles/src/element/toggle.ts diff --git a/styles/src/element/toggle.ts b/styles/src/element/toggle.ts new file mode 100644 index 0000000000000000000000000000000000000000..2b6858e15be6c3db85232371ba38e0bc9127ea33 --- /dev/null +++ b/styles/src/element/toggle.ts @@ -0,0 +1,47 @@ +import merge from "ts-deepmerge" + +type ToggleState = "inactive" | "active" + +type Toggleable = Record + +const NO_INACTIVE_OR_BASE_ERROR = + "A toggleable object must have an inactive state, or a base property." +const NO_ACTIVE_ERROR = "A toggleable object must have an active state." + +interface ToggleableProps { + base?: T + state: Partial> +} + +/** + * Helper function for creating Toggleable objects. + * @template T The type of the object being toggled. + * @param props Object containing the base (inactive) state and state modifications to create the active state. + * @returns A Toggleable object containing both the inactive and active states. + * @example + * ``` + * toggleable({ + * base: { background: "#000000", text: "#CCCCCC" }, + * state: { active: { text: "#CCCCCC" } }, + * }) + * ``` + */ +export function toggleable( + props: ToggleableProps +): Toggleable { + const { base, state } = props + + if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) + if (!state.active) throw new Error(NO_ACTIVE_ERROR) + + const inactiveState = base + ? ((state.inactive ? merge(base, state.inactive) : base) as T) + : (state.inactive as T) + + const toggleObj: Toggleable = { + inactive: inactiveState, + active: merge(base ?? {}, state.active) as T, + } + + return toggleObj +} From 61535ed41f62653efbd966fbf3d15d0632e0eb44 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 01:11:02 -0400 Subject: [PATCH 15/26] Update toggle, add tests --- styles/src/element/index.ts | 3 +- styles/src/element/toggle.test.ts | 52 +++++++++++++++++++++ styles/src/element/toggle.ts | 4 +- styles/src/styleTree/commandPalette.ts | 3 +- styles/src/styleTree/contactList.ts | 3 +- styles/src/styleTree/contextMenu.ts | 3 +- styles/src/styleTree/editor.ts | 3 +- styles/src/styleTree/picker.ts | 3 +- styles/src/styleTree/projectPanel.ts | 3 +- styles/src/styleTree/search.ts | 3 +- styles/src/styleTree/statusBar.ts | 3 +- styles/src/styleTree/tabBar.ts | 3 +- styles/src/styleTree/toolbarDropdownMenu.ts | 3 +- styles/src/styleTree/workspace.ts | 2 +- 14 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 styles/src/element/toggle.test.ts diff --git a/styles/src/element/index.ts b/styles/src/element/index.ts index ad58b89e0e8217fc511d76183453b570a496fb39..b1e3cfe415f402ff1ca45ca97addda32ac1bf0ca 100644 --- a/styles/src/element/index.ts +++ b/styles/src/element/index.ts @@ -1,3 +1,4 @@ import { interactive } from "./interactive" +import { toggleable } from "./toggle" -export { interactive } +export { interactive, toggleable } diff --git a/styles/src/element/toggle.test.ts b/styles/src/element/toggle.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..8018ce10393fb6145f7214e0deb9620f2b627181 --- /dev/null +++ b/styles/src/element/toggle.test.ts @@ -0,0 +1,52 @@ +import { + NO_ACTIVE_ERROR, + NO_INACTIVE_OR_BASE_ERROR, + toggleable, +} from "./toggle" +import { describe, it, expect } from "vitest" + +describe("toggleable", () => { + it("creates a Toggleable with base properties and states", () => { + const result = toggleable({ + base: { background: "#000000", color: "#CCCCCC" }, + state: { + active: { color: "#FFFFFF" }, + }, + }) + + expect(result).toEqual({ + inactive: { background: "#000000", color: "#CCCCCC" }, + active: { background: "#000000", color: "#FFFFFF" }, + }) + }) + + it("creates a Toggleable with no base properties", () => { + const result = toggleable({ + state: { + inactive: { background: "#000000", color: "#CCCCCC" }, + active: { background: "#000000", color: "#FFFFFF" }, + }, + }) + + expect(result).toEqual({ + inactive: { background: "#000000", color: "#CCCCCC" }, + active: { background: "#000000", color: "#FFFFFF" }, + }) + }) + + it("throws error when both inactive and base are missing", () => { + const state = { + active: { background: "#000000", color: "#FFFFFF" }, + } + + expect(() => toggleable({ state })).toThrow(NO_INACTIVE_OR_BASE_ERROR) + }) + + it("throws error when no active state is present", () => { + const state = { + inactive: { background: "#000000", color: "#CCCCCC" }, + } + + expect(() => toggleable({ state })).toThrow(NO_ACTIVE_ERROR) + }) +}) diff --git a/styles/src/element/toggle.ts b/styles/src/element/toggle.ts index 2b6858e15be6c3db85232371ba38e0bc9127ea33..84390810c0dec5877c55a9effea75afa74d2e119 100644 --- a/styles/src/element/toggle.ts +++ b/styles/src/element/toggle.ts @@ -4,9 +4,9 @@ type ToggleState = "inactive" | "active" type Toggleable = Record -const NO_INACTIVE_OR_BASE_ERROR = +export const NO_INACTIVE_OR_BASE_ERROR = "A toggleable object must have an inactive state, or a base property." -const NO_ACTIVE_ERROR = "A toggleable object must have an active state." +export const NO_ACTIVE_ERROR = "A toggleable object must have an active state." interface ToggleableProps { base?: T diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index ae0aae2f81aee160fb6e094e005fd380f052ef89..59e12945db864c1d486bfb68fb6dc349b6165ce6 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -1,8 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" -import { toggleable } from "./toggle" -import { interactive } from "../element" +import { interactive, toggleable } from "../element" export default function commandPalette(colorScheme: ColorScheme) { let layer = colorScheme.highest diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 5c6068408ecb0f06615a52f367520b0783fd5c21..2ac17a4584c222c477709b03fb4a512e8df2093a 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -1,7 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" -import { toggleable } from "./toggle" -import { interactive } from "../element" +import { interactive, toggleable } from "../element" export default function contactsPanel(colorScheme: ColorScheme) { const nameMargin = 8 const sidePadding = 12 diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 6f5eb5364058aa9b790c9b58f36bae8681385452..90ba0ce5b532a60deee752e55ea14c5e70c4c4d0 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -1,7 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, text } from "./components" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function contextMenu(colorScheme: ColorScheme) { let layer = colorScheme.middle diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 9dec64b0ced6218f41043bd48b7758d4fb54de51..e029a724a39e926473c193d3601d766259ddf12d 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -4,8 +4,7 @@ import { background, border, borderColor, foreground, text } from "./components" import hoverPopover from "./hoverPopover" import { buildSyntax } from "../theme/syntax" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function editor(colorScheme: ColorScheme) { const { isLight } = colorScheme diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 7730395ec9653f7661eae91eeee2f1703c4486a7..12fecfa6f89b43bfad580b3594e0804e24d16a67 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -1,8 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, text } from "./components" -import { toggleable } from "./toggle" -import { interactive } from "../element" +import { interactive, toggleable } from "../element" export default function picker(colorScheme: ColorScheme): any { let layer = colorScheme.lowest diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 23df2fbf58f60ada4cd9b36542e71728a398fca0..5f283e551dcaa5181da1dbc9563ad8cf5aca7250 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,8 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function projectPanel(colorScheme: ColorScheme) { const { isLight } = colorScheme diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index a95296971c1af14156f25f9e68d9e21e74e7a173..4b0869f10e626d71072d1401389947cc999c639d 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -1,8 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function search(colorScheme: ColorScheme) { let layer = colorScheme.highest diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 8a91b7eaac434ac4b2c160320ee4ea22220ab956..d6d7eda732ce3bb4435f9dc01fc16eb11bff2862 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -1,7 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function statusBar(colorScheme: ColorScheme) { let layer = colorScheme.lowest diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index c2b5de02159f34b9066594249dbbfdc1e1e270ca..e00f0b8b83cdeae9dcbffaae967842288f327377 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -1,8 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, border, background, foreground } from "./components" -import { toggleable } from "./toggle" -import { interactive } from "../element" +import { interactive, toggleable } from "../element" export default function tabBar(colorScheme: ColorScheme) { const height = 32 diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 1f47c85f4e7563b50577619e5747add669867c94..3ce7ca7d7cda23b4300c22baf38e3de28c6372fc 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -1,7 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function dropdownMenu(colorScheme: ColorScheme) { let layer = colorScheme.middle diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 79e7830aec8e1ad46127516c33cb74892ad17943..a2a21eaff4a88df354c41870118363befd12953f 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" -import { toggleable } from "./toggle" +import { toggleable } from "../element" import { background, border, From ae53c3e6232e30d37fb33fbe4162c07a472b1a67 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 01:41:10 -0400 Subject: [PATCH 16/26] WIP: Start updating style trees to new `toggle()` format. --- styles/src/styleTree/commandPalette.ts | 62 +++++++++++++------------- styles/src/styleTree/contactList.ts | 18 ++++---- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 59e12945db864c1d486bfb68fb6dc349b6165ce6..cb6bb0503afcba951dc36c7443e407a199bfa873 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -1,40 +1,42 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" -import { interactive, toggleable } from "../element" +import { toggleable } from "../element" export default function commandPalette(colorScheme: ColorScheme) { let layer = colorScheme.highest + + const key = toggleable({ + base: { + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, + state: { + active: { + text: text(layer, "mono", "on", "default", { size: "xs" }), + background: withOpacity(background(layer, "on"), 0.2), + } + } + }) + return { keystrokeSpacing: 8, - key: toggleable( - interactive({ - base: { - text: text(layer, "mono", "variant", "default", { - size: "xs", - }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - }, - state: { hovered: { cornerRadius: 4, padding: { top: 17 } } }, - }), - { - default: { - text: text(layer, "mono", "on", "default", { size: "xs" }), - background: withOpacity(background(layer, "on"), 0.2), - }, - } - ), + // TODO: This should be a Toggle on the rust side so we don't have to do this + key: { + ...key.inactive, + active: key.active, + } } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 2ac17a4584c222c477709b03fb4a512e8df2093a..1f38b9b37686856da29ec71ad8c3bc37b333aa51 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -71,8 +71,8 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, rowHeight: 28, sectionIconSize: 8, - headerRow: toggleable( - interactive({ + headerRow: toggleable({ + base: interactive({ base: { ...text(layer, "mono", { size: "sm" }), margin: { top: 14 }, @@ -86,13 +86,15 @@ export default function contactsPanel(colorScheme: ColorScheme) { hovered: { background: background(layer, "default") }, }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. }), - { - default: { - ...text(layer, "mono", "active", { size: "sm" }), - background: background(layer, "active"), - }, + state: { + active: { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), + }, + } } - ), + }), leaveCall: interactive({ base: { background: background(layer), From 60b4054b0a28580e1ebd99205433317fe58577b1 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 16 Jun 2023 14:30:16 +0200 Subject: [PATCH 17/26] Fix up toggles --- .../src/activity_indicator.rs | 2 +- crates/command_palette/src/command_palette.rs | 6 +- crates/theme/src/theme.rs | 12 +- styles/src/element/interactive.ts | 119 +-- styles/src/element/toggle.ts | 32 +- styles/src/styleTree/commandPalette.ts | 64 +- styles/src/styleTree/contactList.ts | 414 +++++----- styles/src/styleTree/contextMenu.ts | 108 +-- styles/src/styleTree/editor.ts | 554 ++++++------- styles/src/styleTree/picker.ts | 170 ++-- styles/src/styleTree/projectPanel.ts | 216 ++--- styles/src/styleTree/search.ts | 222 +++--- styles/src/styleTree/statusBar.ts | 264 ++++--- styles/src/styleTree/tabBar.ts | 201 ++--- styles/src/styleTree/toolbarDropdownMenu.ts | 108 +-- styles/src/styleTree/workspace.ts | 738 +++++++++--------- 16 files changed, 1640 insertions(+), 1590 deletions(-) diff --git a/crates/activity_indicator/src/activity_indicator.rs b/crates/activity_indicator/src/activity_indicator.rs index 801c8f7172ec40d5c111109482d55e345d037592..f795d7321c096fdb8d1a3bae983a58445990d577 100644 --- a/crates/activity_indicator/src/activity_indicator.rs +++ b/crates/activity_indicator/src/activity_indicator.rs @@ -326,7 +326,7 @@ impl View for ActivityIndicator { let mut element = MouseEventHandler::::new(0, cx, |state, cx| { let theme = &theme::current(cx).workspace.status_bar.lsp_status; let style = if state.hovered() && on_click.is_some() { - theme.hover.as_ref().unwrap_or(&theme.default) + theme.hovered.as_ref().unwrap_or(&theme.default) } else { &theme.default }; diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index e7e7462fd9c27c07b5490609c3c7cb77636c021f..aec876bd78ade4312493c2853f51ac09f8dcb489 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -186,11 +186,7 @@ impl PickerDelegate for CommandPaletteDelegate { let command = &self.actions[mat.candidate_id]; let theme = theme::current(cx); let style = theme.picker.item.in_state(selected).style_for(mouse_state); - let key_style = &theme - .command_palette - .key - .in_state(selected) - .style_for(mouse_state); + let key_style = &theme.command_palette.key.in_state(selected); let keystroke_spacing = theme.command_palette.keystroke_spacing; Flex::row() diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index fd30387ad868782fb47c3c877a6e516fce47fcba..8f9f2281291f01078ee0767a74476bbbd59bfaca 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -498,7 +498,7 @@ pub struct ContextMenuItem { #[derive(Debug, Deserialize, Default)] pub struct CommandPalette { - pub key: Toggleable>, + pub key: Toggleable, pub keystroke_spacing: f32, } @@ -805,7 +805,7 @@ pub struct DiffStyle { #[derive(Debug, Default, Clone, Copy)] pub struct Interactive { pub default: T, - pub hover: Option, + pub hovered: Option, pub clicked: Option, pub disabled: Option, } @@ -855,7 +855,7 @@ impl Interactive { if state.clicked() == Some(platform::MouseButton::Left) && self.clicked.is_some() { self.clicked.as_ref().unwrap() } else if state.hovered() { - self.hover.as_ref().unwrap_or(&self.default) + self.hovered.as_ref().unwrap_or(&self.default) } else { &self.default } @@ -873,7 +873,7 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { #[derive(Deserialize)] struct Helper { default: Value, - hover: Option, + hovered: Option, clicked: Option, disabled: Option, } @@ -899,14 +899,14 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { } }; - let hover = deserialize_state(json.hover)?; + let hovered = deserialize_state(json.hovered)?; let clicked = deserialize_state(json.clicked)?; let disabled = deserialize_state(json.disabled)?; let default = serde_json::from_value(json.default).map_err(serde::de::Error::custom)?; Ok(Interactive { default, - hover, + hovered, clicked, disabled, }) diff --git a/styles/src/element/interactive.ts b/styles/src/element/interactive.ts index 5d9772d31343ffb4260a4908c82994200c7839a0..bd90e28aadb2b515cca4c5b626dd7e0b005fa373 100644 --- a/styles/src/element/interactive.ts +++ b/styles/src/element/interactive.ts @@ -1,28 +1,29 @@ import merge from "ts-deepmerge" +import { DeepPartial } from "utility-types" type InteractiveState = - | "default" - | "hovered" - | "clicked" - | "selected" - | "disabled" + | "default" + | "hovered" + | "clicked" + | "selected" + | "disabled" type Interactive = { - default: T - hovered?: T - clicked?: T - selected?: T - disabled?: T + default: T + hovered?: T + clicked?: T + selected?: T + disabled?: T } export const NO_DEFAULT_OR_BASE_ERROR = - "An interactive object must have a default state, or a base property." + "An interactive object must have a default state, or a base property." export const NOT_ENOUGH_STATES_ERROR = - "An interactive object must have a default and at least one other state." + "An interactive object must have a default and at least one other state." interface InteractiveProps { - base?: T - state: Partial> + base?: T + state: Partial>> } /** @@ -37,60 +38,60 @@ interface InteractiveProps { * @returns Interactive object with fields from `base` and `state`. */ export function interactive({ - base, - state, + base, + state, }: InteractiveProps): Interactive { - if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR) + if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR) - let defaultState: T + let defaultState: T - if (state.default && base) { - defaultState = merge(base, state.default) as T - } else { - defaultState = base ? base : (state.default as T) - } + if (state.default && base) { + defaultState = merge(base, state.default) as T + } else { + defaultState = base ? base : (state.default as T) + } - let interactiveObj: Interactive = { - default: defaultState, - } + let interactiveObj: Interactive = { + default: defaultState, + } - let stateCount = 0 + let stateCount = 0 - if (state.hovered !== undefined) { - interactiveObj.hovered = merge( - interactiveObj.default, - state.hovered - ) as T - stateCount++ - } + if (state.hovered !== undefined) { + interactiveObj.hovered = merge( + interactiveObj.default, + state.hovered + ) as T + stateCount++ + } - if (state.clicked !== undefined) { - interactiveObj.clicked = merge( - interactiveObj.default, - state.clicked - ) as T - stateCount++ - } + if (state.clicked !== undefined) { + interactiveObj.clicked = merge( + interactiveObj.default, + state.clicked + ) as T + stateCount++ + } - if (state.selected !== undefined) { - interactiveObj.selected = merge( - interactiveObj.default, - state.selected - ) as T - stateCount++ - } + if (state.selected !== undefined) { + interactiveObj.selected = merge( + interactiveObj.default, + state.selected + ) as T + stateCount++ + } - if (state.disabled !== undefined) { - interactiveObj.disabled = merge( - interactiveObj.default, - state.disabled - ) as T - stateCount++ - } + if (state.disabled !== undefined) { + interactiveObj.disabled = merge( + interactiveObj.default, + state.disabled + ) as T + stateCount++ + } - if (stateCount < 1) { - throw new Error(NOT_ENOUGH_STATES_ERROR) - } + if (stateCount < 1) { + throw new Error(NOT_ENOUGH_STATES_ERROR) + } - return interactiveObj + return interactiveObj } diff --git a/styles/src/element/toggle.ts b/styles/src/element/toggle.ts index 84390810c0dec5877c55a9effea75afa74d2e119..cbf28b71e7050f2e72e831618f3bf5bbac6c376f 100644 --- a/styles/src/element/toggle.ts +++ b/styles/src/element/toggle.ts @@ -1,16 +1,17 @@ import merge from "ts-deepmerge" +import { DeepPartial } from "utility-types" type ToggleState = "inactive" | "active" type Toggleable = Record export const NO_INACTIVE_OR_BASE_ERROR = - "A toggleable object must have an inactive state, or a base property." + "A toggleable object must have an inactive state, or a base property." export const NO_ACTIVE_ERROR = "A toggleable object must have an active state." interface ToggleableProps { - base?: T - state: Partial> + base?: T + state: Partial>> } /** @@ -27,21 +28,20 @@ interface ToggleableProps { * ``` */ export function toggleable( - props: ToggleableProps + props: ToggleableProps ): Toggleable { - const { base, state } = props + const { base, state } = props - if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) - if (!state.active) throw new Error(NO_ACTIVE_ERROR) + if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) + if (!state.active) throw new Error(NO_ACTIVE_ERROR) - const inactiveState = base - ? ((state.inactive ? merge(base, state.inactive) : base) as T) - : (state.inactive as T) + const inactiveState = base + ? ((state.inactive ? merge(base, state.inactive) : base) as T) + : (state.inactive as T) - const toggleObj: Toggleable = { - inactive: inactiveState, - active: merge(base ?? {}, state.active) as T, - } - - return toggleObj + const toggleObj: Toggleable = { + inactive: inactiveState, + active: merge(base ?? {}, state.active) as T, + } + return toggleObj } diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index cb6bb0503afcba951dc36c7443e407a199bfa873..947e730f55b3e54d4b391cf0ffcbe24c67f0c754 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -4,39 +4,39 @@ import { text, background } from "./components" import { toggleable } from "../element" export default function commandPalette(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - const key = toggleable({ - base: { - text: text(layer, "mono", "variant", "default", { size: "xs" }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - }, - state: { - active: { - text: text(layer, "mono", "on", "default", { size: "xs" }), - background: withOpacity(background(layer, "on"), 0.2), - } - } - }) + const key = toggleable({ + base: { + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, + state: { + active: { + text: text(layer, "mono", "on", "default", { size: "xs" }), + background: withOpacity(background(layer, "on"), 0.2), + } + } + }) - return { - keystrokeSpacing: 8, - // TODO: This should be a Toggle on the rust side so we don't have to do this - key: { - ...key.inactive, - active: key.active, - } + return { + keystrokeSpacing: 8, + // TODO: This should be a Toggle on the rust side so we don't have to do this + key: { + inactive: { ...key.inactive }, + active: key.active, } + } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 1f38b9b37686856da29ec71ad8c3bc37b333aa51..d5ecb1c22400b1036503b50acb602cc65020d828 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -2,224 +2,232 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function contactsPanel(colorScheme: ColorScheme) { - const nameMargin = 8 - const sidePadding = 12 + const nameMargin = 8 + const sidePadding = 12 - let layer = colorScheme.middle + let layer = colorScheme.middle - const contactButton = { - background: background(layer, "on"), - color: foreground(layer, "on"), - iconWidth: 8, - buttonWidth: 16, - cornerRadius: 8, - } - const projectRow = { - guestAvatarSpacing: 4, - height: 24, - guestAvatar: { - cornerRadius: 8, - width: 14, - }, - name: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - right: 6, - }, + const contactButton = { + background: background(layer, "on"), + color: foreground(layer, "on"), + iconWidth: 8, + buttonWidth: 16, + cornerRadius: 8, + } + const projectRow = { + guestAvatarSpacing: 4, + height: 24, + guestAvatar: { + cornerRadius: 8, + width: 14, + }, + name: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + right: 6, + }, + }, + guests: { + margin: { + left: nameMargin, + right: nameMargin, + }, + }, + padding: { + left: sidePadding, + right: sidePadding, + }, + } + + return { + background: background(layer), + padding: { top: 12 }, + userQueryEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + margin: { + left: 6, + }, + }, + userQueryEditorHeight: 33, + addContactButton: { + margin: { left: 6, right: 12 }, + color: foreground(layer, "on"), + buttonWidth: 28, + iconWidth: 16, + }, + rowHeight: 28, + sectionIconSize: 8, + headerRow: toggleable({ + base: interactive({ + base: { + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"), // posiewic: breaking change }, - guests: { - margin: { - left: nameMargin, - right: nameMargin, - }, + state: { + hovered: { background: background(layer, "default") }, + }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. + }), + state: { + active: { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), + }, + } + } + }), + leaveCall: interactive({ + base: { + background: background(layer), + border: border(layer), + cornerRadius: 6, + margin: { + top: 1, }, padding: { + top: 1, + bottom: 1, + left: 7, + right: 7, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + }, + state: { + hovered: { + ...text(layer, "sans", "hovered", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "hovered"), + }, + }, + }), + contactRow: { + inactive: { + default: { + padding: { left: sidePadding, right: sidePadding, + }, }, - } - - return { - background: background(layer), - padding: { top: 12 }, - userQueryEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - margin: { - left: 6, - }, + }, + active: { + default: { + background: background(layer, "active"), + padding: { + left: sidePadding, + right: sidePadding, + }, }, - userQueryEditorHeight: 33, - addContactButton: { - margin: { left: 6, right: 12 }, - color: foreground(layer, "on"), - buttonWidth: 28, - iconWidth: 16, + }, + }, + + contactAvatar: { + cornerRadius: 10, + width: 18, + }, + contactStatusFree: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "positive"), + }, + contactStatusBusy: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "negative"), + }, + contactUsername: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + }, + }, + contactButtonSpacing: nameMargin, + contactButton: interactive({ + base: { ...contactButton }, + state: { + hovered: { + background: background(layer, "hovered"), }, - rowHeight: 28, - sectionIconSize: 8, - headerRow: toggleable({ - base: interactive({ - base: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, - }, - background: background(layer, "default"), // posiewic: breaking change - }, - state: { - hovered: { background: background(layer, "default") }, - }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. - }), - state: { - active: { - default: { - ...text(layer, "mono", "active", { size: "sm" }), - background: background(layer, "active"), - }, - } - } - }), - leaveCall: interactive({ - base: { - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, - }, - padding: { - top: 1, - bottom: 1, - left: 7, - right: 7, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - }, - state: { - hovered: { - ...text(layer, "sans", "hovered", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "hovered"), - }, + }, + }), + disabledButton: { + ...contactButton, + background: background(layer, "on"), + color: foreground(layer, "on"), + }, + callingIndicator: { + ...text(layer, "mono", "variant", { size: "xs" }), + }, + treeBranch: toggleable({ + base: + interactive({ + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { + color: borderColor(layer), }, + }, }), - contactRow: { - inactive: { - default: { - padding: { - left: sidePadding, - right: sidePadding, - }, - }, + state: { + active: { + default: { + color: borderColor(layer), + }, + } + } + } + ), + projectRow: toggleable({ + base: + interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, }, - active: { - default: { - background: background(layer, "active"), - padding: { - left: sidePadding, - right: sidePadding, - }, - }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), }, - }, - - contactAvatar: { - cornerRadius: 10, - width: 18, - }, - contactStatusFree: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "positive"), - }, - contactStatusBusy: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "negative"), - }, - contactUsername: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - }, - }, - contactButtonSpacing: nameMargin, - contactButton: interactive({ - base: { ...contactButton }, - state: { - hovered: { - background: background(layer, "hovered"), - }, + }, + state: { + hovered: { + background: background(layer, "hovered"), }, + }, }), - disabledButton: { - ...contactButton, - background: background(layer, "on"), - color: foreground(layer, "on"), - }, - callingIndicator: { - ...text(layer, "mono", "variant", { size: "xs" }), - }, - treeBranch: toggleable( - interactive({ - base: { - color: borderColor(layer), - width: 1, - }, - state: { - hovered: { - color: borderColor(layer), - }, - }, - }), - { - default: { - color: borderColor(layer), - }, - } - ), - projectRow: toggleable( - interactive({ - base: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, - }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), - }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - }, - }, - }), - { - default: { background: background(layer, "active") }, - } - ), + state: { + active: { + default: { background: background(layer, "active") }, + } + } } + ), + } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 90ba0ce5b532a60deee752e55ea14c5e70c4c4d0..661742f8004ca7a0be6073b64cb4f5b33f41cef5 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -3,57 +3,61 @@ import { background, border, borderColor, text } from "./components" import { interactive, toggleable } from "../element" export default function contextMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle - return { - background: background(layer), - cornerRadius: 10, - padding: 4, - shadow: colorScheme.popoverShadow, - border: border(layer), - keystrokeMargin: 30, - item: toggleable( - interactive({ - base: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "hovered", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - }, - }, - }), - { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - } - ), - - separator: { - background: borderColor(layer), - margin: { top: 2, bottom: 2 }, - }, + let layer = colorScheme.middle + return { + background: background(layer), + cornerRadius: 10, + padding: 4, + shadow: colorScheme.popoverShadow, + border: border(layer), + keystrokeMargin: 30, + item: toggleable({ + base: + interactive({ + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + }, + }), + state: { + active: { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + } + } } + ), + + separator: { + background: borderColor(layer), + margin: { top: 2, bottom: 2 }, + }, + } } diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index e029a724a39e926473c193d3601d766259ddf12d..2437257875c9c07c623e2b819942b6f84b72d9e9 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -7,295 +7,303 @@ import { buildSyntax } from "../theme/syntax" import { interactive, toggleable } from "../element" export default function editor(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.highest + let layer = colorScheme.highest - const autocompleteItem = { - cornerRadius: 6, - padding: { - bottom: 2, - left: 6, - right: 6, - top: 2, - }, + const autocompleteItem = { + cornerRadius: 6, + padding: { + bottom: 2, + left: 6, + right: 6, + top: 2, + }, + } + + function diagnostic(layer: Layer, styleSet: StyleSets) { + return { + textScaleFactor: 0.857, + header: { + border: border(layer, { + top: true, + }), + }, + message: { + text: text(layer, "sans", styleSet, "default", { size: "sm" }), + highlightText: text(layer, "sans", styleSet, "default", { + size: "sm", + weight: "bold", + }), + }, } + } - function diagnostic(layer: Layer, styleSet: StyleSets) { - return { - textScaleFactor: 0.857, - header: { - border: border(layer, { - top: true, - }), + const syntax = buildSyntax(colorScheme) + + return { + textColor: syntax.primary.color, + background: background(layer), + activeLineBackground: withOpacity(background(layer, "on"), 0.75), + highlightedLineBackground: background(layer, "on"), + // Inline autocomplete suggestions, Co-pilot suggestions, etc. + suggestion: syntax.predictive, + codeActions: { + indicator: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, }, - message: { - text: text(layer, "sans", styleSet, "default", { size: "sm" }), - highlightText: text(layer, "sans", styleSet, "default", { - size: "sm", - weight: "bold", - }), + }), + state: { + active: { + default: { + color: foreground(layer, "on"), }, + } } - } + } + ), - const syntax = buildSyntax(colorScheme) - - return { - textColor: syntax.primary.color, - background: background(layer), - activeLineBackground: withOpacity(background(layer, "on"), 0.75), - highlightedLineBackground: background(layer, "on"), - // Inline autocomplete suggestions, Co-pilot suggestions, etc. - suggestion: syntax.predictive, - codeActions: { - indicator: toggleable( - interactive({ - base: { - color: foreground(layer, "variant"), - }, - state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - }, - }), - { - default: { - color: foreground(layer, "on"), - }, - } - ), - - verticalScale: 0.55, - }, - folds: { - iconMarginScale: 2.5, - foldedIcon: "icons/chevron_right_8.svg", - foldableIcon: "icons/chevron_down_8.svg", - indicator: toggleable( - interactive({ - base: { - color: foreground(layer, "variant"), - }, - state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - }, - }), - { - default: { - color: foreground(layer, "on"), - }, - } - ), - ellipses: { - textColor: colorScheme.ramps.neutral(0.71).hex(), - cornerRadiusFactor: 0.15, - background: { - // Copied from hover_popover highlight - default: { - color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), - }, + verticalScale: 0.55, + }, + folds: { + iconMarginScale: 2.5, + foldedIcon: "icons/chevron_right_8.svg", + foldableIcon: "icons/chevron_down_8.svg", + indicator: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + }, + }), + state: { + active: { + default: { + color: foreground(layer, "on"), + }, + } + } + } + ), + ellipses: { + textColor: colorScheme.ramps.neutral(0.71).hex(), + cornerRadiusFactor: 0.15, + background: { + // Copied from hover_popover highlight + default: { + color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), + }, - hover: { - color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), - }, + hovered: { + color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), + }, - clicked: { - color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), - }, - }, - }, - foldBackground: foreground(layer, "variant"), + clicked: { + color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), + }, }, - diff: { - deleted: isLight - ? colorScheme.ramps.red(0.5).hex() - : colorScheme.ramps.red(0.4).hex(), - modified: isLight - ? colorScheme.ramps.yellow(0.5).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.4).hex() - : colorScheme.ramps.green(0.5).hex(), - removedWidthEm: 0.275, - widthEm: 0.15, - cornerRadius: 0.05, - }, - /** Highlights matching occurrences of what is under the cursor - * as well as matched brackets - */ - documentHighlightReadBackground: withOpacity( - foreground(layer, "accent"), - 0.1 + }, + foldBackground: foreground(layer, "variant"), + }, + diff: { + deleted: isLight + ? colorScheme.ramps.red(0.5).hex() + : colorScheme.ramps.red(0.4).hex(), + modified: isLight + ? colorScheme.ramps.yellow(0.5).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.4).hex() + : colorScheme.ramps.green(0.5).hex(), + removedWidthEm: 0.275, + widthEm: 0.15, + cornerRadius: 0.05, + }, + /** Highlights matching occurrences of what is under the cursor + * as well as matched brackets + */ + documentHighlightReadBackground: withOpacity( + foreground(layer, "accent"), + 0.1 + ), + documentHighlightWriteBackground: colorScheme.ramps + .neutral(0.5) + .alpha(0.4) + .hex(), // TODO: This was blend * 2 + errorColor: background(layer, "negative"), + gutterBackground: background(layer), + gutterPaddingFactor: 3.5, + lineNumber: withOpacity(foreground(layer), 0.35), + lineNumberActive: foreground(layer), + renameFade: 0.6, + unnecessaryCodeFade: 0.5, + selection: colorScheme.players[0], + whitespace: colorScheme.ramps.neutral(0.5).hex(), + guestSelections: [ + colorScheme.players[1], + colorScheme.players[2], + colorScheme.players[3], + colorScheme.players[4], + colorScheme.players[5], + colorScheme.players[6], + colorScheme.players[7], + ], + autocomplete: { + background: background(colorScheme.middle), + cornerRadius: 8, + padding: 4, + margin: { + left: -14, + }, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + matchHighlight: foreground(colorScheme.middle, "accent"), + item: autocompleteItem, + hoveredItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "hovered" ), - documentHighlightWriteBackground: colorScheme.ramps - .neutral(0.5) - .alpha(0.4) - .hex(), // TODO: This was blend * 2 - errorColor: background(layer, "negative"), - gutterBackground: background(layer), - gutterPaddingFactor: 3.5, - lineNumber: withOpacity(foreground(layer), 0.35), - lineNumberActive: foreground(layer), - renameFade: 0.6, - unnecessaryCodeFade: 0.5, - selection: colorScheme.players[0], - whitespace: colorScheme.ramps.neutral(0.5).hex(), - guestSelections: [ - colorScheme.players[1], - colorScheme.players[2], - colorScheme.players[3], - colorScheme.players[4], - colorScheme.players[5], - colorScheme.players[6], - colorScheme.players[7], - ], - autocomplete: { - background: background(colorScheme.middle), - cornerRadius: 8, - padding: 4, - margin: { - left: -14, - }, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - matchHighlight: foreground(colorScheme.middle, "accent"), - item: autocompleteItem, - hoveredItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "hovered" - ), - background: background(colorScheme.middle, "hovered"), - }, - selectedItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "active" - ), - background: background(colorScheme.middle, "active"), - }, + background: background(colorScheme.middle, "hovered"), + }, + selectedItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "active" + ), + background: background(colorScheme.middle, "active"), + }, + }, + diagnosticHeader: { + background: background(colorScheme.middle), + iconWidthFactor: 1.5, + textScaleFactor: 0.857, + border: border(colorScheme.middle, { + bottom: true, + top: true, + }), + code: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 10, }, - diagnosticHeader: { - background: background(colorScheme.middle), - iconWidthFactor: 1.5, - textScaleFactor: 0.857, - border: border(colorScheme.middle, { - bottom: true, - top: true, - }), - code: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 10, - }, - }, - source: { - text: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - }, - message: { - highlightText: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - text: text(colorScheme.middle, "sans", { size: "sm" }), - }, + }, + source: { + text: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + }, + message: { + highlightText: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + text: text(colorScheme.middle, "sans", { size: "sm" }), + }, + }, + diagnosticPathHeader: { + background: background(colorScheme.middle), + textScaleFactor: 0.857, + filename: text(colorScheme.middle, "mono", { size: "sm" }), + path: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 12, }, - diagnosticPathHeader: { - background: background(colorScheme.middle), - textScaleFactor: 0.857, - filename: text(colorScheme.middle, "mono", { size: "sm" }), - path: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 12, - }, - }, + }, + }, + errorDiagnostic: diagnostic(colorScheme.middle, "negative"), + warningDiagnostic: diagnostic(colorScheme.middle, "warning"), + informationDiagnostic: diagnostic(colorScheme.middle, "accent"), + hintDiagnostic: diagnostic(colorScheme.middle, "warning"), + invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), + hoverPopover: hoverPopover(colorScheme), + linkDefinition: { + color: syntax.linkUri.color, + underline: syntax.linkUri.underline, + }, + jumpIcon: interactive({ + base: { + color: foreground(layer, "on"), + iconWidth: 20, + buttonWidth: 20, + cornerRadius: 6, + padding: { + top: 6, + bottom: 6, + left: 6, + right: 6, }, - errorDiagnostic: diagnostic(colorScheme.middle, "negative"), - warningDiagnostic: diagnostic(colorScheme.middle, "warning"), - informationDiagnostic: diagnostic(colorScheme.middle, "accent"), - hintDiagnostic: diagnostic(colorScheme.middle, "warning"), - invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), - hoverPopover: hoverPopover(colorScheme), - linkDefinition: { - color: syntax.linkUri.color, - underline: syntax.linkUri.underline, + }, + state: { + hovered: { + background: background(layer, "on", "hovered"), }, - jumpIcon: interactive({ - base: { - color: foreground(layer, "on"), - iconWidth: 20, - buttonWidth: 20, - cornerRadius: 6, - padding: { - top: 6, - bottom: 6, - left: 6, - right: 6, - }, - }, - state: { - hovered: { - background: background(layer, "on", "hovered"), - }, - }, - }), + }, + }), - scrollbar: { - width: 12, - minHeightFactor: 1.0, - track: { - border: border(layer, "variant", { left: true }), - }, - thumb: { - background: withOpacity(background(layer, "inverted"), 0.3), - border: { - width: 1, - color: borderColor(layer, "variant"), - top: false, - right: true, - left: true, - bottom: false, - }, - }, - git: { - deleted: isLight - ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), - modified: isLight - ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), - inserted: isLight - ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), - }, + scrollbar: { + width: 12, + minHeightFactor: 1.0, + track: { + border: border(layer, "variant", { left: true }), + }, + thumb: { + background: withOpacity(background(layer, "inverted"), 0.3), + border: { + width: 1, + color: borderColor(layer, "variant"), + top: false, + right: true, + left: true, + bottom: false, }, - compositionMark: { - underline: { - thickness: 1.0, - color: borderColor(layer), - }, - }, - syntax, - } + }, + git: { + deleted: isLight + ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), + modified: isLight + ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), + inserted: isLight + ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), + }, + }, + compositionMark: { + underline: { + thickness: 1.0, + color: borderColor(layer), + }, + }, + syntax, + } } diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 12fecfa6f89b43bfad580b3594e0804e24d16a67..f7cec1bd4145b9ad54715baa172c23fea6ff03ed 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -4,91 +4,95 @@ import { background, border, text } from "./components" import { interactive, toggleable } from "../element" export default function picker(colorScheme: ColorScheme): any { - let layer = colorScheme.lowest - const container = { - background: background(layer), - border: border(layer), - shadow: colorScheme.modalShadow, - cornerRadius: 12, - padding: { - bottom: 4, - }, - } - const inputEditor = { - placeholderText: text(layer, "sans", "on", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "on"), - border: border(layer, { bottom: true }), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - margin: { - bottom: 4, - }, - } - const emptyInputEditor: any = { ...inputEditor } - delete emptyInputEditor.border - delete emptyInputEditor.margin + let layer = colorScheme.lowest + const container = { + background: background(layer), + border: border(layer), + shadow: colorScheme.modalShadow, + cornerRadius: 12, + padding: { + bottom: 4, + }, + } + const inputEditor = { + placeholderText: text(layer, "sans", "on", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "on"), + border: border(layer, { bottom: true }), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + margin: { + bottom: 4, + }, + } + const emptyInputEditor: any = { ...inputEditor } + delete emptyInputEditor.border + delete emptyInputEditor.margin - return { - ...container, - emptyContainer: { - ...container, - padding: {}, - }, - item: toggleable( - interactive({ - base: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, - }, - margin: { - top: 1, - left: 4, - right: 4, - }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { - weight: "bold", - }), - }, - state: { - hovered: { - background: withOpacity( - background(layer, "hovered"), - 0.5 - ), - }, - }, - }), - { - default: { - background: withOpacity( - background(layer, "base", "active"), - 0.5 - ), - //text: text(layer, "sans", "base", "active"), - }, - } - ), - - inputEditor, - emptyInputEditor, - noMatches: { - text: text(layer, "sans", "variant"), + return { + ...container, + emptyContainer: { + ...container, + padding: {}, + }, + item: toggleable({ + base: + interactive({ + base: { padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, + bottom: 4, + left: 12, + right: 12, + top: 4, }, - }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { + weight: "bold", + }), + }, + state: { + hovered: { + background: withOpacity( + background(layer, "hovered"), + 0.5 + ), + }, + }, + }), + state: { + active: { + default: { + background: withOpacity( + background(layer, "base", "active"), + 0.5 + ), + //text: text(layer, "sans", "base", "active"), + }, + } + } } + ), + + inputEditor, + emptyInputEditor, + noMatches: { + text: text(layer, "sans", "variant"), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + }, + } } diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 5f283e551dcaa5181da1dbc9563ad8cf5aca7250..babd1431fb9400fedea468509315b47af5e3616f 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -3,121 +3,125 @@ import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function projectPanel(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.middle + let layer = colorScheme.middle - let baseEntry = { - height: 22, - iconColor: foreground(layer, "variant"), - iconSize: 7, - iconSpacing: 5, - } + let baseEntry = { + height: 22, + iconColor: foreground(layer, "variant"), + iconSize: 7, + iconSpacing: 5, + } + + let status = { + git: { + modified: isLight + ? colorScheme.ramps.yellow(0.6).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.45).hex() + : colorScheme.ramps.green(0.5).hex(), + conflict: isLight + ? colorScheme.ramps.red(0.6).hex() + : colorScheme.ramps.red(0.5).hex(), + }, + } - let status = { - git: { - modified: isLight - ? colorScheme.ramps.yellow(0.6).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.45).hex() - : colorScheme.ramps.green(0.5).hex(), - conflict: isLight - ? colorScheme.ramps.red(0.6).hex() - : colorScheme.ramps.red(0.5).hex(), + let entry = toggleable({ + base: + interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, + state: { + hovered: { + background: background(layer, "variant", "hovered"), + }, + }, + }), + state: { + active: { + default: { + /*background: colorScheme.isLight + ? withOpacity(background(layer, "active"), 0.5) + : background(layer, "active") ,*/ // todo posiewic + text: text(layer, "mono", "active", { size: "sm" }), }, + hovered: { + //background: background(layer, "active"), + text: text(layer, "mono", "active", { size: "sm" }), + }, + } } + } + ) - let entry = toggleable( - interactive({ - base: { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, - }, - state: { - hovered: { - background: background(layer, "variant", "hovered"), - }, - }, - }), - { - default: { - /*background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active") ,*/ // todo posiewic - text: text(layer, "mono", "active", { size: "sm" }), - }, - hovered: { - //background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - } - ) - - return { - openProjectButton: interactive({ - base: { - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 16, - left: 16, - right: 16, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }), - }, - state: { - hovered: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - }), + return { + openProjectButton: interactive({ + base: { background: background(layer), - padding: { left: 6, right: 6, top: 0, bottom: 6 }, - indentWidth: 12, - entry, - draggedEntry: { - ...baseEntry, - text: text(layer, "mono", "on", { size: "sm" }), - background: withOpacity(background(layer, "on"), 0.9), - border: border(layer), - status, + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 16, + left: 16, + right: 16, }, - ignoredEntry: { - ...entry, - iconColor: foreground(layer, "disabled"), - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - iconColor: foreground(layer, "variant"), - }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, }, - cutEntry: { - ...entry, - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - default: { - ...entry.active.default, - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), - }, - }, + ...text(layer, "sans", "default", { size: "sm" }), + }, + state: { + hovered: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), }, - filenameEditor: { - background: background(layer, "on"), - text: text(layer, "mono", "on", { size: "sm" }), - selection: colorScheme.players[0], + }, + }), + background: background(layer), + padding: { left: 6, right: 6, top: 0, bottom: 6 }, + indentWidth: 12, + entry, + draggedEntry: { + ...baseEntry, + text: text(layer, "mono", "on", { size: "sm" }), + background: withOpacity(background(layer, "on"), 0.9), + border: border(layer), + status, + }, + ignoredEntry: { + ...entry, + iconColor: foreground(layer, "disabled"), + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + iconColor: foreground(layer, "variant"), + }, + }, + cutEntry: { + ...entry, + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + default: { + ...entry.active.default, + background: background(layer, "active"), + text: text(layer, "mono", "disabled", { size: "sm" }), }, - } + }, + }, + filenameEditor: { + background: background(layer, "on"), + text: text(layer, "mono", "on", { size: "sm" }), + selection: colorScheme.players[0], + }, + } } diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index 4b0869f10e626d71072d1401389947cc999c639d..aa015d5cde4509439ca2c1c959d20eb23f87da7e 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -4,123 +4,127 @@ import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function search(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - // Search input - const editor = { - background: background(layer), - cornerRadius: 8, - minWidth: 200, - maxWidth: 500, - placeholderText: text(layer, "mono", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "default"), - border: border(layer), - margin: { - right: 12, - }, - padding: { - top: 3, - bottom: 3, - left: 12, - right: 8, - }, - } + // Search input + const editor = { + background: background(layer), + cornerRadius: 8, + minWidth: 200, + maxWidth: 500, + placeholderText: text(layer, "mono", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "default"), + border: border(layer), + margin: { + right: 12, + }, + padding: { + top: 3, + bottom: 3, + left: 12, + right: 8, + }, + } - const includeExcludeEditor = { - ...editor, - minWidth: 100, - maxWidth: 250, - } + const includeExcludeEditor = { + ...editor, + minWidth: 100, + maxWidth: 250, + } - return { - // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive - matchBackground: withOpacity(foreground(layer, "accent"), 0.4), - optionButton: toggleable( - interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - }, - }, - state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, - }, - }), - { - default: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), - }, - } - ), - editor, - invalidEditor: { - ...editor, - border: border(layer, "negative"), - }, - includeExcludeEditor, - invalidIncludeExcludeEditor: { - ...includeExcludeEditor, - border: border(layer, "negative"), - }, - matchIndex: { - ...text(layer, "mono", "variant"), - padding: { - left: 6, - }, - }, - optionButtonGroup: { - padding: { - left: 12, - right: 12, + return { + // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive + matchBackground: withOpacity(foreground(layer, "accent"), 0.4), + optionButton: toggleable({ + base: + interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, }, - }, - includeExcludeInputs: { - ...text(layer, "mono", "variant"), padding: { - right: 6, + bottom: 2, + left: 10, + right: 10, + top: 2, }, - }, - resultsStatus: { - ...text(layer, "mono", "on"), - size: 18, - }, - dismissButton: interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 14, - padding: { - left: 10, - right: 10, - }, + }, + state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), }, - state: { - hovered: { - color: foreground(layer, "hovered"), - }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), }, + }, }), + state: { + active: { + default: { + ...text(layer, "mono", "on", "inverted"), + background: background(layer, "on", "inverted"), + border: border(layer, "on", "inverted"), + }, + } + } } + ), + editor, + invalidEditor: { + ...editor, + border: border(layer, "negative"), + }, + includeExcludeEditor, + invalidIncludeExcludeEditor: { + ...includeExcludeEditor, + border: border(layer, "negative"), + }, + matchIndex: { + ...text(layer, "mono", "variant"), + padding: { + left: 6, + }, + }, + optionButtonGroup: { + padding: { + left: 12, + right: 12, + }, + }, + includeExcludeInputs: { + ...text(layer, "mono", "variant"), + padding: { + right: 6, + }, + }, + resultsStatus: { + ...text(layer, "mono", "on"), + size: 18, + }, + dismissButton: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 14, + padding: { + left: 10, + right: 10, + }, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), + }, + }, + }), + } } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index d6d7eda732ce3bb4435f9dc01fc16eb11bff2862..4c566a5c3a5f099c49d428ffb4b8648526e468eb 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -2,143 +2,147 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function statusBar(colorScheme: ColorScheme) { - let layer = colorScheme.lowest + let layer = colorScheme.lowest - const statusContainer = { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 6, right: 6 }, - } + const statusContainer = { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 6, right: 6 }, + } - const diagnosticStatusContainer = { - cornerRadius: 6, - padding: { top: 1, bottom: 1, left: 6, right: 6 }, - } + const diagnosticStatusContainer = { + cornerRadius: 6, + padding: { top: 1, bottom: 1, left: 6, right: 6 }, + } - return { - height: 30, - itemSpacing: 8, - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, + return { + height: 30, + itemSpacing: 8, + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + border: border(layer, { top: true, overlay: true }), + cursorPosition: text(layer, "sans", "variant"), + activeLanguage: interactive({ + base: { + padding: { left: 6, right: 6 }, + ...text(layer, "sans", "variant"), + }, + state: { + hovered: { + ...text(layer, "sans", "on"), }, - border: border(layer, { top: true, overlay: true }), - cursorPosition: text(layer, "sans", "variant"), - activeLanguage: interactive({ - base: { - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant"), - }, - state: { - hovered: { - ...text(layer, "sans", "on"), - }, - }, - }), - autoUpdateProgressMessage: text(layer, "sans", "variant"), - autoUpdateDoneMessage: text(layer, "sans", "variant"), - lspStatus: interactive({ - base: { - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer), - }, - state: { - hovered: { - message: text(layer, "sans"), - iconColor: foreground(layer), - background: background(layer, "hovered"), - }, - }, - }), - diagnosticMessage: interactive({ - base: { - ...text(layer, "sans"), - }, - state: { hovered: text(layer, "sans", "hovered") }, - }), - diagnosticSummary: interactive({ + }, + }), + autoUpdateProgressMessage: text(layer, "sans", "variant"), + autoUpdateDoneMessage: text(layer, "sans", "variant"), + lspStatus: interactive({ + base: { + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, + message: text(layer, "sans"), + iconColor: foreground(layer), + }, + state: { + hovered: { + message: text(layer, "sans"), + iconColor: foreground(layer), + background: background(layer, "hovered"), + }, + }, + }), + diagnosticMessage: interactive({ + base: { + ...text(layer, "sans"), + }, + state: { hovered: text(layer, "sans", "hovered") }, + }), + diagnosticSummary: interactive({ + base: { + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), + containerOk: { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, + }, + containerWarning: { + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), + }, + containerError: { + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + }, + }, + state: { + hovered: { + iconColorOk: foreground(layer, "on"), + containerOk: { + background: background(layer, "on", "hovered"), + }, + containerWarning: { + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), + }, + containerError: { + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + }, + }, + }, + }), + panelButtons: { + groupLeft: {}, + groupBottom: {}, + groupRight: {}, + button: toggleable({ + base: + interactive({ base: { - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - }, + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, }, state: { - hovered: { - iconColorOk: foreground(layer, "on"), - containerOk: { - background: background(layer, "on", "hovered"), - }, - containerWarning: { - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), - }, - containerError: { - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), - }, - }, + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + }, }, - }), - panelButtons: { - groupLeft: {}, - groupBottom: {}, - groupRight: {}, - button: toggleable( - interactive({ - base: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, - }, - state: { - hovered: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - }, - }, - }), - { - default: { - iconColor: foreground(layer, "active"), - background: background(layer, "active"), - }, - } - ), - badge: { - cornerRadius: 3, - padding: 2, - margin: { bottom: -1, right: -1 }, - border: border(layer), - background: background(layer, "accent"), + }), state: + { + active: { + default: { + iconColor: foreground(layer, "active"), + background: background(layer, "active"), }, - }, - } + } + } + } + ), + badge: { + cornerRadius: 3, + padding: 2, + margin: { bottom: -1, right: -1 }, + border: border(layer), + background: background(layer, "accent"), + }, + }, + } } diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index e00f0b8b83cdeae9dcbffaae967842288f327377..d7b3b58055ae22bca9ed4a6b8cb4ccd2056234dd 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -4,115 +4,120 @@ import { text, border, background, foreground } from "./components" import { interactive, toggleable } from "../element" export default function tabBar(colorScheme: ColorScheme) { - const height = 32 + const height = 32 - let activeLayer = colorScheme.highest - let layer = colorScheme.middle + let activeLayer = colorScheme.highest + let layer = colorScheme.middle - const tab = { - height, - text: text(layer, "sans", "variant", { size: "sm" }), - background: background(layer), - border: border(layer, { - right: true, - bottom: true, - overlay: true, - }), - padding: { - left: 8, - right: 12, - }, - spacing: 8, + const tab = { + height, + text: text(layer, "sans", "variant", { size: "sm" }), + background: background(layer), + border: border(layer, { + right: true, + bottom: true, + overlay: true, + }), + padding: { + left: 8, + right: 12, + }, + spacing: 8, - // Tab type icons (e.g. Project Search) - typeIconWidth: 14, + // Tab type icons (e.g. Project Search) + typeIconWidth: 14, - // Close icons - closeIconWidth: 8, - iconClose: foreground(layer, "variant"), - iconCloseActive: foreground(layer, "hovered"), + // Close icons + closeIconWidth: 8, + iconClose: foreground(layer, "variant"), + iconCloseActive: foreground(layer, "hovered"), - // Indicators - iconConflict: foreground(layer, "warning"), - iconDirty: foreground(layer, "accent"), + // Indicators + iconConflict: foreground(layer, "warning"), + iconDirty: foreground(layer, "accent"), - // When two tabs of the same name are open, a label appears next to them - description: { - margin: { left: 8 }, - ...text(layer, "sans", "disabled", { size: "2xs" }), - }, - } + // When two tabs of the same name are open, a label appears next to them + description: { + margin: { left: 8 }, + ...text(layer, "sans", "disabled", { size: "2xs" }), + }, + } - const activePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(activeLayer, "sans", "active", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const activePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(activeLayer, "sans", "active", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const inactivePaneInactiveTab = { - ...tab, - background: background(layer), - text: text(layer, "sans", "variant", { size: "sm" }), - } + const inactivePaneInactiveTab = { + ...tab, + background: background(layer), + text: text(layer, "sans", "variant", { size: "sm" }), + } - const inactivePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(layer, "sans", "variant", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const inactivePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(layer, "sans", "variant", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const draggedTab = { - ...activePaneActiveTab, - background: withOpacity(tab.background, 0.9), - border: undefined as any, - shadow: colorScheme.popoverShadow, - } + const draggedTab = { + ...activePaneActiveTab, + background: withOpacity(tab.background, 0.9), + border: undefined as any, + shadow: colorScheme.popoverShadow, + } - return { - height, - background: background(layer), - activePane: { - activeTab: activePaneActiveTab, - inactiveTab: tab, - }, - inactivePane: { - activeTab: inactivePaneActiveTab, - inactiveTab: inactivePaneInactiveTab, - }, - draggedTab, - paneButton: toggleable( - interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - }, - state: { - hovered: { - color: foreground(layer, "hovered"), - }, - }, - }), - { - default: { - color: foreground(layer, "accent"), - }, - } - ), - paneButtonContainer: { - background: tab.background, - border: { - ...tab.border, - right: false, + return { + height, + background: background(layer), + activePane: { + activeTab: activePaneActiveTab, + inactiveTab: tab, + }, + inactivePane: { + activeTab: inactivePaneActiveTab, + inactiveTab: inactivePaneInactiveTab, + }, + draggedTab, + paneButton: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), }, - }, + }, + }), + state: + { + active: { + default: { + color: foreground(layer, "accent"), + }, + } + } } + ), + paneButtonContainer: { + background: tab.background, + border: { + ...tab.border, + right: false, + }, + }, + } } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 3ce7ca7d7cda23b4300c22baf38e3de28c6372fc..3a870b008fde58e794d7e861a720de2235e71451 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -2,60 +2,64 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" import { interactive, toggleable } from "../element" export default function dropdownMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - return { - rowHeight: 30, - background: background(layer), - border: border(layer), - shadow: colorScheme.popoverShadow, - header: interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryText: text(layer, "sans", { - size: "sm", - color: "#aaaaaa", - }), - secondaryTextSpacing: 10, - padding: { left: 8, right: 8, top: 2, bottom: 2 }, - cornerRadius: 6, - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - }, - }, + return { + rowHeight: 30, + background: background(layer), + border: border(layer), + shadow: colorScheme.popoverShadow, + header: interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryText: text(layer, "sans", { + size: "sm", + color: "#aaaaaa", }), - sectionHeader: { - ...text(layer, "sans", { size: "sm" }), - padding: { left: 8, right: 8, top: 8, bottom: 8 }, + secondaryTextSpacing: 10, + padding: { left: 8, right: 8, top: 2, bottom: 2 }, + cornerRadius: 6, + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), }, - item: toggleable( - interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - }, - }, - }), - { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - } - ), + }, + }), + sectionHeader: { + ...text(layer, "sans", { size: "sm" }), + padding: { left: 8, right: 8, top: 8, bottom: 8 }, + }, + item: toggleable({ + base: + interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + }, + }, + }), + state: { + active: { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + } + } } + ), + } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index a2a21eaff4a88df354c41870118363befd12953f..96f4b8bdbdd355d1a7e4ec0d2c7e483dcee72e22 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -2,398 +2,406 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { toggleable } from "../element" import { - background, - border, - borderColor, - foreground, - svg, - text, + background, + border, + borderColor, + foreground, + svg, + text, } from "./components" import statusBar from "./statusBar" import tabBar from "./tabBar" import { interactive } from "../element" import merge from "ts-deepmerge" export default function workspace(colorScheme: ColorScheme) { - const layer = colorScheme.lowest - const isLight = colorScheme.isLight - const itemSpacing = 8 - const titlebarButton = toggleable( - interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, - state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { - size: "xs", - }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { - size: "xs", - }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - }, - }, - }), - { - default: { - ...text(layer, "sans", "variant", "active", { size: "xs" }), - background: background(layer, "variant", "active"), - border: border(layer, "variant", "active"), - }, - } - ) - const avatarWidth = 18 - const avatarOuterWidth = avatarWidth + 4 - const followerAvatarWidth = 14 - const followerAvatarOuterWidth = followerAvatarWidth + 4 - - return { - background: background(colorScheme.lowest), - blankPane: { - logoContainer: { - width: 256, - height: 256, - }, - logo: svg( - withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), - "icons/logo_96.svg", - 256, - 256 - ), - - logoShadow: svg( - withOpacity( - colorScheme.isLight - ? "#FFFFFF" - : colorScheme.lowest.base.default.background, - colorScheme.isLight ? 1 : 0.6 - ), - "icons/logo_96.svg", - 256, - 256 - ), - keyboardHints: { - margin: { - top: 96, - }, - cornerRadius: 4, - }, - keyboardHint: interactive({ - base: { - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8, - }, - state: { - hovered: { - ...text(layer, "sans", "active", { size: "sm" }), - }, - }, + const layer = colorScheme.lowest + const isLight = colorScheme.isLight + const itemSpacing = 8 + const titlebarButton = toggleable({ + base: + interactive({ + base: { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, + state: { + hovered: { + ...text(layer, "sans", "variant", "hovered", { + size: "xs", + }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { + size: "xs", }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + }, + }, + }), + state: { + active: { + default: { + ...text(layer, "sans", "variant", "active", { size: "xs" }), + background: background(layer, "variant", "active"), + border: border(layer, "variant", "active"), + }, + } + } + } + ) + const avatarWidth = 18 + const avatarOuterWidth = avatarWidth + 4 + const followerAvatarWidth = 14 + const followerAvatarOuterWidth = followerAvatarWidth + 4 + + return { + background: background(colorScheme.lowest), + blankPane: { + logoContainer: { + width: 256, + height: 256, + }, + logo: svg( + withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), + "icons/logo_96.svg", + 256, + 256 + ), - keyboardHintWidth: 320, + logoShadow: svg( + withOpacity( + colorScheme.isLight + ? "#FFFFFF" + : colorScheme.lowest.base.default.background, + colorScheme.isLight ? 1 : 0.6 + ), + "icons/logo_96.svg", + 256, + 256 + ), + keyboardHints: { + margin: { + top: 96, }, - joiningProjectAvatar: { - cornerRadius: 40, - width: 80, + cornerRadius: 4, + }, + keyboardHint: interactive({ + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8, }, - joiningProjectMessage: { - padding: 12, - ...text(layer, "sans", { size: "lg" }), + state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + }, + }, + }), + + keyboardHintWidth: 320, + }, + joiningProjectAvatar: { + cornerRadius: 40, + width: 80, + }, + joiningProjectMessage: { + padding: 12, + ...text(layer, "sans", { size: "lg" }), + }, + externalLocationMessage: { + background: background(colorScheme.middle, "accent"), + border: border(colorScheme.middle, "accent"), + cornerRadius: 6, + padding: 12, + margin: { bottom: 8, right: 8 }, + ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), + }, + leaderBorderOpacity: 0.7, + leaderBorderWidth: 2.0, + tabBar: tabBar(colorScheme), + modal: { + margin: { + bottom: 52, + top: 52, + }, + cursor: "Arrow", + }, + zoomedBackground: { + cursor: "Arrow", + background: isLight + ? withOpacity(background(colorScheme.lowest), 0.8) + : withOpacity(background(colorScheme.highest), 0.6), + }, + zoomedPaneForeground: { + margin: 16, + shadow: colorScheme.modalShadow, + border: border(colorScheme.lowest, { overlay: true }), + }, + zoomedPanelForeground: { + margin: 16, + border: border(colorScheme.lowest, { overlay: true }), + }, + dock: { + left: { + border: border(layer, { right: true }), + }, + bottom: { + border: border(layer, { top: true }), + }, + right: { + border: border(layer, { left: true }), + }, + }, + paneDivider: { + color: borderColor(layer), + width: 1, + }, + statusBar: statusBar(colorScheme), + titlebar: { + itemSpacing, + facePileSpacing: 2, + height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. + background: background(layer), + border: border(layer, { bottom: true }), + padding: { + left: 80, + right: itemSpacing, + }, + + // Project + title: text(layer, "sans", "variant"), + highlight_color: text(layer, "sans", "active").color, + + // Collaborators + leaderAvatar: { + width: avatarWidth, + outerWidth: avatarOuterWidth, + cornerRadius: avatarWidth / 2, + outerCornerRadius: avatarOuterWidth / 2, + }, + followerAvatar: { + width: followerAvatarWidth, + outerWidth: followerAvatarOuterWidth, + cornerRadius: followerAvatarWidth / 2, + outerCornerRadius: followerAvatarOuterWidth / 2, + }, + inactiveAvatarGrayscale: true, + followerAvatarOverlap: 8, + leaderSelection: { + margin: { + top: 4, + bottom: 4, }, - externalLocationMessage: { - background: background(colorScheme.middle, "accent"), - border: border(colorScheme.middle, "accent"), - cornerRadius: 6, - padding: 12, - margin: { bottom: 8, right: 8 }, - ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), + padding: { + left: 2, + right: 2, + top: 2, + bottom: 2, }, - leaderBorderOpacity: 0.7, - leaderBorderWidth: 2.0, - tabBar: tabBar(colorScheme), - modal: { + cornerRadius: 6, + }, + avatarRibbon: { + height: 3, + width: 12, + // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. + }, + + // Sign in buttom + // FlatButton, Variant + signInPrompt: merge(titlebarButton, { + inactive: { + default: { margin: { - bottom: 52, - top: 52, + left: itemSpacing, }, - cursor: "Arrow", + }, }, - zoomedBackground: { - cursor: "Arrow", - background: isLight - ? withOpacity(background(colorScheme.lowest), 0.8) - : withOpacity(background(colorScheme.highest), 0.6), + }), + + // Offline Indicator + offlineIcon: { + color: foreground(layer, "variant"), + width: 16, + margin: { + left: itemSpacing, }, - zoomedPaneForeground: { - margin: 16, - shadow: colorScheme.modalShadow, - border: border(colorScheme.lowest, { overlay: true }), + padding: { + right: 4, }, - zoomedPanelForeground: { - margin: 16, - border: border(colorScheme.lowest, { overlay: true }), + }, + + // Notice that the collaboration server is out of date + outdatedWarning: { + ...text(layer, "sans", "warning", { size: "xs" }), + background: withOpacity(background(layer, "warning"), 0.3), + border: border(layer, "warning"), + margin: { + left: itemSpacing, }, - dock: { - left: { - border: border(layer, { right: true }), - }, - bottom: { - border: border(layer, { top: true }), - }, - right: { - border: border(layer, { left: true }), - }, + padding: { + left: 8, + right: 8, }, - paneDivider: { - color: borderColor(layer), - width: 1, + cornerRadius: 6, + }, + callControl: interactive({ + base: { + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 20, }, - statusBar: statusBar(colorScheme), - titlebar: { - itemSpacing, - facePileSpacing: 2, - height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. - background: background(layer), - border: border(layer, { bottom: true }), - padding: { - left: 80, - right: itemSpacing, - }, - - // Project - title: text(layer, "sans", "variant"), - highlight_color: text(layer, "sans", "active").color, - - // Collaborators - leaderAvatar: { - width: avatarWidth, - outerWidth: avatarOuterWidth, - cornerRadius: avatarWidth / 2, - outerCornerRadius: avatarOuterWidth / 2, - }, - followerAvatar: { - width: followerAvatarWidth, - outerWidth: followerAvatarOuterWidth, - cornerRadius: followerAvatarWidth / 2, - outerCornerRadius: followerAvatarOuterWidth / 2, - }, - inactiveAvatarGrayscale: true, - followerAvatarOverlap: 8, - leaderSelection: { - margin: { - top: 4, - bottom: 4, - }, - padding: { - left: 2, - right: 2, - top: 2, - bottom: 2, - }, - cornerRadius: 6, - }, - avatarRibbon: { - height: 3, - width: 12, - // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. - }, - - // Sign in buttom - // FlatButton, Variant - signInPrompt: merge(titlebarButton, { - inactive: { - default: { - margin: { - left: itemSpacing, - }, - }, - }, - }), - - // Offline Indicator - offlineIcon: { - color: foreground(layer, "variant"), - width: 16, - margin: { - left: itemSpacing, - }, - padding: { - right: 4, - }, - }, - - // Notice that the collaboration server is out of date - outdatedWarning: { - ...text(layer, "sans", "warning", { size: "xs" }), - background: withOpacity(background(layer, "warning"), 0.3), - border: border(layer, "warning"), - margin: { - left: itemSpacing, - }, - padding: { - left: 8, - right: 8, - }, - cornerRadius: 6, + state: { + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + }, + }), + toggleContactsButton: toggleable({ + base: + interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, }, - callControl: interactive({ - base: { - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - }, - state: { - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - }, - }), - toggleContactsButton: toggleable( - interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - }, - }), - { - default: { - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active"), - }, - } - ), - userMenuButton: merge(titlebarButton, { - inactive: { - default: { - buttonWidth: 20, - iconWidth: 12, - }, - }, - active: { - // posiewic: these properties are not currently set on main - default: { - iconWidth: 12, - button_width: 20, - }, - }, - }), - - toggleContactsBadge: { - cornerRadius: 3, - padding: 2, - margin: { top: 3, left: 3 }, - border: border(layer), - background: foreground(layer, "accent"), + state: { + clicked: { + background: background(layer, "variant", "pressed"), + color: foreground(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, }, - shareButton: { - ...titlebarButton, + }), state: + { + active: { + default: { + background: background(layer, "variant", "active"), + color: foreground(layer, "variant", "active"), }, + } + } + } + ), + userMenuButton: merge(titlebarButton, { + inactive: { + default: { + buttonWidth: 20, + iconWidth: 12, + }, + }, + active: { + // posiewic: these properties are not currently set on main + default: { + iconWidth: 12, + button_width: 20, + }, }, + }), - toolbar: { - height: 34, - background: background(colorScheme.highest), - border: border(colorScheme.highest, { bottom: true }), - itemSpacing: 8, - navButton: interactive({ - base: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, - }, - state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - disabled: { - color: foreground( - colorScheme.highest, - "on", - "disabled" - ), - }, - }, - }), - padding: { left: 8, right: 8, top: 4, bottom: 4 }, + toggleContactsBadge: { + cornerRadius: 3, + padding: 2, + margin: { top: 3, left: 3 }, + border: border(layer), + background: foreground(layer, "accent"), + }, + shareButton: { + ...titlebarButton, + }, + }, + + toolbar: { + height: 34, + background: background(colorScheme.highest), + border: border(colorScheme.highest, { bottom: true }), + itemSpacing: 8, + navButton: interactive({ + base: { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, }, - breadcrumbHeight: 24, - breadcrumbs: interactive({ - base: { - ...text(colorScheme.highest, "sans", "variant"), - cornerRadius: 6, - padding: { - left: 6, - right: 6, - }, - }, - state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - }, - }), - disconnectedOverlay: { - ...text(layer, "sans"), - background: withOpacity(background(layer), 0.8), + state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + disabled: { + color: foreground( + colorScheme.highest, + "on", + "disabled" + ), + }, }, - notification: { - margin: { top: 10 }, - background: background(colorScheme.middle), - cornerRadius: 6, - padding: 12, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, + }), + padding: { left: 8, right: 8, top: 4, bottom: 4 }, + }, + breadcrumbHeight: 24, + breadcrumbs: interactive({ + base: { + ...text(colorScheme.highest, "sans", "variant"), + cornerRadius: 6, + padding: { + left: 6, + right: 6, }, - notifications: { - width: 400, - margin: { right: 10, bottom: 10 }, + }, + state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), }, - dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), - } + }, + }), + disconnectedOverlay: { + ...text(layer, "sans"), + background: withOpacity(background(layer), 0.8), + }, + notification: { + margin: { top: 10 }, + background: background(colorScheme.middle), + cornerRadius: 6, + padding: 12, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + }, + notifications: { + width: 400, + margin: { right: 10, bottom: 10 }, + }, + dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), + } } From dacfd70fb4390b52b04dd66dcb562db4e13e49e8 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 15:46:30 -0700 Subject: [PATCH 18/26] Remove unescessary enum --- crates/context_menu/src/context_menu.rs | 22 +++---------------- crates/theme/src/theme.rs | 29 ++++++------------------- crates/workspace/src/dock.rs | 9 ++------ 3 files changed, 12 insertions(+), 48 deletions(-) diff --git a/crates/context_menu/src/context_menu.rs b/crates/context_menu/src/context_menu.rs index e140177c5c13cda2645184fb71e16ef8b5461894..de78b51e9c071aadd28750c8f45b5d039c502a33 100644 --- a/crates/context_menu/src/context_menu.rs +++ b/crates/context_menu/src/context_menu.rs @@ -9,7 +9,6 @@ use gpui::{ }; use menu::*; use std::{any::TypeId, borrow::Cow, sync::Arc, time::Duration}; -use theme::ToggleState; pub fn init(cx: &mut AppContext) { cx.add_action(ContextMenu::select_first); @@ -329,12 +328,7 @@ impl ContextMenu { Flex::column().with_children(self.items.iter().enumerate().map(|(ix, item)| { match item { ContextMenuItem::Item { label, .. } => { - let toggle_state = if Some(ix) == self.selected_index { - ToggleState::Active - } else { - ToggleState::Inactive - }; - let style = style.item.in_state(toggle_state); + let style = style.item.in_state(self.selected_index == Some(ix)); let style = style.style_for(&mut Default::default()); match label { @@ -367,12 +361,7 @@ impl ContextMenu { .with_children(self.items.iter().enumerate().map(|(ix, item)| { match item { ContextMenuItem::Item { action, .. } => { - let toggle_state = if Some(ix) == self.selected_index { - ToggleState::Active - } else { - ToggleState::Inactive - }; - let style = style.item.in_state(toggle_state); + let style = style.item.in_state(self.selected_index == Some(ix)); let style = style.style_for(&mut Default::default()); match action { @@ -419,12 +408,7 @@ impl ContextMenu { let action = action.clone(); let view_id = self.parent_view_id; MouseEventHandler::::new(ix, cx, |state, _| { - let toggle_state = if Some(ix) == self.selected_index { - ToggleState::Active - } else { - ToggleState::Inactive - }; - let style = style.item.in_state(toggle_state); + let style = style.item.in_state(self.selected_index == Some(ix)); let style = style.style_for(state); let keystroke = match &action { ContextMenuItemAction::Action(action) => Some( diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 8f9f2281291f01078ee0767a74476bbbd59bfaca..586f444ebbf638adb5533390e864b4fca0354f50 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -816,37 +816,22 @@ pub struct Toggleable { inactive: T, } -#[derive(Copy, Clone, Debug, Default, Hash, PartialEq, Eq)] -pub enum ToggleState { - #[default] - Inactive, - Active, -} - -impl> From for ToggleState { - fn from(item: T) -> Self { - match *item.borrow() { - true => Self::Active, - false => Self::Inactive, - } - } -} - impl Toggleable { pub fn new(active: T, inactive: T) -> Self { Self { active, inactive } } - pub fn in_state(&self, state: impl Into) -> &T { - match state.into() { - ToggleState::Inactive => &self.inactive, - ToggleState::Active => &self.active, + pub fn in_state(&self, active: bool) -> &T { + if active { + &self.inactive + } else { + &self.active } } pub fn active_state(&self) -> &T { - self.in_state(ToggleState::Active) + self.in_state(true) } pub fn inactive_state(&self) -> &T { - self.in_state(ToggleState::Inactive) + self.in_state(false) } } diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index ec00ddece8f9a2ee8231df5c4b9123a70d49cbfa..9d23c6aca45af14ef85619c154c8cb2abe344e2f 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -6,7 +6,7 @@ use gpui::{ }; use serde::Deserialize; use std::rc::Rc; -use theme::{ThemeSettings, ToggleState}; +use theme::ThemeSettings; pub trait Panel: View { fn position(&self, cx: &WindowContext) -> DockPosition; @@ -498,12 +498,7 @@ impl View for PanelButtons { Stack::new() .with_child( MouseEventHandler::::new(panel_ix, cx, |state, cx| { - let toggle_state = if is_active { - ToggleState::Active - } else { - ToggleState::Inactive - }; - let style = button_style.in_state(toggle_state); + let style = button_style.in_state(is_active); let style = style.style_for(state); Flex::row() From da9401414160445725f2f855f5ba3310ced97e65 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 15:54:58 -0700 Subject: [PATCH 19/26] Fix flipped boolean --- crates/theme/src/theme.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 586f444ebbf638adb5533390e864b4fca0354f50..69c06c85addfe84ff8fda996abcab1f84a271966 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -822,9 +822,9 @@ impl Toggleable { } pub fn in_state(&self, active: bool) -> &T { if active { - &self.inactive - } else { &self.active + } else { + &self.inactive } } pub fn active_state(&self) -> &T { From b1b4b563c2b1adc377cf52cc4477f287f93ececd Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 15:58:59 -0700 Subject: [PATCH 20/26] Add zed typescript settings Remove 2 space indent --- styles/.zed/settings.json | 11 + styles/src/styleTree/commandPalette.ts | 64 +- styles/src/styleTree/contactList.ts | 420 +++++------ styles/src/styleTree/contextMenu.ts | 108 +-- styles/src/styleTree/editor.ts | 562 +++++++-------- styles/src/styleTree/picker.ts | 174 ++--- styles/src/styleTree/projectPanel.ts | 218 +++--- styles/src/styleTree/search.ts | 226 +++--- styles/src/styleTree/statusBar.ts | 268 +++---- styles/src/styleTree/tabBar.ts | 206 +++--- styles/src/styleTree/toolbarDropdownMenu.ts | 110 +-- styles/src/styleTree/workspace.ts | 742 ++++++++++---------- 12 files changed, 1560 insertions(+), 1549 deletions(-) create mode 100644 styles/.zed/settings.json diff --git a/styles/.zed/settings.json b/styles/.zed/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..0a3c761b8e57ee5c3808c0ac3aa0a1db336ff273 --- /dev/null +++ b/styles/.zed/settings.json @@ -0,0 +1,11 @@ +// Folder-specific settings +// +// For a full list of overridable settings, and general information on folder-specific settings, +// see the documentation: https://docs.zed.dev/configuration/configuring-zed#folder-specific-settings +{ + "languages": { + "TypeScript": { + "tab_size": 4 + } + } +} diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 947e730f55b3e54d4b391cf0ffcbe24c67f0c754..5389a775ed0ae564335cdc1d1b3ebad6f2c31e0b 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -4,39 +4,39 @@ import { text, background } from "./components" import { toggleable } from "../element" export default function commandPalette(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - const key = toggleable({ - base: { - text: text(layer, "mono", "variant", "default", { size: "xs" }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - }, - state: { - active: { - text: text(layer, "mono", "on", "default", { size: "xs" }), - background: withOpacity(background(layer, "on"), 0.2), - } - } - }) + const key = toggleable({ + base: { + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, + state: { + active: { + text: text(layer, "mono", "on", "default", { size: "xs" }), + background: withOpacity(background(layer, "on"), 0.2), + } + } + }) - return { - keystrokeSpacing: 8, - // TODO: This should be a Toggle on the rust side so we don't have to do this - key: { - inactive: { ...key.inactive }, - active: key.active, + return { + keystrokeSpacing: 8, + // TODO: This should be a Toggle on the rust side so we don't have to do this + key: { + inactive: { ...key.inactive }, + active: key.active, + } } - } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index d5ecb1c22400b1036503b50acb602cc65020d828..57034109f1553e8f093dfb22b946ad4485d4573f 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -2,232 +2,232 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function contactsPanel(colorScheme: ColorScheme) { - const nameMargin = 8 - const sidePadding = 12 + const nameMargin = 8 + const sidePadding = 12 - let layer = colorScheme.middle + let layer = colorScheme.middle - const contactButton = { - background: background(layer, "on"), - color: foreground(layer, "on"), - iconWidth: 8, - buttonWidth: 16, - cornerRadius: 8, - } - const projectRow = { - guestAvatarSpacing: 4, - height: 24, - guestAvatar: { - cornerRadius: 8, - width: 14, - }, - name: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - right: 6, - }, - }, - guests: { - margin: { - left: nameMargin, - right: nameMargin, - }, - }, - padding: { - left: sidePadding, - right: sidePadding, - }, - } - - return { - background: background(layer), - padding: { top: 12 }, - userQueryEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - margin: { - left: 6, - }, - }, - userQueryEditorHeight: 33, - addContactButton: { - margin: { left: 6, right: 12 }, - color: foreground(layer, "on"), - buttonWidth: 28, - iconWidth: 16, - }, - rowHeight: 28, - sectionIconSize: 8, - headerRow: toggleable({ - base: interactive({ - base: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, - }, - background: background(layer, "default"), // posiewic: breaking change - }, - state: { - hovered: { background: background(layer, "default") }, - }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. - }), - state: { - active: { - default: { - ...text(layer, "mono", "active", { size: "sm" }), - background: background(layer, "active"), - }, - } - } - }), - leaveCall: interactive({ - base: { - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, - }, - padding: { - top: 1, - bottom: 1, - left: 7, - right: 7, + const contactButton = { + background: background(layer, "on"), + color: foreground(layer, "on"), + iconWidth: 8, + buttonWidth: 16, + cornerRadius: 8, + } + const projectRow = { + guestAvatarSpacing: 4, + height: 24, + guestAvatar: { + cornerRadius: 8, + width: 14, }, - ...text(layer, "sans", "variant", { size: "xs" }), - }, - state: { - hovered: { - ...text(layer, "sans", "hovered", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "hovered"), + name: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + right: 6, + }, }, - }, - }), - contactRow: { - inactive: { - default: { - padding: { - left: sidePadding, - right: sidePadding, - }, + guests: { + margin: { + left: nameMargin, + right: nameMargin, + }, }, - }, - active: { - default: { - background: background(layer, "active"), - padding: { + padding: { left: sidePadding, right: sidePadding, - }, }, - }, - }, + } - contactAvatar: { - cornerRadius: 10, - width: 18, - }, - contactStatusFree: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "positive"), - }, - contactStatusBusy: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "negative"), - }, - contactUsername: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - }, - }, - contactButtonSpacing: nameMargin, - contactButton: interactive({ - base: { ...contactButton }, - state: { - hovered: { - background: background(layer, "hovered"), + return { + background: background(layer), + padding: { top: 12 }, + userQueryEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + margin: { + left: 6, + }, + }, + userQueryEditorHeight: 33, + addContactButton: { + margin: { left: 6, right: 12 }, + color: foreground(layer, "on"), + buttonWidth: 28, + iconWidth: 16, }, - }, - }), - disabledButton: { - ...contactButton, - background: background(layer, "on"), - color: foreground(layer, "on"), - }, - callingIndicator: { - ...text(layer, "mono", "variant", { size: "xs" }), - }, - treeBranch: toggleable({ - base: - interactive({ - base: { - color: borderColor(layer), - width: 1, - }, - state: { - hovered: { - color: borderColor(layer), + rowHeight: 28, + sectionIconSize: 8, + headerRow: toggleable({ + base: interactive({ + base: { + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"), // posiewic: breaking change + }, + state: { + hovered: { background: background(layer, "default") }, + }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. + }), + state: { + active: { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), + }, + } + } + }), + leaveCall: interactive({ + base: { + background: background(layer), + border: border(layer), + cornerRadius: 6, + margin: { + top: 1, + }, + padding: { + top: 1, + bottom: 1, + left: 7, + right: 7, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + }, + state: { + hovered: { + ...text(layer, "sans", "hovered", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "hovered"), + }, }, - }, }), - state: { - active: { - default: { - color: borderColor(layer), - }, - } - } - } - ), - projectRow: toggleable({ - base: - interactive({ - base: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, + contactRow: { + inactive: { + default: { + padding: { + left: sidePadding, + right: sidePadding, + }, + }, }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), + active: { + default: { + background: background(layer, "active"), + padding: { + left: sidePadding, + right: sidePadding, + }, + }, + }, + }, + + contactAvatar: { + cornerRadius: 10, + width: 18, + }, + contactStatusFree: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "positive"), + }, + contactStatusBusy: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "negative"), + }, + contactUsername: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, }, - }, - state: { - hovered: { - background: background(layer, "hovered"), + }, + contactButtonSpacing: nameMargin, + contactButton: interactive({ + base: { ...contactButton }, + state: { + hovered: { + background: background(layer, "hovered"), + }, }, - }, }), - state: { - active: { - default: { background: background(layer, "active") }, + disabledButton: { + ...contactButton, + background: background(layer, "on"), + color: foreground(layer, "on"), + }, + callingIndicator: { + ...text(layer, "mono", "variant", { size: "xs" }), + }, + treeBranch: toggleable({ + base: + interactive({ + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { + color: borderColor(layer), + }, + }, + }), + state: { + active: { + default: { + color: borderColor(layer), + }, + } + } + } + ), + projectRow: toggleable({ + base: + interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + }, + }, + }), + state: { + active: { + default: { background: background(layer, "active") }, + } + } } - } + ), } - ), - } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 661742f8004ca7a0be6073b64cb4f5b33f41cef5..7b2b9be6c2aaec640aa5df934a0e4401ff131afe 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -3,61 +3,61 @@ import { background, border, borderColor, text } from "./components" import { interactive, toggleable } from "../element" export default function contextMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle - return { - background: background(layer), - cornerRadius: 10, - padding: 4, - shadow: colorScheme.popoverShadow, - border: border(layer), - keystrokeMargin: 30, - item: toggleable({ - base: - interactive({ - base: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "hovered", { - size: "sm", - weight: "bold", + let layer = colorScheme.middle + return { + background: background(layer), + cornerRadius: 10, + padding: 4, + shadow: colorScheme.popoverShadow, + border: border(layer), + keystrokeMargin: 30, + item: toggleable({ + base: + interactive({ + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + }, }), - padding: { left: 3, right: 3 }, - }, - }, - }, - }), - state: { - active: { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, + state: { + active: { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + } + } } - } - } - ), + ), - separator: { - background: borderColor(layer), - margin: { top: 2, bottom: 2 }, - }, - } + separator: { + background: borderColor(layer), + margin: { top: 2, bottom: 2 }, + }, + } } diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 2437257875c9c07c623e2b819942b6f84b72d9e9..b02366192a9e1e77cec84d256e9fb68d4370f02c 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -7,303 +7,303 @@ import { buildSyntax } from "../theme/syntax" import { interactive, toggleable } from "../element" export default function editor(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.highest + let layer = colorScheme.highest - const autocompleteItem = { - cornerRadius: 6, - padding: { - bottom: 2, - left: 6, - right: 6, - top: 2, - }, - } - - function diagnostic(layer: Layer, styleSet: StyleSets) { - return { - textScaleFactor: 0.857, - header: { - border: border(layer, { - top: true, - }), - }, - message: { - text: text(layer, "sans", styleSet, "default", { size: "sm" }), - highlightText: text(layer, "sans", styleSet, "default", { - size: "sm", - weight: "bold", - }), - }, + const autocompleteItem = { + cornerRadius: 6, + padding: { + bottom: 2, + left: 6, + right: 6, + top: 2, + }, } - } - const syntax = buildSyntax(colorScheme) - - return { - textColor: syntax.primary.color, - background: background(layer), - activeLineBackground: withOpacity(background(layer, "on"), 0.75), - highlightedLineBackground: background(layer, "on"), - // Inline autocomplete suggestions, Co-pilot suggestions, etc. - suggestion: syntax.predictive, - codeActions: { - indicator: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), - }, - state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, + function diagnostic(layer: Layer, styleSet: StyleSets) { + return { + textScaleFactor: 0.857, + header: { + border: border(layer, { + top: true, + }), }, - }), - state: { - active: { - default: { - color: foreground(layer, "on"), + message: { + text: text(layer, "sans", styleSet, "default", { size: "sm" }), + highlightText: text(layer, "sans", styleSet, "default", { + size: "sm", + weight: "bold", + }), }, - } } - } - ), + } - verticalScale: 0.55, - }, - folds: { - iconMarginScale: 2.5, - foldedIcon: "icons/chevron_right_8.svg", - foldableIcon: "icons/chevron_down_8.svg", - indicator: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), - }, - state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - }, - }), - state: { - active: { - default: { - color: foreground(layer, "on"), - }, - } - } - } - ), - ellipses: { - textColor: colorScheme.ramps.neutral(0.71).hex(), - cornerRadiusFactor: 0.15, - background: { - // Copied from hover_popover highlight - default: { - color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), - }, + const syntax = buildSyntax(colorScheme) - hovered: { - color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), - }, + return { + textColor: syntax.primary.color, + background: background(layer), + activeLineBackground: withOpacity(background(layer, "on"), 0.75), + highlightedLineBackground: background(layer, "on"), + // Inline autocomplete suggestions, Co-pilot suggestions, etc. + suggestion: syntax.predictive, + codeActions: { + indicator: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + }, + }), + state: { + active: { + default: { + color: foreground(layer, "on"), + }, + } + } + } + ), - clicked: { - color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), - }, + verticalScale: 0.55, }, - }, - foldBackground: foreground(layer, "variant"), - }, - diff: { - deleted: isLight - ? colorScheme.ramps.red(0.5).hex() - : colorScheme.ramps.red(0.4).hex(), - modified: isLight - ? colorScheme.ramps.yellow(0.5).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.4).hex() - : colorScheme.ramps.green(0.5).hex(), - removedWidthEm: 0.275, - widthEm: 0.15, - cornerRadius: 0.05, - }, - /** Highlights matching occurrences of what is under the cursor - * as well as matched brackets - */ - documentHighlightReadBackground: withOpacity( - foreground(layer, "accent"), - 0.1 - ), - documentHighlightWriteBackground: colorScheme.ramps - .neutral(0.5) - .alpha(0.4) - .hex(), // TODO: This was blend * 2 - errorColor: background(layer, "negative"), - gutterBackground: background(layer), - gutterPaddingFactor: 3.5, - lineNumber: withOpacity(foreground(layer), 0.35), - lineNumberActive: foreground(layer), - renameFade: 0.6, - unnecessaryCodeFade: 0.5, - selection: colorScheme.players[0], - whitespace: colorScheme.ramps.neutral(0.5).hex(), - guestSelections: [ - colorScheme.players[1], - colorScheme.players[2], - colorScheme.players[3], - colorScheme.players[4], - colorScheme.players[5], - colorScheme.players[6], - colorScheme.players[7], - ], - autocomplete: { - background: background(colorScheme.middle), - cornerRadius: 8, - padding: 4, - margin: { - left: -14, - }, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - matchHighlight: foreground(colorScheme.middle, "accent"), - item: autocompleteItem, - hoveredItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "hovered" - ), - background: background(colorScheme.middle, "hovered"), - }, - selectedItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "active" + folds: { + iconMarginScale: 2.5, + foldedIcon: "icons/chevron_right_8.svg", + foldableIcon: "icons/chevron_down_8.svg", + indicator: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + }, + }), + state: { + active: { + default: { + color: foreground(layer, "on"), + }, + } + } + } + ), + ellipses: { + textColor: colorScheme.ramps.neutral(0.71).hex(), + cornerRadiusFactor: 0.15, + background: { + // Copied from hover_popover highlight + default: { + color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), + }, + + hovered: { + color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), + }, + + clicked: { + color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), + }, + }, + }, + foldBackground: foreground(layer, "variant"), + }, + diff: { + deleted: isLight + ? colorScheme.ramps.red(0.5).hex() + : colorScheme.ramps.red(0.4).hex(), + modified: isLight + ? colorScheme.ramps.yellow(0.5).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.4).hex() + : colorScheme.ramps.green(0.5).hex(), + removedWidthEm: 0.275, + widthEm: 0.15, + cornerRadius: 0.05, + }, + /** Highlights matching occurrences of what is under the cursor + * as well as matched brackets + */ + documentHighlightReadBackground: withOpacity( + foreground(layer, "accent"), + 0.1 ), - background: background(colorScheme.middle, "active"), - }, - }, - diagnosticHeader: { - background: background(colorScheme.middle), - iconWidthFactor: 1.5, - textScaleFactor: 0.857, - border: border(colorScheme.middle, { - bottom: true, - top: true, - }), - code: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 10, + documentHighlightWriteBackground: colorScheme.ramps + .neutral(0.5) + .alpha(0.4) + .hex(), // TODO: This was blend * 2 + errorColor: background(layer, "negative"), + gutterBackground: background(layer), + gutterPaddingFactor: 3.5, + lineNumber: withOpacity(foreground(layer), 0.35), + lineNumberActive: foreground(layer), + renameFade: 0.6, + unnecessaryCodeFade: 0.5, + selection: colorScheme.players[0], + whitespace: colorScheme.ramps.neutral(0.5).hex(), + guestSelections: [ + colorScheme.players[1], + colorScheme.players[2], + colorScheme.players[3], + colorScheme.players[4], + colorScheme.players[5], + colorScheme.players[6], + colorScheme.players[7], + ], + autocomplete: { + background: background(colorScheme.middle), + cornerRadius: 8, + padding: 4, + margin: { + left: -14, + }, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + matchHighlight: foreground(colorScheme.middle, "accent"), + item: autocompleteItem, + hoveredItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "hovered" + ), + background: background(colorScheme.middle, "hovered"), + }, + selectedItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "active" + ), + background: background(colorScheme.middle, "active"), + }, }, - }, - source: { - text: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - }, - message: { - highlightText: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - text: text(colorScheme.middle, "sans", { size: "sm" }), - }, - }, - diagnosticPathHeader: { - background: background(colorScheme.middle), - textScaleFactor: 0.857, - filename: text(colorScheme.middle, "mono", { size: "sm" }), - path: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 12, + diagnosticHeader: { + background: background(colorScheme.middle), + iconWidthFactor: 1.5, + textScaleFactor: 0.857, + border: border(colorScheme.middle, { + bottom: true, + top: true, + }), + code: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 10, + }, + }, + source: { + text: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + }, + message: { + highlightText: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + text: text(colorScheme.middle, "sans", { size: "sm" }), + }, }, - }, - }, - errorDiagnostic: diagnostic(colorScheme.middle, "negative"), - warningDiagnostic: diagnostic(colorScheme.middle, "warning"), - informationDiagnostic: diagnostic(colorScheme.middle, "accent"), - hintDiagnostic: diagnostic(colorScheme.middle, "warning"), - invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), - hoverPopover: hoverPopover(colorScheme), - linkDefinition: { - color: syntax.linkUri.color, - underline: syntax.linkUri.underline, - }, - jumpIcon: interactive({ - base: { - color: foreground(layer, "on"), - iconWidth: 20, - buttonWidth: 20, - cornerRadius: 6, - padding: { - top: 6, - bottom: 6, - left: 6, - right: 6, + diagnosticPathHeader: { + background: background(colorScheme.middle), + textScaleFactor: 0.857, + filename: text(colorScheme.middle, "mono", { size: "sm" }), + path: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 12, + }, + }, }, - }, - state: { - hovered: { - background: background(layer, "on", "hovered"), + errorDiagnostic: diagnostic(colorScheme.middle, "negative"), + warningDiagnostic: diagnostic(colorScheme.middle, "warning"), + informationDiagnostic: diagnostic(colorScheme.middle, "accent"), + hintDiagnostic: diagnostic(colorScheme.middle, "warning"), + invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), + hoverPopover: hoverPopover(colorScheme), + linkDefinition: { + color: syntax.linkUri.color, + underline: syntax.linkUri.underline, }, - }, - }), + jumpIcon: interactive({ + base: { + color: foreground(layer, "on"), + iconWidth: 20, + buttonWidth: 20, + cornerRadius: 6, + padding: { + top: 6, + bottom: 6, + left: 6, + right: 6, + }, + }, + state: { + hovered: { + background: background(layer, "on", "hovered"), + }, + }, + }), - scrollbar: { - width: 12, - minHeightFactor: 1.0, - track: { - border: border(layer, "variant", { left: true }), - }, - thumb: { - background: withOpacity(background(layer, "inverted"), 0.3), - border: { - width: 1, - color: borderColor(layer, "variant"), - top: false, - right: true, - left: true, - bottom: false, + scrollbar: { + width: 12, + minHeightFactor: 1.0, + track: { + border: border(layer, "variant", { left: true }), + }, + thumb: { + background: withOpacity(background(layer, "inverted"), 0.3), + border: { + width: 1, + color: borderColor(layer, "variant"), + top: false, + right: true, + left: true, + bottom: false, + }, + }, + git: { + deleted: isLight + ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), + modified: isLight + ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), + inserted: isLight + ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), + }, }, - }, - git: { - deleted: isLight - ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), - modified: isLight - ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), - inserted: isLight - ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), - }, - }, - compositionMark: { - underline: { - thickness: 1.0, - color: borderColor(layer), - }, - }, - syntax, - } + compositionMark: { + underline: { + thickness: 1.0, + color: borderColor(layer), + }, + }, + syntax, + } } diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index f7cec1bd4145b9ad54715baa172c23fea6ff03ed..809cd1743ff9f21684407132c7ce734757a01869 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -4,95 +4,95 @@ import { background, border, text } from "./components" import { interactive, toggleable } from "../element" export default function picker(colorScheme: ColorScheme): any { - let layer = colorScheme.lowest - const container = { - background: background(layer), - border: border(layer), - shadow: colorScheme.modalShadow, - cornerRadius: 12, - padding: { - bottom: 4, - }, - } - const inputEditor = { - placeholderText: text(layer, "sans", "on", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "on"), - border: border(layer, { bottom: true }), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - margin: { - bottom: 4, - }, - } - const emptyInputEditor: any = { ...inputEditor } - delete emptyInputEditor.border - delete emptyInputEditor.margin + let layer = colorScheme.lowest + const container = { + background: background(layer), + border: border(layer), + shadow: colorScheme.modalShadow, + cornerRadius: 12, + padding: { + bottom: 4, + }, + } + const inputEditor = { + placeholderText: text(layer, "sans", "on", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "on"), + border: border(layer, { bottom: true }), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + margin: { + bottom: 4, + }, + } + const emptyInputEditor: any = { ...inputEditor } + delete emptyInputEditor.border + delete emptyInputEditor.margin - return { - ...container, - emptyContainer: { - ...container, - padding: {}, - }, - item: toggleable({ - base: - interactive({ - base: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, - }, - margin: { - top: 1, - left: 4, - right: 4, - }, - cornerRadius: 8, + return { + ...container, + emptyContainer: { + ...container, + padding: {}, + }, + item: toggleable({ + base: + interactive({ + base: { + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, + }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { + weight: "bold", + }), + }, + state: { + hovered: { + background: withOpacity( + background(layer, "hovered"), + 0.5 + ), + }, + }, + }), + state: { + active: { + default: { + background: withOpacity( + background(layer, "base", "active"), + 0.5 + ), + //text: text(layer, "sans", "base", "active"), + }, + } + } + } + ), + + inputEditor, + emptyInputEditor, + noMatches: { text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { - weight: "bold", - }), - }, - state: { - hovered: { - background: withOpacity( - background(layer, "hovered"), - 0.5 - ), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, }, - }, - }), - state: { - active: { - default: { - background: withOpacity( - background(layer, "base", "active"), - 0.5 - ), - //text: text(layer, "sans", "base", "active"), - }, - } - } + }, } - ), - - inputEditor, - emptyInputEditor, - noMatches: { - text: text(layer, "sans", "variant"), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - }, - } } diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index babd1431fb9400fedea468509315b47af5e3616f..7c37ce6bd3ebbc2f0199171d65ba2121769347e0 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -3,125 +3,125 @@ import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function projectPanel(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.middle + let layer = colorScheme.middle - let baseEntry = { - height: 22, - iconColor: foreground(layer, "variant"), - iconSize: 7, - iconSpacing: 5, - } - - let status = { - git: { - modified: isLight - ? colorScheme.ramps.yellow(0.6).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.45).hex() - : colorScheme.ramps.green(0.5).hex(), - conflict: isLight - ? colorScheme.ramps.red(0.6).hex() - : colorScheme.ramps.red(0.5).hex(), - }, - } + let baseEntry = { + height: 22, + iconColor: foreground(layer, "variant"), + iconSize: 7, + iconSpacing: 5, + } - let entry = toggleable({ - base: - interactive({ - base: { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, + let status = { + git: { + modified: isLight + ? colorScheme.ramps.yellow(0.6).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.45).hex() + : colorScheme.ramps.green(0.5).hex(), + conflict: isLight + ? colorScheme.ramps.red(0.6).hex() + : colorScheme.ramps.red(0.5).hex(), }, + } + + let entry = toggleable({ + base: + interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, + state: { + hovered: { + background: background(layer, "variant", "hovered"), + }, + }, + }), state: { - hovered: { - background: background(layer, "variant", "hovered"), - }, - }, - }), - state: { - active: { - default: { - /*background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active") ,*/ // todo posiewic - text: text(layer, "mono", "active", { size: "sm" }), - }, - hovered: { - //background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - } + active: { + default: { + /*background: colorScheme.isLight + ? withOpacity(background(layer, "active"), 0.5) + : background(layer, "active") ,*/ // todo posiewic + text: text(layer, "mono", "active", { size: "sm" }), + }, + hovered: { + //background: background(layer, "active"), + text: text(layer, "mono", "active", { size: "sm" }), + }, + } + } } - } - ) + ) - return { - openProjectButton: interactive({ - base: { + return { + openProjectButton: interactive({ + base: { + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 16, + left: 16, + right: 16, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }), + }, + state: { + hovered: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + }, + }), background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 16, - left: 16, - right: 16, + padding: { left: 6, right: 6, top: 0, bottom: 6 }, + indentWidth: 12, + entry, + draggedEntry: { + ...baseEntry, + text: text(layer, "mono", "on", { size: "sm" }), + background: withOpacity(background(layer, "on"), 0.9), + border: border(layer), + status, }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, + ignoredEntry: { + ...entry, + iconColor: foreground(layer, "disabled"), + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + iconColor: foreground(layer, "variant"), + }, }, - ...text(layer, "sans", "default", { size: "sm" }), - }, - state: { - hovered: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), + cutEntry: { + ...entry, + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + default: { + ...entry.active.default, + background: background(layer, "active"), + text: text(layer, "mono", "disabled", { size: "sm" }), + }, + }, }, - }, - }), - background: background(layer), - padding: { left: 6, right: 6, top: 0, bottom: 6 }, - indentWidth: 12, - entry, - draggedEntry: { - ...baseEntry, - text: text(layer, "mono", "on", { size: "sm" }), - background: withOpacity(background(layer, "on"), 0.9), - border: border(layer), - status, - }, - ignoredEntry: { - ...entry, - iconColor: foreground(layer, "disabled"), - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - iconColor: foreground(layer, "variant"), - }, - }, - cutEntry: { - ...entry, - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - default: { - ...entry.active.default, - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), + filenameEditor: { + background: background(layer, "on"), + text: text(layer, "mono", "on", { size: "sm" }), + selection: colorScheme.players[0], }, - }, - }, - filenameEditor: { - background: background(layer, "on"), - text: text(layer, "mono", "on", { size: "sm" }), - selection: colorScheme.players[0], - }, - } + } } diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index aa015d5cde4509439ca2c1c959d20eb23f87da7e..0123ddee22b40536a823f36e3f437c20bb353b27 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -4,127 +4,127 @@ import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function search(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - // Search input - const editor = { - background: background(layer), - cornerRadius: 8, - minWidth: 200, - maxWidth: 500, - placeholderText: text(layer, "mono", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "default"), - border: border(layer), - margin: { - right: 12, - }, - padding: { - top: 3, - bottom: 3, - left: 12, - right: 8, - }, - } + // Search input + const editor = { + background: background(layer), + cornerRadius: 8, + minWidth: 200, + maxWidth: 500, + placeholderText: text(layer, "mono", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "default"), + border: border(layer), + margin: { + right: 12, + }, + padding: { + top: 3, + bottom: 3, + left: 12, + right: 8, + }, + } - const includeExcludeEditor = { - ...editor, - minWidth: 100, - maxWidth: 250, - } + const includeExcludeEditor = { + ...editor, + minWidth: 100, + maxWidth: 250, + } - return { - // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive - matchBackground: withOpacity(foreground(layer, "accent"), 0.4), - optionButton: toggleable({ - base: - interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, + return { + // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive + matchBackground: withOpacity(foreground(layer, "accent"), 0.4), + optionButton: toggleable({ + base: + interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, + }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, + }, + }, + state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + }, + }), + state: { + active: { + default: { + ...text(layer, "mono", "on", "inverted"), + background: background(layer, "on", "inverted"), + border: border(layer, "on", "inverted"), + }, + } + } + } + ), + editor, + invalidEditor: { + ...editor, + border: border(layer, "negative"), + }, + includeExcludeEditor, + invalidIncludeExcludeEditor: { + ...includeExcludeEditor, + border: border(layer, "negative"), + }, + matchIndex: { + ...text(layer, "mono", "variant"), + padding: { + left: 6, }, + }, + optionButtonGroup: { padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, + left: 12, + right: 12, }, - }, - state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), + }, + includeExcludeInputs: { + ...text(layer, "mono", "variant"), + padding: { + right: 6, + }, + }, + resultsStatus: { + ...text(layer, "mono", "on"), + size: 18, + }, + dismissButton: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 14, + padding: { + left: 10, + right: 10, + }, }, - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), + state: { + hovered: { + color: foreground(layer, "hovered"), + }, }, - }, }), - state: { - active: { - default: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), - }, - } - } } - ), - editor, - invalidEditor: { - ...editor, - border: border(layer, "negative"), - }, - includeExcludeEditor, - invalidIncludeExcludeEditor: { - ...includeExcludeEditor, - border: border(layer, "negative"), - }, - matchIndex: { - ...text(layer, "mono", "variant"), - padding: { - left: 6, - }, - }, - optionButtonGroup: { - padding: { - left: 12, - right: 12, - }, - }, - includeExcludeInputs: { - ...text(layer, "mono", "variant"), - padding: { - right: 6, - }, - }, - resultsStatus: { - ...text(layer, "mono", "on"), - size: 18, - }, - dismissButton: interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 14, - padding: { - left: 10, - right: 10, - }, - }, - state: { - hovered: { - color: foreground(layer, "hovered"), - }, - }, - }), - } } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 4c566a5c3a5f099c49d428ffb4b8648526e468eb..e4a48e8215dd2ebed127ed237f2b4faa977cacd5 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -2,147 +2,147 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function statusBar(colorScheme: ColorScheme) { - let layer = colorScheme.lowest + let layer = colorScheme.lowest - const statusContainer = { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 6, right: 6 }, - } + const statusContainer = { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 6, right: 6 }, + } - const diagnosticStatusContainer = { - cornerRadius: 6, - padding: { top: 1, bottom: 1, left: 6, right: 6 }, - } + const diagnosticStatusContainer = { + cornerRadius: 6, + padding: { top: 1, bottom: 1, left: 6, right: 6 }, + } - return { - height: 30, - itemSpacing: 8, - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - border: border(layer, { top: true, overlay: true }), - cursorPosition: text(layer, "sans", "variant"), - activeLanguage: interactive({ - base: { - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant"), - }, - state: { - hovered: { - ...text(layer, "sans", "on"), + return { + height: 30, + itemSpacing: 8, + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, }, - }, - }), - autoUpdateProgressMessage: text(layer, "sans", "variant"), - autoUpdateDoneMessage: text(layer, "sans", "variant"), - lspStatus: interactive({ - base: { - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer), - }, - state: { - hovered: { - message: text(layer, "sans"), - iconColor: foreground(layer), - background: background(layer, "hovered"), - }, - }, - }), - diagnosticMessage: interactive({ - base: { - ...text(layer, "sans"), - }, - state: { hovered: text(layer, "sans", "hovered") }, - }), - diagnosticSummary: interactive({ - base: { - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - }, - }, - state: { - hovered: { - iconColorOk: foreground(layer, "on"), - containerOk: { - background: background(layer, "on", "hovered"), - }, - containerWarning: { - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), - }, - containerError: { - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), - }, - }, - }, - }), - panelButtons: { - groupLeft: {}, - groupBottom: {}, - groupRight: {}, - button: toggleable({ - base: - interactive({ + border: border(layer, { top: true, overlay: true }), + cursorPosition: text(layer, "sans", "variant"), + activeLanguage: interactive({ + base: { + padding: { left: 6, right: 6 }, + ...text(layer, "sans", "variant"), + }, + state: { + hovered: { + ...text(layer, "sans", "on"), + }, + }, + }), + autoUpdateProgressMessage: text(layer, "sans", "variant"), + autoUpdateDoneMessage: text(layer, "sans", "variant"), + lspStatus: interactive({ + base: { + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, + message: text(layer, "sans"), + iconColor: foreground(layer), + }, + state: { + hovered: { + message: text(layer, "sans"), + iconColor: foreground(layer), + background: background(layer, "hovered"), + }, + }, + }), + diagnosticMessage: interactive({ + base: { + ...text(layer, "sans"), + }, + state: { hovered: text(layer, "sans", "hovered") }, + }), + diagnosticSummary: interactive({ base: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), + containerOk: { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, + }, + containerWarning: { + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), + }, + containerError: { + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + }, }, state: { - hovered: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - }, + hovered: { + iconColorOk: foreground(layer, "on"), + containerOk: { + background: background(layer, "on", "hovered"), + }, + containerWarning: { + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), + }, + containerError: { + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + }, + }, }, - }), state: - { - active: { - default: { - iconColor: foreground(layer, "active"), - background: background(layer, "active"), + }), + panelButtons: { + groupLeft: {}, + groupBottom: {}, + groupRight: {}, + button: toggleable({ + base: + interactive({ + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, + }, + state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + }, + }, + }), state: + { + active: { + default: { + iconColor: foreground(layer, "active"), + background: background(layer, "active"), + }, + } + } + } + ), + badge: { + cornerRadius: 3, + padding: 2, + margin: { bottom: -1, right: -1 }, + border: border(layer), + background: background(layer, "accent"), }, - } - } - } - ), - badge: { - cornerRadius: 3, - padding: 2, - margin: { bottom: -1, right: -1 }, - border: border(layer), - background: background(layer, "accent"), - }, - }, - } + }, + } } diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index d7b3b58055ae22bca9ed4a6b8cb4ccd2056234dd..f2c99ea736d18d717c865ab1b8d0ff48efcff3bd 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -4,120 +4,120 @@ import { text, border, background, foreground } from "./components" import { interactive, toggleable } from "../element" export default function tabBar(colorScheme: ColorScheme) { - const height = 32 + const height = 32 - let activeLayer = colorScheme.highest - let layer = colorScheme.middle + let activeLayer = colorScheme.highest + let layer = colorScheme.middle - const tab = { - height, - text: text(layer, "sans", "variant", { size: "sm" }), - background: background(layer), - border: border(layer, { - right: true, - bottom: true, - overlay: true, - }), - padding: { - left: 8, - right: 12, - }, - spacing: 8, + const tab = { + height, + text: text(layer, "sans", "variant", { size: "sm" }), + background: background(layer), + border: border(layer, { + right: true, + bottom: true, + overlay: true, + }), + padding: { + left: 8, + right: 12, + }, + spacing: 8, - // Tab type icons (e.g. Project Search) - typeIconWidth: 14, + // Tab type icons (e.g. Project Search) + typeIconWidth: 14, - // Close icons - closeIconWidth: 8, - iconClose: foreground(layer, "variant"), - iconCloseActive: foreground(layer, "hovered"), + // Close icons + closeIconWidth: 8, + iconClose: foreground(layer, "variant"), + iconCloseActive: foreground(layer, "hovered"), - // Indicators - iconConflict: foreground(layer, "warning"), - iconDirty: foreground(layer, "accent"), + // Indicators + iconConflict: foreground(layer, "warning"), + iconDirty: foreground(layer, "accent"), - // When two tabs of the same name are open, a label appears next to them - description: { - margin: { left: 8 }, - ...text(layer, "sans", "disabled", { size: "2xs" }), - }, - } + // When two tabs of the same name are open, a label appears next to them + description: { + margin: { left: 8 }, + ...text(layer, "sans", "disabled", { size: "2xs" }), + }, + } - const activePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(activeLayer, "sans", "active", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const activePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(activeLayer, "sans", "active", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const inactivePaneInactiveTab = { - ...tab, - background: background(layer), - text: text(layer, "sans", "variant", { size: "sm" }), - } + const inactivePaneInactiveTab = { + ...tab, + background: background(layer), + text: text(layer, "sans", "variant", { size: "sm" }), + } - const inactivePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(layer, "sans", "variant", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const inactivePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(layer, "sans", "variant", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const draggedTab = { - ...activePaneActiveTab, - background: withOpacity(tab.background, 0.9), - border: undefined as any, - shadow: colorScheme.popoverShadow, - } + const draggedTab = { + ...activePaneActiveTab, + background: withOpacity(tab.background, 0.9), + border: undefined as any, + shadow: colorScheme.popoverShadow, + } - return { - height, - background: background(layer), - activePane: { - activeTab: activePaneActiveTab, - inactiveTab: tab, - }, - inactivePane: { - activeTab: inactivePaneActiveTab, - inactiveTab: inactivePaneInactiveTab, - }, - draggedTab, - paneButton: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - }, - state: { - hovered: { - color: foreground(layer, "hovered"), - }, - }, - }), - state: - { - active: { - default: { - color: foreground(layer, "accent"), - }, + return { + height, + background: background(layer), + activePane: { + activeTab: activePaneActiveTab, + inactiveTab: tab, + }, + inactivePane: { + activeTab: inactivePaneActiveTab, + inactiveTab: inactivePaneInactiveTab, + }, + draggedTab, + paneButton: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), + }, + }, + }), + state: + { + active: { + default: { + color: foreground(layer, "accent"), + }, + } + } } - } + ), + paneButtonContainer: { + background: tab.background, + border: { + ...tab.border, + right: false, + }, + }, } - ), - paneButtonContainer: { - background: tab.background, - border: { - ...tab.border, - right: false, - }, - }, - } } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 3a870b008fde58e794d7e861a720de2235e71451..b1b28d789e11dd34cb856785648c5f371abccb77 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -2,64 +2,64 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" import { interactive, toggleable } from "../element" export default function dropdownMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - return { - rowHeight: 30, - background: background(layer), - border: border(layer), - shadow: colorScheme.popoverShadow, - header: interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryText: text(layer, "sans", { - size: "sm", - color: "#aaaaaa", - }), - secondaryTextSpacing: 10, - padding: { left: 8, right: 8, top: 2, bottom: 2 }, - cornerRadius: 6, - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - }, - }, - }), - sectionHeader: { - ...text(layer, "sans", { size: "sm" }), - padding: { left: 8, right: 8, top: 8, bottom: 8 }, - }, - item: toggleable({ - base: - interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), + return { + rowHeight: 30, + background: background(layer), + border: border(layer), + shadow: colorScheme.popoverShadow, + header: interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryText: text(layer, "sans", { + size: "sm", + color: "#aaaaaa", + }), + secondaryTextSpacing: 10, + padding: { left: 8, right: 8, top: 2, bottom: 2 }, + cornerRadius: 6, + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + }, }, - }, }), - state: { - active: { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, + sectionHeader: { + ...text(layer, "sans", { size: "sm" }), + padding: { left: 8, right: 8, top: 8, bottom: 8 }, + }, + item: toggleable({ + base: + interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + }, + }, + }), + state: { + active: { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + } + } } - } + ), } - ), - } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 96f4b8bdbdd355d1a7e4ec0d2c7e483dcee72e22..fdc7657481df832bc189e20c00f2873b036c9361 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -2,406 +2,406 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { toggleable } from "../element" import { - background, - border, - borderColor, - foreground, - svg, - text, + background, + border, + borderColor, + foreground, + svg, + text, } from "./components" import statusBar from "./statusBar" import tabBar from "./tabBar" import { interactive } from "../element" import merge from "ts-deepmerge" export default function workspace(colorScheme: ColorScheme) { - const layer = colorScheme.lowest - const isLight = colorScheme.isLight - const itemSpacing = 8 - const titlebarButton = toggleable({ - base: - interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, - state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { - size: "xs", - }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { - size: "xs", + const layer = colorScheme.lowest + const isLight = colorScheme.isLight + const itemSpacing = 8 + const titlebarButton = toggleable({ + base: + interactive({ + base: { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, + state: { + hovered: { + ...text(layer, "sans", "variant", "hovered", { + size: "xs", + }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { + size: "xs", + }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + }, + }, }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - }, - }, - }), - state: { - active: { - default: { - ...text(layer, "sans", "variant", "active", { size: "xs" }), - background: background(layer, "variant", "active"), - border: border(layer, "variant", "active"), - }, - } + state: { + active: { + default: { + ...text(layer, "sans", "variant", "active", { size: "xs" }), + background: background(layer, "variant", "active"), + border: border(layer, "variant", "active"), + }, + } + } } - } - ) - const avatarWidth = 18 - const avatarOuterWidth = avatarWidth + 4 - const followerAvatarWidth = 14 - const followerAvatarOuterWidth = followerAvatarWidth + 4 + ) + const avatarWidth = 18 + const avatarOuterWidth = avatarWidth + 4 + const followerAvatarWidth = 14 + const followerAvatarOuterWidth = followerAvatarWidth + 4 - return { - background: background(colorScheme.lowest), - blankPane: { - logoContainer: { - width: 256, - height: 256, - }, - logo: svg( - withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), - "icons/logo_96.svg", - 256, - 256 - ), + return { + background: background(colorScheme.lowest), + blankPane: { + logoContainer: { + width: 256, + height: 256, + }, + logo: svg( + withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), + "icons/logo_96.svg", + 256, + 256 + ), - logoShadow: svg( - withOpacity( - colorScheme.isLight - ? "#FFFFFF" - : colorScheme.lowest.base.default.background, - colorScheme.isLight ? 1 : 0.6 - ), - "icons/logo_96.svg", - 256, - 256 - ), - keyboardHints: { - margin: { - top: 96, + logoShadow: svg( + withOpacity( + colorScheme.isLight + ? "#FFFFFF" + : colorScheme.lowest.base.default.background, + colorScheme.isLight ? 1 : 0.6 + ), + "icons/logo_96.svg", + 256, + 256 + ), + keyboardHints: { + margin: { + top: 96, + }, + cornerRadius: 4, + }, + keyboardHint: interactive({ + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8, + }, + state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + }, + }, + }), + + keyboardHintWidth: 320, }, - cornerRadius: 4, - }, - keyboardHint: interactive({ - base: { - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8, + joiningProjectAvatar: { + cornerRadius: 40, + width: 80, }, - state: { - hovered: { - ...text(layer, "sans", "active", { size: "sm" }), - }, + joiningProjectMessage: { + padding: 12, + ...text(layer, "sans", { size: "lg" }), }, - }), - - keyboardHintWidth: 320, - }, - joiningProjectAvatar: { - cornerRadius: 40, - width: 80, - }, - joiningProjectMessage: { - padding: 12, - ...text(layer, "sans", { size: "lg" }), - }, - externalLocationMessage: { - background: background(colorScheme.middle, "accent"), - border: border(colorScheme.middle, "accent"), - cornerRadius: 6, - padding: 12, - margin: { bottom: 8, right: 8 }, - ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), - }, - leaderBorderOpacity: 0.7, - leaderBorderWidth: 2.0, - tabBar: tabBar(colorScheme), - modal: { - margin: { - bottom: 52, - top: 52, - }, - cursor: "Arrow", - }, - zoomedBackground: { - cursor: "Arrow", - background: isLight - ? withOpacity(background(colorScheme.lowest), 0.8) - : withOpacity(background(colorScheme.highest), 0.6), - }, - zoomedPaneForeground: { - margin: 16, - shadow: colorScheme.modalShadow, - border: border(colorScheme.lowest, { overlay: true }), - }, - zoomedPanelForeground: { - margin: 16, - border: border(colorScheme.lowest, { overlay: true }), - }, - dock: { - left: { - border: border(layer, { right: true }), - }, - bottom: { - border: border(layer, { top: true }), - }, - right: { - border: border(layer, { left: true }), - }, - }, - paneDivider: { - color: borderColor(layer), - width: 1, - }, - statusBar: statusBar(colorScheme), - titlebar: { - itemSpacing, - facePileSpacing: 2, - height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. - background: background(layer), - border: border(layer, { bottom: true }), - padding: { - left: 80, - right: itemSpacing, - }, - - // Project - title: text(layer, "sans", "variant"), - highlight_color: text(layer, "sans", "active").color, - - // Collaborators - leaderAvatar: { - width: avatarWidth, - outerWidth: avatarOuterWidth, - cornerRadius: avatarWidth / 2, - outerCornerRadius: avatarOuterWidth / 2, - }, - followerAvatar: { - width: followerAvatarWidth, - outerWidth: followerAvatarOuterWidth, - cornerRadius: followerAvatarWidth / 2, - outerCornerRadius: followerAvatarOuterWidth / 2, - }, - inactiveAvatarGrayscale: true, - followerAvatarOverlap: 8, - leaderSelection: { - margin: { - top: 4, - bottom: 4, - }, - padding: { - left: 2, - right: 2, - top: 2, - bottom: 2, + externalLocationMessage: { + background: background(colorScheme.middle, "accent"), + border: border(colorScheme.middle, "accent"), + cornerRadius: 6, + padding: 12, + margin: { bottom: 8, right: 8 }, + ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), }, - cornerRadius: 6, - }, - avatarRibbon: { - height: 3, - width: 12, - // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. - }, - - // Sign in buttom - // FlatButton, Variant - signInPrompt: merge(titlebarButton, { - inactive: { - default: { + leaderBorderOpacity: 0.7, + leaderBorderWidth: 2.0, + tabBar: tabBar(colorScheme), + modal: { margin: { - left: itemSpacing, + bottom: 52, + top: 52, }, - }, - }, - }), - - // Offline Indicator - offlineIcon: { - color: foreground(layer, "variant"), - width: 16, - margin: { - left: itemSpacing, + cursor: "Arrow", }, - padding: { - right: 4, + zoomedBackground: { + cursor: "Arrow", + background: isLight + ? withOpacity(background(colorScheme.lowest), 0.8) + : withOpacity(background(colorScheme.highest), 0.6), }, - }, - - // Notice that the collaboration server is out of date - outdatedWarning: { - ...text(layer, "sans", "warning", { size: "xs" }), - background: withOpacity(background(layer, "warning"), 0.3), - border: border(layer, "warning"), - margin: { - left: itemSpacing, - }, - padding: { - left: 8, - right: 8, + zoomedPaneForeground: { + margin: 16, + shadow: colorScheme.modalShadow, + border: border(colorScheme.lowest, { overlay: true }), }, - cornerRadius: 6, - }, - callControl: interactive({ - base: { - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - }, - state: { - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, + zoomedPanelForeground: { + margin: 16, + border: border(colorScheme.lowest, { overlay: true }), }, - }), - toggleContactsButton: toggleable({ - base: - interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, + dock: { + left: { + border: border(layer, { right: true }), }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, + bottom: { + border: border(layer, { top: true }), }, - }), state: - { - active: { - default: { - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active"), + right: { + border: border(layer, { left: true }), }, - } - } - } - ), - userMenuButton: merge(titlebarButton, { - inactive: { - default: { - buttonWidth: 20, - iconWidth: 12, - }, }, - active: { - // posiewic: these properties are not currently set on main - default: { - iconWidth: 12, - button_width: 20, - }, + paneDivider: { + color: borderColor(layer), + width: 1, }, - }), + statusBar: statusBar(colorScheme), + titlebar: { + itemSpacing, + facePileSpacing: 2, + height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. + background: background(layer), + border: border(layer, { bottom: true }), + padding: { + left: 80, + right: itemSpacing, + }, - toggleContactsBadge: { - cornerRadius: 3, - padding: 2, - margin: { top: 3, left: 3 }, - border: border(layer), - background: foreground(layer, "accent"), - }, - shareButton: { - ...titlebarButton, - }, - }, + // Project + title: text(layer, "sans", "variant"), + highlight_color: text(layer, "sans", "active").color, - toolbar: { - height: 34, - background: background(colorScheme.highest), - border: border(colorScheme.highest, { bottom: true }), - itemSpacing: 8, - navButton: interactive({ - base: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, - }, - state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - disabled: { - color: foreground( - colorScheme.highest, - "on", - "disabled" + // Collaborators + leaderAvatar: { + width: avatarWidth, + outerWidth: avatarOuterWidth, + cornerRadius: avatarWidth / 2, + outerCornerRadius: avatarOuterWidth / 2, + }, + followerAvatar: { + width: followerAvatarWidth, + outerWidth: followerAvatarOuterWidth, + cornerRadius: followerAvatarWidth / 2, + outerCornerRadius: followerAvatarOuterWidth / 2, + }, + inactiveAvatarGrayscale: true, + followerAvatarOverlap: 8, + leaderSelection: { + margin: { + top: 4, + bottom: 4, + }, + padding: { + left: 2, + right: 2, + top: 2, + bottom: 2, + }, + cornerRadius: 6, + }, + avatarRibbon: { + height: 3, + width: 12, + // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. + }, + + // Sign in buttom + // FlatButton, Variant + signInPrompt: merge(titlebarButton, { + inactive: { + default: { + margin: { + left: itemSpacing, + }, + }, + }, + }), + + // Offline Indicator + offlineIcon: { + color: foreground(layer, "variant"), + width: 16, + margin: { + left: itemSpacing, + }, + padding: { + right: 4, + }, + }, + + // Notice that the collaboration server is out of date + outdatedWarning: { + ...text(layer, "sans", "warning", { size: "xs" }), + background: withOpacity(background(layer, "warning"), 0.3), + border: border(layer, "warning"), + margin: { + left: itemSpacing, + }, + padding: { + left: 8, + right: 8, + }, + cornerRadius: 6, + }, + callControl: interactive({ + base: { + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 20, + }, + state: { + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + }, + }), + toggleContactsButton: toggleable({ + base: + interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), + color: foreground(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + }, + }), state: + { + active: { + default: { + background: background(layer, "variant", "active"), + color: foreground(layer, "variant", "active"), + }, + } + } + } ), - }, + userMenuButton: merge(titlebarButton, { + inactive: { + default: { + buttonWidth: 20, + iconWidth: 12, + }, + }, + active: { + // posiewic: these properties are not currently set on main + default: { + iconWidth: 12, + button_width: 20, + }, + }, + }), + + toggleContactsBadge: { + cornerRadius: 3, + padding: 2, + margin: { top: 3, left: 3 }, + border: border(layer), + background: foreground(layer, "accent"), + }, + shareButton: { + ...titlebarButton, + }, + }, + + toolbar: { + height: 34, + background: background(colorScheme.highest), + border: border(colorScheme.highest, { bottom: true }), + itemSpacing: 8, + navButton: interactive({ + base: { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, + state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + disabled: { + color: foreground( + colorScheme.highest, + "on", + "disabled" + ), + }, + }, + }), + padding: { left: 8, right: 8, top: 4, bottom: 4 }, }, - }), - padding: { left: 8, right: 8, top: 4, bottom: 4 }, - }, - breadcrumbHeight: 24, - breadcrumbs: interactive({ - base: { - ...text(colorScheme.highest, "sans", "variant"), - cornerRadius: 6, - padding: { - left: 6, - right: 6, + breadcrumbHeight: 24, + breadcrumbs: interactive({ + base: { + ...text(colorScheme.highest, "sans", "variant"), + cornerRadius: 6, + padding: { + left: 6, + right: 6, + }, + }, + state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + }, + }), + disconnectedOverlay: { + ...text(layer, "sans"), + background: withOpacity(background(layer), 0.8), + }, + notification: { + margin: { top: 10 }, + background: background(colorScheme.middle), + cornerRadius: 6, + padding: 12, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, }, - }, - state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), + notifications: { + width: 400, + margin: { right: 10, bottom: 10 }, }, - }, - }), - disconnectedOverlay: { - ...text(layer, "sans"), - background: withOpacity(background(layer), 0.8), - }, - notification: { - margin: { top: 10 }, - background: background(colorScheme.middle), - cornerRadius: 6, - padding: 12, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - }, - notifications: { - width: 400, - margin: { right: 10, bottom: 10 }, - }, - dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), - } + dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), + } } From f1dc6124dd7687cadccee4e4eddcde5bf5caaa60 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 16:09:17 -0700 Subject: [PATCH 21/26] Fix rebase mistake --- crates/editor/src/element.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 835d53bc8c27e2357fd3b228891b817370d4a44d..9cc058133b8aafc95b7be6165229959b39096986 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1527,7 +1527,7 @@ impl EditorElement { enum JumpIcon {} MouseEventHandler::::new((*id).into(), cx, |state, _| { - let style = style.jump_icon.style_for(state, false); + let style = style.jump_icon.style_for(state); Svg::new("icons/arrow_up_right_8.svg") .with_color(style.color) .constrained() From 86506a89aba71d85afd0123af16fe13b527b59fc Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 21 Jun 2023 19:11:55 +0200 Subject: [PATCH 22/26] Remove theme_testbench --- Cargo.lock | 13 - Cargo.toml | 1 - crates/theme_testbench/Cargo.toml | 19 -- crates/theme_testbench/src/theme_testbench.rs | 300 ------------------ crates/zed/Cargo.toml | 1 - crates/zed/src/main.rs | 1 - 6 files changed, 335 deletions(-) delete mode 100644 crates/theme_testbench/Cargo.toml delete mode 100644 crates/theme_testbench/src/theme_testbench.rs diff --git a/Cargo.lock b/Cargo.lock index a4b12223e5a8fe6770464280bf652e08346a26ba..206859ee45584a7c183765b98e651ef8dfdc464b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6916,18 +6916,6 @@ dependencies = [ "workspace", ] -[[package]] -name = "theme_testbench" -version = "0.1.0" -dependencies = [ - "gpui", - "project", - "settings", - "smallvec", - "theme", - "workspace", -] - [[package]] name = "thiserror" version = "1.0.40" @@ -8888,7 +8876,6 @@ dependencies = [ "text", "theme", "theme_selector", - "theme_testbench", "thiserror", "tiny_http", "toml", diff --git a/Cargo.toml b/Cargo.toml index fca735596489a222208e2f65874efc4fcd04ffd5..a49d75d3e2f8ee9f4e6bc08df2813a92b49d6061 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,6 @@ members = [ "crates/text", "crates/theme", "crates/theme_selector", - "crates/theme_testbench", "crates/util", "crates/vim", "crates/workspace", diff --git a/crates/theme_testbench/Cargo.toml b/crates/theme_testbench/Cargo.toml deleted file mode 100644 index 32dca6a07ade6123617ae3bfa480a6c231f9cecb..0000000000000000000000000000000000000000 --- a/crates/theme_testbench/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "theme_testbench" -version = "0.1.0" -edition = "2021" -publish = false - -[lib] -path = "src/theme_testbench.rs" -doctest = false - - -[dependencies] -gpui = { path = "../gpui" } -theme = { path = "../theme" } -settings = { path = "../settings" } -workspace = { path = "../workspace" } -project = { path = "../project" } - -smallvec.workspace = true diff --git a/crates/theme_testbench/src/theme_testbench.rs b/crates/theme_testbench/src/theme_testbench.rs deleted file mode 100644 index 258249b59932c8c087d5e27a85cb75dea7dbf2f2..0000000000000000000000000000000000000000 --- a/crates/theme_testbench/src/theme_testbench.rs +++ /dev/null @@ -1,300 +0,0 @@ -use gpui::{ - actions, - color::Color, - elements::{ - AnyElement, Canvas, Container, ContainerStyle, Flex, Label, Margin, MouseEventHandler, - Padding, ParentElement, - }, - fonts::TextStyle, - AppContext, Border, Element, Entity, ModelHandle, Quad, Task, View, ViewContext, ViewHandle, - WeakViewHandle, -}; -use project::Project; -use theme::{ColorScheme, Layer, Style, StyleSet, ThemeSettings}; -use workspace::{item::Item, register_deserializable_item, Pane, Workspace}; - -actions!(theme, [DeployThemeTestbench]); - -pub fn init(cx: &mut AppContext) { - cx.add_action(ThemeTestbench::deploy); - - register_deserializable_item::(cx) -} - -pub struct ThemeTestbench {} - -impl ThemeTestbench { - pub fn deploy( - workspace: &mut Workspace, - _: &DeployThemeTestbench, - cx: &mut ViewContext, - ) { - let view = cx.add_view(|_| ThemeTestbench {}); - workspace.add_item(Box::new(view), cx); - } - - fn render_ramps(color_scheme: &ColorScheme) -> Flex { - fn display_ramp(ramp: &Vec) -> AnyElement { - Flex::row() - .with_children(ramp.iter().cloned().map(|color| { - Canvas::new(move |scene, bounds, _, _, _| { - scene.push_quad(Quad { - bounds, - background: Some(color), - ..Default::default() - }); - }) - .flex(1.0, false) - })) - .flex(1.0, false) - .into_any() - } - - Flex::column() - .with_child(display_ramp(&color_scheme.ramps.neutral)) - .with_child(display_ramp(&color_scheme.ramps.red)) - .with_child(display_ramp(&color_scheme.ramps.orange)) - .with_child(display_ramp(&color_scheme.ramps.yellow)) - .with_child(display_ramp(&color_scheme.ramps.green)) - .with_child(display_ramp(&color_scheme.ramps.cyan)) - .with_child(display_ramp(&color_scheme.ramps.blue)) - .with_child(display_ramp(&color_scheme.ramps.violet)) - .with_child(display_ramp(&color_scheme.ramps.magenta)) - } - - fn render_layer( - layer_index: usize, - layer: &Layer, - cx: &mut ViewContext, - ) -> Container { - Flex::column() - .with_child( - Self::render_button_set(0, layer_index, "base", &layer.base, cx).flex(1., false), - ) - .with_child( - Self::render_button_set(1, layer_index, "variant", &layer.variant, cx) - .flex(1., false), - ) - .with_child( - Self::render_button_set(2, layer_index, "on", &layer.on, cx).flex(1., false), - ) - .with_child( - Self::render_button_set(3, layer_index, "accent", &layer.accent, cx) - .flex(1., false), - ) - .with_child( - Self::render_button_set(4, layer_index, "positive", &layer.positive, cx) - .flex(1., false), - ) - .with_child( - Self::render_button_set(5, layer_index, "warning", &layer.warning, cx) - .flex(1., false), - ) - .with_child( - Self::render_button_set(6, layer_index, "negative", &layer.negative, cx) - .flex(1., false), - ) - .contained() - .with_style(ContainerStyle { - margin: Margin { - top: 10., - bottom: 10., - left: 10., - right: 10., - }, - background_color: Some(layer.base.default.background), - ..Default::default() - }) - } - - fn render_button_set( - set_index: usize, - layer_index: usize, - set_name: &'static str, - style_set: &StyleSet, - cx: &mut ViewContext, - ) -> Flex { - Flex::row() - .with_child(Self::render_button( - set_index * 6, - layer_index, - set_name, - &style_set, - None, - cx, - )) - .with_child(Self::render_button( - set_index * 6 + 1, - layer_index, - "hovered", - &style_set, - Some(|style_set| &style_set.hovered), - cx, - )) - .with_child(Self::render_button( - set_index * 6 + 2, - layer_index, - "pressed", - &style_set, - Some(|style_set| &style_set.pressed), - cx, - )) - .with_child(Self::render_button( - set_index * 6 + 3, - layer_index, - "active", - &style_set, - Some(|style_set| &style_set.active), - cx, - )) - .with_child(Self::render_button( - set_index * 6 + 4, - layer_index, - "disabled", - &style_set, - Some(|style_set| &style_set.disabled), - cx, - )) - .with_child(Self::render_button( - set_index * 6 + 5, - layer_index, - "inverted", - &style_set, - Some(|style_set| &style_set.inverted), - cx, - )) - } - - fn render_button( - button_index: usize, - layer_index: usize, - text: &'static str, - style_set: &StyleSet, - style_override: Option &Style>, - cx: &mut ViewContext, - ) -> AnyElement { - enum TestBenchButton {} - MouseEventHandler::::new(layer_index + button_index, cx, |state, cx| { - let style = if let Some(style_override) = style_override { - style_override(&style_set) - } else if state.clicked().is_some() { - &style_set.pressed - } else if state.hovered() { - &style_set.hovered - } else { - &style_set.default - }; - - Self::render_label(text.to_string(), style, cx) - .contained() - .with_style(ContainerStyle { - margin: Margin { - top: 4., - bottom: 4., - left: 4., - right: 4., - }, - padding: Padding { - top: 4., - bottom: 4., - left: 4., - right: 4., - }, - background_color: Some(style.background), - border: Border { - width: 1., - color: style.border, - overlay: false, - top: true, - bottom: true, - left: true, - right: true, - }, - corner_radius: 2., - ..Default::default() - }) - }) - .flex(1., true) - .into_any() - } - - fn render_label(text: String, style: &Style, cx: &mut ViewContext) -> Label { - let settings = settings::get::(cx); - let font_cache = cx.font_cache(); - let family_id = settings.buffer_font_family; - let font_size = settings.buffer_font_size(cx); - let font_id = font_cache - .select_font(family_id, &Default::default()) - .unwrap(); - - let text_style = TextStyle { - color: style.foreground, - font_family_id: family_id, - font_family_name: font_cache.family_name(family_id).unwrap(), - font_id, - font_size, - font_properties: Default::default(), - underline: Default::default(), - }; - - Label::new(text, text_style) - } -} - -impl Entity for ThemeTestbench { - type Event = (); -} - -impl View for ThemeTestbench { - fn ui_name() -> &'static str { - "ThemeTestbench" - } - - fn render(&mut self, cx: &mut gpui::ViewContext) -> AnyElement { - let color_scheme = &theme::current(cx).clone().color_scheme; - - Flex::row() - .with_child( - Self::render_ramps(color_scheme) - .contained() - .with_margin_right(10.) - .flex(0.1, false), - ) - .with_child( - Flex::column() - .with_child(Self::render_layer(100, &color_scheme.lowest, cx).flex(1., true)) - .with_child(Self::render_layer(200, &color_scheme.middle, cx).flex(1., true)) - .with_child(Self::render_layer(300, &color_scheme.highest, cx).flex(1., true)) - .flex(1., false), - ) - .into_any() - } -} - -impl Item for ThemeTestbench { - fn tab_content( - &self, - _: Option, - style: &theme::Tab, - _: &AppContext, - ) -> AnyElement { - Label::new("Theme Testbench", style.label.clone()) - .aligned() - .contained() - .into_any() - } - - fn serialized_item_kind() -> Option<&'static str> { - Some("ThemeTestBench") - } - - fn deserialize( - _project: ModelHandle, - _workspace: WeakViewHandle, - _workspace_id: workspace::WorkspaceId, - _item_id: workspace::ItemId, - cx: &mut ViewContext, - ) -> Task>> { - Task::ready(Ok(cx.add_view(|_| Self {}))) - } -} diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index d8e47d1c3ea6a0ce2fe099a11a37ee53d66158b2..6c15973b50b0bf81a203cf83fc68ceaada5e20b2 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -62,7 +62,6 @@ text = { path = "../text" } terminal_view = { path = "../terminal_view" } theme = { path = "../theme" } theme_selector = { path = "../theme_selector" } -theme_testbench = { path = "../theme_testbench" } util = { path = "../util" } vim = { path = "../vim" } workspace = { path = "../workspace" } diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index dcdf5c1ea5f542339cfac3ef7edeac61c5ab34c4..23ecbf978ba3b4a9d66d19022743cb9da46f2143 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -154,7 +154,6 @@ fn main() { search::init(cx); vim::init(cx); terminal_view::init(cx); - theme_testbench::init(cx); copilot::init(http.clone(), node_runtime, cx); ai::init(cx); From 127f4aa506118470cfc981f751eb1ffb27befb44 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 13:14:39 -0400 Subject: [PATCH 23/26] Fix status bar buttons --- styles/src/styleTree/statusBar.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index e4a48e8215dd2ebed127ed237f2b4faa977cacd5..636da15badf7c6c1569a5818c56f73706287108c 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -132,6 +132,15 @@ export default function statusBar(colorScheme: ColorScheme) { iconColor: foreground(layer, "active"), background: background(layer, "active"), }, + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "hovered"), + }, + clicked: { + iconColor: foreground(layer, "pressed"), + background: background(layer, "pressed"), + }, + } } } From ed8bdd186e9515e648a83d3448e7c9805cb3d2eb Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 13:56:27 -0400 Subject: [PATCH 24/26] Update toggle active styles --- styles/src/styleTree/contactList.ts | 13 ++++- styles/src/styleTree/contextMenu.ts | 8 ++- styles/src/styleTree/editor.ts | 27 +++++++---- styles/src/styleTree/picker.ts | 19 +++++++- styles/src/styleTree/projectPanel.ts | 54 +++++++++++++-------- styles/src/styleTree/search.ts | 23 ++++++--- styles/src/styleTree/tabBar.ts | 9 ++++ styles/src/styleTree/toolbarDropdownMenu.ts | 9 ++-- styles/src/styleTree/workspace.ts | 11 +++-- 9 files changed, 126 insertions(+), 47 deletions(-) diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 57034109f1553e8f093dfb22b946ad4485d4573f..cee17219c82925629a06fd1fda4c6e31bec1a42a 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -83,7 +83,12 @@ export default function contactsPanel(colorScheme: ColorScheme) { background: background(layer, "default"), // posiewic: breaking change }, state: { - hovered: { background: background(layer, "default") }, + hovered: { + background: background(layer, "hovered"), + }, + clicked: { + background: background(layer, "pressed"), + } }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. }), state: { @@ -92,6 +97,12 @@ export default function contactsPanel(colorScheme: ColorScheme) { ...text(layer, "mono", "active", { size: "sm" }), background: background(layer, "active"), }, + hovered: { + background: background(layer, "hovered"), + }, + clicked: { + background: background(layer, "pressed"), + } } } }), diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 7b2b9be6c2aaec640aa5df934a0e4401ff131afe..a217018c977f75e8483921387acf602c549c2482 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -40,6 +40,9 @@ export default function contextMenu(colorScheme: ColorScheme) { padding: { left: 3, right: 3 }, }, }, + clicked: { + background: background(layer, "pressed"), + }, }, }), state: { @@ -48,7 +51,10 @@ export default function contextMenu(colorScheme: ColorScheme) { background: background(layer, "active"), }, hovered: { - background: background(layer, "active"), + background: background(layer, "hovered"), + }, + clicked: { + background: background(layer, "pressed"), }, } } diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index b02366192a9e1e77cec84d256e9fb68d4370f02c..62792f6febaade285aa9809de59748548c6e7e97 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -56,18 +56,24 @@ export default function editor(colorScheme: ColorScheme) { color: foreground(layer, "variant"), }, state: { - clicked: { - color: foreground(layer, "base"), - }, hovered: { - color: foreground(layer, "on"), + color: foreground(layer, "variant", "hovered"), + }, + clicked: { + color: foreground(layer, "variant", "pressed"), }, }, }), state: { active: { default: { - color: foreground(layer, "on"), + color: foreground(layer, "accent"), + }, + hovered: { + color: foreground(layer, "accent", "hovered"), + }, + clicked: { + color: foreground(layer, "accent", "pressed"), }, } } @@ -87,18 +93,21 @@ export default function editor(colorScheme: ColorScheme) { color: foreground(layer, "variant"), }, state: { - clicked: { - color: foreground(layer, "base"), - }, hovered: { color: foreground(layer, "on"), }, + clicked: { + color: foreground(layer, "base"), + }, }, }), state: { active: { default: { - color: foreground(layer, "on"), + color: foreground(layer, "default"), + }, + hovered: { + color: foreground(layer, "variant"), }, } } diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 809cd1743ff9f21684407132c7ce734757a01869..57ee71efb40f1d96f44f45bb6bd00ac75f6e5ea0 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -67,6 +67,12 @@ export default function picker(colorScheme: ColorScheme): any { 0.5 ), }, + clicked: { + background: withOpacity( + background(layer, "pressed"), + 0.5 + ), + }, }, }), state: { @@ -76,7 +82,18 @@ export default function picker(colorScheme: ColorScheme): any { background(layer, "base", "active"), 0.5 ), - //text: text(layer, "sans", "base", "active"), + }, + hovered: { + background: withOpacity( + background(layer, "hovered"), + 0.5 + ), + }, + clicked: { + background: withOpacity( + background(layer, "pressed"), + 0.5 + ), }, } } diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 7c37ce6bd3ebbc2f0199171d65ba2121769347e0..2c94a51dbaded161bfffa755f1052b08a16c1f7e 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -28,33 +28,44 @@ export default function projectPanel(colorScheme: ColorScheme) { }, } + const default_entry = interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, + state: { + default: { + background: background(layer), + }, + hovered: { + background: background(layer, "variant", "hovered"), + }, + clicked: { + background: background(layer, "variant", "pressed"), + } + }, + }) + let entry = toggleable({ - base: - interactive({ + base: default_entry, + state: { + active: interactive({ base: { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, + ...default_entry }, state: { + default: { + background: background(colorScheme.lowest), + }, hovered: { - background: background(layer, "variant", "hovered"), + background: background(colorScheme.lowest, "hovered"), + }, + clicked: { + background: background(colorScheme.lowest, "pressed"), }, }, }), - state: { - active: { - default: { - /*background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active") ,*/ // todo posiewic - text: text(layer, "mono", "active", { size: "sm" }), - }, - hovered: { - //background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - } } } ) @@ -84,6 +95,11 @@ export default function projectPanel(colorScheme: ColorScheme) { background: background(layer, "hovered"), border: border(layer, "active"), }, + clicked: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "pressed"), + border: border(layer, "active"), + } }, }), background: background(layer), diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index 0123ddee22b40536a823f36e3f437c20bb353b27..40816e673c774e153ca30175d306c7ff025b1987 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -55,24 +55,28 @@ export default function search(colorScheme: ColorScheme) { }, }, state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, hovered: { ...text(layer, "mono", "on", "hovered"), background: background(layer, "on", "hovered"), border: border(layer, "on", "hovered"), }, + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, }, }), state: { active: { default: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), + ...text(layer, "mono", "accent"), + }, + hovered: { + ...text(layer, "mono", "accent", "hovered"), + }, + clicked: { + ...text(layer, "mono", "accent", "pressed"), }, } } @@ -124,6 +128,9 @@ export default function search(colorScheme: ColorScheme) { hovered: { color: foreground(layer, "hovered"), }, + clicked: { + color: foreground(layer, "pressed"), + }, }, }), } diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index f2c99ea736d18d717c865ab1b8d0ff48efcff3bd..85291c9edb52e8d4b89722014244b61a2a591da8 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -100,6 +100,9 @@ export default function tabBar(colorScheme: ColorScheme) { hovered: { color: foreground(layer, "hovered"), }, + clicked: { + color: foreground(layer, "pressed"), + }, }, }), state: @@ -108,6 +111,12 @@ export default function tabBar(colorScheme: ColorScheme) { default: { color: foreground(layer, "accent"), }, + hovered: { + color: foreground(layer, "hovered"), + }, + clicked: { + color: foreground(layer, "pressed"), + }, } } } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index b1b28d789e11dd34cb856785648c5f371abccb77..3837f5e1a4f2a96dd5701c61922785e2f6da6404 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -19,13 +19,14 @@ export default function dropdownMenu(colorScheme: ColorScheme) { secondaryTextSpacing: 10, padding: { left: 8, right: 8, top: 2, bottom: 2 }, cornerRadius: 6, - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), + background: background(layer, "on") }, state: { hovered: { background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), + }, + clicked: { + background: background(layer, "pressed"), }, }, }), @@ -55,7 +56,7 @@ export default function dropdownMenu(colorScheme: ColorScheme) { background: background(layer, "active"), }, hovered: { - background: background(layer, "active"), + background: background(layer, "hovered"), }, } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index fdc7657481df832bc189e20c00f2873b036c9361..d835dfe3a138085d69943f595e3dc597171381fe 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -287,20 +287,23 @@ export default function workspace(colorScheme: ColorScheme) { state: { clicked: { background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), }, hovered: { background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), }, }, }), state: { active: { default: { - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active"), + background: background(layer, "on", "default"), }, + hovered: { + background: background(layer, "on", "hovered"), + }, + clicked: { + background: background(layer, "on", "pressed"), + } } } } From a845e82173366e2e37504ea9b3f6cf0582c0995d Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 13:58:42 -0400 Subject: [PATCH 25/26] Update settings.json --- styles/.zed/settings.json | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/styles/.zed/settings.json b/styles/.zed/settings.json index 0a3c761b8e57ee5c3808c0ac3aa0a1db336ff273..5c31fc5ac13790f1fc813811dce63904b9a79b6a 100644 --- a/styles/.zed/settings.json +++ b/styles/.zed/settings.json @@ -3,9 +3,18 @@ // For a full list of overridable settings, and general information on folder-specific settings, // see the documentation: https://docs.zed.dev/configuration/configuring-zed#folder-specific-settings { - "languages": { - "TypeScript": { - "tab_size": 4 + "languages": { + "TypeScript": { + "tab_size": 4 + }, + "TSX": { + "tab_size": 4 + }, + "JavaScript": { + "tab_size": 4 + }, + "JSON": { + "tab_size": 4 + } } - } } From 9d9bbfdabfb04389beb7989babed076369ce3cb5 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 13:58:54 -0400 Subject: [PATCH 26/26] Format --- styles/src/buildTokens.ts | 86 +++++++------- styles/src/element/interactive.ts | 118 ++++++++++---------- styles/src/element/toggle.ts | 30 ++--- styles/src/styleTree/commandPalette.ts | 6 +- styles/src/styleTree/contactList.ts | 78 ++++++------- styles/src/styleTree/contextMenu.ts | 56 +++++----- styles/src/styleTree/editor.ts | 60 +++++----- styles/src/styleTree/picker.ts | 72 ++++++------ styles/src/styleTree/projectPanel.ts | 11 +- styles/src/styleTree/search.ts | 62 +++++----- styles/src/styleTree/statusBar.ts | 41 ++++--- styles/src/styleTree/tabBar.ts | 37 +++--- styles/src/styleTree/toolbarDropdownMenu.ts | 36 +++--- styles/src/styleTree/workspace.ts | 106 +++++++++--------- 14 files changed, 387 insertions(+), 412 deletions(-) diff --git a/styles/src/buildTokens.ts b/styles/src/buildTokens.ts index 0cf1ea037e779818d88d05383b1b8fffd6337ade..6c6acd2f2278aef4aa08ab54068f94dc5fc15223 100644 --- a/styles/src/buildTokens.ts +++ b/styles/src/buildTokens.ts @@ -1,13 +1,13 @@ -import * as fs from "fs"; -import * as path from "path"; -import { ColorScheme, createColorScheme } from "./common"; -import { themes } from "./themes"; -import { slugify } from "./utils/slugify"; -import { colorSchemeTokens } from "./theme/tokens/colorScheme"; +import * as fs from "fs" +import * as path from "path" +import { ColorScheme, createColorScheme } from "./common" +import { themes } from "./themes" +import { slugify } from "./utils/slugify" +import { colorSchemeTokens } from "./theme/tokens/colorScheme" -const TOKENS_DIRECTORY = path.join(__dirname, "..", "target", "tokens"); -const TOKENS_FILE = path.join(TOKENS_DIRECTORY, "$themes.json"); -const METADATA_FILE = path.join(TOKENS_DIRECTORY, "$metadata.json"); +const TOKENS_DIRECTORY = path.join(__dirname, "..", "target", "tokens") +const TOKENS_FILE = path.join(TOKENS_DIRECTORY, "$themes.json") +const METADATA_FILE = path.join(TOKENS_DIRECTORY, "$metadata.json") function clearTokens(tokensDirectory: string) { if (!fs.existsSync(tokensDirectory)) { @@ -22,64 +22,66 @@ function clearTokens(tokensDirectory: string) { } type TokenSet = { - id: string; - name: string; - selectedTokenSets: { [key: string]: "enabled" }; -}; + id: string + name: string + selectedTokenSets: { [key: string]: "enabled" } +} -function buildTokenSetOrder(colorSchemes: ColorScheme[]): { tokenSetOrder: string[] } { - const tokenSetOrder: string[] = colorSchemes.map( - (scheme) => scheme.name.toLowerCase().replace(/\s+/g, "_") - ); - return { tokenSetOrder }; +function buildTokenSetOrder(colorSchemes: ColorScheme[]): { + tokenSetOrder: string[] +} { + const tokenSetOrder: string[] = colorSchemes.map((scheme) => + scheme.name.toLowerCase().replace(/\s+/g, "_") + ) + return { tokenSetOrder } } function buildThemesIndex(colorSchemes: ColorScheme[]): TokenSet[] { const themesIndex: TokenSet[] = colorSchemes.map((scheme, index) => { const id = `${scheme.isLight ? "light" : "dark"}_${scheme.name .toLowerCase() - .replace(/\s+/g, "_")}_${index}`; - const selectedTokenSets: { [key: string]: "enabled" } = {}; - const tokenSet = scheme.name.toLowerCase().replace(/\s+/g, "_"); - selectedTokenSets[tokenSet] = "enabled"; + .replace(/\s+/g, "_")}_${index}` + const selectedTokenSets: { [key: string]: "enabled" } = {} + const tokenSet = scheme.name.toLowerCase().replace(/\s+/g, "_") + selectedTokenSets[tokenSet] = "enabled" return { id, name: `${scheme.name} - ${scheme.isLight ? "Light" : "Dark"}`, selectedTokenSets, - }; - }); + } + }) - return themesIndex; + return themesIndex } function writeTokens(colorSchemes: ColorScheme[], tokensDirectory: string) { - clearTokens(tokensDirectory); + clearTokens(tokensDirectory) for (const colorScheme of colorSchemes) { - const fileName = slugify(colorScheme.name) + ".json"; - const tokens = colorSchemeTokens(colorScheme); - const tokensJSON = JSON.stringify(tokens, null, 2); - const outPath = path.join(tokensDirectory, fileName); - fs.writeFileSync(outPath, tokensJSON, { mode: 0o644 }); - console.log(`- ${outPath} created`); + const fileName = slugify(colorScheme.name) + ".json" + const tokens = colorSchemeTokens(colorScheme) + const tokensJSON = JSON.stringify(tokens, null, 2) + const outPath = path.join(tokensDirectory, fileName) + fs.writeFileSync(outPath, tokensJSON, { mode: 0o644 }) + console.log(`- ${outPath} created`) } - const themeIndexData = buildThemesIndex(colorSchemes); + const themeIndexData = buildThemesIndex(colorSchemes) - const themesJSON = JSON.stringify(themeIndexData, null, 2); - fs.writeFileSync(TOKENS_FILE, themesJSON, { mode: 0o644 }); - console.log(`- ${TOKENS_FILE} created`); + const themesJSON = JSON.stringify(themeIndexData, null, 2) + fs.writeFileSync(TOKENS_FILE, themesJSON, { mode: 0o644 }) + console.log(`- ${TOKENS_FILE} created`) - const tokenSetOrderData = buildTokenSetOrder(colorSchemes); + const tokenSetOrderData = buildTokenSetOrder(colorSchemes) - const metadataJSON = JSON.stringify(tokenSetOrderData, null, 2); - fs.writeFileSync(METADATA_FILE, metadataJSON, { mode: 0o644 }); - console.log(`- ${METADATA_FILE} created`); + const metadataJSON = JSON.stringify(tokenSetOrderData, null, 2) + fs.writeFileSync(METADATA_FILE, metadataJSON, { mode: 0o644 }) + console.log(`- ${METADATA_FILE} created`) } const colorSchemes: ColorScheme[] = themes.map((theme) => createColorScheme(theme) -); +) -writeTokens(colorSchemes, TOKENS_DIRECTORY); +writeTokens(colorSchemes, TOKENS_DIRECTORY) diff --git a/styles/src/element/interactive.ts b/styles/src/element/interactive.ts index bd90e28aadb2b515cca4c5b626dd7e0b005fa373..1c0f393cff5041e27fb4e295b4ead5f1a2c43c75 100644 --- a/styles/src/element/interactive.ts +++ b/styles/src/element/interactive.ts @@ -2,28 +2,28 @@ import merge from "ts-deepmerge" import { DeepPartial } from "utility-types" type InteractiveState = - | "default" - | "hovered" - | "clicked" - | "selected" - | "disabled" + | "default" + | "hovered" + | "clicked" + | "selected" + | "disabled" type Interactive = { - default: T - hovered?: T - clicked?: T - selected?: T - disabled?: T + default: T + hovered?: T + clicked?: T + selected?: T + disabled?: T } export const NO_DEFAULT_OR_BASE_ERROR = - "An interactive object must have a default state, or a base property." + "An interactive object must have a default state, or a base property." export const NOT_ENOUGH_STATES_ERROR = - "An interactive object must have a default and at least one other state." + "An interactive object must have a default and at least one other state." interface InteractiveProps { - base?: T - state: Partial>> + base?: T + state: Partial>> } /** @@ -38,60 +38,60 @@ interface InteractiveProps { * @returns Interactive object with fields from `base` and `state`. */ export function interactive({ - base, - state, + base, + state, }: InteractiveProps): Interactive { - if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR) + if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR) - let defaultState: T + let defaultState: T - if (state.default && base) { - defaultState = merge(base, state.default) as T - } else { - defaultState = base ? base : (state.default as T) - } + if (state.default && base) { + defaultState = merge(base, state.default) as T + } else { + defaultState = base ? base : (state.default as T) + } - let interactiveObj: Interactive = { - default: defaultState, - } + let interactiveObj: Interactive = { + default: defaultState, + } - let stateCount = 0 + let stateCount = 0 - if (state.hovered !== undefined) { - interactiveObj.hovered = merge( - interactiveObj.default, - state.hovered - ) as T - stateCount++ - } + if (state.hovered !== undefined) { + interactiveObj.hovered = merge( + interactiveObj.default, + state.hovered + ) as T + stateCount++ + } - if (state.clicked !== undefined) { - interactiveObj.clicked = merge( - interactiveObj.default, - state.clicked - ) as T - stateCount++ - } + if (state.clicked !== undefined) { + interactiveObj.clicked = merge( + interactiveObj.default, + state.clicked + ) as T + stateCount++ + } - if (state.selected !== undefined) { - interactiveObj.selected = merge( - interactiveObj.default, - state.selected - ) as T - stateCount++ - } + if (state.selected !== undefined) { + interactiveObj.selected = merge( + interactiveObj.default, + state.selected + ) as T + stateCount++ + } - if (state.disabled !== undefined) { - interactiveObj.disabled = merge( - interactiveObj.default, - state.disabled - ) as T - stateCount++ - } + if (state.disabled !== undefined) { + interactiveObj.disabled = merge( + interactiveObj.default, + state.disabled + ) as T + stateCount++ + } - if (stateCount < 1) { - throw new Error(NOT_ENOUGH_STATES_ERROR) - } + if (stateCount < 1) { + throw new Error(NOT_ENOUGH_STATES_ERROR) + } - return interactiveObj + return interactiveObj } diff --git a/styles/src/element/toggle.ts b/styles/src/element/toggle.ts index cbf28b71e7050f2e72e831618f3bf5bbac6c376f..ead8f1e8248d16241706d2098067a913d8737917 100644 --- a/styles/src/element/toggle.ts +++ b/styles/src/element/toggle.ts @@ -6,12 +6,12 @@ type ToggleState = "inactive" | "active" type Toggleable = Record export const NO_INACTIVE_OR_BASE_ERROR = - "A toggleable object must have an inactive state, or a base property." + "A toggleable object must have an inactive state, or a base property." export const NO_ACTIVE_ERROR = "A toggleable object must have an active state." interface ToggleableProps { - base?: T - state: Partial>> + base?: T + state: Partial>> } /** @@ -28,20 +28,20 @@ interface ToggleableProps { * ``` */ export function toggleable( - props: ToggleableProps + props: ToggleableProps ): Toggleable { - const { base, state } = props + const { base, state } = props - if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) - if (!state.active) throw new Error(NO_ACTIVE_ERROR) + if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) + if (!state.active) throw new Error(NO_ACTIVE_ERROR) - const inactiveState = base - ? ((state.inactive ? merge(base, state.inactive) : base) as T) - : (state.inactive as T) + const inactiveState = base + ? ((state.inactive ? merge(base, state.inactive) : base) as T) + : (state.inactive as T) - const toggleObj: Toggleable = { - inactive: inactiveState, - active: merge(base ?? {}, state.active) as T, - } - return toggleObj + const toggleObj: Toggleable = { + inactive: inactiveState, + active: merge(base ?? {}, state.active) as T, + } + return toggleObj } diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 5389a775ed0ae564335cdc1d1b3ebad6f2c31e0b..5d4b7373c36169de47219f357a27046acf59d8b1 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -27,8 +27,8 @@ export default function commandPalette(colorScheme: ColorScheme) { active: { text: text(layer, "mono", "on", "default", { size: "xs" }), background: withOpacity(background(layer, "on"), 0.2), - } - } + }, + }, }) return { @@ -37,6 +37,6 @@ export default function commandPalette(colorScheme: ColorScheme) { key: { inactive: { ...key.inactive }, active: key.active, - } + }, } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index cee17219c82925629a06fd1fda4c6e31bec1a42a..88ae04277eea5e0b8417da48f38495d513a8a03e 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -88,7 +88,7 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, clicked: { background: background(layer, "pressed"), - } + }, }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. }), state: { @@ -102,9 +102,9 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, clicked: { background: background(layer, "pressed"), - } - } - } + }, + }, + }, }), leaveCall: interactive({ base: { @@ -190,55 +190,51 @@ export default function contactsPanel(colorScheme: ColorScheme) { ...text(layer, "mono", "variant", { size: "xs" }), }, treeBranch: toggleable({ - base: - interactive({ - base: { + base: interactive({ + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { color: borderColor(layer), - width: 1, }, - state: { - hovered: { - color: borderColor(layer), - }, - }, - }), + }, + }), state: { active: { default: { color: borderColor(layer), }, - } - } - } - ), + }, + }, + }), projectRow: toggleable({ - base: - interactive({ - base: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, - }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), - }, + base: interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, }, - state: { - hovered: { - background: background(layer, "hovered"), - }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), }, - }), + }, + state: { + hovered: { + background: background(layer, "hovered"), + }, + }, + }), state: { active: { default: { background: background(layer, "active") }, - } - } - } - ), + }, + }, + }), } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index a217018c977f75e8483921387acf602c549c2482..a59284c43a4a096e0cd7a739dc5b76ab0158ded5 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -12,39 +12,38 @@ export default function contextMenu(colorScheme: ColorScheme) { border: border(layer), keystrokeMargin: 30, item: toggleable({ - base: - interactive({ - base: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), + base: interactive({ + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), keystroke: { - ...text(layer, "sans", "variant", { + ...text(layer, "sans", "hovered", { size: "sm", weight: "bold", }), padding: { left: 3, right: 3 }, }, }, - state: { - hovered: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "hovered", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - }, - clicked: { - background: background(layer, "pressed"), - }, + clicked: { + background: background(layer, "pressed"), }, - }), + }, + }), state: { active: { default: { @@ -56,10 +55,9 @@ export default function contextMenu(colorScheme: ColorScheme) { clicked: { background: background(layer, "pressed"), }, - } - } - } - ), + }, + }, + }), separator: { background: borderColor(layer), diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 62792f6febaade285aa9809de59748548c6e7e97..c53f3ba2ff54d7ec2c48547f4bd77236cad85b77 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -50,20 +50,19 @@ export default function editor(colorScheme: ColorScheme) { suggestion: syntax.predictive, codeActions: { indicator: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), + base: interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + hovered: { + color: foreground(layer, "variant", "hovered"), }, - state: { - hovered: { - color: foreground(layer, "variant", "hovered"), - }, - clicked: { - color: foreground(layer, "variant", "pressed"), - }, + clicked: { + color: foreground(layer, "variant", "pressed"), }, - }), + }, + }), state: { active: { default: { @@ -75,10 +74,9 @@ export default function editor(colorScheme: ColorScheme) { clicked: { color: foreground(layer, "accent", "pressed"), }, - } - } - } - ), + }, + }, + }), verticalScale: 0.55, }, @@ -87,20 +85,19 @@ export default function editor(colorScheme: ColorScheme) { foldedIcon: "icons/chevron_right_8.svg", foldableIcon: "icons/chevron_down_8.svg", indicator: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), + base: interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + hovered: { + color: foreground(layer, "on"), }, - state: { - hovered: { - color: foreground(layer, "on"), - }, - clicked: { - color: foreground(layer, "base"), - }, + clicked: { + color: foreground(layer, "base"), }, - }), + }, + }), state: { active: { default: { @@ -109,10 +106,9 @@ export default function editor(colorScheme: ColorScheme) { hovered: { color: foreground(layer, "variant"), }, - } - } - } - ), + }, + }, + }), ellipses: { textColor: colorScheme.ramps.neutral(0.71).hex(), cornerRadiusFactor: 0.15, diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 57ee71efb40f1d96f44f45bb6bd00ac75f6e5ea0..5501bd4df2f5cd0cd21bcf53f5aa5d307e6ed0e6 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -40,41 +40,40 @@ export default function picker(colorScheme: ColorScheme): any { padding: {}, }, item: toggleable({ - base: - interactive({ - base: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, - }, - margin: { - top: 1, - left: 4, - right: 4, - }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { - weight: "bold", - }), + base: interactive({ + base: { + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, }, - state: { - hovered: { - background: withOpacity( - background(layer, "hovered"), - 0.5 - ), - }, - clicked: { - background: withOpacity( - background(layer, "pressed"), - 0.5 - ), - }, + margin: { + top: 1, + left: 4, + right: 4, }, - }), + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { + weight: "bold", + }), + }, + state: { + hovered: { + background: withOpacity( + background(layer, "hovered"), + 0.5 + ), + }, + clicked: { + background: withOpacity( + background(layer, "pressed"), + 0.5 + ), + }, + }, + }), state: { active: { default: { @@ -95,10 +94,9 @@ export default function picker(colorScheme: ColorScheme): any { 0.5 ), }, - } - } - } - ), + }, + }, + }), inputEditor, emptyInputEditor, diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 2c94a51dbaded161bfffa755f1052b08a16c1f7e..6bec9512883976e60d110d80d3feba294260ae04 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -43,7 +43,7 @@ export default function projectPanel(colorScheme: ColorScheme) { }, clicked: { background: background(layer, "variant", "pressed"), - } + }, }, }) @@ -52,7 +52,7 @@ export default function projectPanel(colorScheme: ColorScheme) { state: { active: interactive({ base: { - ...default_entry + ...default_entry, }, state: { default: { @@ -66,9 +66,8 @@ export default function projectPanel(colorScheme: ColorScheme) { }, }, }), - } - } - ) + }, + }) return { openProjectButton: interactive({ @@ -99,7 +98,7 @@ export default function projectPanel(colorScheme: ColorScheme) { ...text(layer, "sans", "default", { size: "sm" }), background: background(layer, "pressed"), border: border(layer, "active"), - } + }, }, }), background: background(layer), diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index 40816e673c774e153ca30175d306c7ff025b1987..b471e6cbdab31249acd93bd13fda824f4343fa13 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -37,36 +37,35 @@ export default function search(colorScheme: ColorScheme) { // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive matchBackground: withOpacity(foreground(layer, "accent"), 0.4), optionButton: toggleable({ - base: - interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - }, + base: interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, }, - state: { - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, }, - }), + }, + state: { + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + }, + }), state: { active: { default: { @@ -78,10 +77,9 @@ export default function search(colorScheme: ColorScheme) { clicked: { ...text(layer, "mono", "accent", "pressed"), }, - } - } - } - ), + }, + }, + }), editor, invalidEditor: { ...editor, diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 636da15badf7c6c1569a5818c56f73706287108c..339e2e40cf25535ac5e682b059bbe8e504e61bbf 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -108,25 +108,24 @@ export default function statusBar(colorScheme: ColorScheme) { groupBottom: {}, groupRight: {}, button: toggleable({ - base: - interactive({ - base: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, + base: interactive({ + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), }, - state: { - hovered: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - }, + }, + state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), }, - }), state: - { + }, + }), + state: { active: { default: { iconColor: foreground(layer, "active"), @@ -140,11 +139,9 @@ export default function statusBar(colorScheme: ColorScheme) { iconColor: foreground(layer, "pressed"), background: background(layer, "pressed"), }, - - } - } - } - ), + }, + }, + }), badge: { cornerRadius: 3, padding: 2, diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index 85291c9edb52e8d4b89722014244b61a2a591da8..af35a8fef4c379471f172950f96520626045a14c 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -89,24 +89,22 @@ export default function tabBar(colorScheme: ColorScheme) { }, draggedTab, paneButton: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, + base: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), }, - state: { - hovered: { - color: foreground(layer, "hovered"), - }, - clicked: { - color: foreground(layer, "pressed"), - }, + clicked: { + color: foreground(layer, "pressed"), }, - }), - state: - { + }, + }), + state: { active: { default: { color: foreground(layer, "accent"), @@ -117,10 +115,9 @@ export default function tabBar(colorScheme: ColorScheme) { clicked: { color: foreground(layer, "pressed"), }, - } - } - } - ), + }, + }, + }), paneButtonContainer: { background: tab.background, border: { diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 3837f5e1a4f2a96dd5701c61922785e2f6da6404..d82e5f1cde6ed4543dc3bbf4b9f3d224952da33e 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -19,7 +19,7 @@ export default function dropdownMenu(colorScheme: ColorScheme) { secondaryTextSpacing: 10, padding: { left: 8, right: 8, top: 2, bottom: 2 }, cornerRadius: 6, - background: background(layer, "on") + background: background(layer, "on"), }, state: { hovered: { @@ -35,21 +35,20 @@ export default function dropdownMenu(colorScheme: ColorScheme) { padding: { left: 8, right: 8, top: 8, bottom: 8 }, }, item: toggleable({ - base: - interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - }, + base: interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), }, - }), + }, + }), state: { active: { default: { @@ -58,9 +57,8 @@ export default function dropdownMenu(colorScheme: ColorScheme) { hovered: { background: background(layer, "hovered"), }, - } - } - } - ), + }, + }, + }), } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index d835dfe3a138085d69943f595e3dc597171381fe..bd14a3af727beb28252c6b30c928d98d963fe92a 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -18,37 +18,36 @@ export default function workspace(colorScheme: ColorScheme) { const isLight = colorScheme.isLight const itemSpacing = 8 const titlebarButton = toggleable({ - base: - interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), + base: interactive({ + base: { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, }, - state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { - size: "xs", - }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { - size: "xs", - }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, + state: { + hovered: { + ...text(layer, "sans", "variant", "hovered", { + size: "xs", + }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), }, - }), + clicked: { + ...text(layer, "sans", "variant", "pressed", { + size: "xs", + }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + }, + }, + }), state: { active: { default: { @@ -56,10 +55,9 @@ export default function workspace(colorScheme: ColorScheme) { background: background(layer, "variant", "active"), border: border(layer, "variant", "active"), }, - } - } - } - ) + }, + }, + }) const avatarWidth = 18 const avatarOuterWidth = avatarWidth + 4 const followerAvatarWidth = 14 @@ -275,25 +273,24 @@ export default function workspace(colorScheme: ColorScheme) { }, }), toggleContactsButton: toggleable({ - base: - interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, + base: interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - }, + hovered: { + background: background(layer, "variant", "hovered"), }, - }), state: - { + }, + }), + state: { active: { default: { background: background(layer, "on", "default"), @@ -303,11 +300,10 @@ export default function workspace(colorScheme: ColorScheme) { }, clicked: { background: background(layer, "on", "pressed"), - } - } - } - } - ), + }, + }, + }, + }), userMenuButton: merge(titlebarButton, { inactive: { default: {