Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui-manchette: add fit button #649

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ const useManchettesWithSpaceTimeChart = (
}
}, [yZoom]);

const resetZoom = useCallback(() => {
setState((prev) => ({ ...prev, yZoom: 1 }));
}, []);

const handleScroll = useCallback(() => {
if (!isShiftPressed && manchetteWithSpaceTimeChartContainer.current) {
const { scrollTop } = manchetteWithSpaceTimeChartContainer.current;
Expand Down Expand Up @@ -146,11 +150,12 @@ const useManchettesWithSpaceTimeChart = (
operationalPoints: operationalPointsWithHeight,
zoomYIn,
zoomYOut,
resetZoom,
toggleMode,
yZoom,
isProportional,
}),
[operationalPointsWithHeight, zoomYIn, zoomYOut, toggleMode, yZoom, isProportional]
[operationalPointsWithHeight, zoomYIn, zoomYOut, resetZoom, toggleMode, yZoom, isProportional]
);

// Memoize spaceTimeChartProps separately
Expand Down
25 changes: 10 additions & 15 deletions ui-manchette/src/components/Manchette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type ManchetteProps = {
activeOperationalPointId?: string;
zoomYIn: () => void;
zoomYOut: () => void;
resetZoom: () => void;
height?: number;
yZoom?: number;
children?: React.ReactNode;
Expand All @@ -22,6 +23,7 @@ type ManchetteProps = {
const Manchette = ({
zoomYIn,
zoomYOut,
resetZoom,
yZoom = 1,
operationalPoints,
activeOperationalPointId,
Expand All @@ -31,7 +33,7 @@ const Manchette = ({
}: ManchetteProps) => (
<div className="manchette-container">
<div
className=" bg-ambientB-10 border-r border-grey-30"
className="bg-ambientB-10 border-r border-grey-30"
style={{ minHeight: `${INITIAL_OP_LIST_HEIGHT}px` }}
>
<OperationalPointList
Expand All @@ -40,24 +42,17 @@ const Manchette = ({
/>
{children}
</div>
<div className="manchette-actions flex items-center">
<div className=" flex items-center ">
<button
className="h-full px-3 w-full zoom-out"
onClick={zoomYOut}
disabled={yZoom <= MIN_ZOOM_Y}
>
<div className="manchette-actions">
<div className="zoom-buttons">
<button className="zoom-out" onClick={zoomYOut} disabled={yZoom <= MIN_ZOOM_Y}>
<ZoomOut />
</button>
</div>
<div className=" flex items-center border-x border-black-25 h-full">
<button
className="h-full px-3 w-full zoom-in"
disabled={yZoom >= MAX_ZOOM_Y}
onClick={zoomYIn}
>
<button className="zoom-in" onClick={zoomYIn} disabled={yZoom >= MAX_ZOOM_Y}>
<ZoomIn />
</button>
<button className="zoom-reset" onClick={resetZoom}>
Fit
</button>
</div>
<div className="flex items-center ml-auto text-sans font-semibold">
<button className="toggle-mode" onClick={toggleMode}>
Expand Down
1 change: 1 addition & 0 deletions ui-manchette/src/stories/Manchette.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const ManchetteWithWaypointMenu = () => {
}))}
zoomYIn={() => {}}
zoomYOut={() => {}}
resetZoom={() => {}}
toggleMode={() => {}}
activeOperationalPointId={activeOperationalPointId}
>
Expand Down
36 changes: 27 additions & 9 deletions ui-manchette/src/styles/manchette.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.manchette-container {
.manchette-actions {
align-items: center;
background-color: rgba(250, 249, 245, 0.6);
border-top: solid 1px;
border-right: solid 1px;
border-radius: 0 0 0 10px;
@apply border-black-25;
display: flex;
height: 2.5rem;
width: inherit;
position: sticky;
Expand All @@ -9,17 +15,29 @@
width: 100%;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
border-top: solid 1px;
border-right: solid 1px;
@apply border-black-25;
border-radius: 0px 0px 0px 10px;

.zoom-out:disabled {
opacity: 0.4;
}

.zoom-in:disabled {
opacity: 0.4;
.zoom-buttons {
display: flex;
align-items: center;
height: 100%;

button {
border-right: solid 1px theme('colors.grey.20');
border-top: solid 1px white;
height: 100%;
padding-inline: 12px;
}

button:disabled {
@apply text-grey-30;
}

.zoom-reset {
@apply text-grey-50;
font-weight: 600;
font-size: 14px;
}
}

.toggle-mode {
Expand Down
Loading