UI: Added the ability to change the font size (#1703)

This commit is contained in:
G4mingJon4s
2024-11-10 01:50:18 +01:00
committed by GitHub
parent 90cb8a9551
commit d6874d68aa
9 changed files with 99 additions and 45 deletions

View File

@@ -60,6 +60,7 @@ const lineClass = (classes: Record<string, string>, s: string): string => {
type ANSIITypographyProps = {
text: unknown;
color: "primary" | "error" | "success" | "info" | "warn";
styles?: React.CSSProperties;
};
export const ANSIITypography = React.memo(function ANSIITypography(props: ANSIITypographyProps): React.ReactElement {
@@ -94,9 +95,14 @@ export const ANSIITypography = React.memo(function ANSIITypography(props: ANSIIT
parts.push({ code: null, text: text });
}
return (
<Typography component={"div"} classes={{ root: lineClass(classes, props.color) }} paragraph={false}>
<Typography
component={"div"}
classes={{ root: lineClass(classes, props.color) }}
paragraph={false}
sx={{ ...(props.styles ?? {}) }}
>
{parts.map((part, i) => (
<span key={i} style={ansiCodeStyle(part.code)}>
<span key={i} style={{ ...ansiCodeStyle(part.code), ...(props.styles ?? {}) }}>
{part.text}
</span>
))}

View File

@@ -407,7 +407,19 @@ function LogWindow({ hidden, script, onClose }: LogWindowProps): React.ReactElem
<div style={{ display: "flex", flexDirection: "column" }}>
{script.logs.map(
(line: React.ReactNode, i: number): React.ReactNode =>
typeof line !== "string" ? line : <ANSIITypography key={i} text={line} color={lineColor(line)} />,
typeof line !== "string" ? (
line
) : (
<ANSIITypography
key={i}
text={line}
color={lineColor(line)}
styles={{
display: "inline-block",
fontSize: Settings.styles.tailFontSize,
}}
/>
),
)}
</div>
</Paper>