toggle left sidebar button
Reviewed By: elboman Differential Revision: D47399778 fbshipit-source-id: 842a6900f05e629c4c4fca60928fb9ab107b46fd
This commit is contained in:
committed by
Facebook GitHub Bot
parent
12997086eb
commit
5b27a6a4c9
@@ -20,12 +20,9 @@ import {
|
|||||||
BugOutlined,
|
BugOutlined,
|
||||||
ApiOutlined,
|
ApiOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import {SidebarLeft, SidebarRight} from './SandyIcons';
|
import {SidebarRight} from './SandyIcons';
|
||||||
import {useDispatch, useStore} from '../utils/useStore';
|
import {useDispatch, useStore} from '../utils/useStore';
|
||||||
import {
|
import {toggleRightSidebarVisible} from '../reducers/application';
|
||||||
toggleLeftSidebarVisible,
|
|
||||||
toggleRightSidebarVisible,
|
|
||||||
} from '../reducers/application';
|
|
||||||
import {
|
import {
|
||||||
theme,
|
theme,
|
||||||
Layout,
|
Layout,
|
||||||
@@ -201,7 +198,6 @@ export const LeftRail = withTrackingScope(function LeftRail({
|
|||||||
<LaunchEmulatorButton />
|
<LaunchEmulatorButton />
|
||||||
<SetupDoctorButton />
|
<SetupDoctorButton />
|
||||||
<RightSidebarToggleButton />
|
<RightSidebarToggleButton />
|
||||||
<LeftSidebarToggleButton />
|
|
||||||
<ExportEverythingEverywhereAllAtOnceButton />
|
<ExportEverythingEverywhereAllAtOnceButton />
|
||||||
<ExtrasMenu />
|
<ExtrasMenu />
|
||||||
</Layout.Container>
|
</Layout.Container>
|
||||||
@@ -332,25 +328,6 @@ function ExtrasMenu() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function LeftSidebarToggleButton() {
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
const mainMenuVisible = useStore(
|
|
||||||
(state) => state.application.leftSidebarVisible,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<LeftRailButton
|
|
||||||
icon={<SidebarLeft />}
|
|
||||||
small
|
|
||||||
title="Left Sidebar Toggle"
|
|
||||||
toggled={mainMenuVisible}
|
|
||||||
onClick={() => {
|
|
||||||
dispatch(toggleLeftSidebarVisible());
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function RightSidebarToggleButton() {
|
function RightSidebarToggleButton() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const rightSidebarAvailable = useStore(
|
const rightSidebarAvailable = useStore(
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import {Layout, styled, theme, useValue} from 'flipper-plugin';
|
import {Layout, styled, theme, useValue} from 'flipper-plugin';
|
||||||
import React, {cloneElement, useCallback, useState} from 'react';
|
import React, {cloneElement, useCallback, useState} from 'react';
|
||||||
import {useStore} from '../utils/useStore';
|
import {useDispatch, useStore} from '../utils/useStore';
|
||||||
import config from '../fb-stubs/config';
|
import config from '../fb-stubs/config';
|
||||||
import {isConnected, currentUser, logoutUser} from '../fb-stubs/user';
|
import {isConnected, currentUser, logoutUser} from '../fb-stubs/user';
|
||||||
import {showLoginDialog} from '../chrome/fb-stubs/SignInSheet';
|
import {showLoginDialog} from '../chrome/fb-stubs/SignInSheet';
|
||||||
@@ -27,10 +27,12 @@ import {
|
|||||||
VideoCameraOutlined,
|
VideoCameraOutlined,
|
||||||
WarningOutlined,
|
WarningOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
|
import {toggleLeftSidebarVisible} from '../reducers/application';
|
||||||
|
|
||||||
export function Navbar() {
|
export function Navbar() {
|
||||||
return (
|
return (
|
||||||
<Layout.Horizontal
|
<Layout.Horizontal
|
||||||
|
borderBottom
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: 68,
|
height: 68,
|
||||||
@@ -38,10 +40,9 @@ export function Navbar() {
|
|||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
background: theme.backgroundDefault,
|
background: theme.backgroundDefault,
|
||||||
borderBottom: `solid 1px ${theme.dividerColor}`,
|
|
||||||
}}>
|
}}>
|
||||||
<Layout.Horizontal style={{gap: 4}}>
|
<Layout.Horizontal style={{gap: 4}}>
|
||||||
<NavbarButton label="Toggle Sidebar" icon={LayoutOutlined} />
|
<LeftSidebarToggleButton />
|
||||||
<button>device picker</button>
|
<button>device picker</button>
|
||||||
<NavbarButton label="Screenshot" icon={CameraOutlined} />
|
<NavbarButton label="Screenshot" icon={CameraOutlined} />
|
||||||
<NavbarButton label="Record" icon={VideoCameraOutlined} />
|
<NavbarButton label="Record" icon={VideoCameraOutlined} />
|
||||||
@@ -59,27 +60,52 @@ export function Navbar() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function LeftSidebarToggleButton() {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const mainMenuVisible = useStore(
|
||||||
|
(state) => state.application.leftSidebarVisible,
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<NavbarButton
|
||||||
|
label="Toggle Sidebar"
|
||||||
|
icon={LayoutOutlined}
|
||||||
|
toggled={!mainMenuVisible}
|
||||||
|
onClick={() => {
|
||||||
|
dispatch(toggleLeftSidebarVisible());
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function NavbarButton({
|
function NavbarButton({
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
label,
|
label,
|
||||||
selected,
|
toggled = false,
|
||||||
|
onClick,
|
||||||
}: {
|
}: {
|
||||||
icon: typeof LoginOutlined;
|
icon: typeof LoginOutlined;
|
||||||
label: string;
|
label: string;
|
||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
|
// TODO remove optional
|
||||||
|
onClick?: () => void;
|
||||||
|
toggled?: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
const color = toggled ? theme.primaryColor : theme.textColorActive;
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
ghost={!selected}
|
aria-pressed={toggled}
|
||||||
|
ghost
|
||||||
|
onClick={onClick}
|
||||||
style={{
|
style={{
|
||||||
color: theme.textColorPrimary,
|
color,
|
||||||
boxShadow: 'none',
|
boxShadow: 'none',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
}}>
|
}}>
|
||||||
<Icon style={{color: theme.textColorPrimary, fontSize: 24}} />
|
<Icon style={{color, fontSize: 24}} />
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
margin: 0,
|
margin: 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user