diff --git a/src/actions/actionExport.tsx b/src/actions/actionExport.tsx index aab3aa83..0c46736a 100644 --- a/src/actions/actionExport.tsx +++ b/src/actions/actionExport.tsx @@ -1,6 +1,6 @@ import React from "react"; import { trackEvent } from "../analytics"; -import { load, questionCircle, save, saveAs } from "../components/icons"; +import { load, questionCircle, saveAs } from "../components/icons"; import { ProjectName } from "../components/ProjectName"; import { ToolButton } from "../components/ToolButton"; import "../components/ToolIcon.scss"; @@ -17,6 +17,7 @@ import { getExportSize } from "../scene/export"; import { DEFAULT_EXPORT_PADDING, EXPORT_SCALES } from "../constants"; import { getSelectedElements, isSomeElementSelected } from "../scene"; import { getNonDeletedElements } from "../element"; +import { ActiveFile } from "../components/ActiveFile"; export const actionChangeProjectName = register({ name: "changeProjectName", @@ -153,14 +154,10 @@ export const actionSaveToActiveFile = register({ }, keyTest: (event) => event.key === KEYS.S && event[KEYS.CTRL_OR_CMD] && !event.shiftKey, - PanelComponent: ({ updateData }) => ( - updateData(null)} - data-testid="save-button" + PanelComponent: ({ updateData, appState }) => ( + updateData(null)} + fileName={appState.fileHandle?.name} /> ), }); diff --git a/src/components/ActiveFile.scss b/src/components/ActiveFile.scss new file mode 100644 index 00000000..404df84e --- /dev/null +++ b/src/components/ActiveFile.scss @@ -0,0 +1,21 @@ +.excalidraw { + .ActiveFile { + .ActiveFile__fileName { + display: flex; + align-items: center; + + span { + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + width: 9.3em; + } + + svg { + width: 1.15em; + margin-inline-end: 0.3em; + transform: scaleY(0.9); + } + } + } +} diff --git a/src/components/ActiveFile.tsx b/src/components/ActiveFile.tsx new file mode 100644 index 00000000..ba0f4c51 --- /dev/null +++ b/src/components/ActiveFile.tsx @@ -0,0 +1,29 @@ +import React from "react"; +import Stack from "../components/Stack"; +import { ToolButton } from "../components/ToolButton"; +import { save, file } from "../components/icons"; +import { t } from "../i18n"; + +import "./ActiveFile.scss"; + +type ActiveFileProps = { + fileName?: string; + onSave: () => void; +}; + +export const ActiveFile = ({ fileName, onSave }: ActiveFileProps) => ( + + + {file} + {fileName} + + + +); diff --git a/src/components/BackgroundPickerAndDarkModeToggle.tsx b/src/components/BackgroundPickerAndDarkModeToggle.tsx index 9e3adf4d..07c1c060 100644 --- a/src/components/BackgroundPickerAndDarkModeToggle.tsx +++ b/src/components/BackgroundPickerAndDarkModeToggle.tsx @@ -16,10 +16,5 @@ export const BackgroundPickerAndDarkModeToggle = ({
{actionManager.renderAction("changeViewBackgroundColor")} {showThemeBtn && actionManager.renderAction("toggleTheme")} - {appState.fileHandle && ( -
- {actionManager.renderAction("saveToActiveFile")} -
- )}
); diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index 2fe07896..e64ee575 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -488,6 +488,9 @@ const LayerUI = ({ setAppState={setAppState} showThemeBtn={showThemeBtn} /> + {appState.fileHandle && ( + <>{actionManager.renderAction("saveToActiveFile")} + )} @@ -506,7 +509,8 @@ const LayerUI = ({ style={{ // we want to make sure this doesn't overflow so substracting 200 // which is approximately height of zoom footer and top left menu items with some buffer - maxHeight: `${appState.height - 200}px`, + // if active file name is displayed, subtracting 248 to account for its height + maxHeight: `${appState.height - (appState.fileHandle ? 248 : 200)}px`, }} > createIcon( <>