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

FormEditor: remove all overflows from markup #1147

Merged
merged 1 commit into from
Aug 19, 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
24 changes: 15 additions & 9 deletions src/harmony/FormEditor/FormEditor.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
}

.UploadButton {
margin-bottom: calc(var(--form-editor-buttons-height) * -1);
position: relative;
margin-top: var(--gap-s);
margin-top: var(--gap-xs);
display: flex;
align-items: center;
justify-content: space-between;
Expand Down Expand Up @@ -47,8 +48,8 @@
border-radius: var(--radius-m);
}

.FormEditor_outlined .UploadButton {
padding: var(--gap-xs) 0;
.FormEditor_outlined + .UploadButton {
padding: var(--gap-xs);
}

.FormEditorWrapper {
Expand All @@ -59,17 +60,27 @@
transition: 200ms ease-in;
transition-property: border, color, background-color;
border-radius: var(--radius-m);
overflow: hidden;
padding-bottom: var(--form-editor-buttons-height)
}

.EditorBackground {
background-color: var(--background);
border-radius: var(--radius-m);
margin-bottom: calc(var(--form-editor-buttons-height) * -1);
padding-bottom: var(--form-editor-buttons-height)
}

.EditorBackground.FormEditor_outlined {
margin-bottom: 0px;
padding-bottom: var(--gap-xs);
}

.PaddingWrapper {
padding-top: 12px;
height: 100%;
box-sizing: border-box;
border-top-left-radius: var(--radius-m);
border-top-right-radius: var(--radius-m);
}

.MonacoWrapper {
Expand Down Expand Up @@ -108,11 +119,6 @@
border-color: var(--danger-500);
}

.FormEditorWrapper_view_danger .MonacoEditor {
background-color: var(--danger-900);
color: var(--danger-400);
}

.FormEditorWrapper_view_danger .Placeholder {
color: var(--danger-500);
}
Expand Down
61 changes: 32 additions & 29 deletions src/harmony/FormEditor/FormEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ const maxEditorHeight = 450;

const monacoWrapperProps = { className: s.MonacoWrapper };

const formEditorWrapperStyles: Record<string, string> = {
'--form-editor-buttons-height': '36px',
};

export const FormEditor = React.forwardRef<HTMLDivElement, FormEditorProps>(
(
{
Expand Down Expand Up @@ -266,14 +270,12 @@ export const FormEditor = React.forwardRef<HTMLDivElement, FormEditorProps>(
}, [disabled]);

const editorContentStyles = useMemo(() => {
const indent = outline ? 'marginBottom' : 'paddingBottom';
return {
height: contentHeight,
minHeight: height,
maxHeight: maxEditorHeight,
[indent]: '40px',
};
}, [height, contentHeight, maxEditorHeight, outline]);
}, [height, contentHeight]);

const editorOptions = useMemo(() => ({ ...defaultOptions, ...options }), [options]);

Expand All @@ -288,6 +290,7 @@ export const FormEditor = React.forwardRef<HTMLDivElement, FormEditorProps>(
{ [s.FormEditor_focused]: focused && !outline },
brick ? brickMap[brick] : '',
)}
style={formEditorWrapperStyles}
>
<div
{...getRootProps()}
Expand Down Expand Up @@ -333,33 +336,33 @@ export const FormEditor = React.forwardRef<HTMLDivElement, FormEditorProps>(
wrapperProps={monacoWrapperProps}
/>
</div>
{nullable(focused && !disableAttaches, () => (
<div className={s.UploadButton}>
<input className={s.UploadInput} onChange={onFileInputChange} type="file" multiple />

{nullable(
loading,
() => (
<Text as="span" size="s" className={s.LoadingMessage}>
{messages?.attachmentsUploading || defaultAttachmentsUploadingMessage}
</Text>
),
<>
<Button
size="xs"
view="ghost"
text={messages?.attachmentsButton || defaultAttachmentsButtonMessage}
iconLeft={<IconAttachOutline size="xs" />}
onClick={onUploadLinkClick}
/>
<Text as="span" size="s" className={s.AttachmentDescriptionMessage}>
{messages?.attachmentsDescription || defaultAttachmentsDescriptionMessage}
</Text>
</>,
)}
</div>
))}
</div>
{nullable(focused && !disableAttaches, () => (
<div className={s.UploadButton}>
<input className={s.UploadInput} onChange={onFileInputChange} type="file" multiple />

{nullable(
loading,
() => (
<Text as="span" size="s" className={s.LoadingMessage}>
{messages?.attachmentsUploading || defaultAttachmentsUploadingMessage}
</Text>
),
<>
<Button
size="xs"
view="ghost"
text={messages?.attachmentsButton || defaultAttachmentsButtonMessage}
iconLeft={<IconAttachOutline size="xs" />}
onClick={onUploadLinkClick}
/>
<Text as="span" size="s" className={s.AttachmentDescriptionMessage}>
{messages?.attachmentsDescription || defaultAttachmentsDescriptionMessage}
</Text>
</>,
)}
</div>
))}
</div>
</div>
);
Expand Down
Loading