Aliases
You can use the system of alias properties to make it easier to use.
For example, bgc === backgroundColor:
To see the full list of properties and aliases, follow this
link.
Themes
By default, Atomize components do not include a theme and you need to set up dependencies:
Quarkly themes are based on CSS variables. The key feature is that variables from themes can be reused both in props and themes. You don’t have to use additional abstractions, like template functions, and no additional editing is needed.
To use variables from a theme, just add your theme to an application with a Theme component, describe the property in the theme and call this property using the prefix "--". You can also use it in the theme itself:
import Theme from "@quarkly/theme";
const theme = {
color: {
dark: "#212121"
},
border: {
dark: "1px solid --color-dark"
}
};
export const MyBox = () => (
<Theme theme={ theme }>
<Box
width="100px"
height="100px"
border="--border-dark"
color="--color-dark"
/>
</Theme>
);
Shorter syntax is used for colors in the JSX markup:
Breakpoints
Themes have breakpoints for working with media expressions. Any property can be prefixed with a breakpoint key name:
import Theme from "@quarkly/theme";
const theme = {
breakpoints: {
sm: [{ type: "min-width", value: 576 }],
md: [{ type: "min-width", value: 768 }],
lg: [{ type: "min-width", value: 992 }]
},
color: {
'dark-mobile': "#424242",
'dark-tablet': "#212121"
}
}
export const MyBox = () => (
<Theme theme={ theme }>
<Box
width="100px"
height="100px"
color="--dark-mobile"
md-color="--dark-tablet"
/>
</Theme>
);
Effects
Just pass an object with the configuration to a component when creating it:
const Button = atomize.button({
effects: {
hover: ":hover",
focus: ":focus",
active: ":active",
disabled: ":disabled"
}
});
The key is the prefix in the name of the property, and the value is a CSS selector. This is the same way we implemented pseudo-classes.
For example, if you specify the hover prefix for any CSS property, it will be applied to a certain effect:
<MySuperButton
bgc="red"
hover-bgc="yellow"
focus-bgc="blue"
/>
You can also combine effects with media expressions:
<Box
md-hover-bgc="yellow"
lg-hover-bgc="blue"
/>