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
32cafbff
Commit
32cafbff
authored
Nov 06, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add OverflowTip kit component
parent
9c4f72c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
11 deletions
+45
-11
CreateTagDialog.tsx
web/src/components/CreateTagDialog.tsx
+13
-10
TagList.tsx
web/src/components/TagList.tsx
+1
-1
OverflowTip.tsx
web/src/components/kit/OverflowTip.tsx
+31
-0
No files found.
web/src/components/CreateTagDialog.tsx
View file @
32cafbff
...
@@ -8,6 +8,7 @@ import { useTagStore } from "@/store/module";
...
@@ -8,6 +8,7 @@ import { useTagStore } from "@/store/module";
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
generateDialog
}
from
"./Dialog"
;
import
{
generateDialog
}
from
"./Dialog"
;
import
Icon
from
"./Icon"
;
import
Icon
from
"./Icon"
;
import
OverflowTip
from
"./kit/OverflowTip"
;
type
Props
=
DialogProps
;
type
Props
=
DialogProps
;
...
@@ -108,13 +109,14 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
...
@@ -108,13 +109,14 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
{
Array
.
from
(
tagNameList
)
{
Array
.
from
(
tagNameList
)
.
sort
()
.
sort
()
.
map
((
tag
)
=>
(
.
map
((
tag
)
=>
(
<
span
<
OverflowTip
className=
"max-w-[120px] text-sm mr-2 mt-1 font-mono cursor-pointer truncate dark:text-gray-300 hover:opacity-60 hover:line-through"
key=
{
tag
}
key=
{
tag
}
onClick=
{
()
=>
handleDeleteTag
(
tag
)
}
className=
"max-w-[120px] text-sm mr-2 mt-1 font-mono cursor-pointer dark:text-gray-300 hover:opacity-60 hover:line-through"
>
>
#
{
tag
}
<
span
className=
"w-full"
onClick=
{
()
=>
handleDeleteTag
(
tag
)
}
>
</
span
>
#
{
tag
}
</
span
>
</
OverflowTip
>
))
}
))
}
</
div
>
</
div
>
</>
</>
...
@@ -135,13 +137,14 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
...
@@ -135,13 +137,14 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
<>
<>
<
div
className=
"w-full flex flex-row justify-start items-start flex-wrap mb-2"
>
<
div
className=
"w-full flex flex-row justify-start items-start flex-wrap mb-2"
>
{
shownSuggestTagNameList
.
map
((
tag
)
=>
(
{
shownSuggestTagNameList
.
map
((
tag
)
=>
(
<
span
<
OverflowTip
className=
"max-w-[120px] text-sm mr-2 mt-1 font-mono cursor-pointer truncate dark:text-gray-300 hover:opacity-60"
key=
{
tag
}
key=
{
tag
}
onClick=
{
()
=>
handleUpsertTag
(
tag
)
}
className=
"max-w-[120px] text-sm mr-2 mt-1 font-mono cursor-pointer dark:text-gray-300 hover:opacity-60"
>
>
#
{
tag
}
<
span
className=
"w-full"
onClick=
{
()
=>
handleUpsertTag
(
tag
)
}
>
</
span
>
#
{
tag
}
</
span
>
</
OverflowTip
>
))
}
))
}
</
div
>
</
div
>
<
Button
size=
"sm"
variant=
"outlined"
onClick=
{
handleSaveSuggestTagList
}
>
<
Button
size=
"sm"
variant=
"outlined"
onClick=
{
handleSaveSuggestTagList
}
>
...
...
web/src/components/TagList.tsx
View file @
32cafbff
...
@@ -139,7 +139,7 @@ const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContain
...
@@ -139,7 +139,7 @@ const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContain
</
div
>
</
div
>
{
hasSubTags
?
(
{
hasSubTags
?
(
<
div
<
div
className=
{
`w-
full flex flex-col justify-start items-start h-auto ml-5
pl-1 border-l-2 border-l-gray-200 dark:border-l-gray-400 ${
className=
{
`w-
[calc(100%-1rem)] flex flex-col justify-start items-start h-auto ml-4
pl-1 border-l-2 border-l-gray-200 dark:border-l-gray-400 ${
!showSubTags && "!hidden"
!showSubTags && "!hidden"
}`
}
}`
}
>
>
...
...
web/src/components/kit/OverflowTip.tsx
0 → 100644
View file @
32cafbff
import
{
Tooltip
}
from
"@mui/joy"
;
import
classNames
from
"classnames"
;
import
{
useRef
,
useState
,
useEffect
}
from
"react"
;
interface
Props
{
children
:
React
.
ReactNode
;
className
?:
string
;
}
const
OverflowTip
=
({
children
,
className
}:
Props
)
=>
{
const
[
isOverflowed
,
setIsOverflow
]
=
useState
(
false
);
const
textElementRef
=
useRef
<
HTMLDivElement
>
(
null
);
useEffect
(()
=>
{
if
(
!
textElementRef
.
current
)
{
return
;
}
setIsOverflow
(
textElementRef
.
current
.
scrollWidth
>
textElementRef
.
current
.
clientWidth
);
},
[]);
return
(
<
Tooltip
title=
{
children
}
placement=
"top"
arrow
disableHoverListener=
{
!
isOverflowed
}
>
<
div
ref=
{
textElementRef
}
className=
{
classNames
(
"truncate"
,
className
)
}
>
{
children
}
</
div
>
</
Tooltip
>
);
};
export
default
OverflowTip
;
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