mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-20 04:14:12 +01:00
feat: legacy
This commit is contained in:
1 parent
9640920863
commit
8d9ca3d716
271 files changed
+1
-1
No files matched your search
@@ -1,31 +0,0 @@
|
||||
import { TextProps } from '@radix-ui/themes';
|
||||
import { EmbedConfig } from '.';
|
||||
import * as EmbedState from './';
|
||||
import { EmbedConfigItemType, EmbedItemType } from './constants';
|
||||
|
||||
export function useEmbedStateCurry<Config extends EmbedConfig>() {
|
||||
function useState<Key extends keyof Config>(key: Key) {
|
||||
return EmbedState.use((state) => {
|
||||
return (state as EmbedState.ExtractEmbedConfigTypes<Config>)[key];
|
||||
});
|
||||
}
|
||||
|
||||
function useRichText<
|
||||
Key extends {
|
||||
[K in keyof Config]: Config[K] extends { type: EmbedItemType.RichText }
|
||||
? K
|
||||
: never;
|
||||
}[keyof Config],
|
||||
>(key: Key) {
|
||||
const { color, ...state } = useState(
|
||||
key,
|
||||
) as EmbedConfigItemType<EmbedItemType.RichText>['default'];
|
||||
|
||||
return {
|
||||
style: { color },
|
||||
...state,
|
||||
} satisfies TextProps;
|
||||
}
|
||||
|
||||
return { useState, useRichText };
|
||||
}
|
||||
Reference in new issue
Block a user