mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
Merge branch 'feature/better-images'
This commit is contained in:
commit
e1525edccb
6 changed files with 124 additions and 105 deletions
|
@ -9,12 +9,13 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: transparentize(black, 0.5);
|
background: transparentize(black, 0.5);
|
||||||
display: flex;
|
display: flex;
|
||||||
right: $gap;
|
left: 50%;
|
||||||
top: $gap;
|
top: -60px;
|
||||||
border-radius: 24px;
|
border-radius: 24px;
|
||||||
padding: 0 3px;
|
padding: 0 3px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
transition: background-color 0.5s;
|
transition: background-color 0.5s;
|
||||||
|
transform: translate(-50%, 0);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: transparentize(black, 0.2);
|
background: transparentize(black, 0.2);
|
||||||
|
|
|
@ -41,6 +41,7 @@ const NodeImageSlideBlock: FC<IProps> = ({
|
||||||
const [initial_x, setInitialX] = useState(0);
|
const [initial_x, setInitialX] = useState(0);
|
||||||
const [offset, setOffset] = useState(0);
|
const [offset, setOffset] = useState(0);
|
||||||
const [is_dragging, setIsDragging] = useState(false);
|
const [is_dragging, setIsDragging] = useState(false);
|
||||||
|
const [drag_start, setDragStart] = useState();
|
||||||
|
|
||||||
const slide = useRef<HTMLDivElement>();
|
const slide = useRef<HTMLDivElement>();
|
||||||
const wrap = useRef<HTMLDivElement>();
|
const wrap = useRef<HTMLDivElement>();
|
||||||
|
@ -165,7 +166,7 @@ const NodeImageSlideBlock: FC<IProps> = ({
|
||||||
const updateMaxHeight = useCallback(() => {
|
const updateMaxHeight = useCallback(() => {
|
||||||
if (!wrap.current) return;
|
if (!wrap.current) return;
|
||||||
const { width } = wrap.current.getBoundingClientRect();
|
const { width } = wrap.current.getBoundingClientRect();
|
||||||
setMaxHeight(width * NODE_SETTINGS.MAX_IMAGE_ASPECT);
|
setMaxHeight(window.innerHeight - 143);
|
||||||
normalizeOffset();
|
normalizeOffset();
|
||||||
}, [wrap, setMaxHeight, normalizeOffset]);
|
}, [wrap, setMaxHeight, normalizeOffset]);
|
||||||
|
|
||||||
|
@ -182,11 +183,12 @@ const NodeImageSlideBlock: FC<IProps> = ({
|
||||||
setIsDragging(false);
|
setIsDragging(false);
|
||||||
normalizeOffset();
|
normalizeOffset();
|
||||||
|
|
||||||
if (initial_x - getX(event) < 10) {
|
if (+new Date() - drag_start < 300) {
|
||||||
|
// click detection
|
||||||
onOpenPhotoSwipe();
|
onOpenPhotoSwipe();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[setIsDragging, is_dragging, normalizeOffset, onOpenPhotoSwipe]
|
[setIsDragging, is_dragging, normalizeOffset, onOpenPhotoSwipe, drag_start]
|
||||||
);
|
);
|
||||||
|
|
||||||
const startDragging = useCallback(
|
const startDragging = useCallback(
|
||||||
|
@ -194,8 +196,9 @@ const NodeImageSlideBlock: FC<IProps> = ({
|
||||||
setIsDragging(true);
|
setIsDragging(true);
|
||||||
setInitialX(getX(event));
|
setInitialX(getX(event));
|
||||||
setInitialOffset(offset);
|
setInitialOffset(offset);
|
||||||
|
setDragStart(+new Date());
|
||||||
},
|
},
|
||||||
[setIsDragging, setInitialX, offset, setInitialOffset]
|
[setIsDragging, setInitialX, offset, setInitialOffset, setDragStart]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => updateMaxHeight(), [images]);
|
useEffect(() => updateMaxHeight(), [images]);
|
||||||
|
@ -242,15 +245,6 @@ const NodeImageSlideBlock: FC<IProps> = ({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!is_loading && (
|
|
||||||
<ImageSwitcher
|
|
||||||
total={images.length}
|
|
||||||
current={current}
|
|
||||||
onChange={changeCurrent}
|
|
||||||
loaded={loaded}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.image_container, { [styles.is_dragging]: is_dragging })}
|
className={classNames(styles.image_container, { [styles.is_dragging]: is_dragging })}
|
||||||
style={{
|
style={{
|
||||||
|
@ -282,6 +276,15 @@ const NodeImageSlideBlock: FC<IProps> = ({
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{!is_loading && (
|
||||||
|
<ImageSwitcher
|
||||||
|
total={images.length}
|
||||||
|
current={current}
|
||||||
|
onChange={changeCurrent}
|
||||||
|
loaded={loaded}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
width: 100%;
|
|
||||||
transition: height 0.25s;
|
transition: height 0.25s;
|
||||||
border-radius: $radius $radius 0 0;
|
border-radius: $radius;
|
||||||
|
margin-right: -10px;
|
||||||
|
margin-left: -10px;
|
||||||
|
|
||||||
.is_loading {
|
.is_loading {
|
||||||
.placeholder {
|
.placeholder {
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.image_container {
|
.image_container {
|
||||||
// background: $node_image_bg;
|
|
||||||
border-radius: $panel_radius 0 0 $panel_radius;
|
border-radius: $panel_radius 0 0 $panel_radius;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
@ -24,17 +24,18 @@
|
||||||
user-select: none;
|
user-select: none;
|
||||||
will-change: transform, height;
|
will-change: transform, height;
|
||||||
transition: height 500ms, transform 500ms;
|
transition: height 500ms, transform 500ms;
|
||||||
|
padding: 0 0 20px 0;
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.image {
|
.image {
|
||||||
// max-height: 960px;
|
|
||||||
max-height: 120vh !important;
|
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
border-radius: $radius $radius 0 0;
|
border-radius: $radius;
|
||||||
|
box-shadow: transparentize($color: white, $amount: 0.95) 0 -1px,
|
||||||
|
transparentize($color: #000000, $amount: 0.6) 0 2px 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is_dragging {
|
&.is_dragging {
|
||||||
|
@ -44,15 +45,13 @@
|
||||||
|
|
||||||
.image_wrap {
|
.image_wrap {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
// top: 0;
|
|
||||||
// left: 0;
|
|
||||||
// opacity: 0;
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
touch-action: none;
|
touch-action: none;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
padding: 0 10px;
|
||||||
|
|
||||||
&:global(.is_active) {
|
&:global(.is_active) {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
justify-content: stretch;
|
justify-content: stretch;
|
||||||
border-radius: $radius $radius 0 0;
|
border-radius: $radius $radius 0 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 0 $gap;
|
padding: $gap $gap;
|
||||||
background: $node_bg;
|
background: $node_bg;
|
||||||
height: 64px;
|
height: 64px;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font: $font_24_semibold;
|
font: $font_24_semibold;
|
||||||
// height: 24px;
|
// height: 24px;
|
||||||
padding-bottom: 3px;
|
// padding-bottom: 6px;
|
||||||
|
|
||||||
@include tablet {
|
@include tablet {
|
||||||
// font-size: 16px;
|
// font-size: 16px;
|
||||||
|
|
|
@ -112,91 +112,107 @@ const NodeLayoutUnconnected: FC<IProps> = memo(
|
||||||
}, [nodeSetCoverImage, node.cover]);
|
}, [nodeSetCoverImage, node.cover]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className={styles.node} seamless>
|
<div className={styles.node}>
|
||||||
{block &&
|
{block &&
|
||||||
createElement(block, { node, is_loading, updateLayout, layout, modalShowPhotoswipe })}
|
createElement(block, { node, is_loading, updateLayout, layout, modalShowPhotoswipe })}
|
||||||
|
|
||||||
<NodePanel
|
<Card seamless>
|
||||||
node={pick(['title', 'user', 'is_liked', 'is_heroic', 'deleted_at', 'created_at'], node)}
|
<NodePanel
|
||||||
layout={layout}
|
node={pick(
|
||||||
can_edit={can_edit}
|
['title', 'user', 'is_liked', 'is_heroic', 'deleted_at', 'created_at'],
|
||||||
can_like={can_like}
|
node
|
||||||
can_star={can_star}
|
)}
|
||||||
onEdit={onEdit}
|
layout={layout}
|
||||||
onLike={onLike}
|
can_edit={can_edit}
|
||||||
onStar={onStar}
|
can_like={can_like}
|
||||||
onLock={onLock}
|
can_star={can_star}
|
||||||
is_loading={is_loading}
|
onEdit={onEdit}
|
||||||
/>
|
onLike={onLike}
|
||||||
|
onStar={onStar}
|
||||||
|
onLock={onLock}
|
||||||
|
is_loading={is_loading}
|
||||||
|
/>
|
||||||
|
|
||||||
{node.deleted_at ? (
|
{node.deleted_at ? (
|
||||||
<NodeDeletedBadge />
|
<NodeDeletedBadge />
|
||||||
) : (
|
) : (
|
||||||
<Group>
|
<Group>
|
||||||
<Padder>
|
<Padder>
|
||||||
<Group horizontal className={styles.content}>
|
<Group horizontal className={styles.content}>
|
||||||
<Group className={styles.comments}>
|
<Group className={styles.comments}>
|
||||||
{inline_block && (
|
{inline_block && (
|
||||||
<div className={styles.inline_block}>
|
<div className={styles.inline_block}>
|
||||||
{createElement(inline_block, {
|
{createElement(inline_block, {
|
||||||
node,
|
node,
|
||||||
is_loading,
|
is_loading,
|
||||||
updateLayout,
|
updateLayout,
|
||||||
layout,
|
layout,
|
||||||
modalShowPhotoswipe,
|
modalShowPhotoswipe,
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{is_loading || is_loading_comments || (!comments.length && !inline_block) ? (
|
{is_loading || is_loading_comments || (!comments.length && !inline_block) ? (
|
||||||
<NodeNoComments is_loading={is_loading_comments || is_loading} />
|
<NodeNoComments is_loading={is_loading_comments || is_loading} />
|
||||||
) : (
|
) : (
|
||||||
<NodeComments
|
<NodeComments
|
||||||
comments={comments}
|
comments={comments}
|
||||||
comment_data={comment_data}
|
comment_data={comment_data}
|
||||||
comment_count={comment_count}
|
comment_count={comment_count}
|
||||||
user={user}
|
user={user}
|
||||||
onDelete={nodeLockComment}
|
onDelete={nodeLockComment}
|
||||||
onEdit={nodeEditComment}
|
onEdit={nodeEditComment}
|
||||||
onLoadMore={nodeLoadMoreComments}
|
onLoadMore={nodeLoadMoreComments}
|
||||||
order="DESC"
|
order="DESC"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{is_user && !is_loading && <NodeCommentForm />}
|
{is_user && !is_loading && <NodeCommentForm />}
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<div className={styles.panel}>
|
||||||
|
<Sticky>
|
||||||
|
<Group style={{ flex: 1, minWidth: 0 }}>
|
||||||
|
{!is_loading && (
|
||||||
|
<NodeTags
|
||||||
|
is_editable={is_user}
|
||||||
|
tags={node.tags}
|
||||||
|
onChange={onTagsChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{is_loading && <NodeRelatedPlaceholder />}
|
||||||
|
|
||||||
|
{!is_loading &&
|
||||||
|
related &&
|
||||||
|
related.albums &&
|
||||||
|
Object.keys(related.albums)
|
||||||
|
.filter(album => related.albums[album].length > 0)
|
||||||
|
.map(album => (
|
||||||
|
<NodeRelated
|
||||||
|
title={album}
|
||||||
|
items={related.albums[album]}
|
||||||
|
key={album}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{!is_loading &&
|
||||||
|
related &&
|
||||||
|
related.similar &&
|
||||||
|
related.similar.length > 0 && (
|
||||||
|
<NodeRelated title="ПОХОЖИЕ" items={related.similar} />
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
</Sticky>
|
||||||
|
</div>
|
||||||
</Group>
|
</Group>
|
||||||
|
</Padder>
|
||||||
|
</Group>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className={styles.panel}>
|
<Footer />
|
||||||
<Sticky>
|
</Card>
|
||||||
<Group style={{ flex: 1, minWidth: 0 }}>
|
</div>
|
||||||
{!is_loading && (
|
|
||||||
<NodeTags is_editable={is_user} tags={node.tags} onChange={onTagsChange} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{is_loading && <NodeRelatedPlaceholder />}
|
|
||||||
|
|
||||||
{!is_loading &&
|
|
||||||
related &&
|
|
||||||
related.albums &&
|
|
||||||
Object.keys(related.albums)
|
|
||||||
.filter(album => related.albums[album].length > 0)
|
|
||||||
.map(album => (
|
|
||||||
<NodeRelated title={album} items={related.albums[album]} key={album} />
|
|
||||||
))}
|
|
||||||
|
|
||||||
{!is_loading && related && related.similar && related.similar.length > 0 && (
|
|
||||||
<NodeRelated title="ПОХОЖИЕ" items={related.similar} />
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
</Sticky>
|
|
||||||
</div>
|
|
||||||
</Group>
|
|
||||||
</Padder>
|
|
||||||
</Group>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</Card>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.node {
|
.node {
|
||||||
background: $node_bg;
|
// background: $node_bg;
|
||||||
box-shadow: $node_shadow;
|
// box-shadow: $node_shadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttons {
|
.buttons {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue