Skip to content

Commit

Permalink
feat: add possibility to inherit parent on a link (#1825)
Browse files Browse the repository at this point in the history
Signed-off-by: Théo Mesnil <mesniltheo@gmail.com>

Signed-off-by: Théo Mesnil <mesniltheo@gmail.com>
  • Loading branch information
theo-mesnil committed Jan 5, 2023
1 parent 71c671c commit 5bb7479
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions docs/pages/components/link.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ For a target `_blank` we add `rel='noopener noreferrer'`
</Link>
```

## With a Text component

By default link is set to medium on fontWeight, you can force inherit to get the parent style.

```jsx
<Text variant="h5">
A text with h5{' '}
<Link href="#" fontWeight="inherit" target="_blank">
variant
</Link>
</Text>
```

## Usage with React Router

<code>
Expand Down
3 changes: 2 additions & 1 deletion packages/Link/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled, { css, system, th } from '@xstyled/styled-components'
import styled, { css, system, th, typography } from '@xstyled/styled-components'
import { UniversalLink } from '@welcome-ui/universal-link'
import { shouldForwardProp } from '@welcome-ui/system'

Expand Down Expand Up @@ -26,6 +26,7 @@ export const Link = styled(UniversalLink).withConfig({ shouldForwardProp })<{
${th('links.default')};
${th(`links.${variant}.default`)};
${isExternalLink && th('links.withExternalLink')};
${typography};
}
&:hover,
Expand Down

0 comments on commit 5bb7479

Please sign in to comment.