diff --git a/src/universal/partials/Welcome/PartialCards.js b/src/universal/partials/Welcome/PartialCards.js new file mode 100644 index 0000000..b679102 --- /dev/null +++ b/src/universal/partials/Welcome/PartialCards.js @@ -0,0 +1,70 @@ +import React from 'react'; +import groupBy from 'lodash/groupBy'; +import ReactDOMServer from 'react-dom/server'; +import { ServerStyleSheet } from 'styled-components'; + +import partials from './partials'; +const STATUS_COLOR = { + live: '#8dc63f', + dev: '#FF6000', + page: '#00abff', + 1: '#9b59b6', + 2: '#c0392b', + 3: '#16a085' +}; + +const sheet = new ServerStyleSheet(); + +const Welcome = () => { + const { live = [], dev = [], page = [], ...others } = groupBy(partials, item => item.status); + + const renderItem = ({ item, status, title }) => ( + +
+
+
+ {title} +
+
+
{item.name}
+
+ {status === 'page' ? 'Multiple partials' : 'Single partial'} +
+ +
+
+ ); + + const renderGroup = ({ title, data, status }) => { + return ( +
+
+
+ {title.toUpperCase()} ({data.length}) +
+
+
{data.map(item => renderItem({ item, status, title }))}
+
+ ); + }; + + return ( +
+ {page.length > 0 && renderGroup({ title: 'page', data: page, status: 'page' })} + {live.length > 0 && renderGroup({ title: 'live', data: live, status: 'live' })} + {dev.length > 0 && renderGroup({ title: 'dev', data: dev, status: 'dev' })} + {Object.entries(others).map((entity, index) => { + const [key, data] = entity; + return renderGroup({ title: key, data, status: index + 1 }); + })} +
+ ); +}; +export default ReactDOMServer.renderToString(sheet.collectStyles()); +const styleTags = sheet.getStyleTags(); + +export { styleTags }; diff --git a/src/universal/partials/Welcome/PartialList.js b/src/universal/partials/Welcome/PartialList.js deleted file mode 100644 index fd90e8b..0000000 --- a/src/universal/partials/Welcome/PartialList.js +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react'; -import groupBy from 'lodash/groupBy'; -import ReactDOMServer from 'react-dom/server'; -import { ServerStyleSheet } from 'styled-components'; - -import { List, ListItem, Name, Url, Footer, Label, Dot, Link, HeaderName } from './styled'; -import partials from './partials'; - -const sheet = new ServerStyleSheet(); - -const Welcome = () => { - const { live = [], dev = [], page = [], ...others } = groupBy(partials, item => item.status); - - const renderItem = ({ item, status }) => ( - - - {item.name} - {item.url} -
- -
- -
- ); - - const renderGroup = ({ title, value, status }) => { - return ( - <> - {title} - {value.map(item => renderItem({ item, status }))} - - ); - }; - - return ( - - {page.length > 0 && renderGroup({ title: 'page', value: page, status: 'page' })} - {live.length > 0 && renderGroup({ title: 'live', value: live, status: 'live' })} - {dev.length > 0 && renderGroup({ title: 'dev', value: dev, status: 'dev' })} - {Object.entries(others).map((entity, index) => { - const [key, value] = entity; - return renderGroup({ title: key, value, status: index + 1 }); - })} - - ); -}; -export default ReactDOMServer.renderToString(sheet.collectStyles()); -const styleTags = sheet.getStyleTags(); - -export { styleTags }; diff --git a/src/universal/partials/Welcome/Welcome.js b/src/universal/partials/Welcome/Welcome.js index 173aff5..97413c4 100644 --- a/src/universal/partials/Welcome/Welcome.js +++ b/src/universal/partials/Welcome/Welcome.js @@ -1,4 +1,7 @@ -import PartialList, { styleTags } from './PartialList'; +import PartialCards from './PartialCards'; +import welcomeStyle from './welcomeStyle'; + +import voltranConfig from '../../../../voltran.config'; export default () => { return ` @@ -6,23 +9,69 @@ export default () => { Welcome - - ${styleTags} + ${welcomeStyle()} - ${PartialList} + +
+
+ +
+
+
+ ${PartialCards} +
+
+
+ + `; }; diff --git a/src/universal/partials/Welcome/styled.js b/src/universal/partials/Welcome/styled.js deleted file mode 100644 index 0f55d4f..0000000 --- a/src/universal/partials/Welcome/styled.js +++ /dev/null @@ -1,145 +0,0 @@ -import styled from 'styled-components'; - -const STATUS_COLOR = { - live: '#8dc63f', - dev: '#FF6000', - page: '#00abff', - 1: '#9b59b6', - 2: '#c0392b', - 3: '#16a085' -}; - -export const List = styled.ul` - list-style: none; - margin: 0; - padding: 0; - margin-bottom: 20px; -`; - -export const HeaderName = styled.div` - font-size: 36px; - font-weight: bold; - margin: 10px; -`; - -export const ListItem = styled.li` - padding: 20px; - display: inline-block; - vertical-align: top; - height: 120px; - width: 240px; - margin: 10px; - cursor: pointer; - border-radius: 10px; - - position: relative; - background-color: #fff; - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); - -webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1); - transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1); - - :after { - content: ''; - border-radius: 10px; - position: absolute; - z-index: -1; - top: 0; - left: 0; - width: 100%; - height: 100%; - box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); - opacity: 0; - -webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1); - transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1); - } - - &:hover { - transform: scale(1.02, 1.02); - :after { - opacity: 1; - } - } - - @media screen and (max-width: 600px) { - display: block; - width: auto; - height: 150px; - margin: 10px auto; - } -`; - -export const Link = styled.a` - text-decoration: none; - color: #49494a; - - &:before { - position: absolute; - z-index: 0; - top: 0; - right: 0; - bottom: 0; - left: 0; - display: block; - content: ''; - } -`; - -export const Name = styled.span` - font-weight: 800; - display: block; - max-width: 80%; - font-size: 16px; - line-height: 18px; -`; - -export const Url = styled.span` - font-size: 11px; - line-height: 16px; - color: #a1a1a4; -`; - -export const Footer = styled.span` - display: block; - position: absolute; - bottom: 0; - left: 0; - right: 0; - width: 100%; - padding: 20px; - border-top: 1px solid ${({ status }) => (status && STATUS_COLOR[status]) || '#eeeeee'}50; - font-size: 13px; -`; - -export const Label = styled.span` - font-size: 13px; - align-items: center; - font-weight: bold; - display: flex; - position: absolute; - right: 20px; - top: 0; - line-height: 40px; - margin: 0 10px; - - @media screen and (max-width: 200px) { - right: auto; - left: 10px; - } - - color: ${({ status }) => (status && STATUS_COLOR[status]) || '#8dc63f'}; -`; - -export const Dot = styled.span` - display: inline-block; - vertical-align: middle; - width: 16px; - height: 16px; - overflow: hidden; - border-radius: 50%; - padding: 0; - text-indent: -9999px; - color: transparent; - line-height: 16px; - margin-left: 10px; - background: ${({ status }) => (status && STATUS_COLOR[status]) || '#8dc63f'}; -`; diff --git a/src/universal/partials/Welcome/welcomeStyle.js b/src/universal/partials/Welcome/welcomeStyle.js new file mode 100644 index 0000000..9b09e2b --- /dev/null +++ b/src/universal/partials/Welcome/welcomeStyle.js @@ -0,0 +1,322 @@ +const welcomeStyle = () => { + return ``; +}; + +export default welcomeStyle;