diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index cb696dab9d9a0259f91cb282f9e3be60e3c17dbe..52f0bc7d6180277dd601eee8517419769721853a 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -639,12 +639,17 @@ impl CollabTitlebarItem { avatar: Option>, cx: &mut ViewContext, ) -> AnyElement { - let titlebar = &theme.workspace.titlebar; - let avatar_style = &theme.workspace.titlebar.follower_avatar; + let tooltip = theme.tooltip.clone(); + let user_menu_button = &theme.titlebar; + let avatar_style = &user_menu_button.user_menu_button.avatar; Stack::new() .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.call_control.style_for(state); + let style = user_menu_button + .user_menu_button + .user_menu + .inactive_state() + .style_for(state); let mut dropdown = Flex::row().align_children_center(); @@ -658,15 +663,15 @@ impl CollabTitlebarItem { dropdown .with_child( Svg::new("icons/caret_down_8.svg") - .with_color(style.color) + .with_color(theme.titlebar.user_menu_button.icon.color) .constrained() - .with_width(style.icon_width) + .with_width(theme.titlebar.user_menu_button.icon.width) .contained() .into_any(), ) .aligned() .constrained() - .with_height(style.button_width) + .with_height(style.width) .contained() .with_style(style.container) .into_any() @@ -679,11 +684,10 @@ impl CollabTitlebarItem { 0, "Toggle user menu".to_owned(), Some(Box::new(ToggleUserMenu)), - theme.tooltip.clone(), + tooltip, cx, ) - .contained() - .with_margin_left(theme.workspace.titlebar.item_spacing), + .contained(), ) .with_child( ChildView::new(&self.user_menu, cx) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index b4a4ba69fd88df8bcc016d46871e951a1402fa8e..7de10db6c5684d46607d928ecf8f751e606b0ea2 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -65,6 +65,7 @@ pub struct Theme { pub feedback: FeedbackStyle, pub welcome: WelcomeStyle, pub color_scheme: ColorScheme, + pub titlebar: UserMenu, } #[derive(Deserialize, Default, Clone)] @@ -140,6 +141,16 @@ pub struct Titlebar { pub toggle_contacts_badge: ContainerStyle, } +#[derive(Clone, Deserialize, Default)] +pub struct UserMenu { + pub user_menu_button: UserMenuButton, +} +#[derive(Clone, Deserialize, Default)] +pub struct UserMenuButton { + pub user_menu: Toggleable>, + pub avatar: AvatarStyle, + pub icon: Icon, +} #[derive(Copy, Clone, Deserialize, Default)] pub struct AvatarStyle { #[serde(flatten)] diff --git a/styles/src/styleTree/app.ts b/styles/src/styleTree/app.ts index 754443cc5fb068c07df47f7672521dc68bc9ff17..d98e00383fe019c3fbf5f16168df519140b1c964 100644 --- a/styles/src/styleTree/app.ts +++ b/styles/src/styleTree/app.ts @@ -23,6 +23,7 @@ import feedback from "./feedback" import welcome from "./welcome" import copilot from "./copilot" import assistant from "./assistant" +import { titlebar } from "./titlebar" export default function app(colorScheme: ColorScheme): Object { return { @@ -36,6 +37,7 @@ export default function app(colorScheme: ColorScheme): Object { incomingCallNotification: incomingCallNotification(colorScheme), picker: picker(colorScheme), workspace: workspace(colorScheme), + titlebar: titlebar(colorScheme), copilot: copilot(colorScheme), welcome: welcome(colorScheme), contextMenu: contextMenu(colorScheme), diff --git a/styles/src/styleTree/titlebar.ts b/styles/src/styleTree/titlebar.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c2c2147f846d2c00625bfdf10bb804cee4780fd --- /dev/null +++ b/styles/src/styleTree/titlebar.ts @@ -0,0 +1,81 @@ +import { ColorScheme } from "../common"; +import { interactive, toggleable } from "../element" +import { background, foreground, text } from "./components"; + +const titlebarButton = (theme: ColorScheme) => toggleable({ + base: interactive({ + base: { + cornerRadius: 6, + height: 24, + width: 24, + padding: { + top: 4, + bottom: 4, + left: 4, + right: 4, + }, + ...text(theme.lowest, "sans", { size: "xs" }), + background: background(theme.lowest), + }, + state: { + hovered: { + ...text(theme.lowest, "sans", "hovered", { + size: "xs", + }), + background: background(theme.lowest, "hovered"), + }, + clicked: { + ...text(theme.lowest, "sans", "pressed", { + size: "xs", + }), + background: background(theme.lowest, "pressed"), + }, + }, + }), + state: { + active: { + default: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle), + }, + hovered: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle, "hovered"), + }, + clicked: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle, "pressed"), + }, + }, + } +}); + +/** +* Opens the User Menu when toggled +* +* When logged in shows the user's avatar and a chevron, +* When logged out only shows a chevron. +*/ +function userMenuButton(theme: ColorScheme) { + return { + userMenu: titlebarButton(theme), + avatar: { + icon_width: 16, + icon_height: 16, + cornerRadius: 4, + outerWidth: 10, + outerCornerRadius: 10 + }, + icon: { + width: 11, + height: 11, + color: foreground(theme.lowest) + } + } +} + +export function titlebar(theme: ColorScheme) { + return { + userMenuButton: userMenuButton(theme) + } +}