diff --git a/src/app/tools/embed/configurations/breakdown.tsx b/src/app/tools/embed/configurations/breakdown.tsx index 6bec434ec..2c45f5df1 100644 --- a/src/app/tools/embed/configurations/breakdown.tsx +++ b/src/app/tools/embed/configurations/breakdown.tsx @@ -56,7 +56,7 @@ export const breakdownConfig = { }, columnLabel: { type: EmbedItemType.RichText, - default: { color: 'gray', size: '2', weight: 'regular' }, + default: { color: grayDark.gray11, size: '2', weight: 'regular' }, pad: true, }, diff --git a/src/app/tools/embed/customize/[embed]/components/Color.tsx b/src/app/tools/embed/customize/[embed]/components/Color.tsx deleted file mode 100644 index 324538f6e..000000000 --- a/src/app/tools/embed/customize/[embed]/components/Color.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { Slider } from '@radix-ui/themes'; -import { useRef } from 'react'; -import * as EmbedState from '../../../../../../stores/embedState'; -import { EmbedPreviewControllerProps } from '../page'; - -export function Color({ configKey }: EmbedPreviewControllerProps) { - const mutateEmbedState = EmbedState.useMutation(); - const input = useRef(null); - - return ( - <> - - (state[configKey] as string).slice(0, 7), - )} - onChange={(event) => { - mutateEmbedState((draft) => { - let alpha = (draft[configKey] as string).slice(7, 9); - if (alpha.length === 0) alpha = 'ff'; - draft[configKey] = `${event.target.value}${alpha}`; - }); - }} - /> - { - let alpha = (state[configKey] as string).slice(7, 9); - if (alpha.length === 0) return 255; - return parseInt(alpha, 16); - }), - ]} - onValueChange={([value]) => { - mutateEmbedState((draft) => { - if (!input.current) return; - - const color = input.current.value; - draft[configKey] = `${color}${value.toString(16)}`; - }); - }} - /> - - ); -} diff --git a/src/app/tools/embed/customize/[embed]/components/Color/components/ColorControllerRaw.tsx b/src/app/tools/embed/customize/[embed]/components/Color/components/ColorControllerRaw.tsx new file mode 100644 index 000000000..ecf286466 --- /dev/null +++ b/src/app/tools/embed/customize/[embed]/components/Color/components/ColorControllerRaw.tsx @@ -0,0 +1,37 @@ +import { Slider } from '@radix-ui/themes'; + +interface ColorControllerRawProps { + value: string; + onValueChange: (value: string) => void; +} + +export function ColorControllerRaw({ + value, + onValueChange, +}: ColorControllerRawProps) { + const tintString = value.slice(0, 7); + const alphaString = value.slice(7, 9); + const alpha = alphaString.length === 0 ? 255 : parseInt(alphaString, 16); + + return ( + <> + { + let alpha = value.slice(7, 9); + if (alpha.length === 0) alpha = 'ff'; + onValueChange(`${event.target.value}${alpha}`); + }} + /> + { + onValueChange(`${tintString}${value.toString(16)}`); + }} + /> + + ); +} diff --git a/src/app/tools/embed/customize/[embed]/components/Color/index.tsx b/src/app/tools/embed/customize/[embed]/components/Color/index.tsx new file mode 100644 index 000000000..974a97425 --- /dev/null +++ b/src/app/tools/embed/customize/[embed]/components/Color/index.tsx @@ -0,0 +1,19 @@ +import * as EmbedState from '../../../../../../../stores/embedState'; +import { EmbedPreviewControllerProps } from '../../page'; +import { ColorControllerRaw } from './components/ColorControllerRaw'; + +export function Color({ configKey }: EmbedPreviewControllerProps) { + const mutateEmbedState = EmbedState.useMutation(); + const color = EmbedState.use((state) => state[configKey] as string); + + return ( + { + mutateEmbedState((draft) => { + draft[configKey] = value; + }); + }} + /> + ); +} diff --git a/src/app/tools/embed/customize/[embed]/components/RichText.tsx b/src/app/tools/embed/customize/[embed]/components/RichText.tsx new file mode 100644 index 000000000..480e3a82c --- /dev/null +++ b/src/app/tools/embed/customize/[embed]/components/RichText.tsx @@ -0,0 +1,34 @@ +import * as EmbedState from '../../../../../../stores/embedState'; +import { + EmbedConfigItemType, + EmbedItemType, +} from '../../../../../../stores/embedState/constants'; +import { EmbedPreviewControllerProps } from '../page'; +import { ColorControllerRaw } from './Color/components/ColorControllerRaw'; + +export function RichText({ configKey }: EmbedPreviewControllerProps) { + const mutateEmbedState = EmbedState.useMutation(); + const state = EmbedState.use( + (state) => + state[ + configKey + ] as EmbedConfigItemType['default'], + ); + + console.log(state); + + return ( + { + mutateEmbedState((draft) => { + ( + draft[ + configKey + ] as EmbedConfigItemType['default'] + ).color = value; + }); + }} + /> + ); +} diff --git a/src/app/tools/embed/customize/[embed]/page.tsx b/src/app/tools/embed/customize/[embed]/page.tsx index 94fe6320f..213c01eb2 100644 --- a/src/app/tools/embed/customize/[embed]/page.tsx +++ b/src/app/tools/embed/customize/[embed]/page.tsx @@ -13,6 +13,7 @@ import { configurations, previews } from '../../configurations'; import { Boolean } from './components/Boolean'; import { Color } from './components/Color'; import { Radius } from './components/Radius'; +import { RichText } from './components/RichText'; import { Size } from './components/Size'; import { SizeWithout0 } from './components/SizeWithout0'; import { Slider } from './components/Slider'; @@ -95,6 +96,10 @@ export default function Page({ control = ; break; } + + case EmbedItemType.RichText: { + control = ; + } } return (