This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* v0 by Vercel. | |
* @see https://v0.dev/t/uNOsfYuMiZR | |
* Documentation: https://v0.dev/docs#integrating-generated-code-into-your-nextjs-app | |
*/ | |
import { Button } from "@/components/ui/button" | |
export default function Component() { | |
return ( | |
<div className="max-w-2xl mx-auto px-4 py-8 sm:px-6 lg:px-8"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see: https://www.charlie-coleman.com/experiments/1 | |
export const textToColor = (unsafeColor: string): string => { | |
// Remove all non-alphanumeric characters and spaces | |
let color = unsafeColor.replace(/\s+/g, '').replace(/[^a-zA-Z0-9]+/g, ''); | |
// Calculate required length and padding | |
const lengthC = color.length; | |
const amount = Math.ceil(lengthC / 3); | |
const add = amount * 3 - lengthC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DIGIT = '9'; | |
const ALPHA = 'A'; | |
const ALPHANUM = 'S'; | |
const toPattern = (value: string, pattern: string): string => { | |
const resultArray = pattern.split(''); | |
const values = value.split(''); | |
let index = 0; | |
let i = 0; |