npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-smart-layout

v1.0.1

Published

Using flexbox to create simple and useful components (React Native).

Downloads

41

Readme

react-smart-layout

npm-badge downloads-badge

Simple flexbox abstraction for react-native and react for web.

  • create columns and rows (flex-direction) and put space (defined by you) between children
  • components for padding and margin (put edge value as props)
  • component for space-between (justify-content)
  • other useful components, react-native only

Supports ReactJS through react-native-web

Install

  • npm: npm install react-smart-layout --save
  • yarn: yarn add react-smart-layout

Example

Edit react-smart-layout-example

Components

Column

Create element with direction column and put space between elements

import React from 'react'
import {Text} from 'react-native'
import {Column, Padding} from 'react-smart-layout'
import {Divider} from 'react-native-elements'

function MyComponent() {
    return <Column
       space={10} // space in px
       style={{ backgroundColor: 'gray' }} // custom style
       divider={<Divider/>} // put divider/other component between elements
       wrapper={<Padding left={10}/>} // optional wrapper each element
    >
        <Text>Text 1</Text>
        <Text>Text 2</Text>
        <Text>Text 3</Text>
    </Column>
}

type ColumnProps = ViewProps & ScrollViewProps & {
    wrapper?: React.ReactElement<{}>,
    divider?: React.ReactElement<{}>,
    space?: number,
    scrollable?: boolean,
}

Row

Create element with direction row and put space between elements

import React from 'react'
import {Text} from 'react-native'
import {Row} from 'react-smart-layout'

function MyComponent() {
    return <Row
       space={10} // space in px
       alignCenter // put align-items: center in style
       style={{ backgroundColor: 'gray' }} // custom style
       scrollable // wrap as ScrollView
    >
        <Text>Text 1</Text>
        <Text>Text 2</Text>
        <Text>Text 3</Text>
    </Row>
}

type RowProps = ViewProps & ScrollViewProps & {
    wrapper?: React.ReactElement<{}>,
    divider?: React.ReactElement<{}>,
    space?: number,
    scrollable?: boolean,
    alignCenter?: boolean
}

Padding

import React from 'react'
import {Text} from 'react-native'
import {Padding} from 'react-smart-layout'

function MyComponent() {
    return <Padding
        top={10}
        right={20}
        horizontal={15}
        vertical={5}
    >
        <Text>Testing padding component</Text>
    </Padding>
}

type PaddingProps = {
    children: React.ReactNode,
    horizontal?: number,
    vertical?: number,
    left?: number,
    right?: number,
    bottom?: number,
    top?: number,
    all?: number,
}

Margin

Wrap components with margin, has the same props of padding

RowBetween

Create a component with style:

{
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center'
}
import React from 'react'
import {Text, View} from 'react-native'
import {RowBetween} from 'react-smart-layout'

function MyComponent() {
    return <View>
        <RowBetween>
            <Text>Text 1</Text>
            <Text>Text 2</Text>
        </RowBetween>
    </View>
}

type RowBetweenProps = ViewProps

React-native only:

SpaceStatusBar

Space of status bar (android and ios)

import React from 'react'
import {Text, View} from 'react-native'
import {SpaceStatusBar} from 'react-smart-layout'
import styled from 'styled-components'

function MyComponent() {
    return <View>
        <Header>
            <SpaceStatusBar />
            <Text>Header</Text>
        </Header>
        
        <Content>
            <Text>Content</Text>
        </Content>
    </View>
}

const Header = styled.View``
const Content = styled.ScrollView``

type SpaceStatusBarProps = ViewProps

KeyboardSafe

Wrap elements with KeyboardAvoidingView

import React from 'react'
import {ScrollView, View, TextInput} from 'react-native'
import {KeyboardSafe} from 'react-smart-layout'

function MyComponent() {
    return <ScrollView>
        <KeyboardSafe>
            <TextInput/>
        </KeyboardSafe>
    </ScrollView>
}

Usage

ReactJS

import React from "react";
import { Column, Row, RowBetween } from "react-smart-layout";

function App() {
  return (
    <Column
      space={20}
      divider={<div style={{ borderBottom: "1px solid red" }} />}
    >
      <Column space={20} wrapper={wrapper}>
        <p>First paragraph</p>
        <p>Second paragraph</p>
        <p>Third paragraph</p>
      </Column>
      <Row
        space={30}
        divider={
          <div style={{ height: "100%", borderRight: "1px solid red" }} />
        }
      >
        <span>First column</span>
        <span>Second column</span>
        <span>Third column</span>
      </Row>
      <RowBetween>
        <span>Left</span>
        <span>Right</span>
      </RowBetween>
    </Column>
  );
}

const wrapper = (
  <div
    style={{
      backgroundColor: "#407bdb",
      border: "1px solid white",
      color: "white"
    }}
  />
);

export default App;

image