From f8173ea8a4a8b3644100ddd7e574bcdedb1dbeb8 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 7 Jan 2020 06:31:33 -0800 Subject: [PATCH] Minor sidebar improvements Summary: ~~Two~~ Four small improvements in the sidebar, that give a cleaner look: 1. expanding the plugin section is now a small button instead of text 2. Star / unstar buttons are only shown on hover of a plugin 3. Used all caps for application names, since we are F A C E B O O K now :-P. 4. Fixed styling of loading status of apps, so that it is consistent with a fully loaded app Reviewed By: nikoant Differential Revision: D19297880 fbshipit-source-id: 0fee44511965fc22351eff589d253365c1c6f774 --- src/chrome/mainsidebar/MainSidebar2.tsx | 61 +++++++++++++++---------- src/chrome/mainsidebar/sidebarUtils.tsx | 50 +++++++++++--------- 2 files changed, 66 insertions(+), 45 deletions(-) diff --git a/src/chrome/mainsidebar/MainSidebar2.tsx b/src/chrome/mainsidebar/MainSidebar2.tsx index 321f901b1..959a1184e 100644 --- a/src/chrome/mainsidebar/MainSidebar2.tsx +++ b/src/chrome/mainsidebar/MainSidebar2.tsx @@ -26,6 +26,7 @@ import { SmallText, Info, HBox, + LoadingIndicator, } from 'flipper'; import React, { PureComponent, @@ -55,9 +56,7 @@ import { CategoryName, PluginIcon, PluginSidebarListItem, - ErrorIndicator, NoClients, - Spinner, NoDevices, getColorByApp, } from './sidebarUtils'; @@ -80,6 +79,8 @@ const SidebarSectionButton = styled('button')<{ fontSize: level === 3 ? 11 : 14, color, padding: `${level === 3 ? 0 : 8}px 10px 8px 9px`, + textTransform: 'capitalize', + fontVariantCaps: level === 2 ? 'all-small-caps' : 'normal', })); const SidebarSectionBody = styled('div')<{ @@ -88,8 +89,10 @@ const SidebarSectionBody = styled('div')<{ }>(({collapsed}) => ({ flexShrink: 0, overflow: 'hidden', - maxHeight: collapsed ? 0 : 1000, // might need increase if too many plugins... - transition: 'max-height 0.5s ease', + maxHeight: collapsed ? 0 : 2000, // might need increase if too many plugins... + transition: collapsed + ? 'max-height 0.5s ease-out' + : 'max-height 0.5s ease-in', })); const SidebarSection: React.FC<{ @@ -109,7 +112,7 @@ const SidebarSection: React.FC<{ color={color}> {typeof title === 'function' ? title(collapsed) : title} - {level < 3 && ( + {level < 3 && children && ( { ); })} - {uninitializedClients.map(entry => ( - - {entry.client.appName} - {entry.errorMessage ? ( - - ) : ( - - )} - - ))} {clients.length === 0 ? ( ) : ( @@ -272,6 +265,22 @@ class MainSidebar2 extends PureComponent { /> )) )} + {uninitializedClients.map(entry => ( + + {entry.client.appName} + {entry.errorMessage ? ( + + ) : ( + + )} + + } + level={2}> + ))} ); } @@ -488,22 +497,18 @@ const PluginList = memo(function PluginList({ {!allPluginsStarred && ( 0 && !selectedNonFavoritePlugin } title={collapsed => ( -
- {collapsed ? 'All plugins…' : 'Show less'} + -
+ )}> ); }); + +const ShowMoreButton = styled('div')({ + border: `1px solid ${colors.macOSTitleBarIconBlur}`, + width: 16, + height: 16, + borderRadius: 16, + marginLeft: 'auto', + marginRight: 'auto', + lineHeight: '12px', +}); diff --git a/src/chrome/mainsidebar/sidebarUtils.tsx b/src/chrome/mainsidebar/sidebarUtils.tsx index ce903c048..a3ded1d08 100644 --- a/src/chrome/mainsidebar/sidebarUtils.tsx +++ b/src/chrome/mainsidebar/sidebarUtils.tsx @@ -22,7 +22,7 @@ import { Spacer, Heading, } from 'flipper'; -import React, {Component} from 'react'; +import React, {useState, useCallback} from 'react'; import {StaticView} from '../../reducers/connections'; import {BackgroundColorProperty} from 'csstype'; @@ -135,7 +135,7 @@ export function centerInSidebar(component: any) { }); } -export class PluginSidebarListItem extends Component<{ +export const PluginSidebarListItem: React.FC<{ onClick: () => void; isActive: boolean; plugin: typeof FlipperBasePlugin; @@ -144,27 +144,33 @@ export class PluginSidebarListItem extends Component<{ provided?: any; onFavorite?: () => void; starred?: boolean; -}> { - render() { - const {isActive, plugin, onFavorite, starred} = this.props; - const iconColor = getColorByApp(this.props.app); +}> = function(props) { + const {isActive, plugin, onFavorite, starred} = props; + const iconColor = getColorByApp(props.app); + const [hovered, setHovered] = useState(false); - return ( - - - {plugin.title || plugin.id} - {starred !== undefined && ( - - )} - - ); - } -} + const onEnter = useCallback(() => setHovered(true), []); + const onLeave = useCallback(() => setHovered(false), []); + + return ( + + + {plugin.title || plugin.id} + {starred !== undefined && (hovered || isActive) && ( + + )} + + ); +}; export function getColorByApp(app?: string | null): string { let iconColor: string | undefined = (brandColors as any)[app!];