Git Product home page Git Product logo

ancestor's Introduction

โš ๏ธ DISCLAIMER: Considering the recent changes in the use of CSS in JS with runtime and also the maintenance and adaptation effort of this project to align with the direction the ecosystem is taking in the use of CSS in JS, especially with the advent of RSC and frameworks like Remix and Next, this repository is no longer maintained. Furthermore, there are excellent solid options in the JS ecosystem such as Chakra UI, Panda CSS, and Tailwind that satisfactorily meet requirements and work well with ReScript through bindings.



Docs // Getting Started // ReScript Brazil Community

Introduction

Ancestor is a suite of components that works as layout primitives to develop high-quality web apps, design systems, and style guides focused on responsiveness.

What and Why?

Every front-end project that is using libraries based on components like React, faces the same situation: Choose or develop a UI library to develop the interfaces.

In some cases, you can use libraries like Chakra UI, Material UI, or Ant Design that delivers a set of styled components (grids, buttons, inputs, selects, etc) and a lot of other utility functions and components for your web app.

However, in some cases, the team needs to create its own design system or style guide with a design language, colors, fonts, buttons, inputs and other specifications created by a design team. In this case, the usage of a library like Material UI or Chakra UI might not be the best choice, because depends on a lot of customizations or changes to adapt the library to the design specification.

It was the reason that we created Ancestor: to act as a foundation for your project or design system.

Features

Unstyled ๐Ÿ’€

Different from popular libraries like Material UI, we don't deliver styled components with colors, fonts, borders, etc. All Ancestor's components are layout primitives with support to a lot of CSS properties like padding, margin, height, width, etc.

Responsiveness ๐Ÿ’ก

All properties from Ancestor's components are responsive, which makes it easy to develop interfaces that need to support multiple devices. Through the breakpoints defined by the library, you can change the appearance of a component in a specific device or screen size.

Consistent design ๐ŸŽจ

We don't deliver styled components, but we care about design consistency, especially when dealing with spacing, borders, etc.

Customizable โš™๏ธ

All properties from Ancestor's components and parameters are customizable: Breakpoints, spacing, radius, grid columns, etc which makes it easy to customize and adapt Ancestor to your design system or style guide.

Installation

โš ๏ธ DISCLAIMER: We're working on a new version of Ancestor bringing a complete set of UI tools for ReScript. The most stable version is @rescriptbr/[email protected] and you can install by following the instructions below. Don't forget to install the most stable version, there are unstable pre-release versions that might not work as expected since they're pre-releases.

First off, install Ancestor using npm/yarn:

yarn add @rescriptbr/[email protected]

If you want to use the default setup, you need to install Emotion.

yarn add @emotion/css

Add the package to bs-dependencies in your bsconfig.json:

{
"bs-dependencies": [
  "@rescript/react",
  "@rescriptbr/ancestor"
 ]
}

Basic usage

open Ancestor.Default

@react.component
let make = () => {
  <Grid height=[#xs(100.0->#pct)]>
    <Box
      flexDirection=[#xs(#column), #md(#row)]
      p=[xxs(6), md(12), lg(8)]
      position=[#xs(#relative)]
      columns=[#xs(#12), #md(#6)]
    >
      <Box
        flexGrow=[#xs(#num(1.0))]
        width=[#xs(15.0->#rem), #md(20.0->#rem)]
      >
        <Logo />
      </Box>
      <Box flexGrow=[#xs(#num(3.0))] pt=[xxs(4)]>
        <h1>
          {"A place to share knowledge"->React.string}
        </h1>
        <p>
          {"Where good ideas find you."->React.string}
        </p>
      </Box>
      <Box
        position=[#xs(#absolute)]
        bottom=[#xs(-5.0->#rem)]
        left=[#xs(-5.0->#rem)]
      >
          ....
      </Box>
    </Box>
  </Grid>
}

Example from ReScript Conduit

Documentation

Check out the official documentation.

License

MIT

ancestor's People

Contributors

fakenickels avatar omnisci3nce avatar rescriptbr-admin avatar vinibispo avatar vmarcosp avatar woeps avatar xiniha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

ancestor's Issues

feat: Typography tokens

Description

We could add support for custom tokens related to font properties:

  • line-height
  • font-family
  • font-size
  • font-weight
  • letter-spacing

Feature: Custom CSS in JS Library

Description

Allow customize the CSS in JS library through module functors.

Draft

module CustomAncestor = Ancestor.Make({
  ...
  // Custom CSS function (e.g @emotion/css, styled-components, goober)
 @module("goober") external css: string => string = "css"
})

Feature: <Hidden />

Feature: <Hidden />

Responsively toggle the visibility of components.

Draft

open Ancestor

<Hidden in=[#xxs(true), #md(false)] implementation=#css>
  .....
</Hidden>

References

Add CSS column-count

Add CSS column-count Property.
๐Ÿ‡ง๐Ÿ‡ท Adicionar a Propriedade de contagem de colunas CSS (column-cout).

New customization API

Customization API

  • Spacing
  • Border Radius
  • Breakpoints
  • ZIndex
  • CSS in JS Library

Drafts

1. Using a .js config file (ancestor.config.js)

Generating the customization file using a .js config file.

// ancestor.config.js
export default {
 breakpoints: {
   xs: 0,
   sm: 400,
   lg: 720,
 },
 spacing: v => v * 8,
 zIndex: {
   base: 0,
   above: 5,
   aboveAll, 
 }
}
// Ancestor.res
module AncestorX = Ancestor.Make({
  type breakpoints<'a> = {
    xs?: 'a,
    sm?: 'a,
    lg?: 'a,
  }
  type fields = Xs | Sm | Lg
  let encode = breakpoints => [
    (Xs, breakpoints.xs),
    (Sm, breakpoints.sm),
    (Lg, breakpoints.lg),
  ]
  let sizeByBreakpoints = breakpoint =>
    switch breakpoint {
    | Xs => 0
    | Sm => 400
    | Lg => 1280
    }


  type zIndex = [ #base | #above | #aboveAll]
  let zIndex = v => switch v {
   | #base => 0
   | #above => 5
   | #aboveAll => 10
  }

  type colors = Ancestor_Css.Color.t
  let colors = v => v

  type spacing = int
  let spacing = spacing => #px(spacing * 8)

  type radius = int
  let radius = radius => #px(radius * 8)


  let css = Ancestor_Emotion.css
})

2. Using a PPX

Generating the breakpoints record using a PPX.

// Ancestor.res
module AncestorX = Ancestor.Make({
  @ancestor.breakpoints
  type breakpoints = Xs | Sm | Lg
  let sizeByBreakpoints = breakpoint =>
    switch breakpoint {
    | Xs => 0
    | Sm => 400
    | Lg => 1280
   }


  type zIndex = [ #base | #above | #aboveAll]
  let zIndex = v => switch v {
   | #base => 0
   | #above => 5
   | #aboveAll => 10
  }

  type colors = Ancestor_Css.Color.t
  let colors = v => v

  type spacing = int
  let spacing = spacing => #px(spacing * 8)

  type radius = int
  let radius = radius => #px(radius * 8)


  let css = Ancestor_Emotion.css
})

Why use ppx-ts?

Hi,

I saw you are using @greenlabs/ppx-ts/ppx (keyOf) only at core/Ancestor.res#5.

I'm wondering if it would make sense to just hard-code this one type manually?

Personally - as a future ancestor user - I'd like to see as few ppx's involved as possible. - for the sake of simplicity and performance

docs: Update documentation

  • <Stack />
  • Style props (Color.t vs Config.colors)
  • Customization (zIndex, colors, etc)
  • useResponsiveValue(...)

feat: Support pseudo selectors

Draft

<Box 
   _hover=style(~bgColor=[xs(Colors.red)], ())
   _active=style(
     ~color=[xs(Colors.gray), 
     ~bgColor=[xs(Colors.red], 
     (),
   )
/>
// Using new optional fields API
<Box 
   _hover={ "bgColor": { "xs": Colors.red } }
   _active={ 
     "color": { "xs" : Colors.gray }, 
     "bgColor": { "xs": Colors.red } 
   }
/>

Documentation

Description

We need to create documentation for the library. Since we're using ReScript it will be greater if we have a simple way to create documentation about the library's components, props, functions, and types.

Tasks

  • Translate from pt-br to en-us
  • "What and Why?" section
  • Installation section
  • Getting started section
  • Documentation of all responsive props
  • Examples section
  • Documentation of all components and props
  • Documentation of all functions and types

System props

  • borderRadius
  • border
  • borderRight
  • borderLeft
  • borderTop
  • borderBottom
  • bgColor
  • color
  • display
  • justifyContent
  • flexDirection
  • alignItems
  • flexBasis
  • flexWrap
  • flexGrow
  • alignContent
  • alignSelf
  • justifySelf
  • flexFlow
  • p
  • px
  • py
  • pt
  • pb
  • pl
  • pr
  • m
  • mx
  • my
  • mt
  • mb
  • ml
  • mr
  • textAlign
  • fontWeight
  • fontSize
  • letterSpacing
  • lineHeight
  • width
  • height
  • minW
  • minH
  • maxW
  • maxH
  • position
  • top
  • bottom
  • left
  • right
  • zIndex
  • boxSizing

feat: Improve CSS utility props support

Description

Nowadays, we don't support all CSS props. We can improve by supporting props like overflow, list-style, outline, etc.

Props

  • gap
  • list-style
  • list-style-type
  • list-style-position
  • list-style-image
  • outline
  • text-decoration
  • background-size
  • background-position
  • background-image

Feature: Support main CSS properties

Description

Support all CSS props related to layout primitives.

Texts

  • font-size
  • letter-spacing
  • text-align
  • font-weight

General

  • border-radius
  • background-color๐Ÿ’ก
  • color๐Ÿ’ก
  • border (*-top,*-left, etc) ๐Ÿ’ก

Lists

  • list-style

Flex

  • flex-flow
  • flex-grow
  • align-content
  • align-self
  • justify-self

Notes

๐Ÿ’ก - Analysis

feat: `<Hidden mode=#js />`

Description

Add a js mode to the Hidden component.

Draft

open Ancestor

// Mode / Implementation type
type mode = [#js | #css]

// Usage 
<Hidden on=[#xs(true), #md(false)] mode=#js>
....
</Hidden>

Improve CSS utility props support

Description

Nowadays, we don't support all CSS props. We can improve by supporting props like overflow, list-style, outline, etc.

Props

  • cursor
  • overflow
  • overflow-x
  • overflow-y
  • visibility
  • list-style
  • list-style-type
  • outline
  • outline-style
  • text-decoration
  • text-decoration-style
  • background-size
  • background-position
  • background-cover
  • transform
  • border-(top|bottom|left|right)-style
  • border-(top|bottom|left|right)-width
  • border-(top|bottom|left|right)-color

feat: Themed colors

Description

The current color API is based on the Color.t module. We could provide a feature that relies on the module functor to create a variant based approach like Chakra UI or Material UI.

Draft

module Ancestor = Ancestor.Make({
  type color = [
    | #gray100
    | #gray200
    | #primary100
    | #primary200
   ]
   
   let colors = color => switch color {
     | #gray100 => "#caca"
     | #gray200 => "#cecece"
     | #primary100 => "#f36"
     | #primary200 => "#f33"
   }
})

// Usage
<Box bgColor=[xs(#gray100)] color=[xs(#100)]>
</Box>

feat: Allow custom type for `Spacing.t` and `Radius.t`

Description

Nowadays, the module Spacing (and Radius) is using an int type to represent the scale factor. Sometimes, the design team defines scale factor that allows something 1.25x of spacing/radius. Ancestor doesn't have support for this kind of value since the Spacing.t (and Radius.t) is just a type alias for int.

Proposal

We should allow user set a custom type for these modules. This is probably a breaking change, but we can also provide a migration guide on the release notes.

Draft

TBD

Quality: Snapshot testing

Description

Add snapshot tests using jest + emotion-jest.

Modules / Components

  • Hidden
  • Base
  • Box
  • Grid

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.