From 2658177d162cc68dfc87c9bf20abbcdaaa114a17 Mon Sep 17 00:00:00 2001 From: Aminejv Date: Wed, 4 Aug 2021 17:16:06 +0100 Subject: [PATCH 1/6] feat(DataView): update checkbox boxShadow --- components/core/DataView.js | 1 - 1 file changed, 1 deletion(-) diff --git a/components/core/DataView.js b/components/core/DataView.js index 7a6f0daa..1a749b6d 100644 --- a/components/core/DataView.js +++ b/components/core/DataView.js @@ -753,7 +753,6 @@ export default class DataView extends React.Component { height: 24, width: 24, borderRadius: "8px", - boxShadow: `0 0 0 1px ${Constants.system.white}`, backgroundColor: this.state.checked[i] ? Constants.system.blue : "rgba(255, 255, 255, 0.75)", From 277e8a3d22fe4a9628f95dc649d3255d65a2d346 Mon Sep 17 00:00:00 2001 From: Aminejv Date: Wed, 4 Aug 2021 17:17:59 +0100 Subject: [PATCH 2/6] feat(ObjectPreview): debounce description's hover --- .../ObjectPreview/ObjectPreviewPrimitive.js | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/components/core/ObjectPreview/ObjectPreviewPrimitive.js b/components/core/ObjectPreview/ObjectPreviewPrimitive.js index 2db96811..14c98c9f 100644 --- a/components/core/ObjectPreview/ObjectPreviewPrimitive.js +++ b/components/core/ObjectPreview/ObjectPreviewPrimitive.js @@ -20,24 +20,22 @@ const STYLES_WRAPPER = (theme) => css` `; const STYLES_DESCRIPTION = (theme) => css` + position: relative; box-shadow: 0 -0.5px 0.5px ${theme.system.grayLight4}; border-radius: 0px 0px 16px 16px; box-sizing: border-box; width: 100%; - max-height: 61px; + background-color: ${theme.semantic.bgLight}; + border-radius: 16px; + height: calc(170px + 61px); + padding: 9px 16px 8px; + z-index: 1; @media (max-width: ${theme.sizes.mobile}px) { padding: 8px; } `; -const STYLES_DESCRIPTION_INNER = (theme) => css` - background-color: ${theme.semantic.bgLight}; - padding: 9px 16px 8px; - border-radius: 16px; - height: calc(170px + 61px); -`; - const STYLES_PREVIEW = css` overflow: hidden; position: relative; @@ -73,6 +71,7 @@ export default function ObjectPreviewPrimitive({ isImage, onAction, }) { + const { isDescriptionVisible, showDescription, hideDescription } = useShowDescription(); // const { like, isLiked, likeCount } = useLikeHandler({ file, viewer }); // const { save, isSaved, saveCount } = useSaveHandler({ file, viewer }); // const showSaveButton = viewer?.id !== file?.ownerId; @@ -81,11 +80,8 @@ export default function ObjectPreviewPrimitive({ // const showControls = () => setShowControls(true); // const hideControls = () => setShowControls(false); - const [isBodyVisible, setShowBody] = React.useState(false); - const showBody = () => setShowBody(true); - const hideBody = () => setShowBody(false); const body = file?.data?.body; - const isLink = file.isLink; + const { isLink } = file; const title = file.data.name || file.filename; @@ -126,17 +122,22 @@ export default function ObjectPreviewPrimitive({
{children}
-
- +
{title}
-
+
{typeof tag === "string" ? ( {tag} @@ -148,15 +149,32 @@ export default function ObjectPreviewPrimitive({
{body || ""}
- -
+ + ); } + +const useShowDescription = () => { + const [isDescriptionVisible, setShowDescription] = React.useState(false); + const timeoutId = React.useRef(); + + const showDescription = () => { + clearTimeout(timeoutId.current); + const id = setTimeout(() => setShowDescription(true), 250); + timeoutId.current = id; + }; + const hideDescription = () => { + clearTimeout(timeoutId.current); + setShowDescription(false); + }; + + return { isDescriptionVisible, showDescription, hideDescription }; +}; From 760653bb3fbc3162f0ed48b626f2cfaea013b53c Mon Sep 17 00:00:00 2001 From: Aminejv Date: Wed, 4 Aug 2021 17:18:21 +0100 Subject: [PATCH 3/6] feat(CollectionPreview): show description on hover --- .../core/CollectionPreviewBlock/index.js | 189 ++++++++++-------- 1 file changed, 102 insertions(+), 87 deletions(-) diff --git a/components/core/CollectionPreviewBlock/index.js b/components/core/CollectionPreviewBlock/index.js index 3470d87c..18ad0af8 100644 --- a/components/core/CollectionPreviewBlock/index.js +++ b/components/core/CollectionPreviewBlock/index.js @@ -14,7 +14,7 @@ import { css } from "@emotion/react"; import { FollowButton } from "~/components/core/CollectionPreviewBlock/components"; import { useFollowHandler } from "~/components/core/CollectionPreviewBlock/hooks"; import { Link } from "~/components/core/Link"; -import { AnimatePresence, motion } from "framer-motion"; +import { motion } from "framer-motion"; import ObjectPlaceholder from "~/components/core/ObjectPreview/placeholders"; @@ -46,9 +46,11 @@ const STYLES_PREVIEW = css` `; const STYLES_DESCRIPTION_CONTAINER = (theme) => css` + background-color: ${theme.semantic.bgLight}; + position: absolute; + bottom: 0%; display: flex; flex-direction: column; - position: relative; padding: 9px 16px 12px; border-radius: 0px 0px 16px 16px; box-shadow: 0 -0.5px 0.5px ${theme.system.grayLight4}; @@ -68,11 +70,8 @@ const STYLES_PROFILE_IMAGE = (theme) => css` object-fit: cover; `; -const STYLES_METRICS = (theme) => css` - margin-top: 7px; - @media (max-width: ${theme.sizes.mobile}px) { - margin-top: 12px; - } +const STYLES_METRICS = css` + margin-top: auto; ${Styles.CONTAINER_CENTERED}; ${STYLES_SPACE_BETWEEN} `; @@ -129,11 +128,6 @@ const getObjectToPreview = (objects = []) => { return { ...objects[objectIdx], isImage }; }; -const STYLES_DESCRIPTION_INNER = (theme) => css` - background-color: ${theme.semantic.bgLight}; - border-radius: 16px; -`; - const Preview = ({ collection, children, ...props }) => { const [isLoading, setLoading] = React.useState(true); const handleOnLoaded = () => setLoading(false); @@ -199,10 +193,8 @@ export default function CollectionPreview({ collection, viewer, owner, onAction const showControls = () => setShowControls(true); const hideControls = () => setShowControls(false); - // const [isBodyVisible, setShowBody] = React.useState(false); - // const showBody = () => setShowBody(true); - // const hideBody = () => setShowBody(false); - // const body = collection?.data?.body; + const { isDescriptionVisible, showDescription, hideDescription } = useShowDescription(); + const description = collection?.data?.body; const { follow, followCount, isFollowed } = useFollowHandler({ collection, viewer }); @@ -211,89 +203,112 @@ export default function CollectionPreview({ collection, viewer, owner, onAction return (
- - {areControlsVisible && ( - - - - )} - + + + -
-
+
{collection.slatename}
- - {/* {isBodyVisible && ( -
+ - - {body || ""} - + {description || ""} + + +
+
+ + + {fileCount} +
- )} */} -
- -
-
- - - {fileCount} - + {owner && ( +
+ + {`${owner.username} (e.target.src = Constants.profileDefaultPicture)} + /> + + + + {owner.username} + + +
+ )}
- {owner && ( -
- - {`${owner.username} (e.target.src = Constants.profileDefaultPicture)} - /> - - - - {owner.username} - - -
- )} -
+
); } + +const useShowDescription = () => { + const [isDescriptionVisible, setShowDescription] = React.useState(false); + const timeoutId = React.useRef(); + + const showDescription = () => { + clearTimeout(timeoutId.current); + const id = setTimeout(() => setShowDescription(true), 250); + timeoutId.current = id; + }; + const hideDescription = () => { + clearTimeout(timeoutId.current); + setShowDescription(false); + }; + + return { isDescriptionVisible, showDescription, hideDescription }; +}; From 19b1c7c6d96b2b47e4f0a2dd9345ff38b7230ba9 Mon Sep 17 00:00:00 2001 From: Aminejv Date: Wed, 4 Aug 2021 17:28:15 +0100 Subject: [PATCH 4/6] fix(getSubscriptionByUserId): return slates.id instead of ownerId as id --- node_common/data/methods/get-subscriptions-by-user-id.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node_common/data/methods/get-subscriptions-by-user-id.js b/node_common/data/methods/get-subscriptions-by-user-id.js index 7760e3c5..4fd2d42c 100644 --- a/node_common/data/methods/get-subscriptions-by-user-id.js +++ b/node_common/data/methods/get-subscriptions-by-user-id.js @@ -11,9 +11,9 @@ export default async ({ ownerId }) => { // const slateFiles = () => // DB.raw("json_agg(?? order by ?? asc) as ??", ["files", "slate_files.createdAt", "objects"]); - const ownerQueryFields = ["*", ...Constants.userPreviewProperties, "owner"]; + const ownerQueryFields = [...Constants.userPreviewProperties, "owner"]; const ownerQuery = DB.raw( - `??, json_build_object('id', ??, 'data', ??, 'username', ??) as ??`, + `json_build_object('id', ??, 'data', ??, 'username', ??) as ??`, ownerQueryFields ); @@ -36,7 +36,7 @@ export default async ({ ownerId }) => { // .orderBy("subscriptions.createdAt", "desc"); .groupBy("slates.id") ) - .select(ownerQuery) + .select(...Serializers.slateProperties, "objects", ownerQuery) .from("slates") .join("users", "slates.ownerId", "users.id"); From 322f8f4969b00be677dbb7d14ae63a6be0875a38 Mon Sep 17 00:00:00 2001 From: Aminejv Date: Wed, 4 Aug 2021 20:06:38 +0100 Subject: [PATCH 5/6] feat(previews): add title prop --- common/styles.js | 1 + components/core/CollectionPreviewBlock/index.js | 2 +- components/core/ObjectPreview/ObjectPreviewPrimitive.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/styles.js b/common/styles.js index 3c02e361..3d1a55a6 100644 --- a/common/styles.js +++ b/common/styles.js @@ -18,6 +18,7 @@ export const LINK = css` const TEXT = css` box-sizing: border-box; overflow-wrap: break-word; + text-align: left; a { ${LINK} diff --git a/components/core/CollectionPreviewBlock/index.js b/components/core/CollectionPreviewBlock/index.js index 18ad0af8..009df195 100644 --- a/components/core/CollectionPreviewBlock/index.js +++ b/components/core/CollectionPreviewBlock/index.js @@ -225,7 +225,7 @@ export default function CollectionPreview({ collection, viewer, owner, onAction transition={{ duration: 0.4, ease: "easeOut" }} >
- + {collection.slatename}
diff --git a/components/core/ObjectPreview/ObjectPreviewPrimitive.js b/components/core/ObjectPreview/ObjectPreviewPrimitive.js index 14c98c9f..f9e64e70 100644 --- a/components/core/ObjectPreview/ObjectPreviewPrimitive.js +++ b/components/core/ObjectPreview/ObjectPreviewPrimitive.js @@ -134,7 +134,7 @@ export default function ObjectPreviewPrimitive({ }} transition={{ type: "spring", stiffness: 170, damping: 26 }} > -
+
{title}
From a6173d5fb64a430d219d73690bd3307426018e77 Mon Sep 17 00:00:00 2001 From: Martina Date: Wed, 4 Aug 2021 17:25:16 -0700 Subject: [PATCH 6/6] tweak the checkbox border color to match the object border color --- components/system/components/CheckBox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/system/components/CheckBox.js b/components/system/components/CheckBox.js index 6f425164..9e08361d 100644 --- a/components/system/components/CheckBox.js +++ b/components/system/components/CheckBox.js @@ -17,7 +17,7 @@ const STYLES_CHECKBOX = css` const STYLES_CHECKBOX_FIGURE = css` box-sizing: border-box; - box-shadow: 0 0 0 1px ${Constants.semantic.borderGrayLight}; + box-shadow: 0 0 0 1px ${Constants.system.grayLight4}; background-color: ${Constants.system.white}; border-radius: 4px; display: inline-flex;