diff --git a/packages/yoshiki/package.json b/packages/yoshiki/package.json
index 6f33f9c..e715794 100644
--- a/packages/yoshiki/package.json
+++ b/packages/yoshiki/package.json
@@ -1,6 +1,6 @@
{
"name": "yoshiki",
- "version": "0.2.13",
+ "version": "0.3.1",
"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 3bf32b6..050aaa3 100644
--- a/packages/yoshiki/src/native/generator.tsx
+++ b/packages/yoshiki/src/native/generator.tsx
@@ -36,7 +36,8 @@ const propertyMapper = (
const bpKeys = Object.keys(breakpoints) as Array>;
for (let i = breakpoint; i >= 0; i--) {
if (bpKeys[i] in value) {
- const bpVal = value[bpKeys[i]];
+ const bpValOrF = value[bpKeys[i]];
+ const bpVal = typeof bpValOrF === "function" ? bpValOrF(theme) : bpValOrF;
return bpVal ? [[key, bpVal]] : [];
}
}
diff --git a/packages/yoshiki/src/native/index.tsx b/packages/yoshiki/src/native/index.tsx
index a03e222..61970a8 100644
--- a/packages/yoshiki/src/native/index.tsx
+++ b/packages/yoshiki/src/native/index.tsx
@@ -27,6 +27,7 @@ export { breakpoints, useTheme } from "../theme";
export { useYoshiki } from "./generator";
export { Pressable } from "./hover";
export * from "./units";
+export { sm, md, lg, xl } from "./type";
export const ThemeProvider = ({ theme, children }: { theme: Theme; children?: ReactNode }) => {
return {children};
diff --git a/packages/yoshiki/src/native/type.ts b/packages/yoshiki/src/native/type.ts
index 07b3324..a59780b 100644
--- a/packages/yoshiki/src/native/type.ts
+++ b/packages/yoshiki/src/native/type.ts
@@ -6,6 +6,8 @@
import { FilterOr, WithState, YoshikiStyle, Length, StyleList } from "../type";
import { shorthandsFn } from "../shorthands";
import { ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
+import { Theme } from "../theme";
+import { forceBreakpoint, WithBreakpoints } from "../utils";
// The extends any check is only used to make EnhancedStyle a distributive type.
// This means EnhancedStyle = EnhancedStyle | EnhancedStyle
@@ -21,6 +23,21 @@ export type EnhancedStyle = Properties extends any
}
: never;
+type ForcedBreakpointStyle = Properties extends any
+ ? {
+ [key in keyof Properties]: Properties[key] | ((theme: Theme) => Properties[key]);
+ }
+ : never;
+
+export const sm = (value: ForcedBreakpointStyle) =>
+ forceBreakpoint(value, "sm");
+export const md = (value: ForcedBreakpointStyle) =>
+ forceBreakpoint(value, "md");
+export const lg = (value: ForcedBreakpointStyle) =>
+ forceBreakpoint(value, "lg");
+export const xl = (value: ForcedBreakpointStyle) =>
+ forceBreakpoint(value, "xl");
+
export type StyleFunc