feat: add font size controls to mobile terminal header and fix auto-hide space reclamation
- TerminalComponent: expose changeFontSize via onTerminalReady callback - MobileTerminalWrapper: pass changeFontSize to header - MobileTerminalHeader: add A- and A+ font size buttons - CSS: collapse header height/padding/margin/border when hidden to reclaim space
This commit is contained in:
@@ -6,6 +6,7 @@ interface MobileTerminalHeaderProps {
|
|||||||
onBack?: () => void;
|
onBack?: () => void;
|
||||||
onMenuToggle?: () => void;
|
onMenuToggle?: () => void;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
|
onFontSizeChange?: (delta: number) => void;
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
connectionStatus?: "connecting" | "connected" | "disconnected" | "error";
|
connectionStatus?: "connecting" | "connected" | "disconnected" | "error";
|
||||||
}
|
}
|
||||||
@@ -15,6 +16,7 @@ export const MobileTerminalHeader: React.FC<MobileTerminalHeaderProps> = ({
|
|||||||
onBack,
|
onBack,
|
||||||
onMenuToggle,
|
onMenuToggle,
|
||||||
onClose,
|
onClose,
|
||||||
|
onFontSizeChange,
|
||||||
isVisible,
|
isVisible,
|
||||||
connectionStatus = "connecting",
|
connectionStatus = "connecting",
|
||||||
}) => {
|
}) => {
|
||||||
@@ -56,6 +58,26 @@ export const MobileTerminalHeader: React.FC<MobileTerminalHeaderProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mobile-terminal-header-right">
|
<div className="mobile-terminal-header-right">
|
||||||
|
{onFontSizeChange && (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
className="mobile-terminal-header-button"
|
||||||
|
onClick={() => onFontSizeChange(-1)}
|
||||||
|
type="button"
|
||||||
|
aria-label="Decrease font size"
|
||||||
|
>
|
||||||
|
<span style={{ fontSize: "0.75rem" }}>A-</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="mobile-terminal-header-button"
|
||||||
|
onClick={() => onFontSizeChange(1)}
|
||||||
|
type="button"
|
||||||
|
aria-label="Increase font size"
|
||||||
|
>
|
||||||
|
<span style={{ fontSize: "1rem" }}>A+</span>
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{onClose && (
|
{onClose && (
|
||||||
<button
|
<button
|
||||||
className="mobile-terminal-header-button"
|
className="mobile-terminal-header-button"
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export const MobileTerminalWrapper: React.FC<MobileTerminalWrapperProps> = ({
|
|||||||
sendData: (data: string) => void;
|
sendData: (data: string) => void;
|
||||||
connectionStatus: "connecting" | "connected" | "disconnected" | "error";
|
connectionStatus: "connecting" | "connected" | "disconnected" | "error";
|
||||||
focusInput: () => void;
|
focusInput: () => void;
|
||||||
|
changeFontSize: (delta: number) => void;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
|
|
||||||
const headerAutoHide = useAutoHide({ timeout: 3000, enabled: isMobile });
|
const headerAutoHide = useAutoHide({ timeout: 3000, enabled: isMobile });
|
||||||
@@ -41,8 +42,8 @@ export const MobileTerminalWrapper: React.FC<MobileTerminalWrapperProps> = ({
|
|||||||
}, [headerAutoHide]);
|
}, [headerAutoHide]);
|
||||||
|
|
||||||
const handleTerminalReady = useCallback(
|
const handleTerminalReady = useCallback(
|
||||||
(sendData: (data: string) => void, connectionStatus: "connecting" | "connected" | "disconnected" | "error", focusInput: () => void) => {
|
(sendData: (data: string) => void, connectionStatus: "connecting" | "connected" | "disconnected" | "error", focusInput: () => void, changeFontSize: (delta: number) => void) => {
|
||||||
setTerminalRef({ sendData, connectionStatus, focusInput });
|
setTerminalRef({ sendData, connectionStatus, focusInput, changeFontSize });
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
@@ -71,6 +72,7 @@ export const MobileTerminalWrapper: React.FC<MobileTerminalWrapperProps> = ({
|
|||||||
onBack={onBack}
|
onBack={onBack}
|
||||||
onMenuToggle={onMenuToggle}
|
onMenuToggle={onMenuToggle}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
|
onFontSizeChange={(delta) => terminalRef?.changeFontSize(delta)}
|
||||||
isVisible={headerAutoHide.isVisible}
|
isVisible={headerAutoHide.isVisible}
|
||||||
connectionStatus={terminalRef?.connectionStatus}
|
connectionStatus={terminalRef?.connectionStatus}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ interface TerminalProps {
|
|||||||
onTerminalReady?: (
|
onTerminalReady?: (
|
||||||
sendData: (data: string) => void,
|
sendData: (data: string) => void,
|
||||||
connectionStatus: "connecting" | "connected" | "disconnected" | "error",
|
connectionStatus: "connecting" | "connected" | "disconnected" | "error",
|
||||||
focusInput: () => void
|
focusInput: () => void,
|
||||||
|
changeFontSize: (delta: number) => void
|
||||||
) => void;
|
) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +220,10 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
|||||||
const focusInput = () => {
|
const focusInput = () => {
|
||||||
termRef.current?.focus();
|
termRef.current?.focus();
|
||||||
};
|
};
|
||||||
onTerminalReadyRef.current(sendData, status, focusInput);
|
const changeFontSize = (delta: number) => {
|
||||||
|
handleFontSizeChange(delta);
|
||||||
|
};
|
||||||
|
onTerminalReadyRef.current(sendData, status, focusInput, changeFontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visibility API for reconnection
|
// Visibility API for reconnection
|
||||||
@@ -251,7 +255,10 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
|||||||
const focusInput = () => {
|
const focusInput = () => {
|
||||||
termRef.current?.focus();
|
termRef.current?.focus();
|
||||||
};
|
};
|
||||||
onTerminalReady(sendData, status, focusInput);
|
const changeFontSize = (delta: number) => {
|
||||||
|
handleFontSizeChange(delta);
|
||||||
|
};
|
||||||
|
onTerminalReady(sendData, status, focusInput, changeFontSize);
|
||||||
}
|
}
|
||||||
}, [status, onTerminalReady]);
|
}, [status, onTerminalReady]);
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -2960,19 +2960,28 @@ a.nav-item,
|
|||||||
background: #2d2d2d;
|
background: #2d2d2d;
|
||||||
border-bottom: 1px solid #3e3e3e;
|
border-bottom: 1px solid #3e3e3e;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
transition: transform 0.3s ease, opacity 0.3s ease;
|
transition: transform 0.3s ease, opacity 0.3s ease, height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-terminal-header.hidden {
|
.mobile-terminal-header.hidden {
|
||||||
transform: translateY(-100%);
|
transform: translateY(-100%);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
height: 0;
|
||||||
|
padding-top: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
border-width: 0;
|
||||||
|
flex-shrink: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-terminal-header.visible {
|
.mobile-terminal-header.visible {
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-terminal-header-left,
|
.mobile-terminal-header-left,
|
||||||
|
|||||||
Reference in New Issue
Block a user