mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: full rich text
This commit is contained in:
1 parent
b69abbc75e
commit
8d190b62b0
1 file changed
+53
-4
@@ -1,8 +1,11 @@
|
|||||||
|
import { FontBoldIcon, FontSizeIcon } from '@radix-ui/react-icons';
|
||||||
|
import { Flex, Slider, Text } from '@radix-ui/themes';
|
||||||
import type { EmbedPreviewControllerProps } from '../../pages/tools/embed/[embed]/_index';
|
import type { EmbedPreviewControllerProps } from '../../pages/tools/embed/[embed]/_index';
|
||||||
import { EmbedState } from '../../stores/embedState';
|
import { EmbedState, type RadixSizeWithout0 } from '../../stores/embedState';
|
||||||
import type {
|
import {
|
||||||
EmbedConfigItemType,
|
radixTextWeights,
|
||||||
EmbedItemType,
|
type EmbedConfigItemType,
|
||||||
|
type EmbedItemType,
|
||||||
} from '../../stores/embedState/constants';
|
} from '../../stores/embedState/constants';
|
||||||
import { ColorControllerRaw } from './ColorControllerRaw';
|
import { ColorControllerRaw } from './ColorControllerRaw';
|
||||||
|
|
||||||
@@ -16,6 +19,8 @@ export function RichText({ configKey }: EmbedPreviewControllerProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<Flex direction="column" flexGrow="1" gap="2">
|
||||||
|
<Flex gap="2" align="center">
|
||||||
<ColorControllerRaw
|
<ColorControllerRaw
|
||||||
value={state.color}
|
value={state.color}
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
@@ -28,5 +33,49 @@ export function RichText({ configKey }: EmbedPreviewControllerProps) {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Flex align="center" gap="2" py="2">
|
||||||
|
<Text size="4" trim="both">
|
||||||
|
<FontSizeIcon width="1em" height="1em" />
|
||||||
|
</Text>
|
||||||
|
<Slider
|
||||||
|
variant="soft"
|
||||||
|
min={1}
|
||||||
|
max={9}
|
||||||
|
value={[Number(state.size)]}
|
||||||
|
onValueChange={([value]) => {
|
||||||
|
mutateEmbedState((draft) => {
|
||||||
|
(
|
||||||
|
draft[
|
||||||
|
configKey
|
||||||
|
] as EmbedConfigItemType<EmbedItemType.RichText>['default']
|
||||||
|
).size = `${value}` as RadixSizeWithout0;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Flex align="center" gap="2" py="2">
|
||||||
|
<Text size="4" trim="both">
|
||||||
|
<FontBoldIcon width="1em" height="1em" />
|
||||||
|
</Text>
|
||||||
|
<Slider
|
||||||
|
variant="soft"
|
||||||
|
min={0}
|
||||||
|
max={radixTextWeights.length - 1}
|
||||||
|
value={[radixTextWeights.indexOf(state.weight)]}
|
||||||
|
onValueChange={([value]) => {
|
||||||
|
mutateEmbedState((draft) => {
|
||||||
|
(
|
||||||
|
draft[
|
||||||
|
configKey
|
||||||
|
] as EmbedConfigItemType<EmbedItemType.RichText>['default']
|
||||||
|
).weight = radixTextWeights[value];
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user