diff --git a/src/components/flow/Cell/index.tsx b/src/components/flow/Cell/index.tsx index f21d2326..03fec93d 100644 --- a/src/components/flow/Cell/index.tsx +++ b/src/components/flow/Cell/index.tsx @@ -1,20 +1,20 @@ -import React, { FC, useState, useCallback, useEffect, useRef } from 'react'; -import { INode } from '~/redux/types'; -import { getURL, formatCellText } from '~/utils/dom'; -import classNames from 'classnames'; +import React, { FC, useState, useCallback, useEffect, useRef } from "react"; +import { INode } from "~/redux/types"; +import { getURL, formatCellText } from "~/utils/dom"; +import classNames from "classnames"; -import * as styles from './styles.scss'; -import { Icon } from '~/components/input/Icon'; -import { flowSetCellView } from '~/redux/flow/actions'; -import { PRESETS } from '~/constants/urls'; -import { debounce } from 'throttle-debounce'; +import * as styles from "./styles.scss"; +import { Icon } from "~/components/input/Icon"; +import { flowSetCellView } from "~/redux/flow/actions"; +import { PRESETS } from "~/constants/urls"; +import { debounce } from "throttle-debounce"; interface IProps { node: INode; is_text?: boolean; can_edit?: boolean; - onSelect: (id: INode['id'], type: INode['type']) => void; + onSelect: (id: INode["id"], type: INode["type"]) => void; onChangeCellView: typeof flowSetCellView; } @@ -22,7 +22,7 @@ const Cell: FC = ({ node: { id, title, thumbnail, type, flow, description }, can_edit, onSelect, - onChangeCellView, + onChangeCellView }) => { const ref = useRef(null); const [is_loaded, setIsLoaded] = useState(false); @@ -33,14 +33,16 @@ const Cell: FC = ({ const { top, height } = ref.current.getBoundingClientRect(); - const visibility = top + height > -window.innerHeight && top < window.innerHeight * 2; + const visibility = + top + height > -window.innerHeight && top < window.innerHeight * 2; if (visibility !== is_visible) setIsVisible(visibility); }, [ref, is_visible, setIsVisible]); - const checkIfVisibleDebounced = useCallback(debounce(Math.random() * 200, checkIfVisible), [ - checkIfVisible, - ]); + const checkIfVisibleDebounced = useCallback( + debounce(Math.random() * 200, checkIfVisible), + [checkIfVisible] + ); useEffect(() => { checkIfVisible(); @@ -48,13 +50,13 @@ const Cell: FC = ({ useEffect(() => { // recalc visibility of other elements - window.dispatchEvent(new CustomEvent('scroll')); + window.dispatchEvent(new CustomEvent("scroll")); }, [flow]); useEffect(() => { - window.addEventListener('scroll', checkIfVisibleDebounced); + window.addEventListener("scroll", checkIfVisibleDebounced); - return () => window.removeEventListener('scroll', checkIfVisibleDebounced); + return () => window.removeEventListener("scroll", checkIfVisibleDebounced); }, [checkIfVisibleDebounced]); const onImageLoad = useCallback(() => { @@ -65,49 +67,51 @@ const Cell: FC = ({ const has_description = description && description.length > 160; const text = - (((flow && !!flow.show_description) || type === 'text') && has_description && description) || + (((flow && !!flow.show_description) || type === "text") && + has_description && + description) || null; const toggleViewDescription = useCallback(() => { const show_description = !(flow && flow.show_description); - const display = (flow && flow.display) || 'single'; + const display = (flow && flow.display) || "single"; onChangeCellView(id, { show_description, display }); }, [id, flow, onChangeCellView]); const setViewSingle = useCallback(() => { const show_description = (flow && !!flow.show_description) || false; - onChangeCellView(id, { show_description, display: 'single' }); + onChangeCellView(id, { show_description, display: "single" }); }, [id, flow, onChangeCellView]); const setViewHorizontal = useCallback(() => { const show_description = (flow && !!flow.show_description) || false; - onChangeCellView(id, { show_description, display: 'horizontal' }); + onChangeCellView(id, { show_description, display: "horizontal" }); }, [id, flow, onChangeCellView]); const setViewVertical = useCallback(() => { const show_description = (flow && !!flow.show_description) || false; - onChangeCellView(id, { show_description, display: 'vertical' }); + onChangeCellView(id, { show_description, display: "vertical" }); }, [id, flow, onChangeCellView]); const setViewQuadro = useCallback(() => { const show_description = (flow && !!flow.show_description) || false; - onChangeCellView(id, { show_description, display: 'quadro' }); + onChangeCellView(id, { show_description, display: "quadro" }); }, [id, flow, onChangeCellView]); return (
{is_visible && ( <> {can_edit && (
-
- -
+
{has_description && ( @@ -124,14 +128,28 @@ const Cell: FC = ({
)} -
+
- {title &&
{title}
} - {text && ( -
+ {title && !text &&
{title}
} + + {!!text && !!thumbnail && ( +
+ {title &&
{title}
} + +
+
+ )} + + {!!text && !thumbnail && ( +
+ {title &&
{title}
} + +
+
)}
@@ -140,12 +158,18 @@ const Cell: FC = ({
- +
)} diff --git a/src/components/flow/Cell/styles.scss b/src/components/flow/Cell/styles.scss index a848ac0e..763537d8 100644 --- a/src/components/flow/Cell/styles.scss +++ b/src/components/flow/Cell/styles.scss @@ -28,15 +28,22 @@ .text { font: $font_18_regular; line-height: 22px; - margin-top: $gap; + // margin-top: $gap; // letter-spacing: 0.5px; + background: transparentize($color: $content_bg, $amount: 0.3) + url("~/sprites/stripes.svg"); + padding: $gap; + box-sizing: border-box; + border-radius: $radius; + overflow: hidden; + position: relative; p { margin-bottom: $gap; } &::after { - content: ' '; + content: " "; position: absolute; bottom: 0; left: 0; @@ -44,7 +51,10 @@ height: 160px; pointer-events: none; touch-action: none; - background: linear-gradient(transparentize($content_bg, 1), $content_bg 95%); + background: linear-gradient( + transparentize($content_bg, 1), + $content_bg 95% + ); z-index: 1; border-radius: 0 0 $radius $radius; } @@ -71,6 +81,7 @@ } .title { + padding: $gap / 2; // max-height: 3.3em; } @@ -81,11 +92,25 @@ .horizontal, .quadro { grid-column-end: span 2; + + .text { + width: 50%; + height: 100%; + } } .vertical, .quadro { grid-row-end: span 2; + + .text { + width: 100%; + height: 50%; + } + + .face_content { + align-items: flex-end; + } } @media (max-width: $cell * 2) { @@ -145,10 +170,14 @@ left: 0; width: 100%; height: 100%; - background: linear-gradient($content_bg, transparentize($content_bg, 1)); + background: linear-gradient( + 5deg, + transparentize($content_bg, 0), + transparentize($content_bg, 1) + ); z-index: 2; border-radius: $cell_radius; - padding: $gap; + padding: $gap / 2; pointer-events: none; touch-action: none; animation: appear 1s forwards; @@ -174,8 +203,11 @@ position: relative; &:after { - content: ''; - background: linear-gradient(transparentize($content_bg, 1), $content_bg); + content: ""; + background: linear-gradient( + transparentize($content_bg, 1), + $content_bg + ); position: absolute; bottom: 0; left: 0; @@ -261,17 +293,30 @@ touch-action: auto; position: absolute; z-index: 4; - width: 32px + $gap * 2; - height: 32px + $gap * 2; + width: 32px; + height: 32px; display: flex; align-items: center; justify-content: center; - opacity: 0.2; + opacity: 0.9; + right: $gap; - svg { - fill: white; - width: 30px; - height: 30px; + &::after { + @include inner_shadow(); + + content: " "; + width: 20px; + height: 20px; + background: $content_bg; + border-radius: 100%; + transform: scale(0.5); + transition: transform 0.25s; + } + + &:hover { + &::after { + transform: scale(1); + } } } @@ -314,3 +359,9 @@ opacity: 0.2; border-radius: 2px; } + +.face_content { + display: flex; + align-items: flex-end; + justify-content: flex-start; +} diff --git a/src/redux/auth/sagas.ts b/src/redux/auth/sagas.ts index c10becc6..16fde585 100644 --- a/src/redux/auth/sagas.ts +++ b/src/redux/auth/sagas.ts @@ -117,7 +117,7 @@ function* refreshUser() { function* checkUserSaga({ key }: RehydrateAction) { if (key !== "auth") return; yield call(refreshUser); - yield put(authOpenProfile("gvorcek", "settings")); + // yield put(authOpenProfile("gvorcek", "settings")); } function* gotPostMessageSaga({ token }: ReturnType) {