diff --git a/examples/next-example/src/pages/index.tsx b/examples/next-example/src/pages/index.tsx
index ffbf34e..f8e8a80 100644
--- a/examples/next-example/src/pages/index.tsx
+++ b/examples/next-example/src/pages/index.tsx
@@ -16,7 +16,7 @@ const Box = ({ children, ...props }: { children?: ReactNode } & Stylable) => {
);
};
-export default function Home(props: object) {
+export default function Home(props: Stylable) {
const { css } = useYoshiki();
return (
@@ -27,6 +27,7 @@ export default function Home(props: object) {
display: "flex",
paddingLeft: "2rem",
paddingRight: "2rem",
+ paddingTop: (theme) => theme.background,
bg: (theme) => theme.background,
},
md({
@@ -58,19 +59,31 @@ export default function Home(props: object) {
-
+
Documentation →
Find in-depth information about Next.js features and API.
@@ -89,7 +102,7 @@ export default function Home(props: object) {
diff --git a/packages/yoshiki/src/native/generator.web.ts b/packages/yoshiki/src/native/generator.web.ts
index cedf962..3a9a767 100644
--- a/packages/yoshiki/src/native/generator.web.ts
+++ b/packages/yoshiki/src/native/generator.web.ts
@@ -5,11 +5,11 @@
import { useInsertionEffect } from "react";
import { RegisteredStyle } from "react-native";
import { useTheme } from "../theme";
-import { processStyleList, StyleList } from "../type";
+import { processStyleList, processStyleListWithoutChild, StyleList } from "../type";
import { NativeCssFunc } from "./type";
import createReactDOMStyle from "react-native-web/dist/exports/StyleSheet/compiler/createReactDOMStyle";
import preprocess from "react-native-web/dist/exports/StyleSheet/preprocess";
-import { yoshikiCssToClassNames } from "../web/generator";
+import { useClassId, yoshikiCssToClassNames } from "../web/generator";
import { useStyleRegistry } from "../web";
const rnwPreprocess = (block: Record) => {
@@ -19,25 +19,30 @@ const rnwPreprocess = (block: Record) => {
export const useYoshiki = () => {
const registry = useStyleRegistry();
const theme = useTheme();
+ const childPrefix = useClassId();
useInsertionEffect(() => {
registry.flushToBrowser();
}, [registry]);
const css: NativeCssFunc = (cssList, leftOvers) => {
- const css = processStyleList(cssList);
+ const [css, parentKeys] = processStyleListWithoutChild(cssList);
const getStyle = (
inlineList: StyleList<{ $$css?: true; yoshiki?: string } | RegisteredStyle>,
) => {
const inline = processStyleList(inlineList);
const overrides = "$$css" in inline && inline.$$css ? inline.yoshiki : undefined;
- const classNames = yoshikiCssToClassNames(css, overrides?.split(" "), {
- registry,
- theme,
- preprocessBlock: rnwPreprocess,
- preprocess
- });
+ const classNames = yoshikiCssToClassNames(
+ css,
+ [...parentKeys.map((x) => `${childPrefix}${x}`), ...(overrides?.split(" ") ?? [])],
+ {
+ registry,
+ theme,
+ preprocessBlock: rnwPreprocess,
+ preprocess,
+ },
+ );
// We use the inlineList and not the inline we have locally since $$css and inlines are not mergable.
return [inlineList, { $$css: true, yoshiki: classNames }];
};
diff --git a/packages/yoshiki/src/type.ts b/packages/yoshiki/src/type.ts
index b73c04b..7fbea45 100644
--- a/packages/yoshiki/src/type.ts
+++ b/packages/yoshiki/src/type.ts
@@ -33,6 +33,23 @@ export const processStyleList =