// Button.js => Button.css
import { chakra } from "@chakra-ui/magic";
import "@chakra-ui/css/Button.css";
<chakra.button mb="2" mt="2" _hover={{ bg: "red.200", _focus: {} }} />;
<button css={{mb: "2", mt="2", _hover: { bg: "red.200", _focus: {} }} />
const result = interpret(
`<chakra.button mb="2" mt="2" _hover={{bg: "red.200", _focus: {}}} />`
);
function Button({ className, style }) {
return (
<chakra.button mb="2" mt="2" className={className}>
{children}
</chakra.button>
);
}
// <button className={cx("css-hash-12", className)}>
const dict ={
".css-hash-12": {
mb: 2,
mt: 2,
},
".css-hash-Button": {
mt: 5
}
}
function Page() {
return <Button mt="5">Hello</Button>;
}
// <Button className="css-hash-Button" />
// Store the styles as object
result.element; // button
result.styleProps - // ...
result.static - // ...
result.dynamic; // ...
result.attributes; // ...
const result = compile(
`<chakra.button mb="2" mt="2" _hover={{bg: "red.200", _focus: {}}} />`
);
result; // => <button class="css-hash" />
result; // => <chakra.button class="css-hash" mb={Math.random() ? "3": "4"} />
<template>
<chakra.button mb="2" mt="2" :hover="{bg: "red.200", _focus: {}}" />
</template>
<script lang="ts">
const variants = createVariants({
true: {},
false: {},
});
</script>
import { chakra, variants, cx } from "magic"
import { compile } from "magic/compiler"
module.export = esbuild({
fileProcessor: (file, content)=>{
compile(file, {output: ".chakra"})
}
})
import "button-fileHash.css"
const sizeVariants = variants({
"sm": {},
"md": {}
})
<chakra.div mt="3" bg={Math.random() ? "red" : "green"} _hover={isDragging: styles.dragging: styles.default} />
const style = getStyle(isDragging)
<div
className={`static-css ${style}`}
style={{"--bg-hash": Math.random() ? "red" : "green" }}
>
.css-hash{
margin-top: 3px
bg: var(--bg-hash)
}