on master help sign in
feat: update imports, cleanup sigil components
fa2a8acMatt Condon (shrugs)
package-lock.json+4−5
@@ -2175,8 +2175,7 @@
2175 "version": "github:urbit/sigil-js#03c880ff17a5816d78f659f44cb7df44e0a0c097",
2175 "version": "github:urbit/sigil-js#03c880ff17a5816d78f659f44cb7df44e0a0c097",
2176 "from": "github:urbit/sigil-js",
2176 "from": "github:urbit/sigil-js",
2177 "requires": {
2177 "requires": {
2178− "react": "^16.8.6",
2178+ "lodash": "^4.17.10",
2179− "svgson": "^4.0.0",
2180 "transformation-matrix": "^1.14.0"
2179 "transformation-matrix": "^1.14.0"
2181 }
2180 }
2182 },
2181 },
@@ -17537,9 +17536,9 @@
17537 }
17536 }
17538 },
17537 },
17539 "urbit-sigil-js": {
17538 "urbit-sigil-js": {
17540− "version": "1.3.2",
17539+ "version": "1.3.3",
17541− "resolved": "https://registry.npmjs.org/urbit-sigil-js/-/urbit-sigil-js-1.3.2.tgz",
17540+ "resolved": "https://registry.npmjs.org/urbit-sigil-js/-/urbit-sigil-js-1.3.3.tgz",
17542− "integrity": "sha512-cYmytvhsqYFo1HQSsfsjahJ6/DOW06ZAYEPOQD/OHKfeis3veVBZNOuM5PpAskDb5n68aVq1Xhx2oKno/TZ+LQ==",
17541+ "integrity": "sha512-fYvhNolngM6EFAfrb1T+psNS/Dt2osbhp5w3fUfw4VPHaV0WyxQN0y0HWux0Xnatza8At22h+NtGmvnInZy92g==",
17543 "requires": {
17542 "requires": {
17544 "react": "^16.8.6",
17543 "react": "^16.8.6",
17545 "svgson": "^4.0.0",
17544 "svgson": "^4.0.0",
package.json+1−1
@@ -45,7 +45,7 @@
45 "trezor-connect": "^7.0.1",
45 "trezor-connect": "^7.0.1",
46 "urbit-key-generation": "^0.16.0",
46 "urbit-key-generation": "^0.16.0",
47 "urbit-ob": "^4.0.1",
47 "urbit-ob": "^4.0.1",
48− "urbit-sigil-js": "^1.3.2",
48+ "urbit-sigil-js": "^1.3.3",
49 "web3": "1.0.0-beta.54",
49 "web3": "1.0.0-beta.54",
50 "web3-utils": "^1.0.0-beta.52"
50 "web3-utils": "^1.0.0-beta.52"
51 },
51 },
src/components/InputSigil.js+18−9
@@ -1,8 +1,8 @@
1−import React from 'react';
1+import React, { useEffect, useState } from 'react';
2+import { Just } from 'folktale/maybe';
2import * as ob from 'urbit-ob';
3import * as ob from 'urbit-ob';
3
4
4−import Sigil from './Sigil';
5+import MaybeSigil from './MaybeSigil';
5−import AspectRatio from './AspectRatio';
6
6
7const selectColorway = (pass, fail, focused) => {
7const selectColorway = (pass, fail, focused) => {
8 if (pass) {
8 if (pass) {
@@ -29,12 +29,21 @@ export default function InputSigil({
29 focused,
29 focused,
30 ...rest
30 ...rest
31}) {
31}) {
32− const colorway = selectColorway(pass, error, focused);
32+ const [lastValidPatp, setLastValidPatp] = useState(patp);
33− const valid = ob.isValidPatp(patp);
34
33
34+ useEffect(() => {
35+ if (ob.isValidPatp(patp)) {
36+ setLastValidPatp(patp);
37+ }
38+ }, [patp]);
39+
35− return valid ? (
40+ return (
36− <Sigil patp={patp} size={size} colorway={colorway} margin={0} {...rest} />
41+ <MaybeSigil
37− ) : (
42+ patp={Just(lastValidPatp)}
38− <AspectRatio aspectRatio={1} />
43+ size={size}
44+ colors={selectColorway(pass, error, focused)}
45+ margin={0}
46+ {...rest}
47+ />
39 );
48 );
40}
49}
src/components/Sigil.js+8−12
@@ -1,15 +1,11 @@
1−import React from 'react';
2import { sigil, reactRenderer } from 'urbit-sigil-js';
1import { sigil, reactRenderer } from 'urbit-sigil-js';
3
2
4−export default function Sigil({ patp, size, colorway, ...rest }) {
3+export default function Sigil({ patp, size, colors, ...rest }) {
5− return (
4+ return sigil({
6− <div>
7− {sigil({
8− patp: patp,
5+ patp,
9− renderer: reactRenderer,
6+ renderer: reactRenderer,
10− size: size,
7+ size,
11− colors: colorway,
8+ colors,
12− })}
9+ ...rest,
13− </div>
14− );
10+ });
15}
11}