From 571331b3efbe6b20a64be4b33cc4a58c0d1a934a Mon Sep 17 00:00:00 2001 From: Jacek Pudysz Date: Wed, 1 Nov 2023 01:06:00 +0100 Subject: [PATCH] feat: simplify typescript types --- example/.unistyles/breakpoints.d.ts | 9 - example/.unistyles/themes.d.ts | 13 - examples/expo/babel.config.js | 1 - .../expo/src/examples/{Cxx.jsx => Cxx.tsx} | 9 +- src/UnistylesTheme.tsx | 17 -- src/babel/helpers.js | 227 ------------------ src/babel/plugin.js | 195 --------------- src/createStyleSheet.ts | 7 +- src/createUnistyles.ts | 72 ------ src/index.ts | 3 +- src/types/breakpoints.ts | 20 +- src/types/core.ts | 12 +- src/types/index.ts | 5 +- src/useStyles.ts | 16 +- src/utils/breakpoints.ts | 23 +- src/utils/styles.ts | 21 +- 16 files changed, 56 insertions(+), 594 deletions(-) delete mode 100644 example/.unistyles/breakpoints.d.ts delete mode 100644 example/.unistyles/themes.d.ts rename examples/expo/src/examples/{Cxx.jsx => Cxx.tsx} (88%) delete mode 100644 src/UnistylesTheme.tsx delete mode 100644 src/babel/helpers.js delete mode 100644 src/babel/plugin.js delete mode 100644 src/createUnistyles.ts diff --git a/example/.unistyles/breakpoints.d.ts b/example/.unistyles/breakpoints.d.ts deleted file mode 100644 index 267cc45d..00000000 --- a/example/.unistyles/breakpoints.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare module "unistyles:static" { - type UnistylesBreakpoints = { - xs: 0; - sm: 300; - md: 500; - lg: 800; - xl: 1200; - }; -} \ No newline at end of file diff --git a/example/.unistyles/themes.d.ts b/example/.unistyles/themes.d.ts deleted file mode 100644 index 77ddcafc..00000000 --- a/example/.unistyles/themes.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -declare module "unistyles:static" { - type UnistylesTheme = { - colors: { - barbie: string; - oak: string; - sky: string; - fog: string; - aloes: string; - backgroundColor: string; - typography: string; - }; - }; -} \ No newline at end of file diff --git a/examples/expo/babel.config.js b/examples/expo/babel.config.js index 660579a1..0aa876cf 100644 --- a/examples/expo/babel.config.js +++ b/examples/expo/babel.config.js @@ -7,7 +7,6 @@ module.exports = function (api) { return { presets: ['babel-preset-expo'], plugins: [ - // '../src/babel/plugin.js', [ 'module-resolver', { diff --git a/examples/expo/src/examples/Cxx.jsx b/examples/expo/src/examples/Cxx.tsx similarity index 88% rename from examples/expo/src/examples/Cxx.jsx rename to examples/expo/src/examples/Cxx.tsx index f049ebfd..d5c9ea1f 100644 --- a/examples/expo/src/examples/Cxx.jsx +++ b/examples/expo/src/examples/Cxx.tsx @@ -2,7 +2,6 @@ import React from 'react' import { View, Text, Button } from 'react-native' import { UnistylesRuntime, createStyleSheet, useStyles } from 'react-native-unistyles' -// todo, for now TypeScript is broken export const Cxx = () => { const { styles, theme } = useStyles(stylesheet) @@ -16,7 +15,7 @@ export const Cxx = () => { Current breakpoint: - {` ${UnistylesRuntime.getCurrentBreakpoint()}`} + {` ${UnistylesRuntime.currentBreakpoint}`} @@ -24,20 +23,20 @@ export const Cxx = () => { Theme: - {` ${UnistylesRuntime.getCurrentTheme()}`} + {` ${UnistylesRuntime.theme}`}