Skip to content

Commit

Permalink
Merge branch 'are/export-dialog-design-refresh' of https://github.com…
Browse files Browse the repository at this point in the history
…/excalidraw/excalidraw

# Conflicts:
#	src/components/ImageExportDialog.tsx
#	src/locales/en.json
  • Loading branch information
dwelle committed May 26, 2023
2 parents c863147 + 9f77ea0 commit fe03915
Show file tree
Hide file tree
Showing 21 changed files with 875 additions and 163 deletions.
3 changes: 2 additions & 1 deletion src/actions/actionExport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ export const actionChangeProjectName = register({
perform: (_elements, appState, value) => {
return { appState: { ...appState, name: value }, commitToHistory: false };
},
PanelComponent: ({ appState, updateData, appProps }) => (
PanelComponent: ({ appState, updateData, appProps, data }) => (
<ProjectName
label={t("labels.fileTitle")}
value={appState.name || "Unnamed"}
onChange={(name: string) => updateData(name)}
isNameEditable={
typeof appProps.name === "undefined" && !appState.viewModeEnabled
}
ignoreFocus={data?.ignoreFocus ?? false}
/>
),
});
Expand Down
7 changes: 5 additions & 2 deletions src/actions/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,13 @@ export class ActionManager {
return true;
}

executeAction(action: Action, source: ActionSource = "api") {
executeAction(
action: Action,
source: ActionSource = "api",
value: any = null,
) {
const elements = this.getElementsIncludingDeleted();
const appState = this.getAppState();
const value = null;

trackAction(action, source, appState, elements, this.app, value);

Expand Down
2 changes: 1 addition & 1 deletion src/components/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ConfirmDialog = (props: Props) => {
return (
<Dialog
onCloseRequest={onCancel}
small={true}
size="small"
{...rest}
className={`confirm-dialog ${className}`}
>
Expand Down
29 changes: 29 additions & 0 deletions src/components/Dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,33 @@
padding: 0 0 0.75rem;
margin-bottom: 1.5rem;
}

.Dialog__close {
color: var(--color-gray-40);
margin: 0;
position: absolute;
top: 0.75rem;
right: 0.5rem;
border: 0;
background-color: transparent;
line-height: 0;
cursor: pointer;

&:hover {
color: var(--color-gray-60);
}
&:active {
color: var(--color-gray-40);
}

@include isMobile {
top: 1.25rem;
right: 1.25rem;
}

svg {
width: 1.5rem;
height: 1.5rem;
}
}
}
33 changes: 19 additions & 14 deletions src/components/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { jotaiScope } from "../jotai";
export interface DialogProps {
children: React.ReactNode;
className?: string;
small?: boolean;
size?: "small" | "regular" | "wide";
onCloseRequest(): void;
title: React.ReactNode;
title: React.ReactNode | false;
autofocus?: boolean;
theme?: AppState["theme"];
closeOnClickOutside?: boolean;
Expand All @@ -33,6 +33,7 @@ export const Dialog = (props: DialogProps) => {
const [islandNode, setIslandNode] = useCallbackRefState<HTMLDivElement>();
const [lastActiveElement] = useState(document.activeElement);
const { id } = useExcalidrawContainer();
const device = useDevice();

useEffect(() => {
if (!islandNode) {
Expand Down Expand Up @@ -86,23 +87,27 @@ export const Dialog = (props: DialogProps) => {
<Modal
className={clsx("Dialog", props.className)}
labelledBy="dialog-title"
maxWidth={props.small ? 550 : 800}
maxWidth={
props.size === "wide" ? 1024 : props.size === "small" ? 550 : 800
}
onCloseRequest={onClose}
theme={props.theme}
closeOnClickOutside={props.closeOnClickOutside}
>
<Island ref={setIslandNode}>
<h2 id={`${id}-dialog-title`} className="Dialog__title">
<span className="Dialog__titleContent">{props.title}</span>
<button
className="Modal__close"
onClick={onClose}
title={t("buttons.close")}
aria-label={t("buttons.close")}
>
{useDevice().isMobile ? back : CloseIcon}
</button>
</h2>
{props.title && (
<h2 id={`${id}-dialog-title`} className="Dialog__title">
<span className="Dialog__titleContent">{props.title}</span>
</h2>
)}
<button
className="Dialog__close"
onClick={onClose}
title={t("buttons.close")}
aria-label={t("buttons.close")}
>
{device.isMobile ? back : CloseIcon}
</button>
<div className="Dialog__content">{props.children}</div>
</Island>
</Modal>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ErrorDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const ErrorDialog = ({
<>
{modalIsShown && (
<Dialog
small
size="small"
onCloseRequest={handleClose}
title={t("errorDialog.title")}
>
Expand Down
215 changes: 215 additions & 0 deletions src/components/ImageExportDialog.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
@import "../css/variables.module";

.excalidraw {
--ImageExportModal-preview-border: #d6d6d6;

&.theme--dark {
--ImageExportModal-preview-border: #5c5c5c;
}

.ImageExportModal {
display: flex;
flex-direction: row;
justify-content: space-between;

& h3 {
font-family: "Assistant";
font-style: normal;
font-weight: 700;
font-size: 1.313rem;
line-height: 130%;
padding: 0;
margin: 0;

@include isMobile {
display: none;
}
}

& > h3 {
display: none;

@include isMobile {
display: block;
}
}

@include isMobile {
flex-direction: column;
height: calc(100vh - 5rem);
}

&__preview {
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
height: 360px;
width: 55%;

margin-right: 1.5rem;

@include isMobile {
max-width: unset;
margin-right: unset;

width: 100%;
height: unset;
flex-grow: 1;
}

&__filename {
& > input {
margin-top: 1rem;
}
}

&__canvas {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-grow: 1;
justify-content: center;
align-items: center;

background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==")
left center;

border: 1px solid var(--ImageExportModal-preview-border);
border-radius: 12px;

overflow: hidden;
padding: 1rem;

& > canvas {
max-width: calc(100% - 2rem);
max-height: calc(100% - 2rem);

filter: none !important;

@include isMobile {
max-height: 100%;
}
}

@include isMobile {
margin-top: 24px;
max-width: unset;
}
}
}

&__settings {
display: flex;
flex-direction: column;
flex-wrap: wrap;
gap: 18px;

@include isMobile {
margin-left: unset;
margin-top: 1rem;
flex-direction: row;
gap: 6px 34px;

align-content: flex-start;
}

&__setting {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;

@include isMobile {
flex-direction: column;
align-items: start;
justify-content: unset;
height: 52px;
}

&__label {
display: flex;
flex-direction: row;
align-items: center;

font-family: "Assistant";
font-weight: 600;
font-size: 1rem;
line-height: 150%;

& svg {
width: 20px;
height: 20px;
margin-left: 10px;
}
}

&__content {
display: flex;
height: 100%;
align-items: center;
}
}

&__buttons {
flex-grow: 1;
flex-wrap: wrap;
display: flex;
flex-direction: row;
gap: 11px;

align-items: flex-end;
align-content: flex-end;

@include isMobile {
padding-top: 32px;
flex-basis: 100%;
justify-content: center;
}

&__button {
box-sizing: border-box;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 8px 16px;
flex-shrink: 0;
width: fit-content;
gap: 8px;

height: 40px;
border: 0;
border-radius: 8px;

user-select: none;
font-family: "Assistant";
font-style: normal;
font-weight: 600;
font-size: 0.75rem;
line-height: 100%;
transition: 150ms ease-out;
transition-property: background, color;

background: var(--color-primary);
color: var(--color-icon-white);

&:hover {
background: var(--color-primary-darker);
color: var(--color-icon-white);
}

&:active {
background: var(--color-primary-darkest);
}

& > svg {
width: 20px;
height: 20px;
}
}
}
}
}
}
Loading

0 comments on commit fe03915

Please sign in to comment.