All Projects → mobily → Stacks

mobily / Stacks

Licence: mit
⚡ Build React Native views blazingly fast.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Stacks

Shapeofview
Give a custom shape to any android view, Material Design 2 ready
Stars: ✭ 2,977 (+959.43%)
Mutual labels:  view, layout
Android 3d Layout
Wow effect, transform your layout into 3D views
Stars: ✭ 199 (-29.18%)
Mutual labels:  view, layout
Arclayout
With Arc Layout explore new styles and approaches on material design
Stars: ✭ 1,662 (+491.46%)
Mutual labels:  view, layout
Kotlinanim
Create fluent animations in a kotlin way
Stars: ✭ 72 (-74.38%)
Mutual labels:  view, layout
FillProgressLayout
A simple and flexible Fillable Progress Layout written in Kotlin
Stars: ✭ 77 (-72.6%)
Mutual labels:  view, layout
Kvconstraintkit
An Impressive Auto Layout DSL for iOS, tvOS & OSX. & It is written in pure swift.
Stars: ✭ 91 (-67.62%)
Mutual labels:  view, layout
Expansionpanel
Android - Expansion panels contain creation flows and allow lightweight editing of an element.
Stars: ✭ 1,984 (+606.05%)
Mutual labels:  view, layout
Longshadow
Add a long shadow on any Android View
Stars: ✭ 562 (+100%)
Mutual labels:  view, layout
ShadowDrawable
为View 和 ViewGroup 添加阴影效果--Android,Add shadow for single view or viewgroup layout.
Stars: ✭ 22 (-92.17%)
Mutual labels:  view, layout
pulldownlayout
PullDownLayout is a small library that allows you to implement a view that can be dragged down your layout. PullDownLayout can also be used to implement Pull-To-Dismiss feature for your activities and fragments.
Stars: ✭ 16 (-94.31%)
Mutual labels:  view, layout
Readablebottombar
Yet another material bottom bar library for Android
Stars: ✭ 977 (+247.69%)
Mutual labels:  view, layout
bubble-layout
An Android ViewGroup that displays avatar bubbles... similar to the chat bubbles on Facebook Messenger.
Stars: ✭ 46 (-83.63%)
Mutual labels:  view, layout
Androidlibs
🔥正在成为史上最全分类 Android 开源大全~~~~(长期更新 Star 一下吧)
Stars: ✭ 7,148 (+2443.77%)
Mutual labels:  view, layout
Bannerlayout
Support unlimited picture rotation BannerLayout, the minimum implementation of the code banner
Stars: ✭ 92 (-67.26%)
Mutual labels:  view, layout
Physicslayout
Android layout that simulates physics using JBox2D
Stars: ✭ 658 (+134.16%)
Mutual labels:  view, layout
Android Statefullayout
A custom Android ViewGroup to display different states of screen (CONTENT, PROGRESS, OFFLINE, EMPTY, etc.)
Stars: ✭ 140 (-50.18%)
Mutual labels:  view, layout
Bouncylayout
Make. It. Bounce.
Stars: ✭ 4,035 (+1335.94%)
Mutual labels:  view, layout
Mylinearlayout
MyLayout is a powerful iOS UI framework implemented by Objective-C. It integrates the functions with Android Layout,iOS AutoLayout,SizeClass, HTML CSS float and flexbox and bootstrap. So you can use LinearLayout,RelativeLayout,FrameLayout,TableLayout,FlowLayout,FloatLayout,PathLayout,GridLayout,LayoutSizeClass to build your App 自动布局 UIView UITab…
Stars: ✭ 4,152 (+1377.58%)
Mutual labels:  view, layout
Flexml
🚀基于Litho的Android高性能动态业务容器。
Stars: ✭ 225 (-19.93%)
Mutual labels:  view, layout
table-layout
Styleable plain-text table generator. Useful for formatting console output.
Stars: ✭ 18 (-93.59%)
Mutual labels:  view, layout

⚡ Stacks · Build Status Coverage npm PRs Welcome All Contributors GitHub license

Build React Native views blazingly fast.

Motivation

Disclaimer: Stacks is not yet another full design system.

Max Stoiber has recently written an interesting article about why margin is considered harmful. There are three main disadvantages of using margin:

  • margin breaks component encapsulation
  • margin makes reusability harder
  • margin conflicts with how designers think

I fully agree with this point of view. To me, it's obvious that handling margins across the entire project is simply difficult and might be not scalable. For web projects, a design system called Braid has developer-friendly API for building layouts. However, a similar library was missing for React Native based projects. Therefore, Stacks has been created and it adopts Braid Layouts API with subtle differences.

Getting started

Installation

yarn add @mobily/stacks

or with npm

npm install @mobily/stacks --save

Prerequisites

To use Stacks properly you need to pass a default spacing value to StacksProvider at the top of your react tree.

import { StacksProvider } from '@mobily/stacks'

const App = () => {
  return (
    <StacksProvider spacing={4}></StacksProvider>
  )
}

In short, the spacing value unit here is a logical pixel, the same as you've been using before for either margin or padding. Stacks will automatically multiply the default spacing value by value of space (padding as well) passed to the components, for instance:

<StacksProvider spacing={4}></StacksProvider>

<Stack space={2}></Stack>
// ⬆️ 4 * 2 = 8 logical pixels

<Box padding={3}></Box>
// ⬆️ 4 * 3 = 12 logical pixels

Consistent and clear!

Example

The following example shows how simple is building screens without using neither margin nor padding properties in your style sheets objects. For debugging purposes, you may want to turn the debug mode on (pass the debug property to the provider) or use the customizable Grid component.

Debug mode Grid component
screen screen screen
import React from 'react'
import { ScrollView, Text } from 'react-native'
import { Stack, Box, Columns, Column, Tiles } from '@mobily/stacks'

// import components, styles, etc.

const Profile = () => {
  return (
    <ScrollView>
      <Box padding={4}>
        <Stack space={4}>
          <Stack space={4} align="center">
            <Avatar source="…" size={96} />
            <Stack space={1} align="center">
              <Title>Jenna Doe</Title>
              <Description>Photographer &amp; Artist</Description>
            </Stack>
            <Columns>
              <Column>
                <Stack space={1} align="center">
                  <Text>Followers</Text>
                  <Counter>258</Counter>
                </Stack>
              </Column>
              <Column>
                <Stack space={1} align="center">
                  <Text>Following</Text>
                  <Counter>346</Counter>
                </Stack>
              </Column>
            </Columns>
            <Divider />
          </Stack>
          <Text>Photos</Text>
          <Tiles columns={4} space={2}>
            <Photo source="…" />
            <Photo source="…" />
            <Photo source="…" />
          </Tiles>
          <Text>Followers</Text>
          <Tiles columns={8} space={2}>
            <Avatar source="…" />
            <Avatar source="…" />
            <Avatar source="…" />
          </Tiles>
        </Stack>
      </Box>
    </ScrollView>
  )
}

Breakpoints

Stacks, similarly to Braid supports the responsive props format which allows you to specify an array of values for different screen sizes. Therefore, if you need to customize the spacing, number of columns, or alignments per screen size, then the responsive props are for you.

type ResponsiveProp<T> = T | Readonly<[T, T]> | Readonly<[T, T, T]>

There are three available breakpoints: mobile (default, Stacks components are mobile-first), tablet and desktop.

type Breakpoint = 'mobile' | 'tablet' | 'desktop'

You can define custom breakpoints in the provider.

import { StacksProvider } from '@mobily/stacks'

const App = () => {
  return (
    <StacksProvider spacing={4} breakpoints={{ tablet: 768, desktop: 992 }}></StacksProvider>
  )
}

For example, if you wanted small spacing on mobile but medium spacing from tablet upwards:

<Stack space={[1, 4]}>
  
</Stack>

If you wanted top alignment on mobile and center on tablet upwards.

<Columns space={1} alignY={['top', 'center']}>
  <Column></Column>
  <Column></Column>
</Columns>

If you would like the columns to stack vertically on smaller screens, you can provide the collapseBelow prop.

<Columns space={1} collapseBelow="tablet">
  <Column></Column>
  <Column></Column>
</Columns>

Api Reference

Full documentation is available here.

Contributors

Kudos to @panr for giving this project a name!

Marcin Dziewulski
Marcin Dziewulski

💻 📖

License

The MIT License.

See LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].