Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
vicotor
frontend
Commits
a5e29dcf
Commit
a5e29dcf
authored
Mar 17, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search panel styles
parent
2d28a0e6
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
95 additions
and
33 deletions
+95
-33
CodeEditorFileExplorer.tsx
ui/shared/monaco/CodeEditorFileExplorer.tsx
+1
-1
CodeEditorFileTree.tsx
ui/shared/monaco/CodeEditorFileTree.tsx
+1
-1
CodeEditorSearch.tsx
ui/shared/monaco/CodeEditorSearch.tsx
+31
-4
CodeEditorSearchResultItem.tsx
ui/shared/monaco/CodeEditorSearchResultItem.tsx
+9
-2
CodeEditorSearchSection.tsx
ui/shared/monaco/CodeEditorSearchSection.tsx
+38
-17
CodeEditorSideBar.tsx
ui/shared/monaco/CodeEditorSideBar.tsx
+5
-5
CoderEditorCollapseButton.tsx
ui/shared/monaco/CoderEditorCollapseButton.tsx
+10
-3
No files found.
ui/shared/monaco/CodeEditorFileExplorer.tsx
View file @
a5e29dcf
...
@@ -32,7 +32,7 @@ const CodeEditorFileExplorer = ({ data, onFileSelect }: Props) => {
...
@@ -32,7 +32,7 @@ const CodeEditorFileExplorer = ({ data, onFileSelect }: Props) => {
},
[]);
},
[]);
return
(
return
(
<
Box
pb=
"22px"
>
<
Box
>
<
CoderEditorCollapseButton
onClick=
{
handleCollapseButtonClick
}
label=
"Collapse folders"
/>
<
CoderEditorCollapseButton
onClick=
{
handleCollapseButtonClick
}
label=
"Collapse folders"
/>
<
CodeEditorFileTree
key=
{
key
}
tree=
{
tree
}
onItemClick=
{
handleFileClick
}
isCollapsed=
{
key
>
0
}
/>
<
CodeEditorFileTree
key=
{
key
}
tree=
{
tree
}
onItemClick=
{
handleFileClick
}
isCollapsed=
{
key
>
0
}
/>
</
Box
>
</
Box
>
...
...
ui/shared/monaco/CodeEditorFileTree.tsx
View file @
a5e29dcf
...
@@ -48,7 +48,7 @@ const CodeEditorFileTree = ({ tree, level = 0, onItemClick, isCollapsed }: Props
...
@@ -48,7 +48,7 @@ const CodeEditorFileTree = ({ tree, level = 0, onItemClick, isCollapsed }: Props
h=
"22px"
h=
"22px"
transitionDuration=
"0"
transitionDuration=
"0"
>
>
<
AccordionIcon
transform=
{
isExpanded
?
'
rotate(0deg)
'
:
'
rotate(-90deg)
'
}
boxSize=
"16px"
/>
<
AccordionIcon
transform=
{
isExpanded
?
'
rotate(0deg)
'
:
'
rotate(-90deg)
'
}
boxSize=
"16px"
color=
"#616161"
/>
<
Icon
as=
{
isExpanded
?
iconFolderOpen
:
iconFolder
}
boxSize=
"16px"
mr=
"4px"
/>
<
Icon
as=
{
isExpanded
?
iconFolderOpen
:
iconFolder
}
boxSize=
"16px"
mr=
"4px"
/>
{
leafName
}
{
leafName
}
</
AccordionButton
>
</
AccordionButton
>
...
...
ui/shared/monaco/CodeEditorSearch.tsx
View file @
a5e29dcf
import
{
Accordion
,
Box
,
Input
}
from
'
@chakra-ui/react
'
;
import
{
Accordion
,
Box
,
Input
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
File
,
Monaco
,
SearchResult
}
from
'
./types
'
;
import
type
{
File
,
Monaco
,
SearchResult
}
from
'
./types
'
;
...
@@ -12,9 +12,10 @@ interface Props {
...
@@ -12,9 +12,10 @@ interface Props {
data
:
Array
<
File
>
;
data
:
Array
<
File
>
;
monaco
:
Monaco
|
undefined
;
monaco
:
Monaco
|
undefined
;
onFileSelect
:
(
index
:
number
,
lineNumber
?:
number
)
=>
void
;
onFileSelect
:
(
index
:
number
,
lineNumber
?:
number
)
=>
void
;
isInputStuck
:
boolean
;
}
}
const
CodeEditorSearch
=
({
monaco
,
data
,
onFileSelect
}:
Props
)
=>
{
const
CodeEditorSearch
=
({
monaco
,
data
,
onFileSelect
,
isInputStuck
}:
Props
)
=>
{
const
[
searchTerm
,
changeSearchTerm
]
=
React
.
useState
(
''
);
const
[
searchTerm
,
changeSearchTerm
]
=
React
.
useState
(
''
);
const
[
searchResults
,
setSearchResults
]
=
React
.
useState
<
Array
<
SearchResult
>>
([]);
const
[
searchResults
,
setSearchResults
]
=
React
.
useState
<
Array
<
SearchResult
>>
([]);
const
[
expandedSections
,
setExpandedSections
]
=
React
.
useState
<
Array
<
number
>>
([]);
const
[
expandedSections
,
setExpandedSections
]
=
React
.
useState
<
Array
<
number
>>
([]);
...
@@ -70,15 +71,41 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect }: Props) => {
...
@@ -70,15 +71,41 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect }: Props) => {
}
}
},
[
expandedSections
.
length
,
searchResults
]);
},
[
expandedSections
.
length
,
searchResults
]);
const
inputColor
=
useColorModeValue
(
'
rgb(97, 97, 97)
'
,
'
rgb(204, 204, 204)
'
);
const
inputBgColor
=
useColorModeValue
(
'
white
'
,
'
rgb(60, 60, 60)
'
);
const
inputFocusBorderColor
=
useColorModeValue
(
'
#0090f1
'
,
'
#007fd4
'
);
const
bgColor
=
useColorModeValue
(
'
#eee
'
,
'
#222
'
);
return
(
return
(
<
Box
px=
{
2
}
>
<
Box
>
<
CoderEditorCollapseButton
<
CoderEditorCollapseButton
onClick=
{
handleToggleCollapseClick
}
onClick=
{
handleToggleCollapseClick
}
label=
{
expandedSections
.
length
===
0
?
'
Expand all
'
:
'
Collapse all
'
}
label=
{
expandedSections
.
length
===
0
?
'
Expand all
'
:
'
Collapse all
'
}
isDisabled=
{
searchResults
.
length
===
0
}
isDisabled=
{
searchResults
.
length
===
0
}
isCollapsed=
{
expandedSections
.
length
===
0
}
isCollapsed=
{
expandedSections
.
length
===
0
}
/>
/>
<
Input
size=
"xs"
onChange=
{
handleSearchTermChange
}
value=
{
searchTerm
}
placeholder=
"Search"
/>
<
Box
px=
{
2
}
position=
"sticky"
top=
"35px"
left=
"0"
zIndex=
"2"
bgColor=
{
bgColor
}
pb=
"8px"
boxShadow=
{
isInputStuck
?
'
md
'
:
'
none
'
}
>
<
Input
size=
"xs"
onChange=
{
handleSearchTermChange
}
value=
{
searchTerm
}
placeholder=
"Search"
variant=
"unstyled"
color=
{
inputColor
}
bgColor=
{
inputBgColor
}
borderRadius=
"none"
fontSize=
"13px"
lineHeight=
"19px"
borderWidth=
"1px"
borderColor=
{
inputBgColor
}
py=
"2px"
px=
"4px"
transitionDuration=
"0"
_focus=
{
{
borderColor
:
inputFocusBorderColor
,
}
}
/>
</
Box
>
<
Accordion
<
Accordion
key=
{
debouncedSearchTerm
}
key=
{
debouncedSearchTerm
}
allowMultiple
allowMultiple
...
...
ui/shared/monaco/CodeEditorSearchResultItem.tsx
View file @
a5e29dcf
import
{
Box
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
chakra
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
SearchResult
}
from
'
./types
'
;
import
type
{
SearchResult
}
from
'
./types
'
;
...
@@ -27,9 +27,14 @@ const calculateStartPosition = (lineContent: string, startColumn: number) => {
...
@@ -27,9 +27,14 @@ const calculateStartPosition = (lineContent: string, startColumn: number) => {
const
CodeEditorSearchResultItem
=
({
lineContent
,
filePath
,
onClick
,
startLineNumber
,
startColumn
,
endColumn
}:
Props
)
=>
{
const
CodeEditorSearchResultItem
=
({
lineContent
,
filePath
,
onClick
,
startLineNumber
,
startColumn
,
endColumn
}:
Props
)
=>
{
const
start
=
calculateStartPosition
(
lineContent
,
startColumn
);
const
start
=
calculateStartPosition
(
lineContent
,
startColumn
);
const
rowHoverBgColor
=
useColorModeValue
(
'
blackAlpha.200
'
,
'
whiteAlpha.200
'
);
return
(
return
(
<
Box
<
Box
pr=
"8px"
pl=
"32px"
fontSize=
"13px"
lineHeight=
"22px"
whiteSpace=
"nowrap"
whiteSpace=
"nowrap"
overflow=
"hidden"
overflow=
"hidden"
textOverflow=
"ellipsis"
textOverflow=
"ellipsis"
...
@@ -37,9 +42,11 @@ const CodeEditorSearchResultItem = ({ lineContent, filePath, onClick, startLineN
...
@@ -37,9 +42,11 @@ const CodeEditorSearchResultItem = ({ lineContent, filePath, onClick, startLineN
data
-
file
-
path=
{
filePath
}
data
-
file
-
path=
{
filePath
}
data
-
line
-
number=
{
startLineNumber
}
data
-
line
-
number=
{
startLineNumber
}
onClick=
{
onClick
}
onClick=
{
onClick
}
transitionDuration=
"0"
_hover=
{
{
bgColor
:
rowHoverBgColor
}
}
>
>
<
span
>
{
lineContent
.
slice
(
start
,
startColumn
-
1
)
}
</
span
>
<
span
>
{
lineContent
.
slice
(
start
,
startColumn
-
1
)
}
</
span
>
<
chakra
.
span
bgColor=
"
lime
"
>
{
lineContent
.
slice
(
startColumn
-
1
,
endColumn
-
1
)
}
</
chakra
.
span
>
<
chakra
.
span
bgColor=
"
rgba(234, 92, 0, 0.33)
"
>
{
lineContent
.
slice
(
startColumn
-
1
,
endColumn
-
1
)
}
</
chakra
.
span
>
<
span
>
{
lineContent
.
slice
(
endColumn
-
1
)
}
</
span
>
<
span
>
{
lineContent
.
slice
(
endColumn
-
1
)
}
</
span
>
</
Box
>
</
Box
>
);
);
...
...
ui/shared/monaco/CodeEditorSearchSection.tsx
View file @
a5e29dcf
import
{
AccordionButton
,
AccordionItem
,
AccordionIcon
,
AccordionPanel
}
from
'
@chakra-ui/react
'
;
import
{
AccordionButton
,
AccordionItem
,
AccordionIcon
,
AccordionPanel
,
useColorModeValue
,
Icon
,
Box
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
SearchResult
}
from
'
./types
'
;
import
type
{
SearchResult
}
from
'
./types
'
;
import
CodeEditorSearchResultItem
from
'
./CodeEditorSearchResultItem
'
;
import
CodeEditorSearchResultItem
from
'
./CodeEditorSearchResultItem
'
;
import
iconFile
from
'
./icons/file.svg
'
;
import
iconSolidity
from
'
./icons/solidity.svg
'
;
import
getFileName
from
'
./utils/getFileName
'
;
import
getFileName
from
'
./utils/getFileName
'
;
interface
Props
{
interface
Props
{
...
@@ -21,11 +23,28 @@ const CodeEditorSearchSection = ({ data, onItemClick }: Props) => {
...
@@ -21,11 +23,28 @@ const CodeEditorSearchSection = ({ data, onItemClick }: Props) => {
}
}
},
[
data
.
file_path
,
onItemClick
]);
},
[
data
.
file_path
,
onItemClick
]);
const
rowHoverBgColor
=
useColorModeValue
(
'
blackAlpha.200
'
,
'
whiteAlpha.200
'
);
const
icon
=
/.sol|.yul|.vy$/
.
test
(
fileName
)
?
iconSolidity
:
iconFile
;
const
badgeBgColor
=
useColorModeValue
(
'
#c4c4c4
'
,
'
#4d4d4d
'
);
return
(
return
(
<
AccordionItem
borderWidth=
"0px"
_last=
{
{
borderBottomWidth
:
'
0px
'
}
}
>
<
AccordionItem
borderWidth=
"0px"
_last=
{
{
borderBottomWidth
:
'
0px
'
}
}
>
<
AccordionButton
p=
{
0
}
_hover=
{
{
bgColor
:
'
inherit
'
}
}
fontSize=
"sm"
>
{
({
isExpanded
})
=>
(
<
AccordionIcon
/>
<>
<
AccordionButton
py=
{
0
}
px=
{
2
}
_hover=
{
{
bgColor
:
rowHoverBgColor
}
}
fontSize=
"13px"
transitionDuration=
"0"
lineHeight=
"22px"
alignItems=
"center"
>
<
AccordionIcon
transform=
{
isExpanded
?
'
rotate(0deg)
'
:
'
rotate(-90deg)
'
}
boxSize=
"16px"
color=
"#616161"
/>
<
Icon
as=
{
icon
}
boxSize=
"16px"
mr=
"4px"
/>
<
span
>
{
fileName
}
</
span
>
<
span
>
{
fileName
}
</
span
>
<
Box
className=
"monaco-count-badge"
ml=
"auto"
bgColor=
{
badgeBgColor
}
>
{
data
.
matches
.
length
}
</
Box
>
</
AccordionButton
>
</
AccordionButton
>
<
AccordionPanel
p=
{
0
}
>
<
AccordionPanel
p=
{
0
}
>
{
data
.
matches
.
map
((
match
)
=>
(
{
data
.
matches
.
map
((
match
)
=>
(
...
@@ -38,6 +57,8 @@ const CodeEditorSearchSection = ({ data, onItemClick }: Props) => {
...
@@ -38,6 +57,8 @@ const CodeEditorSearchSection = ({ data, onItemClick }: Props) => {
),
),
)
}
)
}
</
AccordionPanel
>
</
AccordionPanel
>
</>
)
}
</
AccordionItem
>
</
AccordionItem
>
);
);
};
};
...
...
ui/shared/monaco/CodeEditorSideBar.tsx
View file @
a5e29dcf
...
@@ -24,9 +24,9 @@ const CodeEditorSideBar = ({ onFileSelect, data, monaco }: Props) => {
...
@@ -24,9 +24,9 @@ const CodeEditorSideBar = ({ onFileSelect, data, monaco }: Props) => {
fontSize
:
'
11px
'
,
fontSize
:
'
11px
'
,
lineHeight
:
'
35px
'
,
lineHeight
:
'
35px
'
,
fontWeight
:
500
,
fontWeight
:
500
,
color
:
'
gray.600
'
,
color
:
useColorModeValue
(
'
gray.600
'
,
'
gray.500
'
)
,
_selected
:
{
_selected
:
{
color
:
'
black
'
,
color
:
useColorModeValue
(
'
black
'
,
'
white
'
)
,
},
},
px
:
0
,
px
:
0
,
letterSpacing
:
0.3
,
letterSpacing
:
0.3
,
...
@@ -39,7 +39,7 @@ const CodeEditorSideBar = ({ onFileSelect, data, monaco }: Props) => {
...
@@ -39,7 +39,7 @@ const CodeEditorSideBar = ({ onFileSelect, data, monaco }: Props) => {
},
100
));
},
100
));
return
(
return
(
<
Box
w=
"250px"
flexShrink=
{
0
}
bgColor=
{
bgColor
}
fontSize=
"13px"
overflowY=
"scroll"
onScroll=
{
handleScrollThrottled
.
current
}
>
<
Box
w=
"250px"
flexShrink=
{
0
}
bgColor=
{
bgColor
}
fontSize=
"13px"
overflowY=
"scroll"
onScroll=
{
handleScrollThrottled
.
current
}
pb=
"22px"
>
<
Tabs
isLazy
lazyBehavior=
"keepMounted"
variant=
"unstyled"
size=
"13px"
>
<
Tabs
isLazy
lazyBehavior=
"keepMounted"
variant=
"unstyled"
size=
"13px"
>
<
TabList
<
TabList
columnGap=
{
3
}
columnGap=
{
3
}
...
@@ -50,7 +50,7 @@ const CodeEditorSideBar = ({ onFileSelect, data, monaco }: Props) => {
...
@@ -50,7 +50,7 @@ const CodeEditorSideBar = ({ onFileSelect, data, monaco }: Props) => {
zIndex=
"1"
zIndex=
"1"
px=
{
2
}
px=
{
2
}
boxShadow=
{
isStuck
?
'
md
'
:
'
none
'
}
boxShadow=
{
isStuck
?
'
md
'
:
'
none
'
}
borderTopRadius=
"md"
borderTopR
ightR
adius=
"md"
>
>
<
Tab
{
...
tabProps
}
>
Explorer
</
Tab
>
<
Tab
{
...
tabProps
}
>
Explorer
</
Tab
>
<
Tab
{
...
tabProps
}
>
Search
</
Tab
>
<
Tab
{
...
tabProps
}
>
Search
</
Tab
>
...
@@ -61,7 +61,7 @@ const CodeEditorSideBar = ({ onFileSelect, data, monaco }: Props) => {
...
@@ -61,7 +61,7 @@ const CodeEditorSideBar = ({ onFileSelect, data, monaco }: Props) => {
<
CodeEditorFileExplorer
data=
{
data
}
onFileSelect=
{
onFileSelect
}
/>
<
CodeEditorFileExplorer
data=
{
data
}
onFileSelect=
{
onFileSelect
}
/>
</
TabPanel
>
</
TabPanel
>
<
TabPanel
p=
{
0
}
>
<
TabPanel
p=
{
0
}
>
<
CodeEditorSearch
data=
{
data
}
onFileSelect=
{
onFileSelect
}
monaco=
{
monaco
}
/>
<
CodeEditorSearch
data=
{
data
}
onFileSelect=
{
onFileSelect
}
monaco=
{
monaco
}
isInputStuck=
{
isStuck
}
/>
</
TabPanel
>
</
TabPanel
>
</
TabPanels
>
</
TabPanels
>
</
Tabs
>
</
Tabs
>
...
...
ui/shared/monaco/CoderEditorCollapseButton.tsx
View file @
a5e29dcf
import
{
Tooltip
,
Box
}
from
'
@chakra-ui/react
'
;
import
{
Tooltip
,
Box
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
interface
Props
{
interface
Props
{
...
@@ -9,18 +9,25 @@ interface Props {
...
@@ -9,18 +9,25 @@ interface Props {
}
}
const
CoderEditorCollapseButton
=
({
onClick
,
label
,
isDisabled
,
isCollapsed
}:
Props
)
=>
{
const
CoderEditorCollapseButton
=
({
onClick
,
label
,
isDisabled
,
isCollapsed
}:
Props
)
=>
{
const
hoverBgColor
=
useColorModeValue
(
'
rgba(184, 184, 184, 0.31)
'
,
'
rgba(90, 93, 94, 0.31)
'
);
return
(
return
(
<
Tooltip
label=
{
label
}
isDisabled=
{
isDisabled
}
>
<
Tooltip
label=
{
label
}
isDisabled=
{
isDisabled
}
>
<
Box
<
Box
position=
"absolute"
position=
"absolute"
right=
{
3
}
right=
"12px"
top=
{
2
}
top=
"8px"
zIndex=
"sticky1"
zIndex=
"sticky1"
className=
{
isCollapsed
?
'
codicon codicon-search-expand-results
'
:
'
codicon codicon-collapse-all
'
}
className=
{
isCollapsed
?
'
codicon codicon-search-expand-results
'
:
'
codicon codicon-collapse-all
'
}
opacity=
{
isDisabled
?
0.6
:
1
}
opacity=
{
isDisabled
?
0.6
:
1
}
boxSize=
"20px"
p=
"2px"
borderRadius=
"sm"
_before=
{
{
_before=
{
{
content
:
isCollapsed
?
'
"
\\
eb95"
'
:
'
"
\\
eac5"
'
,
content
:
isCollapsed
?
'
"
\\
eb95"
'
:
'
"
\\
eac5"
'
,
}
}
}
}
_hover=
{
{
bgColor
:
hoverBgColor
,
}
}
onClick=
{
onClick
}
onClick=
{
onClick
}
cursor=
"pointer"
cursor=
"pointer"
/>
/>
...
...
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