-
Notifications
You must be signed in to change notification settings - Fork 119
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
Showing
10 changed files
with
139 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react' | ||
import { useHistory, useRouteMatch } from 'react-router-dom' | ||
import cn from 'classnames' | ||
|
||
import { LogStateContext } from 'reducers/log' | ||
import { ISonglist } from 'apis/types/business' | ||
import ROUTES from 'constants/routes' | ||
import styles from './style.module.css' | ||
|
||
interface IProps { | ||
title: string, | ||
data?: ISonglist[] | ||
} | ||
|
||
const { useContext } = React | ||
|
||
const Songlist: React.FC<IProps> = ({ title, data }) => { | ||
const history = useHistory() | ||
const routeMatch = useRouteMatch<{ songlistId: string }>(ROUTES.SONG_LIST_DETAIL) | ||
const logState = useContext(LogStateContext) | ||
|
||
const handleClick = (id: number) => history.push(`${ROUTES.SONG_LISTS}/${id}`) | ||
|
||
return ( | ||
<div className={styles.root}> | ||
<div className={styles.title}>{title}</div> | ||
<div className={styles.content}> | ||
{data?.map(({ id, name }) => { | ||
const isActive = routeMatch && Number(routeMatch.params.songlistId) === id | ||
return ( | ||
<div | ||
key={id} | ||
className={cn(styles.item, isActive && 'active')} | ||
title={name} | ||
onClick={() => handleClick(id)} | ||
> | ||
{name.replace(logState.user.profile.nickname, '我')} | ||
</div> | ||
) | ||
})} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Songlist |
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 @@ | ||
.title { | ||
padding: 0 20px; | ||
margin-bottom: 5px; | ||
font-size: 0.8em; | ||
color: grey; | ||
} | ||
|
||
.content { | ||
.item { | ||
padding: 8px 20px; | ||
overflow: hidden; | ||
text-overflow:ellipsis; | ||
white-space: nowrap; | ||
cursor: default; | ||
font-size: 0.9em; | ||
|
||
&:hover { | ||
background-color: #e3e3e3; | ||
} | ||
} | ||
} |
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
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