GithubHelp home page GithubHelp logo

tiaanduplessis / flapstacks Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 32 KB

๐Ÿฅž Flex layout primitive for React & React Native

License: MIT License

TypeScript 100.00%
flex layout react stack

flapstacks's Introduction

๐Ÿฅž flapstacks

package version package downloads standard-readme compliant package license make a pull request

Flex layout primitive for React & React Native (wip)

๐Ÿ“– Table of Contents

๐Ÿ‘€ Background

This package is a tiny wrapper around the Flexbox one-dimensional layout method to allow for a prop based styling API as seen in Styled System.

Features

  • Works in React and React Native (wip)
  • Flexible shorthand props
  • TypeScript support with API docs
  • Polymorphic component type
  • Style overriding to hook into your Design System

โš™๏ธ Install

Install the package locally within you project folder with your package manager:

With npm:

npm install flapstacks

With yarn:

yarn add flapstacks

With pnpm:

pnpm add flapstacks

๐Ÿ“– Usage

import { Stack } from "flapstacks";

const Box = () => (
  <div style={{ height: 100, width: 100, backgroundColor: "tomato" }} />
);

export default function App() {
  return (
    <Stack
      as="main"
      direction="column"
      cross="center"
      justifyContentSpaceBetween
      gap={2}
    >
      <Box />
      <Box />
      <Box />
      <Box />
      <Box />
    </Stack>
  );
}

Overridable styles

If you have an existing set to design tokens that you would like to connect to the props of the stack then the onOverrideStyles prop can be used:

const CustomStack = (props) => {
  const handleOverride = (style: CSSProperties) => {
      // Design tokens
      const scale = ["16px", "32px"]
      if (style.gap) {
        style.gap = scale[style.gap as number];
      }
    
      return style;
    }
  
  return <Stack {...props} onOverrideStyles={handleOverride}>
}

๐Ÿ“š API

For all configuration options, please see the API docs.

๐Ÿ’ฌ Contributing

Got an idea for a new feature? Found a bug? Contributions are welcome! Please open up an issue or make a pull request.

๐Ÿชช License

MIT ยฉ Tiaan du Plessis

flapstacks's People

Contributors

tiaanduplessis avatar

Stargazers

Roman Hossain Shaon avatar

Watchers

James Cloos avatar  avatar  avatar

flapstacks's Issues

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.