* cwv3 test * Updated Playground * Put theme and modal size on first tab * refactor and use embededWallet * Fix RPC for playground * update * Update custom NetworkSelector styles * Fix chain icons in live preview * update * update * Fix Modal title icon * Fix Typo * update wallets * updates * Fix code for recommended * update * update smartWallet code * /connect v2 (#1710) * Update all landing pages (#1697) * Stuff * Pushy push * wut * ? * ?? * Amazing * New images * :) * Menu sections * Fix build * Better logic * local images * Storage hero * Now better logic for real * chore: update landing page copy (#1708) * chore: update env examples based on tair's DM * chore: update build page vercel comment * chore(storage): update copy from feedback * chore(deploy): update copy * chore(sponsored-transactions): update copy * chore(embedded-wallets): update copy * chore(publish): update copy * chore(checkout): update copy * chore(smart-contracts): update copy * chore: update hero images * chore: update mobile product hero * chore(build): update build icons * chore(interact): Update interact icons * chore(smart-contracts): add page icons * chore(publish): add publish icons * chore(deploy): add deploy icons * refactor(contracts): update icon contract pages * chore(connect): add connect icons * chore(embedded-wallets): add icons for embedded-wallets * chore(auth): add auth icons * chore(checkout): add checkout page icons * chore(sponsored-transaction): add icons for sponsored transactions * chore(storage): add storage page icons * chore(rpc-edge): add rpc-edge page icons * chore(checkout): update checkout icon * chore(nav): update nav icons * chore(contracts): update gradient to #F213A4, #F97CCE * chore(payments): update gradient #00A876, #75FFD6 * chore(wallets): update gradient to #3385FF, #7BB0FF * chore(connect): update copy --------- Co-authored-by: Jonas Daniels <[email protected]> Co-authored-by: Winston Yeo <[email protected]> Co-authored-by: ElasticBottle <[email protected]> * Fix wrong link (#1709) Fix link * New sectio on /connect * Updated images --------- Co-authored-by: Jonas Daniels <[email protected]> Co-authored-by: Winston Yeo <[email protected]> Co-authored-by: ElasticBottle <[email protected]> Co-authored-by: Manan Tank <[email protected]> * Fix Hydration issue with link-box and style updates * Add Mini playground for landing page * Add Hover overlay * Update Modal Size style * Fix color for nouns dao theme * Fix ModalSize button style * UI updates * update * update guides * update icon styles * resolve vercel comments * UI updates * update hero and OG * update * Remove old * bruh * Fix vertical image * Remove * Fix build * Fix build again * tracking and other stuff * update tracking * update tracking --------- Co-authored-by: Nacho Iacovino <[email protected]> Co-authored-by: Jonas Daniels <[email protected]> Co-authored-by: Winston Yeo <[email protected]> Co-authored-by: ElasticBottle <[email protected]> Co-authored-by: Nacho Iacovino <[email protected]>
66 lines
1.6 KiB
TypeScript
66 lines
1.6 KiB
TypeScript
/* eslint-disable react/forbid-dom-props */
|
|
import { Box, Flex, Input, Spacer } from "@chakra-ui/react";
|
|
import { FormLabel } from "tw-components";
|
|
import styles from "./ColorInput.module.css";
|
|
|
|
function hslToHex(h: number, s: number, l: number) {
|
|
l /= 100;
|
|
const a = (s * Math.min(l, 1 - l)) / 100;
|
|
const f = (n: number) => {
|
|
const k = (n + h / 30) % 12;
|
|
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
return Math.round(255 * color)
|
|
.toString(16)
|
|
.padStart(2, "0");
|
|
};
|
|
return `#${f(0)}${f(8)}${f(4)}`;
|
|
}
|
|
|
|
export function ColorInput(props: {
|
|
value: string;
|
|
name: string;
|
|
onChange: (value: string) => void;
|
|
onClick?: () => void;
|
|
}) {
|
|
let hexColor = props.value;
|
|
if (props.value.startsWith("hsl(") && props.value.endsWith(")")) {
|
|
const [h, s, l] = props.value
|
|
.replace(/[^0-9.]/g, " ")
|
|
.split(/\s+/)
|
|
.filter((value) => value)
|
|
.map(Number);
|
|
|
|
// if all three are numbers
|
|
if (!isNaN(h) && !isNaN(s) && !isNaN(l)) {
|
|
hexColor = hslToHex(h, s, l);
|
|
} else {
|
|
// give up
|
|
hexColor = props.value;
|
|
}
|
|
}
|
|
|
|
return (
|
|
<Box>
|
|
<FormLabel>{props.name}</FormLabel>
|
|
<Spacer height={2} />
|
|
<Flex alignItems="center" gap={3} onClick={props.onClick}>
|
|
<input
|
|
onChange={(e) => {
|
|
props.onChange(e.target.value);
|
|
}}
|
|
type="color"
|
|
className={styles.ColorInput}
|
|
value={hexColor}
|
|
/>
|
|
|
|
<Input
|
|
value={hexColor}
|
|
onChange={(e) => {
|
|
props.onChange(e.target.value);
|
|
}}
|
|
/>
|
|
</Flex>
|
|
</Box>
|
|
);
|
|
}
|