Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
4cfd000b
Unverified
Commit
4cfd000b
authored
Jan 13, 2023
by
boojack
Committed by
GitHub
Jan 13, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support audio player (#948)
parent
aacaf3f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
32 deletions
+44
-32
MemoResource.tsx
web/src/components/MemoResource.tsx
+36
-0
MemoResources.tsx
web/src/components/MemoResources.tsx
+8
-16
memo-resources.less
web/src/less/memo-resources.less
+0
-16
No files found.
web/src/components/MemoResource.tsx
0 → 100644
View file @
4cfd000b
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
;
web/src/components/MemoResources.tsx
View file @
4cfd000b
import
{
absolutifyLink
}
from
"../helpers/utils"
;
import
{
absolutifyLink
}
from
"../helpers/utils"
;
import
Icon
from
"./Icon"
;
import
SquareDiv
from
"./common/SquareDiv"
;
import
SquareDiv
from
"./common/SquareDiv"
;
import
showPreviewImageDialog
from
"./PreviewImageDialog"
;
import
showPreviewImageDialog
from
"./PreviewImageDialog"
;
import
MemoResource
from
"./MemoResource"
;
import
"../less/memo-resources.less"
;
import
"../less/memo-resources.less"
;
interface
Props
{
interface
Props
{
...
@@ -24,11 +24,6 @@ const MemoResources: React.FC<Props> = (props: Props) => {
...
@@ -24,11 +24,6 @@ const MemoResources: React.FC<Props> = (props: Props) => {
const
availableResourceList
=
resourceList
.
filter
((
resource
)
=>
resource
.
type
.
startsWith
(
"image"
)
||
resource
.
type
.
startsWith
(
"video"
));
const
availableResourceList
=
resourceList
.
filter
((
resource
)
=>
resource
.
type
.
startsWith
(
"image"
)
||
resource
.
type
.
startsWith
(
"video"
));
const
otherResourceList
=
resourceList
.
filter
((
resource
)
=>
!
availableResourceList
.
includes
(
resource
));
const
otherResourceList
=
resourceList
.
filter
((
resource
)
=>
!
availableResourceList
.
includes
(
resource
));
const
handlePreviewBtnClick
=
(
resource
:
Resource
)
=>
{
const
resourceUrl
=
`
${
window
.
location
.
origin
}
/o/r/
${
resource
.
id
}
/
${
resource
.
filename
}
`
;
window
.
open
(
resourceUrl
);
};
const
imgUrls
=
availableResourceList
const
imgUrls
=
availableResourceList
.
filter
((
resource
)
=>
resource
.
type
.
startsWith
(
"image"
))
.
filter
((
resource
)
=>
resource
.
type
.
startsWith
(
"image"
))
.
map
((
resource
)
=>
{
.
map
((
resource
)
=>
{
...
@@ -68,16 +63,13 @@ const MemoResources: React.FC<Props> = (props: Props) => {
...
@@ -68,16 +63,13 @@ const MemoResources: React.FC<Props> = (props: Props) => {
</
div
>
</
div
>
)
}
)
}
</
div
>
</
div
>
<
div
className=
"other-resource-wrapper"
>
{
otherResourceList
.
length
>
0
&&
(
{
otherResourceList
.
map
((
resource
)
=>
{
<
div
className=
"w-full flex flex-row justify-start flex-wrap mt-2"
>
return
(
{
otherResourceList
.
map
((
resource
)
=>
{
<
div
className=
"other-resource-container"
key=
{
resource
.
id
}
onClick=
{
()
=>
handlePreviewBtnClick
(
resource
)
}
>
return
<
MemoResource
key=
{
resource
.
id
}
className=
"my-1 mr-2"
resource=
{
resource
}
/>;
<
Icon
.
FileText
className=
"icon-img"
/>
})
}
<
span
className=
"name-text"
>
{
resource
.
filename
}
</
span
>
</
div
>
</
div
>
)
}
);
})
}
</
div
>
</>
</>
);
);
};
};
...
...
web/src/less/memo-resources.less
View file @
4cfd000b
...
@@ -17,19 +17,3 @@
...
@@ -17,19 +17,3 @@
}
}
}
}
}
}
.other-resource-wrapper {
@apply w-full flex flex-row justify-start flex-wrap;
> .other-resource-container {
@apply mt-1 mr-1 max-w-full flex flex-row justify-start items-center flex-nowrap bg-gray-100 px-2 py-1 rounded cursor-pointer hover:bg-gray-200;
> .icon-img {
@apply w-4 h-auto mr-1 text-gray-500;
}
> .name-text {
@apply text-gray-500 text-sm max-w-xs truncate font-mono;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment