-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #450 from kgarner7/more-metadata
[feature]: Show album comment, Last.fm/MusicBrainz links
- Loading branch information
Showing
18 changed files
with
335 additions
and
72 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import clsx from 'clsx'; | ||
import { HTMLAttributes, ReactNode, useRef, useState } from 'react'; | ||
import styles from './spoiler.module.scss'; | ||
import { useIsOverflow } from '/@/renderer/hooks'; | ||
|
||
interface SpoilerProps extends HTMLAttributes<HTMLDivElement> { | ||
children?: ReactNode; | ||
defaultOpened?: boolean; | ||
maxHeight?: number; | ||
} | ||
|
||
export const Spoiler = ({ maxHeight, defaultOpened, children, ...props }: SpoilerProps) => { | ||
const ref = useRef(null); | ||
const isOverflow = useIsOverflow(ref); | ||
const [isExpanded, setIsExpanded] = useState(!!defaultOpened); | ||
|
||
const spoilerClassNames = clsx(styles.spoiler, { | ||
[styles.canExpand]: isOverflow, | ||
[styles.isExpanded]: isExpanded, | ||
}); | ||
|
||
const handleToggleExpand = () => { | ||
setIsExpanded((val) => !val); | ||
}; | ||
|
||
return ( | ||
<div | ||
ref={ref} | ||
className={spoilerClassNames} | ||
role="button" | ||
style={{ maxHeight: maxHeight ?? '100px' }} | ||
tabIndex={-1} | ||
onClick={handleToggleExpand} | ||
{...props} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; |
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,31 @@ | ||
.control:hover { | ||
color: var(--btn-subtle-fg-hover); | ||
text-decoration: none; | ||
} | ||
|
||
.spoiler { | ||
position: relative; | ||
text-align: justify; | ||
width: 100%; | ||
height: 100%; | ||
overflow: hidden; | ||
} | ||
|
||
.spoiler:not(.is-expanded).can-expand:after { | ||
position: absolute; | ||
left: 0; | ||
bottom: 0; | ||
width: 100%; | ||
height: 100%; | ||
content: ''; | ||
background: linear-gradient(to top, var(--main-bg) 10%, transparent 60%); | ||
pointer-events: none; | ||
} | ||
|
||
.spoiler.can-expand { | ||
cursor: pointer; | ||
} | ||
|
||
.spoiler.is-expanded { | ||
max-height: 2500px !important; | ||
} |
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.