From d60e27cf7726a88a417a2426fc0c0971e842b369 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 16 Nov 2022 11:40:17 +0900 Subject: [PATCH] Add pressable support on the web --- examples/next-example/src/pages/_app.tsx | 3 + examples/next-example/src/pages/index.tsx | 27 +++++-- packages/yoshiki/src/index.ts | 2 + packages/yoshiki/src/native/generator.tsx | 18 ++--- packages/yoshiki/src/react/generator.tsx | 86 ++++++++++++++++------- packages/yoshiki/src/react/hover.ts | 34 +++++++++ packages/yoshiki/src/react/index.tsx | 3 + packages/yoshiki/src/react/shorthands.ts | 2 + packages/yoshiki/src/type.ts | 15 +++- 9 files changed, 143 insertions(+), 47 deletions(-) create mode 100644 packages/yoshiki/src/react/hover.ts diff --git a/examples/next-example/src/pages/_app.tsx b/examples/next-example/src/pages/_app.tsx index fdfcd2f..2cf3f62 100644 --- a/examples/next-example/src/pages/_app.tsx +++ b/examples/next-example/src/pages/_app.tsx @@ -5,6 +5,7 @@ import { Theme, ThemeProvider, useYoshiki } from "yoshiki"; import { AppProps } from "next/app"; +import { useMobileHover } from "yoshiki"; declare module "yoshiki" { export interface Theme { @@ -25,6 +26,8 @@ const AppName = () => { }; const App = ({ Component, pageProps }: AppProps) => { + useMobileHover(); + return ( diff --git a/examples/next-example/src/pages/index.tsx b/examples/next-example/src/pages/index.tsx index 75ff55b..a2033c4 100644 --- a/examples/next-example/src/pages/index.tsx +++ b/examples/next-example/src/pages/index.tsx @@ -12,12 +12,9 @@ const Box = ({ children, ...props }: { children?: ReactNode } & Stylable) => { const { css } = useYoshiki(); return ( -
- {children} -
- ) -} - +
{children}
+ ); +}; export default function Home(props: object) { const { css } = useYoshiki(); @@ -44,14 +41,30 @@ export default function Home(props: object) {

Documentation →

Find in-depth information about Next.js features and API.

+
+

Learn →

Learn about Next.js in an interactive course with quizzes!

diff --git a/packages/yoshiki/src/index.ts b/packages/yoshiki/src/index.ts index 33776ad..1d7b11f 100644 --- a/packages/yoshiki/src/index.ts +++ b/packages/yoshiki/src/index.ts @@ -11,4 +11,6 @@ export { StyleRegistryProvider, createStyleRegistry, type Stylable, + useMobileHover, + Pressable } from "./react"; diff --git a/packages/yoshiki/src/native/generator.tsx b/packages/yoshiki/src/native/generator.tsx index f83a500..16c118c 100644 --- a/packages/yoshiki/src/native/generator.tsx +++ b/packages/yoshiki/src/native/generator.tsx @@ -5,7 +5,7 @@ import { ViewStyle, TextStyle, ImageStyle, useWindowDimensions } from "react-native"; import { breakpoints, Theme, useTheme } from "../theme"; -import { Breakpoints, YoshikiStyle } from "../type"; +import { AtLeastOne, Breakpoints, WithState, YoshikiStyle, hasState } from "../type"; import { isBreakpoints } from "../utils"; import { shorthandsFn } from "./shorthands"; @@ -54,18 +54,6 @@ const propertyMapper = < return [[key, value]]; }; -type WithState