on master help sign in
updated sigil downloading to use button
commite93e2a4a52762ca90a203f7502674442e4dae50a authorLiam Fitzgerald <hastuc-dibtux@gmail.com> dateMon 7 Oct 2019, 23:14 (7 years ago) parentda154dd
2 files changed+22−12
src/components/SigilDownloader.js → src/components/DownloadSigilButton.js+18−8 src/views/Point.js+4−4
src/components/SigilDownloader.js → src/components/DownloadSigilButton.jsrenamed+18−8
@@ -5,9 +5,13 @@ import { sigil, stringRenderer } from 'urbit-sigil-js';
55
66import { dataURItoBlob, loadImg, initCanvas } from 'lib/SigilDownloader';
77
8−import WithTooltip from 'components/WithTooltip';
8+import { DownloadButton } from 'components/Buttons';
99
10−export default function SigilDownloader({ point, children }) {
10+export default function DownloadSigilButton({
11+ point,
12+ children = 'Download Sigil',
13+ ...rest
14+}) {
1115 const [downloaded, setDownloaded] = useState(false);
1216 const downloadSigil = () => {
1317 const patp = ob.patp(point);
@@ -24,7 +28,6 @@ export default function SigilDownloader({ point, children }) {
2428 // make sigil svg and encoded into base64
2529 const svg = sigil({
2630 patp,
27− full: true,
2831 renderer: stringRenderer,
2932 size: _size,
3033 colors: ['#FFFFFF', '#000000'],
@@ -52,11 +55,18 @@ export default function SigilDownloader({ point, children }) {
5255 const canvasRef = useRef(null);
5356
5457 return (
55− <WithTooltip content={downloaded ? 'Downloaded!' : 'Download'}>
56− {React.Children.map(children, child =>
57− React.cloneElement(child, { onClick: downloadSigil })
58− )}
58+ <>
59+ <DownloadButton
60+ as="span"
61+ disabled={downloaded}
62+ onClick={downloadSigil}
63+ detail={
64+ downloaded ? 'Downloaded!' : 'Download the sigil for this point'
65+ }
66+ {...rest}>
67+ {children}
68+ </DownloadButton>
5969 <canvas style={{ display: 'none' }} ref={canvasRef} />
60− </WithTooltip>
70+ </>
6171 );
6272}
src/views/Point.js+4−4
@@ -10,7 +10,7 @@ import Greeting from 'components/Greeting';
1010import Passport from 'components/Passport';
1111import { ForwardButton, BootArvoButton } from 'components/Buttons';
1212import { matchBlinky } from 'components/Blinky';
13−import SigilDownloader from 'components/SigilDownloader';
13+import DownloadSigilButton from 'components/SigilDownloader';
1414
1515import * as need from 'lib/need';
1616import useInvites from 'lib/useInvites';
@@ -90,9 +90,7 @@ export default function Point() {
9090 return (
9191 <View pop={pop} inset>
9292 <Greeting point={point} />
93− <SigilDownloader point={point}>
94− <Passport point={Just(point)} />
95− </SigilDownloader>
93+ <Passport point={Just(point)} />
9694 <Grid className="pt2">
9795 {inviteButton}
9896 <Grid.Item
@@ -117,6 +115,8 @@ export default function Point() {
117115 )}
118116 <Grid.Item full as={BootArvoButton} />
119117 <Grid.Divider />
118+ <Grid.Item full as={DownloadSigilButton} point={point} />
119+ <Grid.Divider />
120120 </Grid>
121121 </View>
122122 );