This repository has been archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
219df5b
commit fae7735
Showing
16 changed files
with
499 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@use '../../popup/variables' as v; | ||
|
||
.wrapper { | ||
width: 100%; | ||
&::after { | ||
height: 450px; | ||
display: block; | ||
content: attr(data-content); | ||
font-size: 14px; | ||
color: v.$secondary-text-color; | ||
border-radius: 4px; | ||
background: { | ||
position: 50%; | ||
repeat: no-repeat; | ||
image: url('../../assets/nodata.png'); | ||
} | ||
overflow: hidden; | ||
line-height: 640px; | ||
text-align: center; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { FC } from 'react'; | ||
|
||
import styles from './index.module.scss'; | ||
|
||
interface IEmptyProps { | ||
content: string; | ||
} | ||
|
||
const Empty: FC<IEmptyProps> = (props) => ( | ||
<div | ||
className={styles.wrapper} | ||
style={{ content: 'Hello' }} | ||
data-content={props.content} | ||
/> | ||
); | ||
|
||
export default Empty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.wrapper { | ||
padding: 4px 12px; | ||
display: flex; | ||
border-radius: 4px; | ||
transition: background-color 0.3s ease-in-out; | ||
cursor: pointer; | ||
|
||
&:hover { | ||
background-color: #f5f5f5; | ||
} | ||
|
||
.avatar { | ||
margin-right: 8px; | ||
width: 34px; | ||
height: 34px; | ||
border: 1px solid #e5e5e5 { | ||
radius: 50%; | ||
} | ||
transition: width 0.2s ease-in-out, height 0.2s ease-in-out; | ||
} | ||
|
||
.contentWrapper { | ||
height: 38px; | ||
|
||
.section { | ||
margin: 0; | ||
width: 120px; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.name { | ||
font: { | ||
size: 14px; | ||
weight: 500; | ||
} | ||
} | ||
|
||
.sign { | ||
color: #1c1f239f; | ||
font: { | ||
size: 12px; | ||
weight: 300; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.select { | ||
background-color: #f5f5f5; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { FC, useMemo } from 'react'; | ||
import { useStorage } from '@plasmohq/storage'; | ||
|
||
import { FOLLOW_X_KEY } from '~layouts/follow/config'; | ||
import type { FollowingInfoType, IUpInfo } from '~types'; | ||
|
||
import styles from './index.module.scss'; | ||
|
||
interface IUpCardProps { | ||
up: FollowingInfoType; | ||
} | ||
|
||
const UpCard: FC<IUpCardProps> = (props) => { | ||
const { up } = props; | ||
const [follow] = useStorage<IUpInfo[]>( | ||
FOLLOW_X_KEY, | ||
(v: IUpInfo[]) => v || [] | ||
); | ||
|
||
const ids = useMemo(() => follow.map((item) => item.mid), [follow]); | ||
|
||
return ( | ||
<div | ||
className={`${styles.wrapper} ${ | ||
ids.includes(up.mid) ? styles.select : '' | ||
}`} | ||
> | ||
<img className={styles.avatar} src={up.face} /> | ||
<div className={styles.contentWrapper}> | ||
<h3 className={`${styles.section} ${styles.name}`} title={up.uname}> | ||
{up.uname} | ||
</h3> | ||
<p className={`${styles.section} ${styles.sign}`} title={up.sign}> | ||
{up.sign} | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default UpCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.wrapper { | ||
width: 400px; | ||
padding: 16px; | ||
|
||
.contentWrapper { | ||
display: grid; | ||
grid-template-columns: repeat(2, 1fr); | ||
grid-gap: 8px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { FC, useEffect, useState } from 'react'; | ||
import { useLocation, useParams } from 'react-router-dom'; | ||
|
||
import Empty from '~components/empty'; | ||
import UpCard from '~components/up-card'; | ||
import { fetchUpFollowing } from '~utils'; | ||
import type { FollowingInfoType, IUpInfo } from '~types'; | ||
import UpSpaceNavigate from '~components/up-space-navigate'; | ||
import UpSpacePagination from '~components/up-space-pagination'; | ||
|
||
import styles from './index.module.scss'; | ||
|
||
const Following: FC = () => { | ||
const { state } = useLocation(); | ||
const { uid } = useParams<{ uid: string }>(); | ||
const [isPrivate, setIsPrivate] = useState(false); | ||
const [total, setTotal] = useState(0); | ||
const [page, setPage] = useState(1); | ||
const [followList, setFollowList] = useState<FollowingInfoType[]>([]); | ||
|
||
const fetchFollow = async (pn = 1) => { | ||
setPage(pn); | ||
const response = await fetchUpFollowing({ vmid: uid, pn }); | ||
if (response) { | ||
setTotal(Math.max(response.total - (pn - 1) * 50, 0)); | ||
setFollowList(response.list); | ||
} else { | ||
setIsPrivate(true); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
fetchFollow(); | ||
}, []); | ||
|
||
return ( | ||
<div className={styles.wrapper}> | ||
<UpSpaceNavigate up={(state as { up: IUpInfo }).up} /> | ||
{isPrivate ? ( | ||
<Empty content='由于该用户隐私设置,关注列表不可见' /> | ||
) : ( | ||
<> | ||
<div className={styles.contentWrapper}> | ||
{followList.map((item) => ( | ||
<UpCard key={item.mid} up={item} /> | ||
))} | ||
</div> | ||
<UpSpacePagination | ||
total={total} | ||
onNextClick={() => fetchFollow(page + 1)} | ||
onPrevClick={() => fetchFollow(page - 1)} | ||
/> | ||
</> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Following; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.