From 6db83a7675c778c92a9624ceb9c44f9ac52e3528 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Wed, 17 Apr 2019 10:21:35 -0700 Subject: [PATCH] Use ToggleSwitches for binary options Summary: We've had a bunch of different options that were all binary switches with very different ways of displaying them. This consolidates them all to use ToggleSwitches. I think it may still make sense to move them all to a sidebar as it's the case for the Analytics plugin, but that's for another diff. Reviewed By: danielbuechele Differential Revision: D14933392 fbshipit-source-id: 7ef286b61142a564a7cde6de875266ac8641704b --- src/plugins/fresco/ImagesCacheOverview.js | 64 +++++++++++++++++------ src/ui/components/ToggleSwitch.js | 7 ++- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/src/plugins/fresco/ImagesCacheOverview.js b/src/plugins/fresco/ImagesCacheOverview.js index 69a7d9a5f..e849ae4dd 100644 --- a/src/plugins/fresco/ImagesCacheOverview.js +++ b/src/plugins/fresco/ImagesCacheOverview.js @@ -19,7 +19,8 @@ import { LoadingIndicator, styled, Select, - Checkbox, + ToggleButton, + Text, } from 'flipper'; import type {ImagesMap} from './ImagePool.js'; import {clipboard} from 'electron'; @@ -33,6 +34,36 @@ function formatKB(bytes: number) { return Math.floor(bytes / 1024) + 'KB'; } +type ToggleProps = {| + label: string, + onClick?: (newValue: boolean) => void, + toggled: boolean, +|}; + +const ToolbarToggleButton = styled(ToggleButton)(_props => ({ + alignSelf: 'center', + marginRight: 4, + minWidth: 30, +})); + +const ToggleLabel = styled(Text)(_props => ({ + whiteSpace: 'nowrap', +})); + +function Toggle(props: ToggleProps) { + return ( + <> + { + props.onClick && props.onClick(!props.toggled); + }} + toggled={props.toggled} + /> + {props.label} + + ); +} + type ImagesCacheOverviewProps = { onColdStartChange: (checked: boolean) => void, coldStartFilter: boolean, @@ -61,12 +92,7 @@ const StyledSelect = styled(Select)(props => ({ marginLeft: 6, marginRight: 6, height: '100%', -})); - -const StyledCheckbox = styled(Checkbox)(props => ({ - marginLeft: 6, - marginRight: 6, - height: '100%', + maxWidth: 164, })); export default class ImagesCacheOverview extends PureComponent< @@ -137,23 +163,27 @@ export default class ImagesCacheOverview extends PureComponent< - - - + + - Show ColdStart Images { render() { return ( - + ); } }