1import React, { useRef, useCallback } from 'react';
2import { Grid, Flex } from 'indigo-react';
3import * as ob from 'urbit-ob';
4import { FORM_ERROR } from 'final-form';
5import { colors } from 'indigo-tokens';
7import { usePointCursor } from 'store/pointCursor';
9import View from 'components/View';
10import Sigil from 'components/Sigil';
12import * as need from 'lib/need';
13import { useLocalRouter } from 'lib/LocalRouter';
14import useSigilDownloader from 'lib/useSigilDownloader';
16import { composeValidator, buildNumberValidator } from 'form/validators';
17import BridgeForm from 'form/BridgeForm';
18import FormError from 'form/FormError';
19import SubmitButton from 'form/SubmitButton';
20import { NumberInput } from 'form/Inputs';
21import ColorInput from 'form/ColorInput';
40const FG_COLORS = [colors.black, colors.white];
42export default function SigilGenerator() {
43 const { pop } = useLocalRouter();
44 const { pointCursor } = usePointCursor();
46 const validate = composeValidator({ size: buildNumberValidator(16) });
47 const point = need.point(pointCursor);
49 const canvasRef = useRef(null);
51 const { downloadSigil } = useSigilDownloader(canvasRef);
52 const onSubmit = useCallback(
53 async (values, form) => {
54 const colors = [values.bgColor, values.fgColor];
55 const error = await downloadSigil(point, colors, values.size);
57 return { [FORM_ERROR]: error };
60 setTimeout(() => form.reset(values));
62 [point, downloadSigil]
74 {({ handleSubmit, values }) => (
76 <Grid.Item full className="f7">
79 <Grid.Item fourth={1}>
83 colors={[values.bgColor, values.fgColor]}
87 <Grid.Item full as={Flex} col>
88 <Flex.Item className="mb1">Urbit ID</Flex.Item>
89 <Flex.Item className="mono">{ob.patp(point)}</Flex.Item>
101 label="Background Color"
108 label="Foreground Color"
114 handleSubmit={handleSubmit}
118 <Grid.Item full as={FormError} />
123 <canvas style={{ display: 'none' }} ref={canvasRef} />
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list