Giter Club home page Giter Club logo

fast-styles's Issues

[Expo][Typescript] 'StyledView' cannot be used as a JSX component.

Describe the bug
Typescript error on using styled component

To Reproduce
Reproducible example

import { styled } from "@fast-styles/react";
import { View } from "react-native";

const StyledView = () => {
  return styled(View, {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    backgroundColor: "red",
  });
};

export default StyledView;
image

Expected behavior
No error expected.

Environment
"@fast-styles/babel-plugin": "^0.2.3",
"@fast-styles/react": "^0.2.9",
"expo": "~49.0.8",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.4"

There's no way to pass a ref to the styled result

Quick fix in the tests with

  // return fast styled component
  return React.forwardRef((props:WithStyles<Props> | VariantsProps<Variants> | StyleProps<Binds>, ref)=>{
    const key = resolveKey(props);

Environment

  • @fast-styles/react version 0.2.9

[Expo][Typescript] Unable to assign children to a styled component

Describe the bug
Unable to assign children to a styled component.

import { defaultTheme, styled } from "@fast-styles/react";
import { View } from "react-native";

export const StyledView = styled(View, {
  flex: 1,
  justifyContent: "center",
  alignItems: "center",
  backgroundColor: "red",
  variants: {
    mode: {
      light: {
        color: defaultTheme.tokens.$textDefault,
      },
      dark: {
        color: defaultTheme.tokens.$textLight,
      },
    },
  },
});
export default function App() {
  const [mode] = useMode();

  return (
    <ModeProvider>
      <View style={styles.container}>
        <Text>Open up App.tsx to start working on your app!</Text>
        <StyledView mode={mode}>
          <Text>Styled View</Text>
        </StyledView>
        <StatusBar style="auto" />
      </View>
    </ModeProvider>
  );
}
Type 'Element' is not assignable to type 'string | number | OpaqueColorValue | AnimatedNode | Readonly<{ width: number; height: number; }> | (PerpectiveTransform | ... 11 more ... | MatrixTransform)[] | number[] | null | undefined'.ts(2322)
image

To Reproduce
Reproducible example

Expected behavior
No ts errors

Environment
"@fast-styles/babel-plugin": "^0.2.3",
"@fast-styles/react": "^0.2.9",
"expo": "~49.0.8",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.4"

Roadmap

  • Add support for theming
  • Add support for design tokens
  • Include a set of basic components as a showcase of the library
  • Conduct benchmarks with other libraries
  • Introduce hooks as an alternative to styled components

Syntactic sugar for compound variants

For a scenario like this, the syntax of compound variants using '+' implies defining empty variants.

const Surface = styled(View, {
  variants: {
    elevation: {
      0: {},
      1: {},
    },
    mode: {
      light: {
        backgroundColor: "$backgroundLight",
      },
      dark: {
        backgroundColor: "$backgroundDark",
      },
    },
  },
  compoundVariants: {
    "light+1": {
      backgroundColor: "$elevationBackgroundLight",
    },
    "dark+1": {
      backgroundColor: "$elevationBackgroundDark",
    },
  }
});

This can be simplified by declaring the compound variants in this way:

const SurfaceView2 = styled(View, {
  variants: {
    mode: {
      light: {
        bg: "$backgroundLight",
      },
      dark: {
        bg: "$backgroundDark",
      },
    },
  },
  compoundVariants: [
    {
      mode: "light",
      elevation: 0,
      value: {
        bg: "$elevationBackgroundLight",
      },
    },
    {
      mode: "dark",
      elevation: 1,
      value: {
        bg: "$elevationBackgroundDark",
      },
    },
  ],
})

the babel-plugin doesn't select default variants if the 'defaultVariants' field is missing in the styled object

Describe the bug
The babel-plugin doesn't select default variants if the defaultVariants field is missing in the styled object.

To Reproduce

export const CardRoot = styled(View, {
  borderRadius: theme.borderRadiuses.$lg,
  padding: theme.spacings.$6,
  variants: {
    colorScheme: {
      green: {
        backgroundColor: theme.colors.$green3,
      },
    },
  },
  // try removing this defaultVariants: {},
});

Environment

  • @fast-styles/babel-plugin version 0.2.3

[Expo] Typescript error using useMode

Describe the bug
Typescript error using useMode();

To Reproduce
Implementing the modes guide

Reproducible example

import { ModeProvider, useMode } from "@fast-styles/react";
import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View } from "react-native";
import StyledView from "./StyledView";

export default function App() {
  const [mode] = useMode();

  return (
    <ModeProvider>
      <View style={styles.container}>
        <Text>Open up App.tsx to start working on your app!</Text>
        <StyledView mode={mode}>
          <Text>Styled View</Text>
        </StyledView>
        <StatusBar style="auto" />
      </View>
    </ModeProvider>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});
image

Expected behavior
Typescript errors should not happen

Environment
"@fast-styles/babel-plugin": "^0.2.3",
"@fast-styles/react": "^0.2.9",
"expo": "~49.0.8",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.4"

Unable to install using pnpm

Describe the bug

pnpm add @fast-styes/react
../..                                    |  WARN  `node_modules` is present. Lockfile only installation will make it out-of-date
 ERR_PNPM_FETCH_404  GET https://registry.npmjs.org/@fast-styes%2Freact: Not Found - 404

This error happened while installing a direct dependency of xxx/apps/native

@fast-styes/react is not in the npm registry, or you have no permission to fetch it.

No authorization header was set for the request.
../..                                    | Progress: resolved 0, reused 1, downloaded 0, added 0

To Reproduce

pnpm add @fast-styes/react @fast-styes/babel-plugin

Expected behavior
Should be able to install @fast-styes/react @fast-styes/babel-plugin using pnpm

Environment

  • @fast-styles/babel-plugin version latest
  • @fast-styles/react version latest
  • react-native version 0.72.4
  • expo version 49.0.8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.