mirror of
https://github.com/zoriya/yoshiki.git
synced 2026-06-02 02:25:37 +00:00
Fix leftover style functions without props in the options.
This commit is contained in:
@@ -100,6 +100,7 @@ const P = (props: TextProps) => {
|
||||
function App() {
|
||||
const { css } = useYoshiki();
|
||||
const test: ImageProps = {};
|
||||
const funcStyle = css({ focus: { self: { bg: "red" } } });
|
||||
|
||||
return (
|
||||
<View
|
||||
@@ -114,7 +115,7 @@ function App() {
|
||||
<Text>Open up App.tsx to start working on your app!</Text>
|
||||
<CustomBox color="black" {...css({ borderColor: "red", borderWidth: px(3) })} />
|
||||
<BoxWithoutProps {...css({ borderColor: "red", borderWidth: px(3) })} />
|
||||
<Pressable android_ripple={{ color: "black" }}>
|
||||
<Pressable android_ripple={{ color: "black" }} {...css({ bg: "black" }, funcStyle)}>
|
||||
<P
|
||||
accessibilityLabel="toto"
|
||||
{...css([undefined, false, { color: "red" }, [{ color: "green" }, false]])}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yoshiki",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"author": "Zoe Roux <zoe.roux@sdg.moe> (https://github.com/AnonymusRaccoon)",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import {
|
||||
ImageStyle,
|
||||
PressableProps,
|
||||
PressableStateCallbackType,
|
||||
TextStyle,
|
||||
useWindowDimensions,
|
||||
ViewStyle,
|
||||
@@ -87,8 +88,8 @@ export const useYoshiki = (_?: string) => {
|
||||
|
||||
if (hasState<State>(css)) {
|
||||
const { hover, focus, fover, press, ...inline } = css;
|
||||
const { onPressIn, onPressOut, onHoverIn, onHoverOut, onFocus, onBlur } =
|
||||
leftOvers as PressableProps;
|
||||
const { onPressIn, onPressOut, onHoverIn, onHoverOut, onFocus, onBlur } = (leftOvers ??
|
||||
{}) as PressableProps;
|
||||
const ret: StyleFunc<unknown> = ({ hovered, focused, pressed }) => {
|
||||
childStyles.current = {};
|
||||
assignChilds(childStyles.current, child);
|
||||
@@ -142,9 +143,14 @@ export const useYoshiki = (_?: string) => {
|
||||
},
|
||||
} satisfies PressableProps;
|
||||
} else {
|
||||
const ret = [processStyle(css), processStyle(child?.self ?? {})];
|
||||
const loStyle = leftOvers?.style;
|
||||
return {
|
||||
...leftOvers,
|
||||
style: [processStyle(css), processStyle(child?.self ?? {}), leftOvers?.style],
|
||||
style:
|
||||
typeof loStyle === "function"
|
||||
? (state: PressableStateCallbackType) => [...ret, loStyle(state)]
|
||||
: [...ret, loStyle],
|
||||
} as any;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user