Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(common): add some step content when empty
- Loading branch information
Showing
14 changed files
with
343 additions
and
101 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
This file was deleted.
Oops, something went wrong.
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,65 @@ | ||
import Button from 'modules/common/components/Button'; | ||
import { __ } from 'modules/common/utils'; | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import Icon from '../Icon'; | ||
import { ITEM_COLORS } from './constants'; | ||
import { Action, Container, ItemContent, Items } from './styles'; | ||
|
||
type Props = { | ||
content: any; | ||
vertical?: boolean; | ||
maxItemWidth?: string; | ||
}; | ||
|
||
function EmptyContent({ content, vertical, maxItemWidth }: Props) { | ||
const { steps, title, description, url, urlText } = content; | ||
|
||
const renderButton = (buttonUrl: string, text: string, isOutside: boolean, target: string) => { | ||
if(!buttonUrl) { | ||
return null; | ||
} | ||
|
||
const buttonText = text || __('Learn More'); | ||
|
||
if(isOutside) { | ||
return ( | ||
<Button uppercase={false} href={buttonUrl} target={target}> | ||
{buttonText} | ||
</Button> | ||
); | ||
} | ||
|
||
return ( | ||
<Button uppercase={false}> | ||
<Link to={buttonUrl}>{buttonText}</Link> | ||
</Button> | ||
); | ||
} | ||
|
||
return ( | ||
<Container> | ||
<h2>{title}</h2> | ||
<p>{description} {url && <Link to={url}>{urlText}</Link>}</p> | ||
<Items vertical={vertical}> | ||
{steps.map((step, index) => ( | ||
<ItemContent | ||
key={step.title + index} | ||
color={ITEM_COLORS[index]} | ||
vertical={vertical} | ||
max={maxItemWidth} | ||
> | ||
{step.icon ? <Icon size={16} icon={step.icon} /> : <i>{index + 1}</i>} | ||
<h4>{step.title}</h4> | ||
<p>{step.description}</p> | ||
<Action> | ||
{renderButton(step.url, step.urlText, step.isOutside, step.target)} | ||
</Action> | ||
</ItemContent> | ||
))} | ||
</Items> | ||
</Container> | ||
); | ||
} | ||
|
||
export default EmptyContent; |
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,3 @@ | ||
export const ITEM_COLORS = [ | ||
"#3bc5cb", "#65b657", "#f9b920", "#2649f2", "#e64b4b", "#5b48a2" | ||
]; |
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,104 @@ | ||
import { darken, rgba } from 'modules/common/styles/color'; | ||
import styled from 'styled-components'; | ||
import styledTS from 'styled-components-ts'; | ||
import { colors } from '../../styles'; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
min-height: 100%; | ||
flex: 1; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 20px 40px; | ||
background: ${colors.bgLight}; | ||
flex-direction: column; | ||
h2 { | ||
margin: 0px 0 10px; | ||
font-weight: 700; | ||
text-align: center; | ||
} | ||
> p { | ||
font-size: 16px; | ||
text-align: center; | ||
color: ${colors.colorCoreGray}; | ||
max-width: 65%; | ||
@media (max-width: 1170px) { | ||
max-width: 100%; | ||
} | ||
} | ||
`; | ||
|
||
const Items = styledTS<{ vertical?: boolean }>(styled.div)` | ||
display: flex; | ||
flex-wrap: wrap; | ||
flex-direction: ${props => props.vertical ? 'column' : 'row'}; | ||
`; | ||
|
||
const Action = styled.div` | ||
margin-top: auto; | ||
button, a { | ||
&:active, &:focus { | ||
box-shadow: none; | ||
} | ||
} | ||
`; | ||
|
||
|
||
const ItemContent = styledTS<{ color: string, vertical?: boolean; max?:string }>(styled.div)` | ||
background: ${props => rgba(props.color, 0.2)}; | ||
padding: 25px 30px; | ||
border-radius: 5px; | ||
margin: 10px; | ||
min-width: 220px; | ||
max-width: ${props => props.vertical ? '420px' : props.max}; | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
border: 1px solid transparent; | ||
position: relative; | ||
transition: background 0.3s ease; | ||
h4 { | ||
margin: 20px 0 10px; | ||
font-size: 16px; | ||
font-weight: 700; | ||
line-height: 20px; | ||
} | ||
${Action} > button, ${Action} > a { | ||
background: ${props => props.color}; | ||
&:hover { | ||
background: ${props => darken(props.color, 15)}; | ||
} | ||
} | ||
p { | ||
margin: 0 0 20px; | ||
} | ||
&:hover { | ||
background: ${props => rgba(props.color, 0.3)}; | ||
border-color: ${props => props.color}; | ||
} | ||
> i { | ||
line-height: 32px; | ||
background: ${colors.colorWhite}; | ||
width: 32px; | ||
text-align: center; | ||
box-shadow: 0 0 6px 1px rgba(0,0,0,0.08); | ||
border-radius: 16px; | ||
font-weight: 800; | ||
display: block; | ||
font-style: normal; | ||
} | ||
`; | ||
|
||
export { Container, Items, Action, ItemContent }; | ||
|
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
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
Oops, something went wrong.