-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add loading state for tags and split TagItem into Item and Link
- Loading branch information
1 parent
17d457c
commit 2aa9499
Showing
7 changed files
with
177 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
module.exports = { | ||
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.js'], | ||
addons: [ | ||
'@storybook/addon-essentials', | ||
'@storybook/addon-storysource', | ||
'@storybook/addon-a11y', | ||
], | ||
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.js', '../src/**/*.stories.tsx'], | ||
addons: ['@storybook/addon-essentials', '@storybook/addon-storysource', '@storybook/addon-a11y'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { TagLink } from './TagLink'; | ||
// @ts-ignore | ||
import { StoryLinkWrapper } from '../StoryLinkWrapper'; | ||
|
||
export default { | ||
component: TagLink, | ||
title: 'Design System/Tag/TagLink', | ||
}; | ||
|
||
export const Default = () => <TagLink href="https://chromatic.com">⚛️ React</TagLink>; | ||
|
||
export const WithLinkWrapper = () => ( | ||
<TagLink to="https://chromatic.com" LinkWrapper={StoryLinkWrapper as React.FC<{ to: string }>}> | ||
⚛️ React | ||
</TagLink> | ||
); | ||
|
||
export const Loading = () => <TagLink isLoading />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import styled, { css } from 'styled-components'; | ||
import { rgba } from 'polished'; | ||
import { color, typography, background, spacing } from '../shared/styles'; | ||
// @ts-ignore | ||
import { inlineGlow } from '../shared/animation'; | ||
// @ts-ignore | ||
import { Link } from '../Link'; | ||
|
||
export type TagLinkProps = { | ||
isLoading?: boolean; | ||
containsIcon?: boolean; | ||
inverse?: boolean; | ||
isButton?: boolean; | ||
LinkWrapper?: React.ComponentType | (() => React.ReactNode); | ||
nochrome?: boolean; | ||
secondary?: boolean; | ||
tertiary?: boolean; | ||
withArrow?: boolean; | ||
}; | ||
|
||
export const TagLink = styled(Link).attrs<TagLinkProps>(({ isLoading, children }) => ({ | ||
children: isLoading ? 'Loading tag' : children, | ||
}))<TagLinkProps>` | ||
display: inline-block; | ||
background: ${background.app}; | ||
border-radius: ${spacing.borderRadius.small}px; | ||
padding: 5px 10px; | ||
font-size: ${typography.size.s2}px; | ||
line-height: ${typography.size.m2}px; | ||
position: relative; | ||
color: ${color.darkest}; | ||
border-width: 1px; | ||
border-style: solid; | ||
border-color: transparent; | ||
white-space: nowrap; | ||
&:after { | ||
content: ''; | ||
position: absolute; | ||
z-index: -1; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
box-shadow: rgba(0, 0, 0, 0.08) 0 3px 10px 0; | ||
opacity: 0; | ||
transition: opacity 0.3s ease-in-out; | ||
} | ||
${(props) => | ||
!props.isLoading && | ||
css` | ||
&:hover { | ||
border-color: ${rgba(color.secondary, 0.5)}; | ||
&:after { | ||
opacity: 1; | ||
} | ||
} | ||
`} | ||
${(props) => | ||
props.isLoading && | ||
css` | ||
cursor: progress !important; | ||
${inlineGlow}; | ||
&:hover { | ||
color: transparent; | ||
} | ||
`} | ||
`; | ||
|
||
TagLink.defaultProps = { | ||
isLoading: false, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters