next-yak
Version:
next-yak is a CSS-in-JS solution tailored for Next.js that seamlessly combines the expressive power of styled-components syntax with efficient build-time extraction of CSS using Next.js's built-in CSS configuration
28 lines (27 loc) • 673 B
text/typescript
/**
* This is an internal helper function to merge relevant props of a native element with a css prop.
* It's automatically added when using the `css` prop in a JSX element.
* e.g.:
* ```tsx
* <p
* className="foo"
* css={css`
* color: green;
* `}
* {...{ style: { padding: "30px" }}}
* />
*/
export const mergeCssProp = (
relevantProps: Record<string, unknown>,
cssProp: {
className: string;
style?: Record<string, unknown>;
},
) => {
return {
className: relevantProps.className
? relevantProps.className + " " + cssProp.className
: cssProp.className,
style: { ...(relevantProps.style ?? {}), ...cssProp.style },
};
};