Code Monkey home page Code Monkey logo

foliage's People

Contributors

dependabot[bot] avatar drevoed avatar sergeysova avatar zerobias 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

foliage's Issues

Add support for default props

const Button = styled('button', { data: { enabled: $enabled, theme: $theme } })`
  color: red;
`

What about redefining?

Button({
  data: { enabled: $another }
})

What props should win?

Add property `as` to change tag

const Button = component('div', baseStyles)

<Button as="button" />

Allow to pass custom component and infer props from:

<Button as={MyButton} myProp={1} />

Add presets

export const Button = component('button', baseStyles, {
  variants: {
    color: {
      gray: css`
        background-color: gainsboro;
      `,
      blue: css`
        background-color: dodgerblue;
      `,
    },
    size: {
      md: css`
        height: 26px;
      `,
      lg: css`
        height: 36px;
      `,
    },
  },
  compound: [
    {
      color: 'blue',
      size: 'lg',
      css: css`
        background-color: purple;
      `,
    },
  ],
  defaults: {
    color: 'gray',
    size: 'md',
  },
  presets: {
    primary: {
      color: "blue",
      css: css` @apply p-4;`
    },
  },
});
  1. Preset applies via preset prop.
  2. Preset can apply just css or just variants
  3. Variants passed as props applied over preset
  4. Compound applied after all variants is calculated

`merge` utility

It would be useful to have some utility to merge configs, so we could create common colors, roundness, padding configs for UI-kit and then combine them in components:

Example:

// ./config/index,ts
export const colors = {
  variants: {
    color: {
      primary: css`
        background: white;
        color: black;
      `,
      default: css`
        background: transparent;
        color: white;
      `,
    },
  },
}

export const sizes = {
  variants: {
    size: {
      large: css`
        padding: 20px 30px;
      `,
      normal: css`
        padding: 10px 20px;
      `
    }
  }
}
// ./components/Button.tsx
import { merge } from 'foliage'
import { component } from 'foliage-react'

import { colors, sizes } from '../config'

export const Button = component("button", merge(colors, sizes), {
  defaults: { color: 'primary', size: 'normal' }
})

Debug mode

When debug is on:

  • Add name and location to asserts (assertKeyframe, assertVariable, assertSelector)
  • Asserts should show informative errors when used in incorrect way (ex.: keyframe used as a selector)
  • Do not minify CSS (if not forced)

When debug is off:

  • Do not add names (if not forced)
  • Replace asserts with getters without informative errors, that should help end-users to report problem

Tailwind integration

Would be also cool to see tw utility

import { tw } from 'foliage-tailwind'
import { component } from 'foliage-react'

const Button = component("button", {
  defaults: { size: "normal" },
  variants: {
    size: {
      large: tw`px-4 py-2`,
      normal: tw`px-2 py-1`
    }
  }
})

Support for stores

In React we could use components props and context to create dynamic styles

const Text = styled.div`
  color: ${props => props.color}
`

In Forest we can do something with stores. Simple use case - theming

const Text = styled.div`
  color: ${theme.map(theme => theme.colors.primary)}
`

Now it sets color to [object Object]
image

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.