flatten components

This commit is contained in:
tresabhi committed 2026-12-04 16:38:27 -06:00
1 parent 7cd3e10492
commit 6369491a37
150 files changed
+2160 -6895

No files matched your search

@@ -0,0 +1,23 @@
.rich-text {
flex: 1;
display: flex;
flex-direction: column;
gap: var(--space-3);
}
.row {
display: flex;
align-items: center;
gap: var(--space-3);
&[data-padded] {
padding: var(--space-3) 0;
}
}
.icon {
flex-shrink: 0;
width: var(--font-size-major);
height: var(--font-size-major);
}
@@ -0,0 +1,66 @@
import { FontBoldIcon, FontSizeIcon } from "@radix-ui/react-icons";
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
import { weights } from "../../config/styles";
import { EmbedState } from "../../stores/embedState";
import type {
EmbedConfigItemType,
EmbedItemType,
} from "../../stores/embedState/constants";
import type { SpaceWithout0, Weight } from "../../types/styles";
import { EmbedColorInput } from "../EmbedColorInput";
import { EmbedRangeSlider } from "../EmbedRangeSlider";
import styles from "./index.module.css";
const weightNames = Object.keys(weights) as Weight[];
type RichTextState = EmbedConfigItemType<EmbedItemType.RichText>["default"];
export function EmbedControlRichText({
configKey,
}: EmbedPreviewControllerProps) {
const state = EmbedState.use((state) => state[configKey] as RichTextState);
return (
<div className={styles["rich-text"]}>
<div className={styles.row}>
<EmbedColorInput
value={state.color}
onValueChange={(value) => {
EmbedState.mutate((draft) => {
(draft[configKey] as RichTextState).color = value;
});
}}
/>
</div>
<div className={styles.row} data-padded>
<FontSizeIcon className={styles.icon} />
<EmbedRangeSlider
min={1}
max={9}
value={Number(state.size)}
onValueChange={(value) => {
EmbedState.mutate((draft) => {
(draft[configKey] as RichTextState).size =
`${value}` as SpaceWithout0;
});
}}
/>
</div>
<div className={styles.row} data-padded>
<FontBoldIcon className={styles.icon} />
<EmbedRangeSlider
min={0}
max={weightNames.length - 1}
value={weightNames.indexOf(state.weight)}
onValueChange={(value) => {
EmbedState.mutate((draft) => {
(draft[configKey] as RichTextState).weight = weightNames[value];
});
}}
/>
</div>
</div>
);
}