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

#569 show filename in footer #574

Merged
merged 4 commits into from
Nov 24, 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
1 change: 1 addition & 0 deletions src/core/local-disk/use-local-disk.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const useLocalDisk = () => {
reader.onload = () => {
const content = reader.result as string;
const parseData: QuickMockFileContract = JSON.parse(content);
setFileName(file.name);
if (parseData.version === '0.1') {
// Handle version 0.1 parsing
const appDocument =
Expand Down
1 change: 1 addition & 0 deletions src/core/providers/canvas/canvas.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export interface CanvasContextModel {
addNewPage: () => void;
duplicatePage: (pageIndex: number) => void;
getActivePage: () => Page;
getActivePageName: () => string;
setActivePage: (pageId: string) => void;
deletePage: (pageIndex: number) => void;
editPageTitle: (pageIndex: number, newName: string) => void;
Expand Down
6 changes: 6 additions & 0 deletions src/core/providers/canvas/canvas.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export const CanvasProvider: React.FC<Props> = props => {
return document.pages[document.activePageIndex];
};

const getActivePageName = () => {
return document.pages[document.activePageIndex].name;
};

const setActivePage = (pageId: string) => {
selectionInfo.clearSelection();
selectionInfo.shapeRefs.current = {};
Expand Down Expand Up @@ -179,6 +183,7 @@ export const CanvasProvider: React.FC<Props> = props => {

const createNewFullDocument = () => {
setDocument(createDefaultDocumentModel());
setFileName('');
};

const deleteSelectedShapes = () => {
Expand Down Expand Up @@ -318,6 +323,7 @@ export const CanvasProvider: React.FC<Props> = props => {
addNewPage,
duplicatePage,
getActivePage,
getActivePageName,
setActivePage,
deletePage,
editPageTitle,
Expand Down
21 changes: 18 additions & 3 deletions src/pods/footer/footer.pod.module.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
.container {
display: flex;
justify-content: center;
justify-content: space-between;
align-items: center;
background-color: var(--primary-50);
border-top: 1px solid var(--primary-100);
padding: var(--space-xs) var(--space-md);
}

.title {
flex-grow: 1;
.left,
.center,
.right {
flex: 1;
}

.left {
text-align: left;
}

.center {
text-align: center;
}

.right {
display: flex;
justify-content: flex-end;
}

.zoomContainer {
Expand Down
38 changes: 24 additions & 14 deletions src/pods/footer/footer.pod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,33 @@ import classes from './footer.pod.module.css';
import { ZoomInButton, ZoomOutButton } from './components';

export const FooterPod = () => {
const { scale, setScale } = useCanvasContext();
const { scale, setScale, getActivePageName, fileName } = useCanvasContext();

return (
<footer className={classes.container}>
<p className={classes.title}>Quickmock - © Lemoncode</p>
<div className={classes.zoomContainer}>
<ZoomOutButton
scale={scale}
setScale={setScale}
className={classes.button}
/>
<p className={classes.zoomValue}>{(scale * 100).toFixed(0)} %</p>
<ZoomInButton
scale={scale}
setScale={setScale}
className={classes.button}
/>
<div className={classes.left}>
<p>
<strong>📄 {fileName == '' ? 'New' : fileName}</strong> -{' '}
{getActivePageName()}
</p>
</div>
<div className={classes.center}>
<p>Quickmock - © Lemoncode</p>
</div>
<div className={classes.right}>
<div className={classes.zoomContainer}>
<ZoomOutButton
scale={scale}
setScale={setScale}
className={classes.button}
/>
<p className={classes.zoomValue}>{(scale * 100).toFixed(0)} %</p>
<ZoomInButton
scale={scale}
setScale={setScale}
className={classes.button}
/>
</div>
</div>
</footer>
);
Expand Down