From 47c98245a30f228132e1e64469f7a1cd3886e1a3 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 16 Nov 2022 00:04:02 +0900 Subject: [PATCH] Add pressable support on react native --- .eslintrc.json | 3 +- examples/expo-example/src/app.tsx | 28 ++++++++-- packages/yoshiki/package.json | 9 +-- packages/yoshiki/src/native/generator.tsx | 68 ++++++++++++++++++----- packages/yoshiki/src/native/hover.tsx | 51 +++++++++++++++++ packages/yoshiki/src/native/index.ts | 2 + 6 files changed, 136 insertions(+), 25 deletions(-) create mode 100644 packages/yoshiki/src/native/hover.tsx diff --git a/.eslintrc.json b/.eslintrc.json index 05beca7..d012a7c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,6 +17,7 @@ "" ], 1 - ] + ], + "@typescript-eslint/ban-ts-ignore": "off" } } diff --git a/examples/expo-example/src/app.tsx b/examples/expo-example/src/app.tsx index bdef548..8b6f434 100644 --- a/examples/expo-example/src/app.tsx +++ b/examples/expo-example/src/app.tsx @@ -6,7 +6,7 @@ import { StatusBar } from "expo-status-bar"; import { Text, View } from "react-native"; import { registerRootComponent } from "expo"; -import { Stylable, useYoshiki } from "yoshiki/native"; +import { Pressable, Stylable, useYoshiki } from "yoshiki/native"; const CustomBox = ({ color, ...props }: { color: string } & Stylable) => { const { css } = useYoshiki(); @@ -22,9 +22,29 @@ const BoxWithoutProps = (props: Stylable) => { const { css } = useYoshiki(); return ( - - Text inside the box without props (green on small screens, red on bigs) - + + + Text inside the box without props (green on small screens, red on bigs) + + ); }; diff --git a/packages/yoshiki/package.json b/packages/yoshiki/package.json index fd9eee1..a264e19 100644 --- a/packages/yoshiki/package.json +++ b/packages/yoshiki/package.json @@ -13,14 +13,9 @@ "bugs": { "url": "https://github.com/AnonymusRaccoon/yoshiki/issues" }, - "main": "dist/index.js", - "types": "dist/index.d.ts", + "main": "src/index.ts", + "types": "src/index.ts", "source": "src/index.ts", - "exports": { - ".": "./dist/index.ts", - "./native": "./dist/native/index.ts", - "./web": "./dist/index.ts" - }, "scripts": { "build": "tsc --build ." }, diff --git a/packages/yoshiki/src/native/generator.tsx b/packages/yoshiki/src/native/generator.tsx index 6b3a371..f83a500 100644 --- a/packages/yoshiki/src/native/generator.tsx +++ b/packages/yoshiki/src/native/generator.tsx @@ -54,28 +54,70 @@ const propertyMapper = < return [[key, value]]; }; +type WithState