toggle right sidebar button

Reviewed By: elboman

Differential Revision: D47437493

fbshipit-source-id: c799dddb2bb1a7e6420f41670b130724bb1817eb
This commit is contained in:
Anton Kastritskiy
2023-07-18 03:52:34 -07:00
committed by Facebook GitHub Bot
parent 9882381e48
commit 9a5d421e0a
2 changed files with 43 additions and 31 deletions

View File

@@ -16,9 +16,7 @@ import {
BugOutlined, BugOutlined,
ApiOutlined, ApiOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import {SidebarRight} from './SandyIcons'; import {useStore} from '../utils/useStore';
import {useDispatch, useStore} from '../utils/useStore';
import {toggleRightSidebarVisible} from '../reducers/application';
import { import {
theme, theme,
Layout, Layout,
@@ -165,7 +163,6 @@ export const LeftRail = withTrackingScope(function LeftRail({
<Layout.Container center gap={10} padh={6}> <Layout.Container center gap={10} padh={6}>
<UpdateIndicator /> <UpdateIndicator />
<SandyRatingButton /> <SandyRatingButton />
<RightSidebarToggleButton />
<ExportEverythingEverywhereAllAtOnceButton /> <ExportEverythingEverywhereAllAtOnceButton />
<ExtrasMenu /> <ExtrasMenu />
</Layout.Container> </Layout.Container>
@@ -296,29 +293,6 @@ function ExtrasMenu() {
); );
} }
function RightSidebarToggleButton() {
const dispatch = useDispatch();
const rightSidebarAvailable = useStore(
(state) => state.application.rightSidebarAvailable,
);
const rightSidebarVisible = useStore(
(state) => state.application.rightSidebarVisible,
);
return (
<LeftRailButton
icon={<SidebarRight />}
small
title="Right Sidebar Toggle"
toggled={rightSidebarVisible}
disabled={!rightSidebarAvailable}
onClick={() => {
dispatch(toggleRightSidebarVisible());
}}
/>
);
}
function NotificationButton({ function NotificationButton({
toplevelSelection, toplevelSelection,
setToplevelSelection, setToplevelSelection,

View File

@@ -35,7 +35,10 @@ import {
VideoCameraOutlined, VideoCameraOutlined,
WarningOutlined, WarningOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import {toggleLeftSidebarVisible} from '../reducers/application'; import {
toggleLeftSidebarVisible,
toggleRightSidebarVisible,
} from '../reducers/application';
import {ToplevelProps} from './SandyApp'; import {ToplevelProps} from './SandyApp';
import PluginManager from '../chrome/plugin-manager/PluginManager'; import PluginManager from '../chrome/plugin-manager/PluginManager';
import {showEmulatorLauncher} from './appinspect/LaunchEmulator'; import {showEmulatorLauncher} from './appinspect/LaunchEmulator';
@@ -90,6 +93,7 @@ export const Navbar = withTrackingScope(function Navbar({
<SetupDoctorButton /> <SetupDoctorButton />
<NavbarButton label="Help" icon={QuestionCircleOutlined} /> <NavbarButton label="Help" icon={QuestionCircleOutlined} />
<NavbarButton label="More" icon={EllipsisOutlined} /> <NavbarButton label="More" icon={EllipsisOutlined} />
<RightSidebarToggleButton />
{config.showLogin && <LoginConnectivityButton />} {config.showLogin && <LoginConnectivityButton />}
</Layout.Horizontal> </Layout.Horizontal>
</Layout.Horizontal> </Layout.Horizontal>
@@ -114,6 +118,29 @@ function LeftSidebarToggleButton() {
); );
} }
function RightSidebarToggleButton() {
const dispatch = useDispatch();
const rightSidebarAvailable = useStore(
(state) => state.application.rightSidebarAvailable,
);
const rightSidebarVisible = useStore(
(state) => state.application.rightSidebarVisible,
);
return (
<NavbarButton
icon={LayoutOutlined}
flipIcon
label="Toggle R.Sidebar"
toggled={!rightSidebarVisible}
disabled={!rightSidebarAvailable}
onClick={() => {
dispatch(toggleRightSidebarVisible());
}}
/>
);
}
function LaunchEmulatorButton() { function LaunchEmulatorButton() {
const store = useStore(); const store = useStore();
@@ -184,14 +211,18 @@ function NavbarButton({
toggled = false, toggled = false,
onClick, onClick,
count, count,
disabled = false,
flipIcon = false,
}: { }: {
icon: typeof LoginOutlined; icon: (props: any) => any;
label: string; label: string;
selected?: boolean; selected?: boolean;
// TODO remove optional // TODO remove optional
onClick?: () => void; onClick?: () => void;
toggled?: boolean; toggled?: boolean;
count?: number | true; count?: number | true;
disabled?: boolean;
flipIcon?: boolean;
}) { }) {
const color = toggled ? theme.primaryColor : theme.textColorActive; const color = toggled ? theme.primaryColor : theme.textColorActive;
const button = ( const button = (
@@ -206,8 +237,15 @@ function NavbarButton({
flexDirection: 'column', flexDirection: 'column',
alignItems: 'center', alignItems: 'center',
height: 'auto', height: 'auto',
}}> }}
<Icon style={{color, fontSize: 24}} /> disabled={disabled}>
<Icon
style={{
color,
fontSize: 24,
transform: flipIcon ? 'scaleX(-1)' : undefined,
}}
/>
<span <span
style={{ style={{
margin: 0, margin: 0,