diff --git a/src/components/flow/Cell/index.tsx b/src/components/flow/Cell/index.tsx index bb2a154a..c432401f 100644 --- a/src/components/flow/Cell/index.tsx +++ b/src/components/flow/Cell/index.tsx @@ -1,44 +1,52 @@ -import React, { FC } from 'react'; +import React, { FC, useState, useCallback } from 'react'; +import { INode } from '~/redux/types'; import * as styles from './styles.scss'; -import { TEXTS } from '~/constants/texts'; - +import { getImageSize } from '~/utils/dom'; import classNames = require('classnames'); interface IProps { - height?: number; - width?: number; - title?: string; - is_hero?: boolean; - is_stamp?: boolean; + node: INode; + // height?: number; + // width?: number; + // title?: string; + // is_hero?: boolean; + // is_stamp?: boolean; is_text?: boolean; } -const Cell: FC = ({ - width = 1, - height = 1, - title, - is_hero, - is_text = (Math.random() > 0.8), -}) => ( -
= ({ node: { title, brief }, is_text = false }) => { + const [is_loaded, setIsLoaded] = useState(false); + + const onImageLoad = useCallback(() => { + setIsLoaded(true); + }, [setIsLoaded]); + + return ( +
+
{title &&
{title}
}
+ + {brief && brief.thumbnail && ( +
+ +
)} - style={{ - // gridRowEnd: `span ${height}`, - // gridColumnEnd: `span ${width}`, - }} - > - {is_text &&
-
{title}
- {TEXTS.LOREM_IPSUM} -
} - {title &&
{title}
} -
-); +
+ ); +}; export { Cell }; + +/* + {is_text && ( +
+
{node.title}
+ {TEXTS.LOREM_IPSUM} +
+ )} +*/ diff --git a/src/components/flow/Cell/styles.scss b/src/components/flow/Cell/styles.scss index f3c2b454..e3e93e85 100644 --- a/src/components/flow/Cell/styles.scss +++ b/src/components/flow/Cell/styles.scss @@ -50,7 +50,8 @@ } } -.title, .text_title { +.title, +.text_title { font: $font_cell_title; text-transform: uppercase; @@ -58,16 +59,11 @@ text-overflow: ellipsis; white-space: nowrap; - box-sizing: border-box; } .title { - padding: 0 $gap; - position: absolute; - bottom: $gap; - left: 0; - width: 100%; + max-height: 2em; } .text_title { @@ -97,3 +93,36 @@ box-shadow: inset #444 0 0 0 1px; } } + +.thumbnail { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: 50% 50% no-repeat; + background-size: cover; + z-index: 1; + border-radius: $cell_radius + 2px; + opacity: 0; + transition: opacity 0.5s; + + & > img { + opacity: 0; + width: 0; + height: 0; + } +} + +.face { + box-sizing: border-box; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: linear-gradient($content_bg, transparentize($content_bg, 1)); + z-index: 2; + border-radius: $cell_radius; + padding: $gap; +} diff --git a/src/components/flow/FlowGrid/index.tsx b/src/components/flow/FlowGrid/index.tsx new file mode 100644 index 00000000..1a23154a --- /dev/null +++ b/src/components/flow/FlowGrid/index.tsx @@ -0,0 +1,31 @@ +import React, { FC } from 'react'; +import { Cell } from '~/components/flow/Cell'; + +import * as styles from './styles.scss'; +import { IFlowState } from '~/redux/flow/reducer'; + +type IProps = Partial & {}; + +export const FlowGrid: FC = ({ nodes }) => ( +
+
+
HERO
+
STAMP
+ + {nodes.map(node => ( + + ))} +
+
+); + +// { +// range(1, 20).map(el => ( +// +// )); +// } diff --git a/src/components/flow/TestGrid/styles.scss b/src/components/flow/FlowGrid/styles.scss similarity index 100% rename from src/components/flow/TestGrid/styles.scss rename to src/components/flow/FlowGrid/styles.scss diff --git a/src/components/flow/TestGrid/index.tsx b/src/components/flow/TestGrid/index.tsx deleted file mode 100644 index 3439ca7b..00000000 --- a/src/components/flow/TestGrid/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import * as React from 'react'; -import { range } from 'ramda'; -import { Cell } from '~/components/flow/Cell'; - -import * as styles from './styles.scss'; - -export const TestGrid = () => ( -
-
-
HERO
- -
STAMP
- - {range(1, 20).map(el => ( - - ))} -
-
-); diff --git a/src/containers/flow/FlowLayout/index.tsx b/src/containers/flow/FlowLayout/index.tsx index 9531181c..56bd9c3e 100644 --- a/src/containers/flow/FlowLayout/index.tsx +++ b/src/containers/flow/FlowLayout/index.tsx @@ -1,8 +1,19 @@ -import * as React from 'react'; -import { TestGrid } from '~/components/flow/TestGrid'; -import * as styles from './styles.scss'; -import { Header } from '~/components/main/Header'; +import React, { FC } from 'react'; +import { connect } from 'react-redux'; +import { FlowGrid } from '~/components/flow/FlowGrid'; +import { selectFlow } from '~/redux/flow/selectors'; -export const FlowLayout = () => ( - -); +const mapStateToProps = selectFlow; + +const mapDispatchToProps = {}; + +type IProps = ReturnType & typeof mapDispatchToProps & {}; + +const FlowLayoutUnconnected: FC = ({ nodes }) => ; + +const FlowLayout = connect( + mapStateToProps, + mapDispatchToProps +)(FlowLayoutUnconnected); + +export { FlowLayout, FlowLayoutUnconnected }; diff --git a/src/utils/dom.ts b/src/utils/dom.ts index 8e2c61c5..7edebc03 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -53,3 +53,6 @@ export const describeArc = ( }; export const getURL = url => `${process.env.API_HOST}${url}`; + +export const getImageSize = (image: string, size?: string): string => + `${process.env.API_HOST}${image}`;