feat: use pencil off icon for note bar
This commit is contained in:
@@ -59,10 +59,11 @@ import { SessionsModalDirective } from './components/SessionsModal';
|
|||||||
import { NoAccountWarningDirective } from './components/NoAccountWarning';
|
import { NoAccountWarningDirective } from './components/NoAccountWarning';
|
||||||
import { NoProtectionsdNoteWarningDirective } from './components/NoProtectionsNoteWarning';
|
import { NoProtectionsdNoteWarningDirective } from './components/NoProtectionsNoteWarning';
|
||||||
import { SearchOptionsDirective } from './components/SearchOptions';
|
import { SearchOptionsDirective } from './components/SearchOptions';
|
||||||
import { MultipleSelectedNotesDirective } from './components/MultipleSelectedNotes';
|
|
||||||
import { ConfirmSignoutDirective } from './components/ConfirmSignoutModal';
|
import { ConfirmSignoutDirective } from './components/ConfirmSignoutModal';
|
||||||
|
import { MultipleSelectedNotesDirective } from './components/MultipleSelectedNotes';
|
||||||
import { NotesContextMenuDirective } from './components/NotesContextMenu';
|
import { NotesContextMenuDirective } from './components/NotesContextMenu';
|
||||||
import { NotesOptionsPanelDirective } from './components/NotesOptionsPanel';
|
import { NotesOptionsPanelDirective } from './components/NotesOptionsPanel';
|
||||||
|
import { IconDirective } from './components/Icon';
|
||||||
|
|
||||||
function reloadHiddenFirefoxTab(): boolean {
|
function reloadHiddenFirefoxTab(): boolean {
|
||||||
/**
|
/**
|
||||||
@@ -152,10 +153,11 @@ const startApplication: StartApplication = async function startApplication(
|
|||||||
.directive('noAccountWarning', NoAccountWarningDirective)
|
.directive('noAccountWarning', NoAccountWarningDirective)
|
||||||
.directive('protectedNotePanel', NoProtectionsdNoteWarningDirective)
|
.directive('protectedNotePanel', NoProtectionsdNoteWarningDirective)
|
||||||
.directive('searchOptions', SearchOptionsDirective)
|
.directive('searchOptions', SearchOptionsDirective)
|
||||||
|
.directive('confirmSignout', ConfirmSignoutDirective)
|
||||||
.directive('multipleSelectedNotesPanel', MultipleSelectedNotesDirective)
|
.directive('multipleSelectedNotesPanel', MultipleSelectedNotesDirective)
|
||||||
.directive('notesContextMenu', NotesContextMenuDirective)
|
.directive('notesContextMenu', NotesContextMenuDirective)
|
||||||
.directive('notesOptionsPanel', NotesOptionsPanelDirective)
|
.directive('notesOptionsPanel', NotesOptionsPanelDirective)
|
||||||
.directive('confirmSignout', ConfirmSignoutDirective);
|
.directive('icon', IconDirective);
|
||||||
|
|
||||||
// Filters
|
// Filters
|
||||||
angular.module('app').filter('trusted', ['$sce', trusted]);
|
angular.module('app').filter('trusted', ['$sce', trusted]);
|
||||||
|
|||||||
46
app/assets/javascripts/components/Icon.tsx
Normal file
46
app/assets/javascripts/components/Icon.tsx
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import PencilOffIcon from '../../icons/ic-pencil-off.svg';
|
||||||
|
import RichTextIcon from '../../icons/ic-text-rich.svg';
|
||||||
|
import TrashIcon from '../../icons/ic-trash.svg';
|
||||||
|
import PinIcon from '../../icons/ic-pin.svg';
|
||||||
|
import UnpinIcon from '../../icons/ic-pin-off.svg';
|
||||||
|
import ArchiveIcon from '../../icons/ic-archive.svg';
|
||||||
|
import UnarchiveIcon from '../../icons/ic-unarchive.svg';
|
||||||
|
import { toDirective } from './utils';
|
||||||
|
|
||||||
|
export enum IconType {
|
||||||
|
PencilOff = 'pencil-off',
|
||||||
|
RichText = 'rich-text',
|
||||||
|
Trash = 'trash',
|
||||||
|
Pin = 'pin',
|
||||||
|
Unpin = 'unpin',
|
||||||
|
Archive = 'archive',
|
||||||
|
Unarchive = 'unarchive'
|
||||||
|
}
|
||||||
|
|
||||||
|
const ICONS = {
|
||||||
|
[IconType.PencilOff]: PencilOffIcon,
|
||||||
|
[IconType.RichText]: RichTextIcon,
|
||||||
|
[IconType.Trash]: TrashIcon,
|
||||||
|
[IconType.Pin]: PinIcon,
|
||||||
|
[IconType.Unpin]: UnpinIcon,
|
||||||
|
[IconType.Archive]: ArchiveIcon,
|
||||||
|
[IconType.Unarchive]: UnarchiveIcon
|
||||||
|
};
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
type: IconType;
|
||||||
|
className: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Icon: React.FC<Props> = ({ type, className }) => {
|
||||||
|
const IconComponent = ICONS[type];
|
||||||
|
return type ? <IconComponent className={className} /> : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const IconDirective = toDirective<Props>(
|
||||||
|
Icon,
|
||||||
|
{
|
||||||
|
type: '@',
|
||||||
|
className: '@',
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -1,11 +1,5 @@
|
|||||||
import { AppState } from '@/ui_models/app_state';
|
import { AppState } from '@/ui_models/app_state';
|
||||||
import PencilOffIcon from '../../icons/ic-pencil-off.svg';
|
import { Icon, IconType } from './Icon';
|
||||||
import RichTextIcon from '../../icons/ic-text-rich.svg';
|
|
||||||
import TrashIcon from '../../icons/ic-trash.svg';
|
|
||||||
import PinIcon from '../../icons/ic-pin.svg';
|
|
||||||
import UnpinIcon from '../../icons/ic-pin-off.svg';
|
|
||||||
import ArchiveIcon from '../../icons/ic-archive.svg';
|
|
||||||
import UnarchiveIcon from '../../icons/ic-unarchive.svg';
|
|
||||||
import { Switch } from './Switch';
|
import { Switch } from './Switch';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { useRef } from 'preact/hooks';
|
import { useRef } from 'preact/hooks';
|
||||||
@@ -32,7 +26,7 @@ export const NotesOptions = observer(
|
|||||||
|
|
||||||
const iconClass = 'fill-current color-neutral mr-2';
|
const iconClass = 'fill-current color-neutral mr-2';
|
||||||
const buttonClass =
|
const buttonClass =
|
||||||
'flex items-center border-0 capitalize focus:inner-ring-info ' +
|
'flex items-center border-0 focus:inner-ring-info ' +
|
||||||
'cursor-pointer hover:bg-contrast color-text bg-transparent h-10 px-3 ' +
|
'cursor-pointer hover:bg-contrast color-text bg-transparent h-10 px-3 ' +
|
||||||
'text-left';
|
'text-left';
|
||||||
|
|
||||||
@@ -46,8 +40,8 @@ export const NotesOptions = observer(
|
|||||||
appState.notes.setLockSelectedNotes(!locked);
|
appState.notes.setLockSelectedNotes(!locked);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span className="capitalize flex items-center">
|
<span className="flex items-center">
|
||||||
<PencilOffIcon className={iconClass} />
|
<Icon type={IconType.PencilOff} className={iconClass} />
|
||||||
Prevent editing
|
Prevent editing
|
||||||
</span>
|
</span>
|
||||||
</Switch>
|
</Switch>
|
||||||
@@ -59,9 +53,9 @@ export const NotesOptions = observer(
|
|||||||
appState.notes.setHideSelectedNotePreviews(!hidePreviews);
|
appState.notes.setHideSelectedNotePreviews(!hidePreviews);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span className="capitalize flex items-center">
|
<span className="flex items-center">
|
||||||
<RichTextIcon className={iconClass} />
|
<Icon type={IconType.RichText} className={iconClass} />
|
||||||
Show Preview
|
Show preview
|
||||||
</span>
|
</span>
|
||||||
</Switch>
|
</Switch>
|
||||||
<div className="h-1px my-2 bg-secondary-contrast"></div>
|
<div className="h-1px my-2 bg-secondary-contrast"></div>
|
||||||
@@ -72,17 +66,8 @@ export const NotesOptions = observer(
|
|||||||
appState.notes.setPinSelectedNotes(!pinned);
|
appState.notes.setPinSelectedNotes(!pinned);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{pinned ? (
|
<Icon type={pinned ? IconType.Unpin : IconType.Pin} className={iconClass} />
|
||||||
<>
|
{pinned ? 'Unpin notes' : 'Pin notes'}
|
||||||
<UnpinIcon className={iconClass} />
|
|
||||||
Unpin notes
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<PinIcon className={iconClass} />
|
|
||||||
Pin notes
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onBlur={closeOnBlur}
|
onBlur={closeOnBlur}
|
||||||
@@ -91,17 +76,8 @@ export const NotesOptions = observer(
|
|||||||
appState.notes.setArchiveSelectedNotes(!archived);
|
appState.notes.setArchiveSelectedNotes(!archived);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{archived ? (
|
<Icon type={archived ? IconType.Unarchive : IconType.Archive} className={iconClass} />
|
||||||
<>
|
{archived ? 'Unarchive' : 'Archive'}
|
||||||
<UnarchiveIcon className={iconClass} />
|
|
||||||
Unarchive
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<ArchiveIcon className={iconClass} />
|
|
||||||
Archive
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
ref={trashButtonRef}
|
ref={trashButtonRef}
|
||||||
@@ -113,8 +89,8 @@ export const NotesOptions = observer(
|
|||||||
setLockCloseOnBlur(false);
|
setLockCloseOnBlur(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TrashIcon className={iconClass} />
|
<Icon type={IconType.Trash} className={iconClass} />
|
||||||
{trashed ? 'Restore' : 'Move to trash'}
|
{trashed ? 'Restore' : 'Move to Trash'}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export function useCloseOnBlur(
|
|||||||
|
|
||||||
export function toDirective<Props>(
|
export function toDirective<Props>(
|
||||||
component: FunctionComponent<Props>,
|
component: FunctionComponent<Props>,
|
||||||
scope: Record<string, '=' | '&'> = {}
|
scope: Record<string, '=' | '&' | '@'> = {}
|
||||||
) {
|
) {
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||||
return function () {
|
return function () {
|
||||||
|
|||||||
@@ -10,15 +10,20 @@
|
|||||||
.sn-component
|
.sn-component
|
||||||
.sk-app-bar.no-edges(
|
.sk-app-bar.no-edges(
|
||||||
ng-if='self.noteLocked',
|
ng-if='self.noteLocked',
|
||||||
ng-init="self.lockText = 'Note Editing Disabled'",
|
ng-init="self.lockText = 'Note Editing Disabled'; self.showLockedIcon = true",
|
||||||
ng-mouseleave="self.lockText = 'Note Editing Disabled'",
|
ng-mouseleave="self.lockText = 'Note Editing Disabled'; self.showLockedIcon = true",
|
||||||
ng-mouseover="self.lockText = 'Enable Editing'"
|
ng-mouseover="self.lockText = 'Enable editing'; self.showLockedIcon = false"
|
||||||
)
|
)
|
||||||
.left
|
.sk-app-bar-item(
|
||||||
.sk-app-bar-item(ng-click='self.toggleLockNote()')
|
ng-click='self.toggleLockNote()'
|
||||||
.sk-label.warning
|
)
|
||||||
i.icon.ion-locked
|
.sk-label.warning.flex.items-center
|
||||||
| {{self.lockText}}
|
icon.flex(
|
||||||
|
type="pencil-off"
|
||||||
|
class-name="fill-current mr-2"
|
||||||
|
ng-if="self.showLockedIcon"
|
||||||
|
)
|
||||||
|
| {{self.lockText}}
|
||||||
#editor-title-bar.section-title-bar.flex.items-center.justify-between.w-full(
|
#editor-title-bar.section-title-bar.flex.items-center.justify-between.w-full(
|
||||||
ng-class="{'locked' : self.noteLocked}",
|
ng-class="{'locked' : self.noteLocked}",
|
||||||
ng-show='self.note && !self.note.errorDecrypting'
|
ng-show='self.note && !self.note.errorDecrypting'
|
||||||
|
|||||||
@@ -36,6 +36,10 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.justify-start {
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
.my-2 {
|
.my-2 {
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
@@ -182,3 +186,7 @@ $border-width: 2px;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sn-component .sk-app-bar .sk-app-bar-item {
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user