foliage-ui / foliage Goto Github PK
View Code? Open in Web Editor NEW๐ Style your components with performance
Home Page: https://foliage.sova.dev
๐ Style your components with performance
Home Page: https://foliage.sova.dev
const Button = styled('button', { data: { enabled: $enabled, theme: $theme } })`
color: red;
`
What about redefining?
Button({
data: { enabled: $another }
})
What props should win?
const Button = component('div', baseStyles)
<Button as="button" />
Allow to pass custom component and infer props from:
<Button as={MyButton} myProp={1} />
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;`
},
},
});
preset
prop.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' }
})
When debug is on:
assertKeyframe
, assertVariable
, assertSelector
)When debug is off:
Remove stylis
from runtime dependencies
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`
}
}
})
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)}
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.