fix: adjust web ui item style

This commit is contained in:
GyDi 2022-08-16 01:08:54 +08:00
parent 2f8146b11f
commit bd576ca808
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084

View File

@ -1,5 +1,11 @@
import { useState } from "react"; import { useState } from "react";
import { IconButton, Stack, TextField, Typography } from "@mui/material"; import {
Divider,
IconButton,
Stack,
TextField,
Typography,
} from "@mui/material";
import { import {
CheckRounded, CheckRounded,
CloseRounded, CloseRounded,
@ -32,7 +38,8 @@ const WebUIItem = (props: Props) => {
if (editing || onlyEdit) { if (editing || onlyEdit) {
return ( return (
<Stack spacing={1} direction="row" mt={1} mb={2} alignItems="center"> <>
<Stack spacing={0.75} direction="row" mt={1} mb={1} alignItems="center">
<TextField <TextField
fullWidth fullWidth
size="small" size="small"
@ -64,23 +71,31 @@ const WebUIItem = (props: Props) => {
<CloseRounded fontSize="inherit" /> <CloseRounded fontSize="inherit" />
</IconButton> </IconButton>
</Stack> </Stack>
<Divider />
</>
); );
} }
const html = value
?.replace("%host", "<span>%host</span>")
.replace("%port", "<span>%port</span>")
.replace("%secret", "<span>%secret</span>");
return ( return (
<Stack spacing={1} direction="row" alignItems="center" mt={1} mb={2}> <>
<Stack spacing={0.75} direction="row" alignItems="center" mt={1} mb={1}>
<Typography <Typography
component="div" component="div"
width="100%" width="100%"
title={value} title={value}
sx={{ color={value ? "text.primary" : "text.secondary"}
overflow: "hidden", sx={({ palette }) => ({
textOverflow: "ellipsis", "> span": {
whiteSpace: "nowrap", color: palette.primary.main,
}} },
> })}
{value || "NULL"} dangerouslySetInnerHTML={{ __html: html || "NULL" }}
</Typography> />
<IconButton <IconButton
size="small" size="small"
title="Open URL" title="Open URL"
@ -109,6 +124,8 @@ const WebUIItem = (props: Props) => {
<DeleteRounded fontSize="inherit" /> <DeleteRounded fontSize="inherit" />
</IconButton> </IconButton>
</Stack> </Stack>
<Divider />
</>
); );
}; };