diff --git a/examples/expo-example/src/app.tsx b/examples/expo-example/src/app.tsx
index 39e9ca6..20ed3ef 100644
--- a/examples/expo-example/src/app.tsx
+++ b/examples/expo-example/src/app.tsx
@@ -4,7 +4,7 @@
//
import { StatusBar } from "expo-status-bar";
-import { Text, View, Pressable } from "react-native";
+import { Text, View, Pressable, TextProps } from "react-native";
import { registerRootComponent } from "expo";
import { Stylable, useYoshiki, px } from "yoshiki/native";
import { H1 } from "@expo/html-elements";
@@ -45,6 +45,20 @@ const BoxWithoutProps = (props: Stylable) => {
);
};
+const P = (props: TextProps) => {
+ const { css } = useYoshiki();
+ return (
+
+ );
+};
+
function App() {
const { css } = useYoshiki();
@@ -60,6 +74,12 @@ function App() {
Open up App.tsx to start working on your app!
+
+ Test
+
);
diff --git a/examples/expo-example/src/theme.d.ts b/examples/expo-example/src/theme.d.ts
new file mode 100644
index 0000000..582c9cf
--- /dev/null
+++ b/examples/expo-example/src/theme.d.ts
@@ -0,0 +1,19 @@
+//
+// Copyright (c) Zoe Roux and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for details.
+//
+
+import "yoshiki";
+import "yoshiki/native";
+
+declare module "yoshiki" {
+ interface Theme {
+ font: string;
+ }
+}
+
+declare module "yoshiki/native" {
+ interface Theme {
+ font: string;
+ }
+}
diff --git a/packages/yoshiki/package.json b/packages/yoshiki/package.json
index 5fe5391..d042bd0 100644
--- a/packages/yoshiki/package.json
+++ b/packages/yoshiki/package.json
@@ -1,6 +1,6 @@
{
"name": "yoshiki",
- "version": "0.2.2",
+ "version": "0.2.3",
"author": "Zoe Roux (https://github.com/AnonymusRaccoon)",
"license": "MIT",
"keywords": [
diff --git a/packages/yoshiki/src/native/generator.tsx b/packages/yoshiki/src/native/generator.tsx
index cd8482a..a04b4d4 100644
--- a/packages/yoshiki/src/native/generator.tsx
+++ b/packages/yoshiki/src/native/generator.tsx
@@ -3,9 +3,16 @@
// Licensed under the MIT license. See LICENSE file in the project root for details.
//
-import { ViewStyle, TextStyle, ImageStyle, useWindowDimensions } from "react-native";
+import { ViewStyle, TextStyle, ImageStyle, StyleProp, useWindowDimensions } from "react-native";
import { breakpoints, Theme, useTheme } from "../theme";
-import { Breakpoints, WithState, YoshikiStyle, hasState } from "../type";
+import {
+ Breakpoints,
+ WithState,
+ YoshikiStyle,
+ hasState,
+ StyleList,
+ processStyleList,
+} from "../type";
import { isBreakpoints } from "../utils";
import { shorthandsFn } from "../shorthands";
import { EnhancedStyle, YsStyleProps } from "./type";
@@ -17,16 +24,13 @@ const useBreakpoint = (): number => {
return idx - 1;
};
-const propertyMapper = <
- Property extends number | string | boolean | undefined | Property[] | object,
->(
+const propertyMapper = (
key: string,
- value: YoshikiStyle,
+ value: YoshikiStyle,
{ breakpoint, theme }: { breakpoint: number; theme: Theme },
-): [string, number | string | boolean | undefined | object][] => {
+): [string, unknown][] => {
if (key in shorthandsFn) {
- // @ts-ignore `key` is not narrowed to `keyof typeof shorthandsFn` and value is not type safe.
- const expanded = shorthandsFn[key as keyof typeof shorthandsFn](value);
+ const expanded = shorthandsFn[key as keyof typeof shorthandsFn](value as any);
return Object.entries(expanded)
.map(([eKey, eValue]) => propertyMapper(eKey, eValue, { breakpoint, theme }))
.flat();
@@ -35,8 +39,8 @@ const propertyMapper = <
if (typeof value === "function") {
value = value(theme);
}
- if (isBreakpoints(value)) {
- const bpKeys = Object.keys(breakpoints) as Array>;
+ if (isBreakpoints(value)) {
+ const bpKeys = Object.keys(breakpoints) as Array>;
for (let i = breakpoint; i >= 0; i--) {
if (bpKeys[i] in value) {
const bpVal = value[bpKeys[i]];
@@ -56,19 +60,21 @@ export const useYoshiki = () => {
css: <
Style extends ViewStyle | TextStyle | ImageStyle,
State extends Partial>> | Record,
+ Leftover,
>(
- css: EnhancedStyle