mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-23 03:56:20 +00:00
Make top controls always visible, but only allow page editor outside of tools
This commit is contained in:
parent
edeed49e0b
commit
d8ff2c0aa8
@ -19,7 +19,8 @@ const viewOptionStyle = {
|
|||||||
|
|
||||||
|
|
||||||
// Build view options showing text always
|
// Build view options showing text always
|
||||||
const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchType | null) => [
|
const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchType | null, isToolSelected: boolean) => {
|
||||||
|
const options = [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
<div style={viewOptionStyle as React.CSSProperties}>
|
<div style={viewOptionStyle as React.CSSProperties}>
|
||||||
@ -33,24 +34,6 @@ const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchTyp
|
|||||||
),
|
),
|
||||||
value: "viewer",
|
value: "viewer",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: (
|
|
||||||
<div style={viewOptionStyle as React.CSSProperties}>
|
|
||||||
{currentView === "pageEditor" ? (
|
|
||||||
<>
|
|
||||||
{switchingTo === "pageEditor" ? <Loader size="xs" /> : <EditNoteIcon fontSize="small" />}
|
|
||||||
<span>Page Editor</span>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{switchingTo === "pageEditor" ? <Loader size="xs" /> : <EditNoteIcon fontSize="small" />}
|
|
||||||
<span>Page Editor</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
value: "pageEditor",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
<div style={viewOptionStyle as React.CSSProperties}>
|
<div style={viewOptionStyle as React.CSSProperties}>
|
||||||
@ -71,6 +54,31 @@ const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchTyp
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Only add Page Editor option when not in a tool
|
||||||
|
if (!isToolSelected) {
|
||||||
|
options.splice(1, 0, {
|
||||||
|
label: (
|
||||||
|
<div style={viewOptionStyle as React.CSSProperties}>
|
||||||
|
{currentView === "pageEditor" ? (
|
||||||
|
<>
|
||||||
|
{switchingTo === "pageEditor" ? <Loader size="xs" /> : <EditNoteIcon fontSize="small" />}
|
||||||
|
<span>Page Editor</span>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{switchingTo === "pageEditor" ? <Loader size="xs" /> : <EditNoteIcon fontSize="small" />}
|
||||||
|
<span>Page Editor</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
value: "pageEditor",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
|
};
|
||||||
|
|
||||||
interface TopControlsProps {
|
interface TopControlsProps {
|
||||||
currentView: WorkbenchType;
|
currentView: WorkbenchType;
|
||||||
setCurrentView: (view: WorkbenchType) => void;
|
setCurrentView: (view: WorkbenchType) => void;
|
||||||
@ -111,10 +119,9 @@ const TopControls = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="absolute left-0 w-full top-0 z-[100] pointer-events-none">
|
<div className="absolute left-0 w-full top-0 z-[100] pointer-events-none">
|
||||||
{!isToolSelected && (
|
|
||||||
<div className="flex justify-center mt-[0.5rem]">
|
<div className="flex justify-center mt-[0.5rem]">
|
||||||
<SegmentedControl
|
<SegmentedControl
|
||||||
data={createViewOptions(currentView, switchingTo)}
|
data={createViewOptions(currentView, switchingTo, isToolSelected)}
|
||||||
value={currentView}
|
value={currentView}
|
||||||
onChange={handleViewChange}
|
onChange={handleViewChange}
|
||||||
color="blue"
|
color="blue"
|
||||||
@ -143,7 +150,6 @@ const TopControls = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user