braid-design-system@25.0.0
Major Changes
-
BraidProvider: Add
linkComponentprop to customise link rendering. (#574)If you'd like to customise the technical implementation of all
LinkandTextLinkcomponents from Braid, you can now pass a custom component to thelinkComponentprop onBraidProvider. For example, if you wanted to ensure that all relative links are React Router links:import React, { ComponentProps } from 'react'; import { Link as ReactRouterLink } from 'react-router-dom'; import { BraidProvider, LinkComponent } from 'braid-design-system'; // First create the custom link implementation: const BraidLink: LinkComponent = ({ href, ...restProps }) => href[0] === '/' ? ( <ReactRouterLink to={href} {...restProps} /> ) : ( <a href={href} {...restProps} /> ); // Then pass it to BraidProvider: export const App = () => ( <BraidProvider theme={jobStreetTheme} linkComponent={BraidLink}> ... </BraidProvider> );
In order to make your custom link component available for any type of link (not just usages of
TextLink), this release introduces a newLinkcomponent which renders an unstyledatag by default.BREAKING CHANGES
-
TextLinknow requires anhrefprop. Even though this is unlikely to affect anyone (aTextLinkwithout anhrefisn't terribly useful), this is still technically a breaking change.However, if you find an instance of
TextLinkthat you think shouldn't have anhref, this is a sign that it's not actually a link and you should use aTextLinkRendererinstead. Unfortunately, because there's no way for us to know the semantics of your usage ahead of time, we're unable to provide a migration guide, so you'll need to be mindful of how this might impact accessibility. -
The props for
TextLinknow extend React'sAnchorHTMLAttributes<HTMLAnchorElement>type rather thanAllHTMLAttributes<HTMLAnchorElement>. While highly unlikely, this may cause type errors if you've passed props toTextLinkthat aren't considered to be valid anchor props.
-
Patch Changes
-
Themes: Fix OCC theme export (#576)
The
braid-design-system/themes/occtheme export is now exposed correctly.