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

Add Link element #130

Merged
merged 3 commits into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/Link.mdx
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} />
33 changes: 33 additions & 0 deletions src/elements/Link/Link.tsx
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 {
Copy link
Member Author

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.

border: 1px solid ${color("purple100")};
color: ${props =>
props.color ? color(props.color as any) : color("black100")};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to cast props.color to any color(props.color as any) because color expects string and we get "black100" | "black80" | "black60" | "black30" | "black10" | "black5" | "purple100" | "purple30" | "purple5" | "green100" | "red100" | "yellow100" | "yellow30" | "yellow10" | "white100" as props.color.... Not sure what was the proper way here

}
`
1 change: 1 addition & 0 deletions src/elements/Link/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Link"
1 change: 1 addition & 0 deletions src/elements/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from "./Flex"
export * from "./Image"
export * from "./Join"
export * from "./Message"
export * from "./Link"
export * from "./Radio"
export * from "./RadioGroup"
export * from "./Select"
Expand Down