Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
indiscale-files-ui-react
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
indiscale-files-ui-react
Commits
501ef8dc
Unverified
Commit
501ef8dc
authored
2 years ago
by
JinSSJ3
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #4 from files-ui/14-ref-props-table-order-alpha
[REF]: 14 ref props table order alpha
parents
60e3576c
f8938a39
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pages/api/PropsTableApi.jsx
+85
-34
85 additions, 34 deletions
src/pages/api/PropsTableApi.jsx
with
85 additions
and
34 deletions
src/pages/api/PropsTableApi.jsx
+
85
−
34
View file @
501ef8dc
...
@@ -7,6 +7,10 @@ import TableContainer from "@mui/material/TableContainer";
...
@@ -7,6 +7,10 @@ import TableContainer from "@mui/material/TableContainer";
import
TableHead
from
"
@mui/material/TableHead
"
;
import
TableHead
from
"
@mui/material/TableHead
"
;
import
TableRow
from
"
@mui/material/TableRow
"
;
import
TableRow
from
"
@mui/material/TableRow
"
;
import
Paper
from
"
@mui/material/Paper
"
;
import
Paper
from
"
@mui/material/Paper
"
;
import
SortByAlphaIcon
from
"
@mui/icons-material/SortByAlpha
"
;
import
LowPriorityIcon
from
"
@mui/icons-material/LowPriority
"
;
import
SubTitle
from
"
../../components/demo-components/sub-title/SubTitle
"
;
import
{
Tooltip
,
IconButton
,
Stack
}
from
"
@mui/material
"
;
const
StyledTableCell
=
styled
(
TableCell
)(({
theme
})
=>
({
const
StyledTableCell
=
styled
(
TableCell
)(({
theme
})
=>
({
[
`&.
${
tableCellClasses
.
head
}
`
]:
{
[
`&.
${
tableCellClasses
.
head
}
`
]:
{
...
@@ -27,44 +31,91 @@ const StyledTableRow = styled(TableRow)(({ theme }) => ({
...
@@ -27,44 +31,91 @@ const StyledTableRow = styled(TableRow)(({ theme }) => ({
border
:
0
,
border
:
0
,
},
},
}));
}));
function
compareNames
(
a
,
b
)
{
if
(
a
?.
name
<
b
?.
name
)
{
return
-
1
;
}
else
{
return
1
;
}
}
export
default
function
PropsTableApi
({
rows
=
[]
})
{
export
default
function
PropsTableApi
({
rows
=
[]
})
{
const
[
sorted
,
setSorted
]
=
React
.
useState
(
false
);
const
[
localRows
,
setLocalRows
]
=
React
.
useState
(
rows
);
const
handleSort
=
()
=>
{
setSorted
((
_sorted
)
=>
{
const
resultSorted
=
!
_sorted
;
const
rowsToSort
=
[...
rows
];
if
(
resultSorted
)
{
setLocalRows
(
rowsToSort
.
sort
(
compareNames
));
}
else
{
setLocalRows
(
rowsToSort
);
}
return
resultSorted
;
});
};
return
(
return
(
<
TableContainer
component
=
{
Paper
}
>
<
React
.
Fragment
>
<
Table
sx
=
{
{
minWidth
:
700
}
}
aria-label
=
"customized table"
>
<
Stack
<
TableHead
>
direction
=
{
"
row
"
}
<
TableRow
>
justifyContent
=
"flex-start"
<
StyledTableCell
/* width={"30%"} */
>
Name
</
StyledTableCell
>
alignItems
=
{
"
center
"
}
<
StyledTableCell
align
=
"left"
/* width={"30%"} */
>
spacing
=
{
2
}
Type
>
</
StyledTableCell
>
<
SubTitle
content
=
"Props"
/>
{
"
"
}
<
StyledTableCell
align
=
"left"
>
Default
</
StyledTableCell
>
<
Tooltip
title
=
{
sorted
?
"
Sort by importance
"
:
"
Sort alphabetically
"
}
>
<
StyledTableCell
align
=
"left"
/* width={"30%"} */
>
<
IconButton
Description
style
=
{
{
borderRadius
:
"
50%
"
,
border
:
"
0.5px solid #eaeef3
"
}
}
</
StyledTableCell
>
onClick
=
{
handleSort
}
</
TableRow
>
aria-label
=
"upload picture"
</
TableHead
>
component
=
"label"
<
TableBody
>
>
{
rows
.
map
((
row
)
=>
(
{
sorted
?
<
SortByAlphaIcon
/>
:
<
LowPriorityIcon
/>
}
<
StyledTableRow
key
=
{
row
.
name
}
>
</
IconButton
>
<
StyledTableCell
</
Tooltip
>
{
"
"
}
component
=
"th"
</
Stack
>
scope
=
"row"
<
TableContainer
component
=
{
Paper
}
>
style
=
{
{
<
Table
sx
=
{
{
minWidth
:
700
}
}
aria-label
=
"customized table"
>
wordBreak
:
row
.
name
.
length
>
12
?
"
break-word
"
:
"
normal
"
,
<
TableHead
>
}
}
<
TableRow
>
>
<
StyledTableCell
/* width={"30%"} */
>
Name
</
StyledTableCell
>
{
row
.
name
}
<
StyledTableCell
align
=
"left"
/* width={"30%"} */
>
Type
</
StyledTableCell
>
</
StyledTableCell
>
<
StyledTableCell
align
=
"left"
style
=
{
{
wordBreak
:
"
break-word
"
}
}
>
<
StyledTableCell
align
=
"left"
>
Default
</
StyledTableCell
>
{
row
.
type
}
<
StyledTableCell
align
=
"left"
/* width={"30%"} */
>
Description
</
StyledTableCell
>
</
StyledTableCell
>
<
StyledTableCell
align
=
"left"
>
{
row
.
default
}
</
StyledTableCell
>
</
TableRow
>
<
StyledTableCell
align
=
"left"
>
{
row
.
description
}
</
StyledTableCell
>
</
TableHead
>
</
StyledTableRow
>
<
TableBody
>
))
}
{
localRows
.
map
((
row
)
=>
(
</
TableBody
>
<
StyledTableRow
key
=
{
row
.
name
}
>
</
Table
>
<
StyledTableCell
</
TableContainer
>
component
=
"th"
scope
=
"row"
style
=
{
{
wordBreak
:
row
.
name
.
length
>
12
?
"
break-word
"
:
"
normal
"
,
}
}
>
{
row
.
name
}
</
StyledTableCell
>
<
StyledTableCell
align
=
"left"
style
=
{
{
wordBreak
:
"
break-word
"
}
}
>
{
row
.
type
}
</
StyledTableCell
>
<
StyledTableCell
align
=
"left"
>
{
row
.
default
}
</
StyledTableCell
>
<
StyledTableCell
align
=
"left"
>
{
row
.
description
}
</
StyledTableCell
>
</
StyledTableRow
>
))
}
</
TableBody
>
</
Table
>
</
TableContainer
>
</
React
.
Fragment
>
);
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment