GithubHelp home page GithubHelp logo

elemental-design / elemental-react Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 0.0 2.73 MB

Build UI components once, render to any platform: web, React Native and Sketch.

JavaScript 8.13% TypeScript 91.87%
cross-platform react react-primitives react-sketchapp sketch-app react-native ui-components styled-system ui-design

elemental-react's Introduction

Elemental React

Build UI components once, render to any platform using react-primitives. This library abstracts away common UI patterns for you.

npm npm

Abstraction for app presentation to speed up cross-platform UI design and development with code using React/Sketch as a design function. This is an underlying cross-platform abstraction wrapper that allows you to build your own design language

Based off styled-system and styled-components. API is similar to rebass, but using React Native style components.

This is an alpha/preview release. Please test comprehensively before using in production.

Supported React Renderers:

  • react - React web
  • react-native - React Native (WIP)
  • react-sketchapp - React Sketch.app
  • more - Post an issue to suggest more! Ideally an API should exist that lets you override the primitives

Getting Started

npm install elemental-react
import React from 'react';
import {
  Box, Text, Button,
} from 'elemental-react';

// ...
return (
  <Box mt={3} bg="dark-blue">
    <Text color="white">
      Hello World
    </Text>
  </Box>
);

Example UI

Quick example of a design created by a coder (me πŸ™‚), developed with live rendering to react-sketchapp: Example Blog UI

Related Reading

Design Properties

Line

Themed colour (primary)

  • Weight
  • Color
  • Texture
  • Style

Shape

Foundational element.

  • Depth
    • Light, shadow and depth (illusion)

Texture

Physical quality of a surface.

Balance

Equal distribution of visual weight – spacing.

  • Symmetry (each side is the same)
  • Asymmetry – evenly distribute weight
  • Rule of thirds – grid divided into thirds

Color

Properties

  • Hue
  • Saturation
    • Monochromatic
  • Value

Analagous Colour Scheme

elemental-react's People

Contributors

dependabot[bot] avatar macintoshhelper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

elemental-react's Issues

Radix UI and Tailwind CSS

How can we implement cross-platform support together with Radix UI and Tailwind CSS for web? Multilayer abstraction where base components have a styled-components/native implementation and Radix UI implementation? And molecules/components created from these elements can declare what primitive platforms they support?

  • Radix UI
  • Tailwind CSS

Standardise around Yoga CSS and styled-system API

Support 100% of Yoga CSS API.

Support styled-system aliases with proposed system:

const useStyles = (styles) => {
  return useMemo(() => {
    const parsedStyles = parseStyles(styles);
    return StyleSheet.create(parsedStyles);
  }, styles);
};

const filterStyles = props => props.filter(prop => ['backgroundColor, 'color, 'fontSize'].includes(prop);
const filterProps = props => props.filter(prop => !['backgroundColor, 'color, 'fontSize'].includes(prop);

const Box = (props) => {
  const styles = filterStyles(props);
  const style = useStyles(styles);

  return <View style={style} {...filterProps(props)} />;
};
const mapping = {
  bg: backgroundColor,
  p: padding,
  pt: paddingTop,
  pb: paddingBottom,
  pl: paddingLeft,
  pr: paddingRight,
  m: margin,
  mt: marginTop,
  mb: marginBottom
// ...
};

const parseStylesheet = (styles) => {
  const parsedStyles = {};

  Object.entries(styles).forEach(([att, val]) => {
    if (mapping[att]) {
      parsedStyles[mapping[att]] = val;
    }
  });

  return parsedStyles;
}

Elemental React | Abstract [WIP]

What is Elemental React?

Prototype rapidly first, polish quickly after.

Elemental React is a new way of building React apps. Build your UI once, render it to any platform with our base elements.

elemental-react provides you base elements, which can be used to build a prototype of your app or design.

e.g. We provide you a base <Button> which can be extended by you to <PrimaryButton>, <SecondaryButton>, <FlatButton>, <OutlinedButton>, etc.

Import spec

Export base primitives from the main entrypoint:

import { Box, Text, Button } from 'elemental-react';

Export components from individual files also for better bundle size management e.g.

import BaseButton from 'elemental-react/lib/Button';

export default extend(BaseButton, {
  bg: 'green',
  outlined: true,
  borderColor: 'black',
  '&:hover': {
    bg: 'greens.7'
  },
});

Infer lineHeight prop from resolved style font size

If someone isn't passing a fontSize prop, but a style object instead, then we should extract the font size with StyleSheet.resolve() and use it as a default lineHeight value, potentially adding a configurable multiplier and grid rounding number in the theme object.

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.