-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add Link element #130
Add Link element #130
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
name: Link | ||
--- | ||
|
||
import { Playground, PropsTable } from 'docz' | ||
import { Box, Link } from '../src' | ||
|
||
# Link | ||
|
||
<Playground> | ||
<Box> | ||
<Link>This is a default link</Link> | ||
</Box> | ||
<Box> | ||
<Link noUnderline>This is a non-underlined link</Link> | ||
</Box> | ||
<Box> | ||
<Link color="purple100">This is a non-standard color link</Link> | ||
</Box> | ||
</Playground> | ||
|
||
<PropsTable of={Link} /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import styled from "styled-components" | ||
import { | ||
color as styledColor, | ||
ColorProps, | ||
space, | ||
SpaceProps, | ||
} from "styled-system" | ||
import { color } from "../../helpers" | ||
|
||
export interface LinkProps extends SpaceProps, ColorProps { | ||
noUnderline?: boolean | ||
} | ||
|
||
/** | ||
* Basic a tag | ||
*/ | ||
export const Link = styled.a<LinkProps>` | ||
${space}; | ||
${styledColor}; | ||
text-decoration: ${props => | ||
props.noUnderline || props.color ? "none" : "underline"}; | ||
cursor: pointer; | ||
transition: color 0.25s; | ||
:hover { | ||
text-decoration: ${props => (props.color ? "none" : "underline")}; | ||
color: ${color("black100")}; | ||
} | ||
:focus { | ||
border: 1px solid ${color("purple100")}; | ||
color: ${props => | ||
props.color ? color(props.color as any) : color("black100")}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to cast props.color to any |
||
} | ||
` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Link" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to actually see this focus state in the browser.