toolbar/buttons: consolidate buttons

This commit is contained in:
David Lechner
2022-03-25 15:54:04 -05:00
parent 9d995ceeef
commit 5dd61fa4c3
47 changed files with 493 additions and 278 deletions
-62
View File
@@ -1,62 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2020-2022 The Pybricks Authors
import React from 'react';
import { useDispatch } from 'react-redux';
import { BleConnectionState } from '../ble/reducers';
import { BootloaderConnectionState } from '../lwp3-bootloader/reducers';
import * as notificationActions from '../notifications/actions';
import { useSelector } from '../reducers';
import { useSettingFlashCurrentProgram, useSettingHubName } from '../settings/hooks';
import OpenFileButton, { OpenFileButtonProps } from '../toolbar/OpenFileButton';
import { I18nId } from '../toolbar/i18n';
import { flashFirmware } from './actions';
import firmwareIcon from './firmware.svg';
type FlashButtonProps = Pick<OpenFileButtonProps, 'label'>;
const FlashButton: React.VoidFunctionComponent<FlashButtonProps> = ({ label }) => {
const bootloaderConnection = useSelector((s) => s.bootloader.connection);
const bleConnection = useSelector((s) => s.ble.connection);
const flashing = useSelector((s) => s.firmware.flashing);
const progress = useSelector((s) => s.firmware.progress);
const [isSettingFlashCurrentProgramEnabled] = useSettingFlashCurrentProgram();
const { hubName } = useSettingHubName();
const dispatch = useDispatch();
return (
<OpenFileButton
label={label}
fileExtension=".zip"
icon={firmwareIcon}
tooltip={flashing ? I18nId.FlashProgress : I18nId.Flash}
enabled={
bootloaderConnection === BootloaderConnectionState.Disconnected &&
bleConnection === BleConnectionState.Disconnected
}
showProgress={flashing}
progress={progress === null ? undefined : progress}
onFile={(data) =>
dispatch(
flashFirmware(data, isSettingFlashCurrentProgramEnabled, hubName),
)
}
onReject={(file) =>
dispatch(
notificationActions.add(
'error',
`'${file.name}' is not a valid firmware file.`,
),
)
}
onClick={() =>
dispatch(
flashFirmware(null, isSettingFlashCurrentProgramEnabled, hubName),
)
}
/>
);
};
export default FlashButton;
-231
View File
@@ -1,231 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="50"
height="50"
viewBox="0 0 26.458333 26.458334"
version="1.1"
id="svg8"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="firmware.svg"
inkscape:export-filename="button.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<defs
id="defs2">
<linearGradient
id="light-circle-fill"
osb:paint="solid"
gradientTransform="matrix(0.04149181,0,0,0.04149181,1.7417234,549.61437)">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop5207" />
</linearGradient>
<linearGradient
id="icon-contents"
osb:paint="solid"
gradientTransform="matrix(0.78378378,0,0,0.78378378,-217.21909,-864.32335)">
<stop
style="stop-color:#3880b7;stop-opacity:1;"
offset="0"
id="stop5179" />
</linearGradient>
<linearGradient
id="light-circle-edge"
osb:paint="solid"
gradientTransform="matrix(0.04571075,0,0,0.26284445,-63.602396,-483.67016)">
<stop
style="stop-color:#b7b7b7;stop-opacity:1;"
offset="0"
id="stop5173" />
</linearGradient>
<linearGradient
id="dark-back"
osb:paint="solid"
gradientTransform="translate(1195.9167,-717.54999)">
<stop
style="stop-color:#333333;stop-opacity:1;"
offset="0"
id="stop1439" />
</linearGradient>
<linearGradient
id="dark-front"
osb:paint="solid"
gradientTransform="translate(4643.556,-4.2349475e-6)">
<stop
style="stop-color:#d4d4d4;stop-opacity:1;"
offset="0"
id="stop1389" />
</linearGradient>
<linearGradient
id="light-front"
osb:paint="solid"
gradientTransform="translate(-313.01005,-269.76128)">
<stop
style="stop-color:#4e4e4e;stop-opacity:1;"
offset="0"
id="stop1184" />
</linearGradient>
<linearGradient
id="light-back"
osb:paint="solid"
gradientTransform="translate(-78.252472)">
<stop
style="stop-color:#eeeeee;stop-opacity:1;"
offset="0"
id="stop1172" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#light-circle-fill"
id="linearGradient5187"
x1="170.49026"
y1="91.974777"
x2="171.5486"
y2="91.974777"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(2.2770973,0,0,2.2770973,-375.89057,64.428671)" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11.313708"
inkscape:cx="33.439167"
inkscape:cy="33.623378"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1853"
inkscape:window-height="1145"
inkscape:window-x="67"
inkscape:window-y="27"
inkscape:window-maximized="1"
units="px"
inkscape:measure-start="0,0"
inkscape:measure-end="0,0"
inkscape:snap-global="false"
showguides="true"
inkscape:pagecheckerboard="true" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-270.54165)">
<path
transform="matrix(0,2.2770972,-2.2770972,0,242.26153,191.39198)"
sodipodi:type="star"
style="fill:url(#light-circle-fill);fill-opacity:1;stroke:none;stroke-width:0.92954594;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path924"
sodipodi:sides="3"
sodipodi:cx="37.758598"
sodipodi:cy="100.44551"
sodipodi:r1="1.9985147"
sodipodi:r2="0.99925733"
sodipodi:arg1="0"
sodipodi:arg2="1.0471976"
inkscape:flatsided="false"
inkscape:rounded="0"
inkscape:randomized="0"
d="m 39.757113,100.44551 -1.498886,0.86538 -1.498886,0.86539 v -1.73077 -1.730764 l 1.498886,0.865383 z"
inkscape:transform-center-y="0.56883747"
inkscape:export-filename="out.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:transform-center-x="-5.2936222e-06" />
<path
inkscape:connector-curvature="0"
id="path926"
d="m 13.537299,271.92763 v 3.8731"
style="fill:#4e4e4e;fill-opacity:1;stroke:url(#linearGradient5187);stroke-width:2.11666656;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:export-filename="out.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" />
<rect
style="fill:url(#light-circle-fill);fill-opacity:1;stroke:none;stroke-width:0.59935653;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect940"
width="24.01683"
height="10.585944"
x="1.2748805"
y="284.17142"
rx="0"
ry="0"
inkscape:export-filename="out.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" />
<rect
ry="0"
rx="0"
y="283.18323"
x="3.4314961"
height="10.585944"
width="2.7715306"
id="rect942"
style="fill:url(#light-circle-fill);fill-opacity:1;stroke:none;stroke-width:0.20360442;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:export-filename="out.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" />
<rect
style="fill:url(#light-circle-fill);fill-opacity:1;stroke:none;stroke-width:0.20360442;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect944"
width="2.7715306"
height="10.585944"
x="9.0755405"
y="283.18323"
rx="0"
ry="0"
inkscape:export-filename="out.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" />
<rect
ry="0"
rx="0"
y="283.18323"
x="14.719461"
height="10.585944"
width="2.7715306"
id="rect947"
style="fill:url(#light-circle-fill);fill-opacity:1;stroke:none;stroke-width:0.20360442;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:export-filename="out.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" />
<rect
style="fill:url(#light-circle-fill);fill-opacity:1;stroke:none;stroke-width:0.20360442;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect949"
width="2.7715306"
height="10.585944"
x="20.363565"
y="283.18323"
rx="0"
ry="0"
inkscape:export-filename="out.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 7.7 KiB