GithubHelp home page GithubHelp logo

s-fabian / react-native-alam Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 1.58 MB

A tailwind-like solution for react native

Home Page: https://www.npmjs.com/package/react-native-alam

License: MIT License

JavaScript 8.27% TypeScript 91.73%
react-native tailwind tailwindcss styling

react-native-alam's Introduction

react-native-alam

A tailwind-like solution for react native

Click here to see all properties / alams.

Installation

npm install --save react-native-alam
yarn add react-native-alam
pnpm add react-native-alam
bun add react-native-alam
pip install react-native-alam # wait

Usage

alam.tsx

import createAlam from 'react-native-alam';

export const Alam = createAlam({});

component.tsx

import { Alam } from './alam';

function MySuperComponent({ style }: { style?: Style }) {
  return (
    <Alam.View style={style}>
      <Alam.Text text-xl text-center>
        Hello World!
      </Alam.Text>
    </Alam.View>
  );
}

export default Alam.convert(MySuperComponent);

index.tsx

import MySuperComponent from './component';
import { Alam } from './alam';

export default function App() {
  return (
    <Alam.View p={20}>
      <MySuperComponent mt={30} />
    </Alam.View>
  );
}

Advanced Usage

alam.tsx

import createAlam from 'react-native-alam';

const extended = {
  'custom-extended': (_: true, style: Style) => ({
    color: 'red',
    ...style,
  }),
};

export const Alam = createAlam(extended);

index.tsx

import { Alam } from './alam';

export default function App() {
  return (
    <Alam.View p={20}>
      <Alam.Text mt={30} custom-extended>
        Red Text
      </Alam.Text>
    </Alam.View>
  );
}

With colors

root.tsx

import { ThemeProvider, Appearance } from 'react-native-alam';

export const enum Colors {
  Background = 'background',
  Foreground = 'foreground',
  Primary = 'primary',
}

export default function Root({ component }) {
  const isDarkMode = Appearance.getColorScheme() === 'dark';

  const theme: Record<Colors, string> = isDarkMode
    ? {
        background: '#000000',
        foreground: '#eeeeee',
        primary: '#eee8aa',
      }
    : {
        background: '#ffffff',
        foreground: '#111111',
        primary: '#daa520',
      };

  return <ThemeProvider colors={theme}>{component}</ThemeProvider>;
}

index.tsx

import { Alam } from './alam';
import { Colors } from './root';

export default function App() {
  return (
    <Alam.View bg={Colors.Background} p={20}>
      <Alam.Text color={Colors.Primary}>Primary Text</Alam.Text>
      <Alam.Text color={Colors.Foreground}>Foreground Text</Alam.Text>
    </Alam.View>
  );
}

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.