Files
notesnook/packages/editor-mobile/src/components/header.tsx

499 lines
15 KiB
TypeScript
Raw Normal View History

/*
This file is part of the Notesnook project (https://notesnook.com/)
2023-01-16 13:44:52 +05:00
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2022-08-30 16:13:11 +05:00
2024-01-24 18:58:14 +05:00
import { ControlledMenu, MenuItem as MenuItemInner } from "@szhsin/react-menu";
2022-06-23 19:14:55 +05:00
import ArrowBackIcon from "mdi-react/ArrowBackIcon";
2022-07-07 18:40:05 +05:00
import ArrowULeftTopIcon from "mdi-react/ArrowULeftTopIcon";
import ArrowURightTopIcon from "mdi-react/ArrowURightTopIcon";
2023-12-21 10:14:53 +05:00
import DotsHorizontalIcon from "mdi-react/DotsHorizontalIcon";
2024-01-04 11:38:40 +05:00
import DotsVerticalIcon from "mdi-react/DotsVerticalIcon";
2022-07-11 13:00:06 +05:00
import FullscreenIcon from "mdi-react/FullscreenIcon";
2022-06-23 19:14:55 +05:00
import MagnifyIcon from "mdi-react/MagnifyIcon";
2024-03-14 10:43:25 +05:00
import PencilLockIcon from "mdi-react/PencilLockIcon";
2024-01-24 18:58:14 +05:00
import TableOfContentsIcon from "mdi-react/TableOfContentsIcon";
2024-01-04 11:38:40 +05:00
import React, { useRef, useState } from "react";
2022-06-23 19:14:55 +05:00
import { useSafeArea } from "../hooks/useSafeArea";
2023-12-21 10:14:53 +05:00
import { useTabContext, useTabStore } from "../hooks/useTabStore";
import { EventTypes, Settings } from "../utils";
2022-06-23 19:14:55 +05:00
import styles from "./styles.module.css";
2024-10-10 12:19:33 +05:00
import { strings } from "@notesnook/intl";
2024-01-24 18:58:14 +05:00
2024-01-04 11:38:40 +05:00
const menuClassName = ({ state }: any) =>
state === "opening"
? styles.menuOpening
: state === "closing"
? styles.menuClosing
: styles.menu;
const menuItemClassName = ({ hover, disabled }: any) =>
disabled
? styles.menuItemDisabled
: hover
? styles.menuItemHover
: styles.menuItem;
const MenuItem = (props: any) => (
<MenuItemInner {...props} className={menuItemClassName} />
);
2022-06-23 19:14:55 +05:00
const Button = ({
onPress,
children,
style,
2024-01-04 11:38:40 +05:00
preventDefault = true,
2024-03-14 10:43:25 +05:00
fwdRef,
onClick
2022-06-23 19:14:55 +05:00
}: {
2024-03-14 10:43:25 +05:00
onPress?: () => void;
onClick?: (event: any) => void;
2022-06-23 19:14:55 +05:00
children: React.ReactNode;
style: React.CSSProperties;
preventDefault?: boolean;
2024-01-04 11:38:40 +05:00
fwdRef?: any;
2022-06-23 19:14:55 +05:00
}) => {
return (
<button
2024-01-04 11:38:40 +05:00
ref={fwdRef}
2022-06-23 19:14:55 +05:00
className={styles.btn_header}
style={style}
2022-07-07 18:40:05 +05:00
onMouseDown={(e) => {
if (preventDefault) e.preventDefault();
2024-03-14 10:43:25 +05:00
onPress?.();
onClick?.(e);
2022-06-23 19:14:55 +05:00
}}
>
{children}
</button>
);
};
function Header({
2022-07-11 13:00:06 +05:00
noHeader,
settings,
hasUndo,
hasRedo
}: {
noHeader: boolean;
settings: Settings;
hasUndo: boolean;
hasRedo: boolean;
2022-09-20 16:05:59 +05:00
}): JSX.Element {
2023-12-21 10:14:53 +05:00
const tab = useTabContext();
const editor = editors[tab.id];
2022-07-11 13:00:06 +05:00
const insets = useSafeArea();
2023-12-21 10:14:53 +05:00
const openedTabsCount = useTabStore((state) => state.tabs.length);
2024-01-04 11:38:40 +05:00
const [isOpen, setOpen] = useState(false);
const btnRef = useRef(null);
2023-12-21 10:14:53 +05:00
2022-07-11 13:00:06 +05:00
return (
<div
style={{
display: "flex",
alignItems: "center",
height: noHeader ? `${insets.top}px` : `${50 + insets.top}px`,
global: implement the new theme engine (#2196) * mobile: theme * theme: add theme engine * mobile: migrate app colors to new theme engine * mobile: fixed some colors * mobile: fix colors * mobile: store theme info in store * theme: `ColorsType` -> `Variants` * theme: use explicit return type for `useThemeColors` * theme: add `backdrop` color * mobile: `const colors` -> `const {colors} * theme: add default pitch-black theme * mobile: manage theme state via theme-engine * mobile: add theme scopes * mobile: commit * mobile: fix button width on applock screen * mobile: fix typings * mobile: fix theme definition * web: add partial support for custom themes only context menus & popups are left. * theme: add dialog & sheet scopes * global: sync with master branch and make everything work again * mobile: fix theme-engine usage in editor & app * mobile: fix colors * mobile: fix colors * mobile: cleanup * mobile: fix status bar color incorrect on entering foreground * mobile: fix dark color scheme * web: move emotion theme provider to @notesnook/theme * editor: add support for theme enging * web: adjust hover & focus colors on list item * mobile: migrate share ext to theme engine * mobile: fix editor theme provider * clipper: add support for the new theme engine * mobile: fix statusbar color on switch from bg * misc: fix build * mobile: fix build * misc: fix colors * mobile: fix theme colors * mobile: fix bottom padding * server: add theme server * theme: add previewColors * server: support themes query pagination * mobile: add client from theme server * server: reset cache on sync repo * server: fix types * server: show ip & port on start server * server: theme updates * web: finalize new theme engine on web * editor: fix build * global: fix @emotion/react version to 11.11.1 * editor: update katex patch * web: fix imports * global: fix @trpc/* versions * global: a huge set of changes 1. get rid of ThemeVariant. All variants can now be accessed anywhere. 2. remove unnecessary button variants 3. make buttons more responsive 4. implement themes server * web: add support for theme search and theme switching * global: update lockfiles * mobile: fix error * theme: use vite-plugin-react to start theme server * web: add support for auto updating themes * mobile: update theme selector * mobile: update theme if new verison available * theme: add `isomorphic-fetch` package * global: update lockfiles * web: add theme details dialog * setup: add scope for themes server in bootstrap script * web: add production server url * web: update lockfile * web: update lockfile * mobile: remove `react-native-blob-util` * web: add support for endless scrolling in themes * web: bring back dark/light mode option in settings * web: fix colors in places * theme: add selected variant * global: use single typescript version across the projects * web: fix sort & group options not having submenus * web: apply selected variant where appropriate * ui: use unique id for all menu items * config: add ui scope for commits * theme: export button variant creation fn * web: fix only 1 theme showing in theme selector * web: fix navigation item hover & other colors * mobile: update theme * editor: fix toolbar group alignments * editor: set theme provider at app level * theme: use scope name to get current scope * mobile: fix color usage in message card * theme: remove caching * editor: bring back icons in table menus * theme: use zustand to manage theme engine state * web: fix login/signup theming * mobile: fix webpack build * misc: remove ThemeProvider usage * editor: adjust theming and styling of editor toolbar * mobile: refactor * editor: fix toolbar group padding everywhere * web: fix settings sidebar is not scrollable * web: add loading indicator for themes loading * mobile: fix warning * mobile: fix ui issues * web: fix Loader errors on build * theme: add getPreviewColors & validateTheme * theme: fix theme validation * mobile: load theme from file * mobile: fix share extension crash * mobile: rename state * theme: add sourceURL property * theme: refactor theme-engine * web: add support for loading theme from file * web: improve button hover interaction * mobile: fix floating button color * mobile: update theme * mobile: fix border radius of context menu * mobile: set sheet overlay color to theme backdrop * mobile: set sidemenu backdrop to theme backdrop --------- Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
2023-08-01 12:07:21 +05:00
backgroundColor: "var(--nn_primary_background)",
2022-07-11 13:00:06 +05:00
position: "sticky",
2024-01-04 11:38:40 +05:00
width: "100vw",
zIndex: 99999
2022-07-11 13:00:06 +05:00
}}
>
{noHeader ? null : (
<div
style={{
display: "flex",
width: "100%",
justifyContent: "space-between",
flexDirection: "row",
paddingTop: insets.top,
height: 50,
alignItems: "center"
}}
2022-12-16 22:28:30 +05:00
id="header"
2022-07-11 13:00:06 +05:00
>
{settings.deviceMode !== "mobile" && !settings.fullscreen ? (
<div />
) : (
2022-06-23 19:14:55 +05:00
<Button
onPress={() => {
2023-12-21 10:14:53 +05:00
post(EventTypes.back, undefined, tab.id, tab.noteId);
2022-06-23 19:14:55 +05:00
}}
preventDefault={false}
2022-06-23 19:14:55 +05:00
style={{
borderWidth: 0,
borderRadius: 100,
global: implement the new theme engine (#2196) * mobile: theme * theme: add theme engine * mobile: migrate app colors to new theme engine * mobile: fixed some colors * mobile: fix colors * mobile: store theme info in store * theme: `ColorsType` -> `Variants` * theme: use explicit return type for `useThemeColors` * theme: add `backdrop` color * mobile: `const colors` -> `const {colors} * theme: add default pitch-black theme * mobile: manage theme state via theme-engine * mobile: add theme scopes * mobile: commit * mobile: fix button width on applock screen * mobile: fix typings * mobile: fix theme definition * web: add partial support for custom themes only context menus & popups are left. * theme: add dialog & sheet scopes * global: sync with master branch and make everything work again * mobile: fix theme-engine usage in editor & app * mobile: fix colors * mobile: fix colors * mobile: cleanup * mobile: fix status bar color incorrect on entering foreground * mobile: fix dark color scheme * web: move emotion theme provider to @notesnook/theme * editor: add support for theme enging * web: adjust hover & focus colors on list item * mobile: migrate share ext to theme engine * mobile: fix editor theme provider * clipper: add support for the new theme engine * mobile: fix statusbar color on switch from bg * misc: fix build * mobile: fix build * misc: fix colors * mobile: fix theme colors * mobile: fix bottom padding * server: add theme server * theme: add previewColors * server: support themes query pagination * mobile: add client from theme server * server: reset cache on sync repo * server: fix types * server: show ip & port on start server * server: theme updates * web: finalize new theme engine on web * editor: fix build * global: fix @emotion/react version to 11.11.1 * editor: update katex patch * web: fix imports * global: fix @trpc/* versions * global: a huge set of changes 1. get rid of ThemeVariant. All variants can now be accessed anywhere. 2. remove unnecessary button variants 3. make buttons more responsive 4. implement themes server * web: add support for theme search and theme switching * global: update lockfiles * mobile: fix error * theme: use vite-plugin-react to start theme server * web: add support for auto updating themes * mobile: update theme selector * mobile: update theme if new verison available * theme: add `isomorphic-fetch` package * global: update lockfiles * web: add theme details dialog * setup: add scope for themes server in bootstrap script * web: add production server url * web: update lockfile * web: update lockfile * mobile: remove `react-native-blob-util` * web: add support for endless scrolling in themes * web: bring back dark/light mode option in settings * web: fix colors in places * theme: add selected variant * global: use single typescript version across the projects * web: fix sort & group options not having submenus * web: apply selected variant where appropriate * ui: use unique id for all menu items * config: add ui scope for commits * theme: export button variant creation fn * web: fix only 1 theme showing in theme selector * web: fix navigation item hover & other colors * mobile: update theme * editor: fix toolbar group alignments * editor: set theme provider at app level * theme: use scope name to get current scope * mobile: fix color usage in message card * theme: remove caching * editor: bring back icons in table menus * theme: use zustand to manage theme engine state * web: fix login/signup theming * mobile: fix webpack build * misc: remove ThemeProvider usage * editor: adjust theming and styling of editor toolbar * mobile: refactor * editor: fix toolbar group padding everywhere * web: fix settings sidebar is not scrollable * web: add loading indicator for themes loading * mobile: fix warning * mobile: fix ui issues * web: fix Loader errors on build * theme: add getPreviewColors & validateTheme * theme: fix theme validation * mobile: load theme from file * mobile: fix share extension crash * mobile: rename state * theme: add sourceURL property * theme: refactor theme-engine * web: add support for loading theme from file * web: improve button hover interaction * mobile: fix floating button color * mobile: update theme * mobile: fix border radius of context menu * mobile: set sheet overlay color to theme backdrop * mobile: set sidemenu backdrop to theme backdrop --------- Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
2023-08-01 12:07:21 +05:00
color: "var(--nn_primary_icon)",
2022-06-30 09:47:04 +05:00
marginLeft: 6,
width: 40,
height: 40,
2022-06-23 19:14:55 +05:00
display: "flex",
justifyContent: "center",
2022-07-09 15:51:25 +05:00
alignItems: "center",
flexDirection: "column",
2022-07-09 15:51:25 +05:00
position: "relative"
2022-06-23 19:14:55 +05:00
}}
>
2022-07-09 15:51:25 +05:00
<ArrowBackIcon
2023-12-21 10:14:53 +05:00
size={28 * settings.fontScale}
2022-07-09 15:51:25 +05:00
style={{
position: "absolute"
}}
color="var(--nn_primary_icon)"
2022-07-09 15:51:25 +05:00
/>
2022-06-23 19:14:55 +05:00
</Button>
2022-07-11 13:00:06 +05:00
)}
2022-06-23 19:14:55 +05:00
2022-07-11 13:00:06 +05:00
<div
style={{
display: "flex",
alignItems: "center",
flexDirection: "row"
}}
>
2024-06-01 12:38:13 +05:00
{tab.locked ? null : (
<>
<Button
onPress={() => {
editor?.commands.undo();
}}
2022-07-09 15:51:25 +05:00
style={{
2024-06-01 12:38:13 +05:00
borderWidth: 0,
borderRadius: 100,
color: "var(--nn_primary_icon)",
marginRight: 10,
width: 39,
height: 39,
display: "flex",
justifyContent: "center",
alignItems: "center",
position: "relative"
2022-07-09 15:51:25 +05:00
}}
2024-06-01 12:38:13 +05:00
>
<ArrowULeftTopIcon
color={
!hasUndo
? "var(--nn_secondary_border)"
: "var(--nn_primary_icon)"
}
size={25 * settings.fontScale}
style={{
position: "absolute"
}}
/>
</Button>
<Button
onPress={() => {
if (tab.locked) return;
editor?.commands.redo();
}}
style={{
borderWidth: 0,
borderRadius: 100,
color: "var(--nn_primary_icon)",
marginRight: 10,
width: 39,
height: 39,
display: "flex",
justifyContent: "center",
alignItems: "center",
position: "relative"
}}
>
<ArrowURightTopIcon
color={
!hasRedo
? "var(--nn_secondary_border)"
: "var(--nn_primary_icon)"
}
size={25 * settings.fontScale}
style={{
position: "absolute"
}}
/>
</Button>
</>
2022-07-11 13:00:06 +05:00
)}
{settings.deviceMode !== "mobile" && !settings.fullscreen ? (
2022-06-30 09:47:04 +05:00
<Button
onPress={() => {
2023-12-21 10:14:53 +05:00
post(EventTypes.fullscreen, undefined, tab.id, tab.noteId);
2022-06-30 09:47:04 +05:00
}}
preventDefault={false}
2022-06-30 09:47:04 +05:00
style={{
borderWidth: 0,
borderRadius: 100,
global: implement the new theme engine (#2196) * mobile: theme * theme: add theme engine * mobile: migrate app colors to new theme engine * mobile: fixed some colors * mobile: fix colors * mobile: store theme info in store * theme: `ColorsType` -> `Variants` * theme: use explicit return type for `useThemeColors` * theme: add `backdrop` color * mobile: `const colors` -> `const {colors} * theme: add default pitch-black theme * mobile: manage theme state via theme-engine * mobile: add theme scopes * mobile: commit * mobile: fix button width on applock screen * mobile: fix typings * mobile: fix theme definition * web: add partial support for custom themes only context menus & popups are left. * theme: add dialog & sheet scopes * global: sync with master branch and make everything work again * mobile: fix theme-engine usage in editor & app * mobile: fix colors * mobile: fix colors * mobile: cleanup * mobile: fix status bar color incorrect on entering foreground * mobile: fix dark color scheme * web: move emotion theme provider to @notesnook/theme * editor: add support for theme enging * web: adjust hover & focus colors on list item * mobile: migrate share ext to theme engine * mobile: fix editor theme provider * clipper: add support for the new theme engine * mobile: fix statusbar color on switch from bg * misc: fix build * mobile: fix build * misc: fix colors * mobile: fix theme colors * mobile: fix bottom padding * server: add theme server * theme: add previewColors * server: support themes query pagination * mobile: add client from theme server * server: reset cache on sync repo * server: fix types * server: show ip & port on start server * server: theme updates * web: finalize new theme engine on web * editor: fix build * global: fix @emotion/react version to 11.11.1 * editor: update katex patch * web: fix imports * global: fix @trpc/* versions * global: a huge set of changes 1. get rid of ThemeVariant. All variants can now be accessed anywhere. 2. remove unnecessary button variants 3. make buttons more responsive 4. implement themes server * web: add support for theme search and theme switching * global: update lockfiles * mobile: fix error * theme: use vite-plugin-react to start theme server * web: add support for auto updating themes * mobile: update theme selector * mobile: update theme if new verison available * theme: add `isomorphic-fetch` package * global: update lockfiles * web: add theme details dialog * setup: add scope for themes server in bootstrap script * web: add production server url * web: update lockfile * web: update lockfile * mobile: remove `react-native-blob-util` * web: add support for endless scrolling in themes * web: bring back dark/light mode option in settings * web: fix colors in places * theme: add selected variant * global: use single typescript version across the projects * web: fix sort & group options not having submenus * web: apply selected variant where appropriate * ui: use unique id for all menu items * config: add ui scope for commits * theme: export button variant creation fn * web: fix only 1 theme showing in theme selector * web: fix navigation item hover & other colors * mobile: update theme * editor: fix toolbar group alignments * editor: set theme provider at app level * theme: use scope name to get current scope * mobile: fix color usage in message card * theme: remove caching * editor: bring back icons in table menus * theme: use zustand to manage theme engine state * web: fix login/signup theming * mobile: fix webpack build * misc: remove ThemeProvider usage * editor: adjust theming and styling of editor toolbar * mobile: refactor * editor: fix toolbar group padding everywhere * web: fix settings sidebar is not scrollable * web: add loading indicator for themes loading * mobile: fix warning * mobile: fix ui issues * web: fix Loader errors on build * theme: add getPreviewColors & validateTheme * theme: fix theme validation * mobile: load theme from file * mobile: fix share extension crash * mobile: rename state * theme: add sourceURL property * theme: refactor theme-engine * web: add support for loading theme from file * web: improve button hover interaction * mobile: fix floating button color * mobile: update theme * mobile: fix border radius of context menu * mobile: set sheet overlay color to theme backdrop * mobile: set sidemenu backdrop to theme backdrop --------- Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
2023-08-01 12:07:21 +05:00
color: "var(--nn_primary_icon)",
2022-06-30 09:47:04 +05:00
marginRight: 10,
width: 39,
height: 39,
display: "flex",
justifyContent: "center",
alignItems: "center",
2022-07-09 15:51:25 +05:00
position: "relative"
2022-06-30 09:47:04 +05:00
}}
>
2022-07-11 13:00:06 +05:00
<FullscreenIcon
2023-09-15 14:59:52 +05:00
size={25 * settings.fontScale}
2022-07-09 15:51:25 +05:00
style={{
position: "absolute"
}}
color="var(--nn_primary_icon)"
2022-07-09 15:51:25 +05:00
/>
2022-06-30 09:47:04 +05:00
</Button>
2022-07-11 13:00:06 +05:00
) : null}
2022-06-30 09:47:04 +05:00
2024-03-14 10:43:25 +05:00
{tab.readonly ? (
<Button
onPress={() => {
post(
"editor-events:disable-readonly-mode",
useTabStore
.getState()
.getNoteIdForTab(useTabStore.getState().currentTab)
);
}}
fwdRef={btnRef}
preventDefault={false}
style={{
borderWidth: 0,
borderRadius: 100,
color: "var(--nn_primary_accent)",
marginRight: 12,
width: 39,
height: 39,
display: "flex",
justifyContent: "center",
alignItems: "center",
position: "relative"
}}
>
<PencilLockIcon
size={25 * settings.fontScale}
style={{
position: "absolute"
}}
color="var(--nn_primary_accent)"
/>
</Button>
) : null}
2022-07-11 13:00:06 +05:00
<Button
onPress={() => {
2023-12-21 10:14:53 +05:00
post(EventTypes.showTabs, undefined, tab.id, tab.noteId);
}}
preventDefault={false}
style={{
borderWidth: 0,
borderRadius: 100,
color: "var(--nn_primary_icon)",
marginRight: 12,
width: 39,
height: 39,
display: "flex",
justifyContent: "center",
alignItems: "center",
position: "relative"
}}
>
<div
style={{
border: "2px solid var(--nn_primary_icon)",
2024-01-24 18:58:14 +05:00
width: 19 * settings.fontScale,
height: 19 * settings.fontScale,
minWidth: 19 * settings.fontScale,
2023-12-21 10:14:53 +05:00
borderRadius: 5,
display: "flex",
justifyContent: "center",
alignItems: "center"
}}
>
<p
style={{
fontSize:
openedTabsCount > 100
? 10 * settings.fontScale
: 12 * settings.fontScale
2023-12-21 10:14:53 +05:00
}}
>
{openedTabsCount}
</p>
</div>
</Button>
<Button
2024-03-14 10:43:25 +05:00
fwdRef={btnRef}
2023-12-21 10:14:53 +05:00
onPress={() => {
2024-06-01 12:38:13 +05:00
if (tab.locked) {
post(EventTypes.properties, undefined, tab.id, tab.noteId);
} else {
setOpen(!isOpen);
}
2022-07-11 13:00:06 +05:00
}}
preventDefault={false}
style={{
borderWidth: 0,
borderRadius: 100,
global: implement the new theme engine (#2196) * mobile: theme * theme: add theme engine * mobile: migrate app colors to new theme engine * mobile: fixed some colors * mobile: fix colors * mobile: store theme info in store * theme: `ColorsType` -> `Variants` * theme: use explicit return type for `useThemeColors` * theme: add `backdrop` color * mobile: `const colors` -> `const {colors} * theme: add default pitch-black theme * mobile: manage theme state via theme-engine * mobile: add theme scopes * mobile: commit * mobile: fix button width on applock screen * mobile: fix typings * mobile: fix theme definition * web: add partial support for custom themes only context menus & popups are left. * theme: add dialog & sheet scopes * global: sync with master branch and make everything work again * mobile: fix theme-engine usage in editor & app * mobile: fix colors * mobile: fix colors * mobile: cleanup * mobile: fix status bar color incorrect on entering foreground * mobile: fix dark color scheme * web: move emotion theme provider to @notesnook/theme * editor: add support for theme enging * web: adjust hover & focus colors on list item * mobile: migrate share ext to theme engine * mobile: fix editor theme provider * clipper: add support for the new theme engine * mobile: fix statusbar color on switch from bg * misc: fix build * mobile: fix build * misc: fix colors * mobile: fix theme colors * mobile: fix bottom padding * server: add theme server * theme: add previewColors * server: support themes query pagination * mobile: add client from theme server * server: reset cache on sync repo * server: fix types * server: show ip & port on start server * server: theme updates * web: finalize new theme engine on web * editor: fix build * global: fix @emotion/react version to 11.11.1 * editor: update katex patch * web: fix imports * global: fix @trpc/* versions * global: a huge set of changes 1. get rid of ThemeVariant. All variants can now be accessed anywhere. 2. remove unnecessary button variants 3. make buttons more responsive 4. implement themes server * web: add support for theme search and theme switching * global: update lockfiles * mobile: fix error * theme: use vite-plugin-react to start theme server * web: add support for auto updating themes * mobile: update theme selector * mobile: update theme if new verison available * theme: add `isomorphic-fetch` package * global: update lockfiles * web: add theme details dialog * setup: add scope for themes server in bootstrap script * web: add production server url * web: update lockfile * web: update lockfile * mobile: remove `react-native-blob-util` * web: add support for endless scrolling in themes * web: bring back dark/light mode option in settings * web: fix colors in places * theme: add selected variant * global: use single typescript version across the projects * web: fix sort & group options not having submenus * web: apply selected variant where appropriate * ui: use unique id for all menu items * config: add ui scope for commits * theme: export button variant creation fn * web: fix only 1 theme showing in theme selector * web: fix navigation item hover & other colors * mobile: update theme * editor: fix toolbar group alignments * editor: set theme provider at app level * theme: use scope name to get current scope * mobile: fix color usage in message card * theme: remove caching * editor: bring back icons in table menus * theme: use zustand to manage theme engine state * web: fix login/signup theming * mobile: fix webpack build * misc: remove ThemeProvider usage * editor: adjust theming and styling of editor toolbar * mobile: refactor * editor: fix toolbar group padding everywhere * web: fix settings sidebar is not scrollable * web: add loading indicator for themes loading * mobile: fix warning * mobile: fix ui issues * web: fix Loader errors on build * theme: add getPreviewColors & validateTheme * theme: fix theme validation * mobile: load theme from file * mobile: fix share extension crash * mobile: rename state * theme: add sourceURL property * theme: refactor theme-engine * web: add support for loading theme from file * web: improve button hover interaction * mobile: fix floating button color * mobile: update theme * mobile: fix border radius of context menu * mobile: set sheet overlay color to theme backdrop * mobile: set sidemenu backdrop to theme backdrop --------- Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
2023-08-01 12:07:21 +05:00
color: "var(--nn_primary_icon)",
2022-07-11 13:00:06 +05:00
marginRight: 12,
width: 39,
height: 39,
display: "flex",
justifyContent: "center",
alignItems: "center",
position: "relative"
}}
>
2024-06-01 12:38:13 +05:00
{tab.locked ? (
<DotsHorizontalIcon
size={25 * settings.fontScale}
style={{
position: "absolute"
}}
color="var(--nn_primary_icon)"
/>
) : (
<DotsVerticalIcon
size={25 * settings.fontScale}
style={{
position: "absolute"
}}
color="var(--nn_primary_icon)"
/>
)}
2022-07-11 13:00:06 +05:00
</Button>
2024-01-04 11:38:40 +05:00
<ControlledMenu
align="end"
2024-04-29 20:07:19 +05:00
anchorPoint={{
x: window.innerWidth - 10,
y: 70
}}
2024-01-04 11:38:40 +05:00
state={isOpen ? "open" : "closed"}
menuClassName={menuClassName}
onClose={() => {
setOpen(false);
}}
autoFocus={false}
onItemClick={(e) => {
switch (e.value) {
case "toc":
post(
EventTypes.toc,
editorControllers[tab.id]?.getTableOfContents(),
tab.id,
tab.noteId
);
break;
2024-06-01 12:38:13 +05:00
case "search":
editor?.commands.startSearch();
break;
2024-01-04 11:38:40 +05:00
case "properties":
logger("info", "post properties...");
post(EventTypes.properties, undefined, tab.id, tab.noteId);
break;
default:
break;
}
}}
>
2024-06-01 12:38:13 +05:00
<MenuItem
value="search"
2024-01-24 18:58:14 +05:00
style={{
display: "flex",
2024-06-01 12:38:13 +05:00
gap: 10,
alignItems: "center"
2024-01-24 18:58:14 +05:00
}}
>
2024-06-01 12:38:13 +05:00
<MagnifyIcon
size={22 * settings.fontScale}
color="var(--nn_primary_icon)"
/>
<span
2024-01-24 18:58:14 +05:00
style={{
2024-06-01 12:38:13 +05:00
color: "var(--nn_primary_paragraph)"
2024-01-24 18:58:14 +05:00
}}
>
2024-10-10 12:19:33 +05:00
{strings.search()}
2024-06-01 12:38:13 +05:00
</span>
</MenuItem>
2024-01-24 18:58:14 +05:00
2024-01-04 11:38:40 +05:00
<MenuItem
value="toc"
style={{
display: "flex",
2024-06-01 12:38:13 +05:00
gap: 10,
alignItems: "center"
2024-01-04 11:38:40 +05:00
}}
>
<TableOfContentsIcon
size={22 * settings.fontScale}
color="var(--nn_primary_icon)"
2024-01-04 11:38:40 +05:00
/>
2024-06-01 12:38:13 +05:00
<span
style={{
color: "var(--nn_primary_paragraph)"
}}
>
2024-10-10 12:19:33 +05:00
{strings.toc()}
2024-06-01 12:38:13 +05:00
</span>
2024-01-04 11:38:40 +05:00
</MenuItem>
<MenuItem
value="properties"
style={{
display: "flex",
2024-06-01 12:38:13 +05:00
gap: 10,
alignItems: "center"
2024-01-04 11:38:40 +05:00
}}
>
<DotsHorizontalIcon
size={22 * settings.fontScale}
color="var(--nn_primary_icon)"
2024-01-04 11:38:40 +05:00
/>
2024-06-01 12:38:13 +05:00
<span
style={{
color: "var(--nn_primary_paragraph)"
}}
>
2024-10-10 12:19:33 +05:00
{strings.properties()}
2024-06-01 12:38:13 +05:00
</span>
2024-01-04 11:38:40 +05:00
</MenuItem>
</ControlledMenu>
2022-06-30 09:47:04 +05:00
</div>
2022-07-11 13:00:06 +05:00
</div>
)}
</div>
);
}
export default React.memo(Header, (prev, next) => {
if (
prev.settings.deviceMode !== next.settings.deviceMode ||
prev.settings.fullscreen !== next.settings.fullscreen ||
prev.settings.premium !== next.settings.premium ||
2023-09-15 14:59:52 +05:00
prev.settings.fontScale !== next.settings.fontScale ||
prev.noHeader !== next.noHeader ||
prev.hasRedo !== next.hasRedo ||
prev.hasUndo !== next.hasUndo
)
return false;
return true;
});