Skip to content

Commit

Permalink
修改video页面item
Browse files Browse the repository at this point in the history
  • Loading branch information
master1lan committed Jan 6, 2023
1 parent e03b2e0 commit f48f9c4
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 47 deletions.
4 changes: 1 addition & 3 deletions src/components/image/image.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
display: inline-block;
object-fit: cover;
transition: opacity .5s linear;
-webkit-transition: opacity .5s linear;
transition: transform .2s linear;
-webkit-transition: transform .2s linear;
transition: transform .3s linear;

&:hover {
transform: scale(1.1);
Expand Down
4 changes: 2 additions & 2 deletions src/components/image/imagetype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export type ImageProps = {
fallbackUrl?: string;
/**
* @description 图片默认宽度,因为自适应的原因最终效果可能大于该宽度
* @default 180
* @example 180
* @default 200
* @example 200
*/
width?: number;
/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function useLoading(url: string) {

export default memo(function Image({
url,
width = 180,
width = 200,
height,
fallbackUrl = DefaultFallbackUrl,
observer,
Expand Down
2 changes: 1 addition & 1 deletion src/components/masonry/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function Masonry() {
<div className='feedContainer'>
<Masonic_masonry
items={lists}
columnWidth={180}
columnWidth={200}
rowGutter={10}
columnGutter={10}
maxColumnCount={5}
Expand Down
5 changes: 3 additions & 2 deletions src/components/message/message.module.less
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
.MessageWrapper {
position: fixed;
top: 10px;
top: 40%;
left: 50%;
transform: translate(-50%, 0);
transform: translate(-50%, -50%);
/* 消息提示的优先级应该是最高的! */
z-index: 9999;
}

.message {
border-radius: 8px;
box-shadow: rgba(0, 0, 0, 0.15) 0px 2px 10px;
background-color: #fff;
padding: 12px 24px;
margin-bottom: 10px;
display: flex;
Expand Down
18 changes: 12 additions & 6 deletions src/components/proview/imageSize.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import { useContext, useState, createContext, useEffect } from "react";
import {
useContext,
useState,
createContext,
useEffect,
ReactElement,
} from "react";
import { thorttleFn } from "@utils/index";
export const image_order_width = 180;
export const image_order_width = 200;

const ImageContext = createContext<{ isShouldchangeSize: boolean }>({
isShouldchangeSize: false,
});

//todo
//@ts-ignore
const ImageShouldResizeProview = ({ children }) => {
type ImageProviewProps = {
children: ReactElement;
};
const ImageShouldResizeProview = ({ children }: ImageProviewProps) => {
const [isShouldchangeSize, setIs] = useState<boolean>(false);
useEffect(() => {
const handleWindowResize = () => {
// console.log({ width: window.innerWidth });
setIs(() => window.innerWidth < image_order_width * 2.5);
};
handleWindowResize();
Expand Down
2 changes: 1 addition & 1 deletion src/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
width: 100%;

.element-item {
min-width: 180px;
min-width: 200px;
box-sizing: border-box;
padding: 0 5px;
}
Expand Down
6 changes: 4 additions & 2 deletions src/routers/video/masonry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { VideoRouterImageCard } from "./masonryItem";
*/
export default function VideoMasonry(props: any) {
const [lists, setLists] = useState<VideoRouterImageCardType[]>([]);
const order_width = 180;
const order_width = 200;
useEffect(() => {
// 在内部定义fetchHandler,保证拿到的是同步的
const fetchHandler = async () => {
Expand Down Expand Up @@ -45,7 +45,9 @@ export default function VideoMasonry(props: any) {
"like",
"updated_at",
"danmaku",
"duration"
"duration",
"favorite",
"face"
);

if (imageSize.success === true) {
Expand Down
74 changes: 65 additions & 9 deletions src/routers/video/masonryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import Image from "@components/image";
import { FC } from "react";
import SlowMotionVideoSharpIcon from "@mui/icons-material/SlowMotionVideoSharp";
import SubjectSharpIcon from "@mui/icons-material/SubjectSharp";
import ThumbUpSharpIcon from "@mui/icons-material/ThumbUpSharp";
import FavoriteSharpIcon from "@mui/icons-material/FavoriteSharp";
import Link from "@mui/material/Link";
import { VideoRouterImageCardType } from "./videotype";
import getrealtiveTime, { getVideoTime } from "@utils/time";
import styles from "./video.module.less";
import { Omit, Pick } from "@utils/index";
import getFixedNumber from "../../utils/number/index";

export const VideoRouterImageCard: FC<{ data: VideoRouterImageCardType }> = ({
data,
Expand Down Expand Up @@ -39,11 +42,22 @@ export const VideoRouterImageCard: FC<{ data: VideoRouterImageCardType }> = ({
"duration"
)}
>
{/* todo:lost tag */}
<VideoData {...Pick(data, "view", "danmaku", "duration")} />
</Image>
</Link>
<VideoInfo {...Pick(data, "title", "name", "updated_at", "bvid")} />
<VideoInfo
{...Pick(
data,
"title",
"name",
"updated_at",
"bvid",
"coin",
"favorite",
"like",
"face"
)}
/>
</section>
);
};
Expand All @@ -68,9 +82,19 @@ const VideoData: FC<
);
};
const VideoInfo: FC<
Pick<VideoRouterImageCardType, "title" | "name" | "updated_at" | "bvid">
Pick<
VideoRouterImageCardType,
| "title"
| "name"
| "updated_at"
| "bvid"
| "coin"
| "favorite"
| "like"
| "face"
>
> = (props) => {
const { title, name, bvid, updated_at } = props;
const { title, name, bvid, updated_at, coin, like, favorite, face } = props;
return (
<div className={styles["video-info"]}>
<p title={title}>
Expand All @@ -83,13 +107,45 @@ const VideoInfo: FC<
{title}
</Link>
</p>
<div className={styles["video-up-info"]}>
<Link underline='none' color='inherit'>
<span title={name}>{name}</span>
<span>{getrealtiveTime(updated_at * 1000)}</span>
</Link>
<div className={styles["video-up"]}>
<div className={styles["video-up-face"]} title={`芝士${name}`}>
<img src={face} />
</div>
<div className={styles["video-up-desc"]}>
<Link underline='none' color='inherit'>
<span title={name}>{name}</span>
<span>{getrealtiveTime(updated_at * 1000)}</span>
</Link>
<div className={styles["video-up-desc-data"]}>
<span title='点赞数'>
<ThumbUpSharpIcon fontSize='small' htmlColor='#707070' />{" "}
{getFixedNumber(like)}
</span>
<span title='硬币数'>
<CoinIcon height={"1.25rem"} /> {getFixedNumber(coin)}
</span>
<span title='收藏数'>
<FavoriteSharpIcon fontSize='small' htmlColor='#707070' />{" "}
{getFixedNumber(favorite)}
</span>
</div>
</div>
</div>
</div>
);
};
// 1-6 todo:写完视频页面展示瀑布图

export const CoinIcon: FC<{
height: number | string;
width?: number | string;
}> = ({ height, width = height }) => (
<svg fill='none' viewBox='0 0 24 24' height={height} width={width}>
<path
fillRule='evenodd'
clipRule='evenodd'
d='M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm3.25 4.75a.75.75 0 010 1.5h-2.5v1.29c1.117.125 2.062.539 2.761 1.253.849.867 1.239 2.077 1.239 3.457v.5a.75.75 0 01-1.5 0v-.5c0-1.105-.31-1.895-.81-2.407-.383-.39-.934-.678-1.69-.79V17a.75.75 0 01-1.5 0v-5.947c-.756.112-1.307.4-1.69.79-.5.512-.81 1.302-.81 2.407v.5a.75.75 0 01-1.5 0v-.5c0-1.38.39-2.59 1.239-3.457.7-.714 1.644-1.128 2.761-1.252V8.25h-2.5a.75.75 0 010-1.5h6.5z'
fill='#707070'
/>
</svg>
);
89 changes: 73 additions & 16 deletions src/routers/video/video.module.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
.video-data {
transition: opacity .3s linear;

*:hover+& {
opacity: 0;
}

position: absolute;
left: 0;
bottom: 0;
Expand All @@ -14,8 +20,8 @@
font-size: 13px;
font-weight: 400;
background-image: linear-gradient(180deg,
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, .8) 100%);
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, .8) 100%);

&-left {
flex: 1;
Expand All @@ -36,6 +42,10 @@
}

.video-info {
&>*:not(:first-child) {
margin-top: 5px;
}

&>p {
color: #18191c;
font-size: 15px;
Expand All @@ -49,29 +59,76 @@

}

.video-up-info {
a {
font-size: 13px;
color: rgb(148, 153, 160);
cursor: pointer;
transition: color .2s linear;
.video-up {
display: flex;
align-items: stretch;

&:hover,
&:active {
color: #00aeec;
&>*:not(:first-child) {
margin-left: 5px;
}

&-face {
width: 40px;
height: 40px;

img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 50%;
overflow: hidden;
}
}

&-desc {
font-size: 13px;
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
cursor: default;

&>span {
&-data {
display: flex;
flex-flow: row nowrap;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;

&:not(:last-of-type):after {
content: '·';
margin: 0 4px;
&>span {
white-space: nowrap;
display: flex;
align-items: center;

&:not(:first-of-type) {
margin-left: 10px;
}
}
}


a {

color: rgb(148, 153, 160);
cursor: pointer;
transition: color .2s linear;

&:hover,
&:active {
color: #00aeec;
}

&>span {
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;

&:not(:last-of-type):after {
content: '·';
margin: 0 4px;
}

}
}
}

}
}
2 changes: 2 additions & 0 deletions src/routers/video/videotype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type VideoRouterImageCardType = Pick<
| "updated_at"
| "danmaku"
| "duration"
| "favorite"
| "face"
> &
Omit<ImageProps, "url">;

Expand Down
Loading

0 comments on commit f48f9c4

Please sign in to comment.