Skip to content

Commit

Permalink
feat(link): add a link component
Browse files Browse the repository at this point in the history
  • Loading branch information
glrodasz committed Jul 16, 2021
1 parent 1c65b26 commit abac610
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 8 deletions.
2 changes: 1 addition & 1 deletion atoms/Card/Card.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}

.color-base {
border: var(--border-width-thin) solid var(--color-gray-300);
border: var(--border-width-thin) solid var(--color-gray-400);
background: var(--color-primary-inverted);
}

Expand Down
31 changes: 31 additions & 0 deletions atoms/Link/Link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react'
import PropTypes from 'prop-types'

import styles from './Link.module.css'
import { options } from './constants'
import withStyles from '../../hocs/withStyles'

import Paragraph from '../Paragraph'

export const Link = ({ children, color, getStyles }) => {
return (
<a className={getStyles('link', ['color'])}>
<Paragraph color={color} weight="medium">
{children}
</Paragraph>
</a>
)
}

Link.propTypes = {
children: PropTypes.node.isRequired,
getStyles: PropTypes.func.isRequired,
color: PropTypes.oneOf(options.colors),
}

Link.defaultProps = {
getStyles: () => {},
color: 'primary',
}

export default withStyles(styles)(Link)
13 changes: 13 additions & 0 deletions atoms/Link/Link.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.link {
display: flex;
border-bottom: 1px solid currentColor;
cursor: pointer;
}

.color-primary {
color: var(--color-primary);
}

.color-tertiary {
color: var(--color-tertiary);
}
25 changes: 25 additions & 0 deletions atoms/Link/Link.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Link, styles, options } from '.'

import {
getTemplate,
getListTemplate,
getOptionsArgTypes,
} from '../../helpers/storybook'

const Template = getTemplate(Link, styles)
const ListTemplate = getListTemplate(Link, styles)

export default {
title: 'Atoms/Link',
component: Link,
args: {
children: 'Mouths Muil',
},
argTypes: {
colors: getOptionsArgTypes(options.colors),
},
}

export const Default = Template.bind({})
export const Colors = ListTemplate.bind({})
Colors.args = { items: options.colors.map((color) => ({ color })) }
1 change: 1 addition & 0 deletions atoms/Link/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const options = { colors: ['primary', 'tertiary'] }
3 changes: 3 additions & 0 deletions atoms/Link/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default, Link } from './Link'
export { options } from './constants'
export { default as styles } from './Link.module.css'
8 changes: 8 additions & 0 deletions atoms/Paragraph/Paragraph.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
color: var(--color-font-muted);
}

.color-primary {
color: var(--color-primary);
}

.color-tertiary {
color: var(--color-tertiary);
}

.size-sm {
font-size: var(--font-size-xs);
}
Expand Down
2 changes: 1 addition & 1 deletion atoms/Paragraph/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const options = {
colors: ['base', 'muted', 'inverted'],
colors: ['base', 'muted', 'inverted', 'primary', 'tertiary'],
sizes: ['sm', 'md', 'lg'],
weights: ['normal', 'medium'],
}
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ export { default as CenteredContent } from './layout/CenteredContent'
export { default as FullHeightContent } from './layout/FullHeightContent'

// Atoms
export { default as Heading } from './atoms/Heading'
export { default as Paragraph } from './atoms/Paragraph'
export { default as Icon } from './atoms/Icon'
export { default as Picture } from './atoms/Picture'
export { default as Avatar } from './atoms/Avatar'
export { default as Button } from './atoms/Button'
export { default as Input } from './atoms/Input'
export { default as Card } from './atoms/Card'
export { default as Check } from './atoms/Check'
export { default as Divider } from './atoms/Divider'
export { default as Heading } from './atoms/Heading'
export { default as Icon } from './atoms/Icon'
export { default as Input } from './atoms/Input'
export { default as Link } from './atoms/Link'
export { default as Paragraph } from './atoms/Paragraph'
export { default as Picture } from './atoms/Picture'

// Molecules
export { default as ButtonIcon } from './molecules/ButtonIcon'
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
"watch": "1.0.2"
},
"peerDependencies": {
"react": "16.13.1"
"react": "16.13.1",
"react-dom": "16.13.1",
"classnames": "2.3.1"
}
}

0 comments on commit abac610

Please sign in to comment.