npm-api: fixing hexToUx converter

This commit is contained in:
Hunter Miller 2021-11-24 19:54:47 -06:00
parent 6a6d2200b6
commit 0673fe9e3d
5 changed files with 56108 additions and 24628 deletions

File diff suppressed because it is too large Load Diff

View File

@ -13,9 +13,9 @@
"@react-spring/web": "^9.1.1",
"@tlon/indigo-dark": "^1.0.6",
"@tlon/indigo-light": "^1.0.7",
"@tlon/indigo-react": "^1.2.23",
"@tlon/indigo-react": "^1.2.27",
"@tlon/sigil-js": "^1.4.3",
"@urbit/api": "^1.1.1",
"@urbit/api": "^1.4.0",
"@urbit/http-api": "^1.2.1",
"any-ascii": "^0.1.7",
"aws-sdk": "^2.830.0",

View File

@ -1,3 +1,4 @@
import _ from 'lodash';
import {
Box, Col,
ErrorLabel, Label,
@ -6,9 +7,7 @@ import {
} from '@tlon/indigo-react';
import { useField } from 'formik';
import React, { useState, useEffect, ChangeEvent, useMemo } from 'react';
import { hexToUx } from '~/logic/lib/util';
import { uxToHex } from '@urbit/api/dist';
import _ from 'lodash';
import { uxToHex, hexToUx } from '@urbit/api';
export type ColorInputProps = Parameters<typeof Col>[0] & {
id: string;
@ -49,6 +48,7 @@ export function ColorInput(props: ColorInputProps) {
const updateField = useMemo(() => _.debounce((field: string) => {
const newValue = hexToUx(padHex(field));
console.log({ field, newValue });
setValue(newValue);
setTouched(true);
}, 150), []);

View File

@ -162,8 +162,11 @@ export function uxToHex(ux: string) {
export const hexToUx = (hex: string): string => {
const ux = f.flow(
f.dropWhile(y => y === '0'),
f.reverse,
f.chunk(4),
f.map(x => _.dropWhile(x, (y: unknown) => y === 0).join('')),
f.map(x => x.reverse().join('')),
f.reverse,
f.join('.')
)(hex.split(''));
return `0x${ux}`;

View File

@ -1,6 +1,6 @@
{
"name": "@urbit/api",
"version": "1.4.0",
"version": "1.4.1",
"description": "",
"repository": {
"type": "git",