| examples | ||
| src | ||
| .gitignore | ||
| bun.lock | ||
| package.json | ||
| README.md | ||
| server.tsx | ||
| tsconfig.json | ||
forge
Example:
import { define } from "forge"
export const Button = define("button", {
base: "button",
padding: 20,
background: "blue",
variants: {
kind: {
danger: { background: "red" },
warning: { background: "yellow" },
}
},
})
// Usage
<Button>Click me</Button>
<Button kind="danger">Click me carefully</Button>
<Button kind="warning">Click me?</Button>
export const Profile = define("div", {
padding: 50,
background: "red",
parts: {
Header: { display: "flex" },
Avatar: { base: 'img', width: 50 },
Bio: { color: "gray" },
},
variants: {
size: {
small: {
parts: { Avatar: { width: 20 }}
}
}
},
render({ props, parts: { Root, Header, Avatar, Bio } }) {
return (
<Root>
<Header>
<Avatar src={props.pic} />
<Bio>{props.bio}</Bio>
</Header>
</Root>
)
},
})
// Usage:
import { Profile } from './whatever'
<Profile pic={user.pic} bio={user.bio} />