This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): update styling of connect library
- Loading branch information
Showing
7 changed files
with
138 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,92 @@ | ||
import { Color, colors } from '../colors'; | ||
import * as React from 'react'; | ||
import { getSpace, SpaceSize } from '../space'; | ||
import styled, { css } from 'styled-components'; | ||
|
||
export interface ButtonProps { | ||
color?: Color; | ||
textColor?: Color; | ||
onClick?: React.MouseEventHandler<HTMLElement>; | ||
order?: ButtonOrder; | ||
} | ||
|
||
export interface StyledButtonProps { | ||
color?: Color; | ||
size?: ButtonSize; | ||
inverted?: boolean; | ||
} | ||
|
||
export enum ButtonOrder { | ||
Primary, | ||
Secondary | ||
} | ||
|
||
export enum ButtonSize { | ||
Medium, | ||
Small | ||
} | ||
|
||
const StyledButton = styled.button` | ||
padding: 15px 42px; | ||
border: none; | ||
border-radius: 4px; | ||
font-size: 15px; | ||
cursor: pointer; | ||
border-radius: 3px; | ||
&:hover { | ||
opacity: 0.9; | ||
} | ||
${(props: ButtonProps) => { | ||
switch (props.order) { | ||
case ButtonOrder.Secondary: | ||
return css` | ||
background: ${colors.black.toString()}; | ||
color: ${colors.white.toString()}; | ||
:hover { | ||
background: ${colors.grey20.toString()}; | ||
} | ||
`; | ||
case ButtonOrder.Primary: | ||
default: | ||
return css` | ||
background: ${colors.blue.toString()}; | ||
color: ${colors.white.toString()}; | ||
`; | ||
} | ||
}}; | ||
:hover { | ||
background: ${colors.blue20.toString()}; | ||
} | ||
${(props: ButtonProps) => { | ||
switch (props.size) { | ||
case ButtonSize.Small: | ||
return css` | ||
font-size: 12px; | ||
padding: ${getSpace(SpaceSize.XS)}px ${getSpace(SpaceSize.L)}px; | ||
`; | ||
case ButtonSize.Medium: | ||
default: | ||
return css` | ||
font-size: 15px; | ||
padding: ${getSpace(SpaceSize.M)}px ${getSpace(SpaceSize.XXXL)}px; | ||
`; | ||
} | ||
}}; | ||
${(props: ButtonProps) => | ||
props.inverted | ||
? ` | ||
background: ${colors.white.toString()}; | ||
` | ||
: ''}; | ||
${(props: ButtonProps) => | ||
typeof props.textColor !== 'undefined' | ||
? ` | ||
color: ${props.textColor.toString()}; | ||
` | ||
: ''}; | ||
`; | ||
|
||
export const Button: React.StatelessComponent<ButtonProps> = props => ( | ||
<StyledButton onClick={props.onClick}>{props.children}</StyledButton> | ||
<StyledButton | ||
onClick={props.onClick} | ||
textColor={props.textColor} | ||
order={props.order} | ||
size={props.size} | ||
inverted={props.inverted} | ||
> | ||
{props.children} | ||
</StyledButton> | ||
); | ||
|
||
export default Button; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import Button, { ButtonOrder, ButtonSize } from '../button'; | ||
import { colors } from '../colors'; | ||
import { getSpace, SpaceSize } from '../space'; | ||
import { Headline } from '../headline'; | ||
import { Copy } from '../copy'; | ||
import * as React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
export interface ConnectLibraryProps { | ||
onClick?: React.MouseEventHandler<HTMLElement>; | ||
headline?: string; | ||
description?: string; | ||
primaryButton?: string; | ||
secondaryButton?: string; | ||
onPrimaryButtonClick?: React.MouseEventHandler<HTMLElement>; | ||
onSecondaryButtonClick?: React.MouseEventHandler<HTMLElement>; | ||
} | ||
|
||
const StyledConnectLibrary = styled.div` | ||
background: linear-gradient( | ||
to bottom right, | ||
${colors.orange.toString()}, | ||
${colors.red.toString()} | ||
); | ||
box-sizing: border-box; | ||
padding: ${getSpace(SpaceSize.XL)}px ${getSpace(SpaceSize.L)}px; | ||
color: ${colors.white.toString()}; | ||
`; | ||
|
||
const StyledHeadline = styled(Headline)` | ||
margin-bottom: ${getSpace(SpaceSize.M)}px; | ||
`; | ||
|
||
const StyledButton = styled(Button)` | ||
margin: ${getSpace(SpaceSize.M)}px 0; | ||
`; | ||
|
||
export const ConnectLibrary: React.SFC<ConnectLibraryProps> = props => ( | ||
<StyledConnectLibrary> | ||
<StyledHeadline order={3}>{props.headline}</StyledHeadline> | ||
<Copy>{props.description}</Copy> | ||
<StyledButton | ||
textColor={colors.red} | ||
order={ButtonOrder.Primary} | ||
size={ButtonSize.Small} | ||
onClick={props.onPrimaryButtonClick} | ||
inverted={true} | ||
> | ||
{props.primaryButton} | ||
</StyledButton> | ||
<Copy>{props.secondaryButton}</Copy> | ||
</StyledConnectLibrary> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "connect-library", | ||
"displayName": "Connect Library", | ||
"version": "1.0.0", | ||
"tags": ["molecule", "connect", "library", "status"], | ||
"flag": "alpha" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters