diff --git a/CHANGELOG.md b/CHANGELOG.md index 45e496f5b..2a33752c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Reactist follows [semantic versioning](https://semver.org/) and doesn't introduce breaking changes (API-wise) in minor or patch releases. However, the appearance of a component might change in a minor or patch release so keep an eye on redesigns and make sure your app still looks and feels like you expect it. +# 27.2.0 + +- [Feat] Document `TextLink` component in Storybook and change default styling. + # 27.1.0 - [Feat] Expose CSS variables for customizng the icon color of the `Banner` component system types. diff --git a/package-lock.json b/package-lock.json index fc5d21070..ab0c24f1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@doist/reactist", - "version": "27.1.0", + "version": "27.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@doist/reactist", - "version": "27.1.0", + "version": "27.2.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index d29bc3bb8..eaa3e4f24 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "email": "henning@doist.com", "url": "http://doist.com" }, - "version": "27.1.0", + "version": "27.2.0", "license": "MIT", "homepage": "https://github.com/Doist/reactist#readme", "repository": { diff --git a/src/text-link/text-link.module.css b/src/text-link/text-link.module.css index 4c4015bdd..edd854897 100644 --- a/src/text-link/text-link.module.css +++ b/src/text-link/text-link.module.css @@ -1,7 +1,7 @@ :root { - --reactist-text-link-idle-tint: rgb(36, 111, 224); - --reactist-text-link-hover-tint: var(--reactist-text-link-idle-tint); - --reactist-text-link-idle-decoration: none; + --reactist-text-link-idle-tint: var(--reactist-actionable-tertiary-idle-tint); + --reactist-text-link-hover-tint: var(--reactist-actionable-tertiary-hover-tint); + --reactist-text-link-idle-decoration: underline; --reactist-text-link-hover-decoration: underline; } diff --git a/src/text-link/text-link.stories.mdx b/src/text-link/text-link.stories.mdx new file mode 100644 index 000000000..524d12a98 --- /dev/null +++ b/src/text-link/text-link.stories.mdx @@ -0,0 +1,43 @@ +import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs' +import { Stack } from '../stack' +import { TextLink } from './text-link' + + + +# TextLink + +A component used to create text-based hyperlinks. + + + + + regular + + open in new tab + + { + alert('clicked') + }} + > + button link + + + + + +## Props + + diff --git a/src/text-link/text-link.test.tsx b/src/text-link/text-link.test.tsx new file mode 100644 index 000000000..2f4c90230 --- /dev/null +++ b/src/text-link/text-link.test.tsx @@ -0,0 +1,65 @@ +import { render, screen } from '@testing-library/react' +import * as React from 'react' +import { TextLink } from './text-link' + +describe('TextLink', () => { + it('renders a link with the provided href', () => { + render(Click me) + + const link = screen.getByText('Click me') + expect(link).toHaveAttribute('href', 'https://example.com') + }) + + it('opens in new tab when openInNewTab is true', () => { + render( + + External link + , + ) + + const link = screen.getByText('External link') + expect(link).toHaveAttribute('target', '_blank') + expect(link).toHaveAttribute('rel', 'noopener noreferrer') + }) + + it('does not add target or rel attributes when openInNewTab is false', () => { + render( + + Internal link + , + ) + + const link = screen.getByText('Internal link') + expect(link).not.toHaveAttribute('target') + expect(link).not.toHaveAttribute('rel') + }) + + it('can be rendered as a different element using the as prop', () => { + render( + { + // noop + }} + > + Button link + , + ) + + const button = screen.getByText('Button link') + expect(button.tagName).toBe('BUTTON') + }) + + it('applies custom className while preserving default styles', () => { + render( + + Styled link + , + ) + + const link = screen.getByText('Styled link') + expect(link).toHaveClass('custom-class') + // Verify it still has the default container class + expect(link).toHaveClass('container') + }) +})