forked from usememos/memos
-
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.
feat: support audio player (usememos#948)
- Loading branch information
Showing
3 changed files
with
44 additions
and
32 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,36 @@ | ||
import Icon from "./Icon"; | ||
|
||
interface Props { | ||
resource: Resource; | ||
className?: string; | ||
} | ||
|
||
const MemoResource: React.FC<Props> = (props: Props) => { | ||
const { className, resource } = props; | ||
const resourceUrl = `${window.location.origin}/o/r/${resource.id}/${resource.filename}`; | ||
|
||
const handlePreviewBtnClick = () => { | ||
window.open(resourceUrl); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className={`w-auto flex flex-row justify-start items-center ${className}`}> | ||
{resource.type.startsWith("audio") ? ( | ||
<> | ||
<audio className="h-8" src={resourceUrl} controls></audio> | ||
</> | ||
) : ( | ||
<> | ||
<Icon.FileText className="w-4 h-auto mr-1 text-gray-500" /> | ||
<span className="text-gray-500 text-sm max-w-xs truncate font-mono cursor-pointer" onClick={handlePreviewBtnClick}> | ||
{resource.filename} | ||
</span> | ||
</> | ||
)} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default MemoResource; |
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