-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TailwindCSS in Marigold #2917
Comments
@sebald notice: data attributes must be written as |
root styles on body |
|
some tailwind listbox issues:
|
Use CasesAPI
a. Components may have
Internal API
Case 1aconst Component = ({ className, variant, size }) => {
const classNames = useClassNames('Component', {
variant,
size,
className,
});
return <div className={classNames}>...</div>;
}; Case 1bconst Component = ({ className, variant, size, space }) => {
//
const classNames = useClassNames('Component', {
variant,
size,
className,
space,
});
return <div className={classNames}>...</div>;
};
<Component className="w-[500px]" space="3" />; Case 2aconst Component = ({ className, variant, size }) => {
const classNames = useClassNames('Component', {
variant,
size,
className,
slots: ['container', 'button'],
});
return (
<div className={classNames.container}>
<button className={classNames.button}>Click me!</button>
</div>
);
}; Case 2bconst Component = ({ className, variant, size, containerColor }) => {
// TODO: color???
const classNames = useClassNames('Component', { variant, size, classNames });
return (
<div className={classNames.container}>
<button className={classNames.button}>Click me!</button>
</div>
);
}; type ClassNames = string | { [slot: string]: string }; Style Props
export const fontWeight = {
thin: 'font-thin',
extralight: 'font-extralight',
light: 'font-light',
normal: 'font-normal',
medium: 'font-medium',
semibold: 'font-semibold',
bold: 'font-bold',
extrabold: 'font-extrabold',
black: 'font-black',
}
export type FontWeightProp = { fontWeight: keyof typeof fontWeight }; Idea 1: import { space } from '@marigold/style-props';
const component = tv({
base: [],
variants: {
variant: {},
size: {},
// Styles Props
space,
},
});
// @marigold/style-props
export const space = {
1: 'gap-1',
2: 'gap-2',
}; Idea 2: // @marigold/style-props
export const space = {
1: 'gap-1',
2: 'gap-2',
};
// Component File
import { space, spaceProps } from '@marigold/style-props';
interface Props extends SpaceProps {}
const LayoutComponent = (props: Props) => {
return <div className={space[props.space]}>...</div>;
};
<LayoutComponent space={1} />; Using CSS Vars// This doesn't work just a palceholder
const createVar = o =>
Object.entries(o).map(
([name, val]) => ({ [`--${name}`]: val } as React.CSSProperties)
);
const Component = ({ variant, size, labelWidth }) => {
const classNames = useClassNames({
variant,
size,
className: 'w-[var(--labelWidth)]',
});
return (
<div className={classNames} style={createVar({ labelWidth })}>
...
</div>
);
}; |
@sebald to 'Using CSS Vars' if I add |
Not sure I follow, show me tomorrow? :) |
🗒 Open ToDo's:
system/utils/get
create-preset
-> Components lists here #2961
System finished
✅ Done:
- every theme should be a preset
- maybe solved through presets
- create-preset package
- works with theme switcher (Badge core + unicorn)
- type safty makes problems
- kinda works I have to save the classNames as safelist and an ugly if else condition
related Issue is: #2153
The text was updated successfully, but these errors were encountered: