Allow child id to be specified (still hacky)

This commit is contained in:
Zoe Roux
2023-01-11 14:04:17 +09:00
parent e0c24f6554
commit 2fc5cd77f4
4 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -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": [
+1 -1
View File
@@ -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();
+2 -2
View File
@@ -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();
+5 -4
View File
@@ -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();