mirror of
https://github.com/zoriya/yoshiki.git
synced 2026-06-02 02:25:37 +00:00
Allow child id to be specified (still hacky)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yoshiki",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.2",
|
||||
"author": "Zoe Roux <zoe.roux@sdg.moe> (https://github.com/AnonymusRaccoon)",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -66,7 +66,7 @@ const useForceRerender = () => {
|
||||
|
||||
type State = EnhancedStyle<ViewStyle | TextStyle | ImageStyle> | undefined;
|
||||
|
||||
export const useYoshiki = () => {
|
||||
export const useYoshiki = (_?: string) => {
|
||||
const breakpoint = useBreakpoint();
|
||||
const theme = useTheme();
|
||||
const rerender = useForceRerender();
|
||||
|
||||
@@ -16,10 +16,10 @@ const rnwPreprocess = (block: Record<string, unknown>) => {
|
||||
return createReactDOMStyle(block);
|
||||
};
|
||||
|
||||
export const useYoshiki = () => {
|
||||
export const useYoshiki = (prefixKey?: string) => {
|
||||
const registry = useStyleRegistry();
|
||||
const theme = useTheme();
|
||||
const [parentPrefix, childPrefix] = useClassId();
|
||||
const [parentPrefix, childPrefix] = useClassId(prefixKey);
|
||||
|
||||
useInsertionEffect(() => {
|
||||
registry.flushToBrowser();
|
||||
|
||||
@@ -207,8 +207,9 @@ export const yoshikiCssToClassNames = (
|
||||
);
|
||||
};
|
||||
|
||||
export const useClassId = () => {
|
||||
const id = useId().replaceAll(":", "-");
|
||||
// TODO: This is extremly hacky and an ID should be unique to a component, not an instance.
|
||||
export const useClassId = (prefixKey?: string) => {
|
||||
const id = prefixKey ?? useId().replaceAll(":", "-");
|
||||
return ["ysp" + id, "ysc" + id] as const;
|
||||
};
|
||||
|
||||
@@ -293,10 +294,10 @@ export const generateChildCss = (
|
||||
processStyles(press, "press");
|
||||
};
|
||||
|
||||
export const useYoshiki = () => {
|
||||
export const useYoshiki = (prefixKey?: string) => {
|
||||
const theme = useTheme();
|
||||
const registry = useStyleRegistry();
|
||||
const [parentPrefix, childPrefix] = useClassId();
|
||||
const [parentPrefix, childPrefix] = useClassId(prefixKey);
|
||||
|
||||
useInsertionEffect(() => {
|
||||
registry.flushToBrowser();
|
||||
|
||||
Reference in New Issue
Block a user