You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working with GatsbyJS, Gatsby have their own Link component and only can be customized via styles properties or classNames.
So I create an Wrap to encapsulate the Link component (AKA XLink component), I want to receive the common Xstyled props to generate later an style properties, here is an Example to help understanding my doubt.
import{Link}from'gatsby';import{SpaceProps,TypographyProps,}from'@xstyled/styled-components';exporttypeXLinkProps=SpaceProps&TypographyProps&{children?: React.ReactNode;// Gatsby Link propsto: string;activeClassName?: string;activeStyle?: React.CSSProperties;partiallyActive?: boolean;};functionXLink(props: XLinkProps){const{ to, activeClassName, activeStyle, partiallyActive, ...xstyledProps}=props;// Something magic here to generate style object based on xstyled propsconststyle=someFunctionToGenerateCSSStyles(xstyledProps);constclassName=someFunctionToGenerateClassNames(xstyledProps);return(<Linkto={to}style={style}className={className}>{ children }</Link>);}export{XLink};// Usage example<XLinkto="/about"color="primary"mx={{_: 2,md: 5}}>About</XLink>
The text was updated successfully, but these errors were encountered:
ChristianHardy
changed the title
Exist a way to generate the style object to be used in other third party libraries?
Exist a way to generate the style object or classNames to be used in other third party libraries?
Sep 5, 2023
💬 Questions and Help
Hello, and thanks for advance.
I'm currently working with GatsbyJS, Gatsby have their own Link component and only can be customized via styles properties or classNames.
So I create an Wrap to encapsulate the Link component (AKA XLink component), I want to receive the common Xstyled props to generate later an style properties, here is an Example to help understanding my doubt.
The text was updated successfully, but these errors were encountered: