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 Container with branding component #3

Merged
merged 2 commits into from
Nov 29, 2019
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
68 changes: 68 additions & 0 deletions src/components/Container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React from 'react'
import PropTypes from 'prop-types'
import styled from '@emotion/styled'
import { color, spacing, shadows } from './shared/styles'
import { Paragraph } from './Paragraph'

const StyleContainer = styled.div`
display: flex;
justify-content: space-between;
flex-direction: column;
height: 608px;
width: 352px;
border-radius: ${spacing.borderRadius.default}px;
background-color: ${color.moonGrey};
box-shadow: ${shadows.default};
`

const StyledContent = styled.div`
flex: 1 1 auto;
padding: ${spacing.padding.small}px ${spacing.padding.small}px 0
${spacing.padding.small}px;
overflow-y: auto;
`

const StyledParagraph = styled(Paragraph)`
line-height: 0;
margin-bottom: ${spacing.padding.small}px;
display: block;
flex: 0 0 auto;
`

const StyledHeader = styled.div`
flex: 0 0 auto;
`

export const Container = props => {
const { branded, appName, children, header } = props

return (
<StyleContainer {...props}>
{header && <StyledHeader>{header}</StyledHeader>}

<StyledContent>{children}</StyledContent>

{branded && (
<StyledParagraph size="small" align="center" color="stoneGrey">
{appName ? `${appName} ` : ''} ⚡️by Groove
</StyledParagraph>
)}
</StyleContainer>
)
}

Container.propTypes = {
/**
* Specify whether branded
*/
branded: PropTypes.bool,
/**
* Specify branding app name
*/
appName: PropTypes.string,
}

Container.defaultProps = {
branded: false,
appName: null,
}
20 changes: 20 additions & 0 deletions src/components/Container.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'
import { Container } from './Container'
import { Heading } from './Heading'

export default {
title: 'Design System|Container',
parameters: {
component: Container,
},
}

export const ContainerDefault = () => <Container />
export const ContainerBranded = () => <Container branded appName="Chat" />
export const ContainerWithChildren = () => (
<Container branded appName="Chat">
<Heading size="medium" align="center">
Take care of your children
</Heading>
</Container>
)
7 changes: 6 additions & 1 deletion src/components/Heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const StyledHeading = styled.span`
font-weight: ${props => typography.sizes[SIZES[props.size]].weight};
font-size: ${props => typography.sizes[SIZES[props.size]].size}px;
line-height: ${props => typography.sizes[SIZES[props.size]].height}px;
color: ${color.jetBlack};
color: ${props => color[props.color]};
text-align: ${props => ALIGNMENT[props.align]};
`

Expand All @@ -32,6 +32,10 @@ Heading.propTypes = {
* Specify size
*/
size: PropTypes.oneOf(Object.keys(SIZES)),
/**
* Specify color
*/
color: PropTypes.string,
/**
* Specify alignmnet
*/
Expand All @@ -40,5 +44,6 @@ Heading.propTypes = {

Heading.defaultProps = {
size: 'medium',
color: 'jetBlack',
align: ALIGNMENT.left,
}
7 changes: 6 additions & 1 deletion src/components/Paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const StyledParagraph = styled.span`
font-weight: ${props => typography.sizes[SIZES[props.size]].weight};
font-size: ${props => typography.sizes[SIZES[props.size]].size}px;
line-height: ${props => typography.sizes[SIZES[props.size]].height}px;
color: ${color.jetBlack};
color: ${props => color[props.color]};
text-align: ${props => ALIGNMENT[props.align]};
`

Expand All @@ -34,6 +34,10 @@ Paragraph.propTypes = {
* Specify size
*/
size: PropTypes.oneOf(Object.keys(SIZES)),
/**
* Specify color
*/
color: PropTypes.string,
/**
* Specify alignmnet
*/
Expand All @@ -46,6 +50,7 @@ Paragraph.propTypes = {

Paragraph.defaultProps = {
size: 'medium',
color: 'jetBlack',
align: ALIGNMENT.left,
isInline: false,
}
3 changes: 3 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ import * as animation from './shared/animation'

export { styles, global, animation }

export * from './Container'
export * from './Heading'
export * from './Paragraph'
export * from './Icon'
5 changes: 5 additions & 0 deletions src/components/shared/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export const borderColor = {
default: color.ashGrey,
}

// Shadows
export const shadows = {
default: '0 4px 16px 0 rgba(0, 0, 0, 0.1)',
}

// Spacing
export const spacing = {
padding: {
Expand Down