Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

feat: introduce link component #53

Merged
merged 3 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
42 changes: 42 additions & 0 deletions src/lsg/patterns/link/demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { colors } from '../colors';
import Link from './index';
import * as React from 'react';
import Space, { Size } from '../space';

const clickHandler = (event: React.MouseEvent<HTMLElement>): void => console.log(event);
const LinkDemo: React.StatelessComponent<void> = (): JSX.Element => (
<Space size={Size.L}>
<Space size={Size.L}>
<Link
>
Link
</Link>
</Space>
<Space size={Size.L}>
<Link
color={colors.blue}
>
Link with color
</Link>
</Space>
<Space size={Size.L}>
<Link
color={colors.blue}
onClick={clickHandler}
>
Link with clickHandler
</Link>
</Space>
<Space size={Size.L}>
<Link
color={colors.blue}
onClick={clickHandler}
uppercase={true}
>
Link with uppercase
</Link>
</Space>
</Space>
);

export default LinkDemo;
42 changes: 42 additions & 0 deletions src/lsg/patterns/link/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Color } from '../colors';
import { fonts } from '../fonts';
import * as React from 'react';
import styled, { StyledComponentClass } from 'styled-components';

export interface LinkProps {
className?: string;
color?: Color;
disabled?: boolean;
onClick?: React.MouseEventHandler<HTMLElement>;
uppercase?: boolean;
}

const StyledLink: StyledComponentClass<LinkProps, {}> = styled.a`
font-family: ${fonts().NORMAL_FONT};
${(props: LinkProps) => props.color
? `color: ${props.color.toString()}`
: 'color: inherit'
};
${(props: LinkProps) => props.onClick
? 'cursor: pointer;'
: 'cursor: auto;'
}
${(props: LinkProps) => props.uppercase
? 'text-transform: uppercase;'
: ''
}
`;

const Link: React.StatelessComponent<LinkProps> = props => (
<StyledLink
className={props.className}
color={props.color}
disabled={props.disabled}
onClick={props.onClick}
uppercase={props.uppercase}
>
{props.children}
</StyledLink>
);

export default Link;
12 changes: 12 additions & 0 deletions src/lsg/patterns/link/pattern.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "link",
"displayName": "Link",
"flag": "alpha",
"version": "1.0.0",
"tags": ["link"],
"patterns": {
"colors": "colors",
"fonts": "fonts",
"space": "space"
}
}