Skip to content
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

Link: export linkStyles to allow styling React Router Links #504

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

hoorayimhelping
Copy link
Collaborator

In apps that use ReactRouter or a similar router to mimic <a> functionality, there are two unattractive ways to get links that look and feel like click-ui Links:

  1. Wrap the click-ui Link in a ReactRouter Link, which will throw a validateDOMNesting warning about nesting an <a> inside an <a>. See screenshot below.
  2. Duplicate the existing click-ui styles

The warning shows up in many of the e2e tests because many of them go to the main page of the app where these nested anchor tags are.

Screenshot of problem

(Application redacted; only console shown)
Screenshot 2024-12-11 at 4 40 38 PM

This PR fixes that by exporting the styles that click-ui Link uses.

Usage:

import styled from 'styled-components';
import { linkStyles, StyledLinkProps } from '@clickhouse/click-ui';

const CuiStyledLink = styled(Link)<StyledLinkProps>`
  ${linkStyles}
`;

<CuiStyledLink to={myHref}>Click me to go places</CuiStyledLink>

Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
click-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 9:41pm

@hoorayimhelping hoorayimhelping merged commit 7805348 into main Dec 12, 2024
6 checks passed
@hoorayimhelping hoorayimhelping deleted the bucky-export-link-styles branch December 12, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants