fix: updated "editing disabled" banner (#1037)

This commit is contained in:
Aman Harwara
2022-05-23 19:41:19 +05:30
committed by GitHub
parent 0e258856d8
commit 079140eb92
5 changed files with 57 additions and 15 deletions

View File

@@ -0,0 +1,38 @@
import { FunctionComponent } from 'preact'
import { Icon } from '../Icon/Icon'
type Props = {
onMouseLeave: () => void
onMouseOver: () => void
onClick: () => void
showLockedIcon: boolean
lockText: string
}
export const EditingDisabledBanner: FunctionComponent<Props> = ({
onMouseLeave,
onMouseOver,
onClick,
showLockedIcon,
lockText,
}) => {
const background = showLockedIcon ? 'bg-warning-faded' : 'bg-info-faded'
const iconColor = showLockedIcon ? 'color-accessory-tint-3' : 'color-accessory-tint-1'
const textColor = showLockedIcon ? 'color-warning-contrast' : 'color-accessory-tint-1'
return (
<div
className={`flex items-center px-3.5 py-2 ${background} cursor-pointer`}
onMouseLeave={onMouseLeave}
onMouseOver={onMouseOver}
onClick={onClick}
>
{showLockedIcon ? (
<Icon type="pencil-off" className={`${iconColor} flex fill-current mr-3`} />
) : (
<Icon type="pencil" className={`${iconColor} flex fill-current mr-3`} />
)}
<span className={textColor}>{lockText}</span>
</div>
)
}

View File

@@ -21,7 +21,6 @@ import { STRING_DELETE_PLACEHOLDER_ATTEMPT, STRING_DELETE_LOCKED_ATTEMPT, String
import { confirmDialog } from '@/Services/AlertService'
import { PureComponent } from '@/Components/Abstract/PureComponent'
import { ProtectedNoteOverlay } from '@/Components/ProtectedNoteOverlay/ProtectedNoteOverlay'
import { Icon } from '@/Components/Icon/Icon'
import { PinNoteButton } from '@/Components/PinNoteButton/PinNoteButton'
import { NotesOptionsPanel } from '@/Components/NotesOptions/NotesOptionsPanel'
import { NoteTagsContainer } from '@/Components/NoteTags/NoteTagsContainer'
@@ -30,6 +29,7 @@ import { PanelSide, PanelResizer, PanelResizeType } from '@/Components/PanelResi
import { ElementIds } from '@/ElementIDs'
import { ChangeEditorButton } from '@/Components/ChangeEditor/ChangeEditorButton'
import { AttachedFilesButton } from '@/Components/AttachedFilesPopover/AttachedFilesButton'
import { EditingDisabledBanner } from './EditingDisabledBanner'
import {
transactionForAssociateComponentWithCurrentNote,
transactionForDisassociateComponentWithCurrentNote,
@@ -887,8 +887,7 @@ export class NoteView extends PureComponent<Props, State> {
<div className="flex-grow flex flex-col">
<div className="sn-component">
{this.state.noteLocked && (
<div
className="flex items-center px-3.5 py-2 bg-warning cursor-pointer"
<EditingDisabledBanner
onMouseLeave={() => {
this.setState({
lockText: NOTE_EDITING_DISABLED_TEXT,
@@ -902,14 +901,9 @@ export class NoteView extends PureComponent<Props, State> {
})
}}
onClick={() => this.appState.notes.setLockSelectedNotes(!this.state.noteLocked)}
>
{this.state.showLockedIcon ? (
<Icon type="pencil-off" className="color-accessory-tint-3 flex fill-current mr-3" />
) : (
<Icon type="pencil" className="color-accessory-tint-3 flex fill-current mr-3" />
)}
<span className="color-grey-0">{this.state.lockText}</span>
</div>
showLockedIcon={this.state.showLockedIcon}
lockText={this.state.lockText}
/>
)}
</div>

View File

@@ -167,9 +167,9 @@ const NoteSizeWarning: FunctionComponent<{
note: SNNote
}> = ({ note }) => {
return new Blob([note.text]).size > NOTE_SIZE_WARNING_THRESHOLD ? (
<div className="flex items-center px-3 py-3.5 relative bg-warning">
<div className="flex items-center px-3 py-3.5 relative bg-warning-faded">
<Icon type="warning" className="color-accessory-tint-3 flex-shrink-0 mr-3" />
<div className="color-grey-0 select-none leading-140% max-w-80%">
<div className="color-warning-contrast select-none leading-140% max-w-80%">
This note may have trouble syncing to the mobile application due to its size.
</div>
</div>