fix(striker-ui): prevent text overlap in anvil summary

main
Tsu-ba-me 1 year ago
parent f4a1ab5a0b
commit 0b9d6be08c
  1. 29
      striker-ui/components/Anvils/AnvilSummary.tsx
  2. 13
      striker-ui/components/Anvils/AnvilSummaryList.tsx
  3. 6
      striker-ui/types/AnvilSummary.d.ts

@ -90,7 +90,8 @@ const AnvilSummary: FC<AnvilSummaryProps> = (props) => {
anvil && ( anvil && (
<Grid <Grid
alignItems="center" alignItems="center"
columns={4} columns={20}
columnSpacing="0.5em"
container container
sx={{ sx={{
[`& > .${gridClasses.item}:nth-child(-n + 4)`]: { [`& > .${gridClasses.item}:nth-child(-n + 4)`]: {
@ -107,38 +108,34 @@ const AnvilSummary: FC<AnvilSummaryProps> = (props) => {
let servers: ReactNode; let servers: ReactNode;
if (['offline', 'online'].includes(state)) { if (['offline', 'online'].includes(state)) {
servers = ( servers = <MonoText variant="caption">{serverCount}</MonoText>;
<BodyText variant="caption" whiteSpace="nowrap">
Servers{' '}
<InlineMonoText sx={{ paddingRight: 0 }}>
{serverCount}
</InlineMonoText>
</BodyText>
);
} else { } else {
stateValue = `${stateProgress}%`; stateValue = `${stateProgress}%`;
} }
return [ return [
<Grid item key={`${uuid}-state-label`} xs={1}> <Grid item key={`${uuid}-state-label`} xs={7}>
<BodyText variant="caption" whiteSpace="nowrap"> <BodyText variant="caption" whiteSpace="nowrap">
{name} {name}
</BodyText> </BodyText>
</Grid>, </Grid>,
<Grid item key={`${uuid}-state`} xs={1}> <Grid item key={`${uuid}-state`} xs={5}>
<MonoText inheritColour color={stateColour}> <MonoText inheritColour color={stateColour}>
{stateValue} {stateValue}
</MonoText> </MonoText>
</Grid>, </Grid>,
<Grid item key={`${uuid}-divider`} xs={1}> <Grid item key={`${uuid}-divider`} xs>
<Divider sx={{ marginBottom: '-.2em' }} /> <Divider sx={{ marginBottom: '-.4em' }} />
</Grid>,
<Grid item key={`${uuid}-server-label`} width="2.2em">
{servers && <BodyText variant="caption">Servers</BodyText>}
</Grid>, </Grid>,
<Grid <Grid
display="flex" display="flex"
item item
justifyContent="flex-end" justifyContent="flex-end"
key={`${uuid}-server-count`} key={`${uuid}-server-count`}
xs={1} width="2em"
> >
{servers} {servers}
</Grid>, </Grid>,
@ -167,13 +164,13 @@ const AnvilSummary: FC<AnvilSummaryProps> = (props) => {
alignItems="center" alignItems="center"
columns={2} columns={2}
container container
minWidth="calc(0% + 3.2em)"
sx={{ sx={{
width: '3.7em',
[`& > .${gridClasses.item}:nth-child(-n + 2)`]: { [`& > .${gridClasses.item}:nth-child(-n + 2)`]: {
marginBottom: '-.6em', marginBottom: '-.6em',
}, },
}} }}
width="calc(0% + 3.2em)"
> >
<Grid item xs={1}> <Grid item xs={1}>
<BodyText variant="caption">Cores</BodyText> <BodyText variant="caption">Cores</BodyText>

@ -1,3 +1,4 @@
import { gridClasses } from '@mui/material';
import { FC, ReactNode, useMemo } from 'react'; import { FC, ReactNode, useMemo } from 'react';
import AnvilSummary from './AnvilSummary'; import AnvilSummary from './AnvilSummary';
@ -27,7 +28,7 @@ const AnvilSummaryList: FC = () => {
() => () =>
anvils && ( anvils && (
<Grid <Grid
columns={{ xs: 1, sm: 2, md: 3, lg: 4, xl: 5 }} columns={{ xs: 1, sm: 2, md: 3, xl: 4 }}
layout={Object.values(anvils).reduce<GridLayout>( layout={Object.values(anvils).reduce<GridLayout>(
(previous, current) => { (previous, current) => {
const { description, name, uuid } = current; const { description, name, uuid } = current;
@ -36,7 +37,7 @@ const AnvilSummaryList: FC = () => {
previous[key] = { previous[key] = {
children: ( children: (
<InnerPanel width="22em"> <InnerPanel height="100%" mv={0}>
<InnerPanelHeader> <InnerPanelHeader>
<BodyText <BodyText
overflow="hidden" overflow="hidden"
@ -57,6 +58,14 @@ const AnvilSummaryList: FC = () => {
}, },
{}, {},
)} )}
spacing="1em"
sx={{
alignContent: 'stretch',
[`& > .${gridClasses.item}`]: {
minWidth: '20em',
},
}}
/> />
), ),
[anvils], [anvils],

@ -1,7 +1,3 @@
type AnvilSummaryOptionalProps = { type AnvilSummaryProps = {
loading?: boolean;
};
type AnvilSummaryProps = AnvilSummaryOptionalProps & {
anvilUuid: string; anvilUuid: string;
}; };

Loading…
Cancel
Save