mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
ran prettier over project
This commit is contained in:
parent
4a29e11079
commit
e3be5924bf
27 changed files with 286 additions and 282 deletions
|
@ -94,7 +94,7 @@
|
||||||
"husky": "^7.0.4",
|
"husky": "^7.0.4",
|
||||||
"lint-staged": "^12.1.6",
|
"lint-staged": "^12.1.6",
|
||||||
"next-transpile-modules": "^9.0.0",
|
"next-transpile-modules": "^9.0.0",
|
||||||
"prettier": "^1.18.2"
|
"prettier": "^2.7.1"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"./**/*.{js,jsx,ts,tsx}": [
|
"./**/*.{js,jsx,ts,tsx}": [
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import React, { FC } from "react";
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
import { useAuth } from "~/hooks/auth/useAuth";
|
import { useAuth } from '~/hooks/auth/useAuth';
|
||||||
|
|
||||||
interface IProps {}
|
interface IProps {}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import React, { FC } from "react";
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
import classNames from "classnames";
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface ZoneProps {
|
interface ZoneProps {
|
||||||
title?: string;
|
title?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
color?: "danger" | "normal";
|
color?: 'danger' | 'normal';
|
||||||
}
|
}
|
||||||
|
|
||||||
const Zone: FC<ZoneProps> = ({
|
const Zone: FC<ZoneProps> = ({
|
||||||
title,
|
title,
|
||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
color = "normal",
|
color = 'normal',
|
||||||
}) => (
|
}) => (
|
||||||
<div
|
<div
|
||||||
className={classNames(className, styles.pad, styles[color], {
|
className={classNames(className, styles.pad, styles[color], {
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import React, { FC } from "react";
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
import { Filler } from "~/components/containers/Filler";
|
import { Filler } from '~/components/containers/Filler';
|
||||||
import { Group } from "~/components/containers/Group";
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Padder } from "~/components/containers/Padder";
|
import { Padder } from '~/components/containers/Padder';
|
||||||
import { EditorActionsPanel } from "~/components/editors/EditorActionsPanel";
|
import { EditorActionsPanel } from '~/components/editors/EditorActionsPanel';
|
||||||
import { Button } from "~/components/input/Button";
|
import { Button } from '~/components/input/Button';
|
||||||
import { InputText } from "~/components/input/InputText";
|
import { InputText } from '~/components/input/InputText';
|
||||||
import { useWindowSize } from "~/hooks/dom/useWindowSize";
|
import { useWindowSize } from '~/hooks/dom/useWindowSize';
|
||||||
import { useNodeFormContext } from "~/hooks/node/useNodeFormFormik";
|
import { useNodeFormContext } from '~/hooks/node/useNodeFormFormik';
|
||||||
|
|
||||||
const EditorButtons: FC = () => {
|
const EditorButtons: FC = () => {
|
||||||
const { values, handleChange, isSubmitting } = useNodeFormContext();
|
const { values, handleChange, isSubmitting } = useNodeFormContext();
|
||||||
const { isTablet } = useWindowSize();
|
const { isTablet } = useWindowSize();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Padder style={{ position: "relative" }}>
|
<Padder style={{ position: 'relative' }}>
|
||||||
<EditorActionsPanel />
|
<EditorActionsPanel />
|
||||||
|
|
||||||
<Group horizontal>
|
<Group horizontal>
|
||||||
|
@ -22,7 +22,7 @@ const EditorButtons: FC = () => {
|
||||||
<InputText
|
<InputText
|
||||||
title="Название"
|
title="Название"
|
||||||
value={values.title}
|
value={values.title}
|
||||||
handler={handleChange("title")}
|
handler={handleChange('title')}
|
||||||
autoFocus={!isTablet}
|
autoFocus={!isTablet}
|
||||||
maxLength={256}
|
maxLength={256}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
|
@ -30,9 +30,9 @@ const EditorButtons: FC = () => {
|
||||||
</Filler>
|
</Filler>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
title={isTablet ? undefined : "Сохранить"}
|
title={isTablet ? undefined : 'Сохранить'}
|
||||||
iconRight="check"
|
iconRight="check"
|
||||||
color={values.is_promoted ? "primary" : "lab"}
|
color={values.is_promoted ? 'primary' : 'lab'}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
type="submit"
|
type="submit"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import React, { FC, useCallback } from "react";
|
import React, { FC, useCallback } from 'react';
|
||||||
|
|
||||||
import { SortableImageGrid } from "~/components/sortable";
|
import { SortableImageGrid } from '~/components/sortable';
|
||||||
import { useWindowSize } from "~/hooks/dom/useWindowSize";
|
import { useWindowSize } from '~/hooks/dom/useWindowSize';
|
||||||
import { UploadStatus } from "~/store/uploader/UploaderStore";
|
import { UploadStatus } from '~/store/uploader/UploaderStore';
|
||||||
import { IFile } from "~/types";
|
import { IFile } from '~/types';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
files: IFile[];
|
files: IFile[];
|
||||||
|
@ -22,7 +22,7 @@ const ImageGrid: FC<IProps> = ({ files, setFiles, locked }) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const onDrop = useCallback(
|
const onDrop = useCallback(
|
||||||
(id: IFile["id"]) => {
|
(id: IFile['id']) => {
|
||||||
setFiles(files.filter(file => file && file.id !== id));
|
setFiles(files.filter(file => file && file.id !== id));
|
||||||
},
|
},
|
||||||
[setFiles, files],
|
[setFiles, files],
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
import React, { FC, useMemo } from "react";
|
import React, { FC, useMemo } from 'react';
|
||||||
|
|
||||||
import classNames from "classnames";
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { Anchor } from "~/components/common/Anchor";
|
import { Anchor } from '~/components/common/Anchor';
|
||||||
import { MenuDots } from "~/components/common/MenuDots";
|
import { MenuDots } from '~/components/common/MenuDots';
|
||||||
import { CellShade } from "~/components/flow/CellShade";
|
import { CellShade } from '~/components/flow/CellShade';
|
||||||
import { FlowCellImage } from "~/components/flow/FlowCellImage";
|
import { FlowCellImage } from '~/components/flow/FlowCellImage';
|
||||||
import { FlowCellMenu } from "~/components/flow/FlowCellMenu";
|
import { FlowCellMenu } from '~/components/flow/FlowCellMenu';
|
||||||
import { FlowCellText } from "~/components/flow/FlowCellText";
|
import { FlowCellText } from '~/components/flow/FlowCellText';
|
||||||
import { useClickOutsideFocus } from "~/hooks/dom/useClickOutsideFocus";
|
import { useClickOutsideFocus } from '~/hooks/dom/useClickOutsideFocus';
|
||||||
import { useWindowSize } from "~/hooks/dom/useWindowSize";
|
import { useWindowSize } from '~/hooks/dom/useWindowSize';
|
||||||
import { useFlowCellControls } from "~/hooks/flow/useFlowCellControls";
|
import { useFlowCellControls } from '~/hooks/flow/useFlowCellControls';
|
||||||
import { FlowDisplay, INode } from "~/types";
|
import { FlowDisplay, INode } from '~/types';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
id: INode["id"];
|
id: INode['id'];
|
||||||
to: string;
|
to: string;
|
||||||
title: string;
|
title: string;
|
||||||
image?: string;
|
image?: string;
|
||||||
|
@ -25,7 +25,7 @@ interface Props {
|
||||||
text?: string;
|
text?: string;
|
||||||
flow: FlowDisplay;
|
flow: FlowDisplay;
|
||||||
canEdit?: boolean;
|
canEdit?: boolean;
|
||||||
onChangeCellView: (id: INode["id"], flow: FlowDisplay) => void;
|
onChangeCellView: (id: INode['id'], flow: FlowDisplay) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FlowCell: FC<Props> = ({
|
const FlowCell: FC<Props> = ({
|
||||||
|
@ -42,7 +42,7 @@ const FlowCell: FC<Props> = ({
|
||||||
const { isTablet } = useWindowSize();
|
const { isTablet } = useWindowSize();
|
||||||
|
|
||||||
const withText =
|
const withText =
|
||||||
((!!flow.display && flow.display !== "single") || !image) &&
|
((!!flow.display && flow.display !== 'single') || !image) &&
|
||||||
flow.show_description &&
|
flow.show_description &&
|
||||||
!!text;
|
!!text;
|
||||||
const {
|
const {
|
||||||
|
@ -68,11 +68,11 @@ const FlowCell: FC<Props> = ({
|
||||||
}, [withText, isTablet]);
|
}, [withText, isTablet]);
|
||||||
|
|
||||||
const shadeAngle = useMemo(() => {
|
const shadeAngle = useMemo(() => {
|
||||||
if (flow.display === "vertical") {
|
if (flow.display === 'vertical') {
|
||||||
return 9;
|
return 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flow.display === "horizontal") {
|
if (flow.display === 'horizontal') {
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ const FlowCell: FC<Props> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.cell, styles[flow.display || "single"])}
|
className={classNames(styles.cell, styles[flow.display || 'single'])}
|
||||||
ref={ref as any}
|
ref={ref as any}
|
||||||
>
|
>
|
||||||
{canEdit && !isMenuActive && (
|
{canEdit && !isMenuActive && (
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
import React, { FC, useCallback, useMemo, useState } from "react";
|
import React, { FC, useCallback, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import classNames from "classnames";
|
import classNames from 'classnames';
|
||||||
import SwiperCore, { Autoplay, EffectFade, Lazy, Navigation } from "swiper";
|
import SwiperCore, { Autoplay, EffectFade, Lazy, Navigation } from 'swiper';
|
||||||
import { Swiper, SwiperSlide } from "swiper/react";
|
import { Swiper, SwiperSlide } from 'swiper/react';
|
||||||
import SwiperClass from "swiper/types/swiper-class";
|
import SwiperClass from 'swiper/types/swiper-class';
|
||||||
|
|
||||||
import { Icon } from "~/components/input/Icon";
|
import { Icon } from '~/components/input/Icon';
|
||||||
import { LoaderCircle } from "~/components/input/LoaderCircle";
|
import { LoaderCircle } from '~/components/input/LoaderCircle';
|
||||||
import { ImagePresets, URLS } from "~/constants/urls";
|
import { ImagePresets, URLS } from '~/constants/urls';
|
||||||
import { useWindowSize } from "~/hooks/dom/useWindowSize";
|
import { useWindowSize } from '~/hooks/dom/useWindowSize';
|
||||||
import { useNavigation } from "~/hooks/navigation/useNavigation";
|
import { useNavigation } from '~/hooks/navigation/useNavigation';
|
||||||
import { IFlowNode } from "~/types";
|
import { IFlowNode } from '~/types';
|
||||||
import { getURLFromString } from "~/utils/dom";
|
import { getURLFromString } from '~/utils/dom';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
SwiperCore.use([EffectFade, Lazy, Autoplay, Navigation]);
|
SwiperCore.use([EffectFade, Lazy, Autoplay, Navigation]);
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ export const FlowSwiperHero: FC<Props> = ({ heroes }) => {
|
||||||
<img
|
<img
|
||||||
src={getURLFromString(node.thumbnail!, preset)}
|
src={getURLFromString(node.thumbnail!, preset)}
|
||||||
alt=""
|
alt=""
|
||||||
className={classNames(styles.preview, "swiper-lazy")}
|
className={classNames(styles.preview, 'swiper-lazy')}
|
||||||
/>
|
/>
|
||||||
</SwiperSlide>
|
</SwiperSlide>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import React, { VFC } from "react";
|
import React, { VFC } from 'react';
|
||||||
|
|
||||||
import Tippy from "@tippyjs/react";
|
import Tippy from '@tippyjs/react';
|
||||||
|
|
||||||
import { Icon } from "~/components/input/Icon";
|
import { Icon } from '~/components/input/Icon';
|
||||||
import { MenuButton, MenuItemWithIcon, SeparatedMenu } from "~/components/menu";
|
import { MenuButton, MenuItemWithIcon, SeparatedMenu } from '~/components/menu';
|
||||||
import { useWindowSize } from "~/hooks/dom/useWindowSize";
|
import { useWindowSize } from '~/hooks/dom/useWindowSize';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface NodeEditMenuProps {
|
interface NodeEditMenuProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
@ -40,10 +40,10 @@ const NodeEditMenu: VFC<NodeEditMenuProps> = ({
|
||||||
>
|
>
|
||||||
{canStar && (
|
{canStar && (
|
||||||
<MenuItemWithIcon
|
<MenuItemWithIcon
|
||||||
icon={isHeroic ? "star_full" : "star"}
|
icon={isHeroic ? 'star_full' : 'star'}
|
||||||
onClick={onStar}
|
onClick={onStar}
|
||||||
>
|
>
|
||||||
{isHeroic ? "Убрать с главной" : "На главную"}
|
{isHeroic ? 'Убрать с главной' : 'На главную'}
|
||||||
</MenuItemWithIcon>
|
</MenuItemWithIcon>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
@ -52,10 +52,10 @@ const NodeEditMenu: VFC<NodeEditMenuProps> = ({
|
||||||
</MenuItemWithIcon>
|
</MenuItemWithIcon>
|
||||||
|
|
||||||
<MenuItemWithIcon
|
<MenuItemWithIcon
|
||||||
icon={isLocked ? "locked" : "unlocked"}
|
icon={isLocked ? 'locked' : 'unlocked'}
|
||||||
onClick={onLock}
|
onClick={onLock}
|
||||||
>
|
>
|
||||||
{isLocked ? "Восстановить" : "Удалить"}
|
{isLocked ? 'Восстановить' : 'Удалить'}
|
||||||
</MenuItemWithIcon>
|
</MenuItemWithIcon>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
);
|
);
|
||||||
|
@ -64,9 +64,9 @@ const NodeEditMenu: VFC<NodeEditMenuProps> = ({
|
||||||
return (
|
return (
|
||||||
<SeparatedMenu>
|
<SeparatedMenu>
|
||||||
{canStar && (
|
{canStar && (
|
||||||
<Tippy content={isHeroic ? "Убрать с главной" : "На главную"}>
|
<Tippy content={isHeroic ? 'Убрать с главной' : 'На главную'}>
|
||||||
<button className={className} onClick={onStar}>
|
<button className={className} onClick={onStar}>
|
||||||
<Icon icon={isHeroic ? "star_full" : "star"} size={24} />
|
<Icon icon={isHeroic ? 'star_full' : 'star'} size={24} />
|
||||||
</button>
|
</button>
|
||||||
</Tippy>
|
</Tippy>
|
||||||
)}
|
)}
|
||||||
|
@ -77,9 +77,9 @@ const NodeEditMenu: VFC<NodeEditMenuProps> = ({
|
||||||
</button>
|
</button>
|
||||||
</Tippy>
|
</Tippy>
|
||||||
|
|
||||||
<Tippy content={isLocked ? "Восстановить" : "Удалить"}>
|
<Tippy content={isLocked ? 'Восстановить' : 'Удалить'}>
|
||||||
<button className={className} onClick={onLock}>
|
<button className={className} onClick={onLock}>
|
||||||
<Icon icon={isLocked ? "locked" : "unlocked"} size={24} />
|
<Icon icon={isLocked ? 'locked' : 'unlocked'} size={24} />
|
||||||
</button>
|
</button>
|
||||||
</Tippy>
|
</Tippy>
|
||||||
</SeparatedMenu>
|
</SeparatedMenu>
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import React, { FC, useCallback, useState } from "react";
|
import { FC, useCallback } from 'react';
|
||||||
|
|
||||||
import { FormikConfig, useFormik } from "formik";
|
import { FormikConfig, useFormik } from 'formik';
|
||||||
import { object, string, Asserts } from "yup";
|
import { Asserts, object, string } from 'yup';
|
||||||
|
|
||||||
import { Card } from "~/components/containers/Card";
|
import { Card } from '~/components/containers/Card';
|
||||||
import { Filler } from "~/components/containers/Filler";
|
import { Filler } from '~/components/containers/Filler';
|
||||||
import { Group } from "~/components/containers/Group";
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Button } from "~/components/input/Button";
|
import { Button } from '~/components/input/Button';
|
||||||
import { Textarea } from "~/components/input/Textarea";
|
import { Textarea } from '~/components/input/Textarea';
|
||||||
import { useRandomPhrase } from "~/constants/phrases";
|
import { useRandomPhrase } from '~/constants/phrases';
|
||||||
import { Note } from "~/types/notes";
|
import { getErrorMessage } from '~/utils/errors/getErrorMessage';
|
||||||
import { getErrorMessage } from "~/utils/errors/getErrorMessage";
|
import { showErrorToast } from '~/utils/errors/showToast';
|
||||||
import { showErrorToast } from "~/utils/errors/showToast";
|
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface NoteCreationFormProps {
|
interface NoteCreationFormProps {
|
||||||
text?: string;
|
text?: string;
|
||||||
|
@ -22,19 +21,19 @@ interface NoteCreationFormProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const validationSchema = object({
|
const validationSchema = object({
|
||||||
text: string().required("Напишите что-нибудь"),
|
text: string().required('Напишите что-нибудь'),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Values = Asserts<typeof validationSchema>;
|
type Values = Asserts<typeof validationSchema>;
|
||||||
|
|
||||||
const NoteCreationForm: FC<NoteCreationFormProps> = ({
|
const NoteCreationForm: FC<NoteCreationFormProps> = ({
|
||||||
text = "",
|
text = '',
|
||||||
onSubmit,
|
onSubmit,
|
||||||
onCancel,
|
onCancel,
|
||||||
}) => {
|
}) => {
|
||||||
const placeholder = useRandomPhrase("SIMPLE");
|
const placeholder = useRandomPhrase('SIMPLE');
|
||||||
|
|
||||||
const submit = useCallback<FormikConfig<Values>["onSubmit"]>(
|
const submit = useCallback<FormikConfig<Values>['onSubmit']>(
|
||||||
async (values, { resetForm, setSubmitting, setErrors }) => {
|
async (values, { resetForm, setSubmitting, setErrors }) => {
|
||||||
try {
|
try {
|
||||||
await onSubmit(values.text, () => resetForm());
|
await onSubmit(values.text, () => resetForm());
|
||||||
|
@ -72,10 +71,10 @@ const NoteCreationForm: FC<NoteCreationFormProps> = ({
|
||||||
<Card className={styles.card}>
|
<Card className={styles.card}>
|
||||||
<div className={styles.row}>
|
<div className={styles.row}>
|
||||||
<Textarea
|
<Textarea
|
||||||
handler={handleChange("text")}
|
handler={handleChange('text')}
|
||||||
value={values.text}
|
value={values.text}
|
||||||
error={touched.text ? errors.text : undefined}
|
error={touched.text ? errors.text : undefined}
|
||||||
onBlur={handleBlur("text")}
|
onBlur={handleBlur('text')}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { FC } from "react";
|
import { FC } from 'react';
|
||||||
|
|
||||||
import { Filler } from "~/components/containers/Filler";
|
import { Filler } from '~/components/containers/Filler';
|
||||||
import { Group } from "~/components/containers/Group";
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Padder } from "~/components/containers/Padder";
|
import { Padder } from '~/components/containers/Padder';
|
||||||
import { Button } from "~/components/input/Button";
|
import { Button } from '~/components/input/Button';
|
||||||
import { UserSettingsView } from "~/containers/settings/UserSettingsView";
|
import { UserSettingsView } from '~/containers/settings/UserSettingsView';
|
||||||
import {
|
import {
|
||||||
SettingsProvider,
|
SettingsProvider,
|
||||||
useSettings,
|
useSettings,
|
||||||
} from "~/utils/providers/SettingsProvider";
|
} from '~/utils/providers/SettingsProvider';
|
||||||
|
|
||||||
const Form = ({ children }) => {
|
const Form = ({ children }) => {
|
||||||
const { handleSubmit } = useSettings();
|
const { handleSubmit } = useSettings();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { VFC } from "react";
|
import { VFC } from 'react';
|
||||||
|
|
||||||
import { useStackContext } from "~/components/sidebar/SidebarStack";
|
import { useStackContext } from '~/components/sidebar/SidebarStack';
|
||||||
import { SidebarStackCard } from "~/components/sidebar/SidebarStackCard";
|
import { SidebarStackCard } from '~/components/sidebar/SidebarStackCard';
|
||||||
import { SettingsNotes } from "~/containers/settings/SettingsNotes";
|
import { SettingsNotes } from '~/containers/settings/SettingsNotes';
|
||||||
|
|
||||||
interface ProfileSidebarNotesProps {}
|
interface ProfileSidebarNotesProps {}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import React, { FC } from "react";
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
import { Filler } from "~/components/containers/Filler";
|
import { Filler } from '~/components/containers/Filler';
|
||||||
import { Button } from "~/components/input/Button";
|
import { Button } from '~/components/input/Button';
|
||||||
import { ProfileSettings } from "~/components/profile/ProfileSettings";
|
import { ProfileSettings } from '~/components/profile/ProfileSettings';
|
||||||
import { useStackContext } from "~/components/sidebar/SidebarStack";
|
import { useStackContext } from '~/components/sidebar/SidebarStack';
|
||||||
import { SidebarStackCard } from "~/components/sidebar/SidebarStackCard";
|
import { SidebarStackCard } from '~/components/sidebar/SidebarStackCard';
|
||||||
import { UserSettingsView } from "~/containers/settings/UserSettingsView";
|
import { UserSettingsView } from '~/containers/settings/UserSettingsView';
|
||||||
import {
|
import {
|
||||||
SettingsProvider,
|
SettingsProvider,
|
||||||
useSettings,
|
useSettings,
|
||||||
} from "~/utils/providers/SettingsProvider";
|
} from '~/utils/providers/SettingsProvider';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface IProps {}
|
interface IProps {}
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@ import React, {
|
||||||
useEffect,
|
useEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from 'react';
|
||||||
|
|
||||||
import { isNil } from "~/utils/ramda";
|
import { isNil } from '~/utils/ramda';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface SidebarStackProps extends PropsWithChildren<{}> {
|
interface SidebarStackProps extends PropsWithChildren<{}> {
|
||||||
tab?: number;
|
tab?: number;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { FC } from "react";
|
import { FC } from 'react';
|
||||||
|
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
import { BorisSuperpowers } from "~/components/boris/BorisSuperpowers";
|
import { BorisSuperpowers } from '~/components/boris/BorisSuperpowers';
|
||||||
import { useAuth } from "~/hooks/auth/useAuth";
|
import { useAuth } from '~/hooks/auth/useAuth';
|
||||||
import { useSuperPowers } from "~/hooks/auth/useSuperPowers";
|
import { useSuperPowers } from '~/hooks/auth/useSuperPowers';
|
||||||
|
|
||||||
interface SuperPowersToggleProps {}
|
interface SuperPowersToggleProps {}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { FC } from "react";
|
import { FC } from 'react';
|
||||||
|
|
||||||
import { BorisContacts } from "~/components/boris/BorisContacts";
|
import { BorisContacts } from '~/components/boris/BorisContacts';
|
||||||
import { BorisStats } from "~/components/boris/BorisStats";
|
import { BorisStats } from '~/components/boris/BorisStats';
|
||||||
import { Group } from "~/components/containers/Group";
|
import { Group } from '~/components/containers/Group';
|
||||||
import { SuperPowersToggle } from "~/containers/auth/SuperPowersToggle";
|
import { SuperPowersToggle } from '~/containers/auth/SuperPowersToggle';
|
||||||
import styles from "~/layouts/BorisLayout/styles.module.scss";
|
import styles from '~/layouts/BorisLayout/styles.module.scss';
|
||||||
import { BorisUsageStats } from "~/types/boris";
|
import { BorisUsageStats } from '~/types/boris';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
isUser: boolean;
|
isUser: boolean;
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
import React, { FC, useCallback } from "react";
|
import React, { FC, useCallback } from 'react';
|
||||||
|
|
||||||
import { LoginDialogButtons } from "~/components/auth/login/LoginDialogButtons";
|
import { LoginDialogButtons } from '~/components/auth/login/LoginDialogButtons';
|
||||||
import { LoginScene } from "~/components/auth/login/LoginScene";
|
import { LoginScene } from '~/components/auth/login/LoginScene';
|
||||||
import { Group } from "~/components/containers/Group";
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Padder } from "~/components/containers/Padder";
|
import { Padder } from '~/components/containers/Padder';
|
||||||
import { BetterScrollDialog } from "~/components/dialogs/BetterScrollDialog";
|
import { BetterScrollDialog } from '~/components/dialogs/BetterScrollDialog';
|
||||||
import { DialogTitle } from "~/components/dialogs/DialogTitle";
|
import { DialogTitle } from '~/components/dialogs/DialogTitle';
|
||||||
import { Button } from "~/components/input/Button";
|
import { Button } from '~/components/input/Button';
|
||||||
import { InputText } from "~/components/input/InputText";
|
import { InputText } from '~/components/input/InputText';
|
||||||
import { Dialog } from "~/constants/modal";
|
import { Dialog } from '~/constants/modal';
|
||||||
import { useCloseOnEscape } from "~/hooks";
|
import { useCloseOnEscape } from '~/hooks';
|
||||||
import { useAuth } from "~/hooks/auth/useAuth";
|
import { useAuth } from '~/hooks/auth/useAuth';
|
||||||
import { useLoginForm } from "~/hooks/auth/useLoginForm";
|
import { useLoginForm } from '~/hooks/auth/useLoginForm';
|
||||||
import { useOAuth } from "~/hooks/auth/useOAuth";
|
import { useOAuth } from '~/hooks/auth/useOAuth';
|
||||||
import { useShowModal } from "~/hooks/modal/useShowModal";
|
import { useShowModal } from '~/hooks/modal/useShowModal';
|
||||||
import { DialogComponentProps } from "~/types/modal";
|
import { DialogComponentProps } from '~/types/modal';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
type LoginDialogProps = DialogComponentProps & {};
|
type LoginDialogProps = DialogComponentProps & {};
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ const LoginDialog: FC<LoginDialogProps> = ({ onRequestClose }) => {
|
||||||
|
|
||||||
<InputText
|
<InputText
|
||||||
title="Логин"
|
title="Логин"
|
||||||
handler={handleChange("username")}
|
handler={handleChange('username')}
|
||||||
value={values.username}
|
value={values.username}
|
||||||
error={errors.username}
|
error={errors.username}
|
||||||
autoFocus
|
autoFocus
|
||||||
|
@ -63,7 +63,7 @@ const LoginDialog: FC<LoginDialogProps> = ({ onRequestClose }) => {
|
||||||
|
|
||||||
<InputText
|
<InputText
|
||||||
title="Пароль"
|
title="Пароль"
|
||||||
handler={handleChange("password")}
|
handler={handleChange('password')}
|
||||||
value={values.password}
|
value={values.password}
|
||||||
error={errors.password}
|
error={errors.password}
|
||||||
type="password"
|
type="password"
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import React, { useEffect, useRef, VFC } from "react";
|
import React, { useEffect, useRef, VFC } from 'react';
|
||||||
|
|
||||||
import classNames from "classnames";
|
import classNames from 'classnames';
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from 'mobx-react-lite';
|
||||||
import PhotoSwipeUI_Default from "photoswipe/dist/photoswipe-ui-default.js";
|
import PhotoSwipeUI_Default from 'photoswipe/dist/photoswipe-ui-default.js';
|
||||||
import PhotoSwipeJs from "photoswipe/dist/photoswipe.js";
|
import PhotoSwipeJs from 'photoswipe/dist/photoswipe.js';
|
||||||
|
|
||||||
import { ImagePresets } from "~/constants/urls";
|
import { ImagePresets } from '~/constants/urls';
|
||||||
import { useWindowSize } from "~/hooks/dom/useWindowSize";
|
import { useWindowSize } from '~/hooks/dom/useWindowSize';
|
||||||
import { useModal } from "~/hooks/modal/useModal";
|
import { useModal } from '~/hooks/modal/useModal';
|
||||||
import { IFile } from "~/types";
|
import { IFile } from '~/types';
|
||||||
import { DialogComponentProps } from "~/types/modal";
|
import { DialogComponentProps } from '~/types/modal';
|
||||||
import { getURL } from "~/utils/dom";
|
import { getURL } from '~/utils/dom';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
export interface PhotoSwipeProps extends DialogComponentProps {
|
export interface PhotoSwipeProps extends DialogComponentProps {
|
||||||
items: IFile[];
|
items: IFile[];
|
||||||
|
@ -61,8 +61,8 @@ const PhotoSwipe: VFC<PhotoSwipeProps> = observer(({ index, items }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ps.init();
|
ps.init();
|
||||||
ps.listen("destroy", hideModal);
|
ps.listen('destroy', hideModal);
|
||||||
ps.listen("close", hideModal);
|
ps.listen('close', hideModal);
|
||||||
});
|
});
|
||||||
}, [hideModal, items, index, isTablet]);
|
}, [hideModal, items, index, isTablet]);
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@ const PhotoSwipe: VFC<PhotoSwipeProps> = observer(({ index, items }) => {
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
<div className={classNames("pswp__bg", styles.bg)} />
|
<div className={classNames('pswp__bg', styles.bg)} />
|
||||||
<div className={classNames("pswp__scroll-wrap", styles.wrap)}>
|
<div className={classNames('pswp__scroll-wrap', styles.wrap)}>
|
||||||
<div className="pswp__container">
|
<div className="pswp__container">
|
||||||
<div className="pswp__item" />
|
<div className="pswp__item" />
|
||||||
<div className="pswp__item" />
|
<div className="pswp__item" />
|
||||||
|
@ -83,7 +83,7 @@ const PhotoSwipe: VFC<PhotoSwipeProps> = observer(({ index, items }) => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="pswp__ui pswp__ui--hidden">
|
<div className="pswp__ui pswp__ui--hidden">
|
||||||
<div className={classNames("pswp__top-bar", styles.bar)}>
|
<div className={classNames('pswp__top-bar', styles.bar)}>
|
||||||
<div className="pswp__counter" />
|
<div className="pswp__counter" />
|
||||||
<button
|
<button
|
||||||
className="pswp__button pswp__button--close"
|
className="pswp__button pswp__button--close"
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
import React, { useCallback, VFC } from "react";
|
import React, { useCallback, VFC } from 'react';
|
||||||
|
|
||||||
import classNames from "classnames";
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { Filler } from "~/components/containers/Filler";
|
import { Filler } from '~/components/containers/Filler';
|
||||||
import { Group } from "~/components/containers/Group";
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Button } from "~/components/input/Button";
|
import { Button } from '~/components/input/Button';
|
||||||
import { Icon } from "~/components/input/Icon";
|
import { Icon } from '~/components/input/Icon';
|
||||||
import { MenuButton, MenuItemWithIcon } from "~/components/menu";
|
import { MenuButton, MenuItemWithIcon } from '~/components/menu';
|
||||||
import { VerticalMenu } from "~/components/menu/VerticalMenu";
|
import { VerticalMenu } from '~/components/menu/VerticalMenu';
|
||||||
import { useStackContext } from "~/components/sidebar/SidebarStack";
|
import { useStackContext } from '~/components/sidebar/SidebarStack';
|
||||||
import { ProfileSidebarHead } from "~/containers/profile/ProfileSidebarHead";
|
import { ProfileSidebarHead } from '~/containers/profile/ProfileSidebarHead';
|
||||||
import { ProfileStats } from "~/containers/profile/ProfileStats";
|
import { ProfileStats } from '~/containers/profile/ProfileStats';
|
||||||
import { useAuth } from "~/hooks/auth/useAuth";
|
import { useAuth } from '~/hooks/auth/useAuth';
|
||||||
import markdown from "~/styles/common/markdown.module.scss";
|
import markdown from '~/styles/common/markdown.module.scss';
|
||||||
|
|
||||||
import { ProfileSidebarLogoutButton } from "../ProfileSidebarLogoutButton";
|
import { ProfileSidebarLogoutButton } from '../ProfileSidebarLogoutButton';
|
||||||
import { ProfileToggles } from "../ProfileToggles";
|
import { ProfileToggles } from '../ProfileToggles';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface ProfileSidebarMenuProps {
|
interface ProfileSidebarMenuProps {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import React, { FC } from "react";
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
import { Group } from "~/components/containers/Group";
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Zone } from "~/components/containers/Zone";
|
import { Zone } from '~/components/containers/Zone';
|
||||||
import { SuperPowersToggle } from "~/containers/auth/SuperPowersToggle";
|
import { SuperPowersToggle } from '~/containers/auth/SuperPowersToggle';
|
||||||
|
|
||||||
interface ProfileTogglesProps {}
|
interface ProfileTogglesProps {}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { FC, useCallback, useState, VFC } from "react";
|
import { FC, useCallback, useState, VFC } from 'react';
|
||||||
|
|
||||||
import { Filler } from "~/components/containers/Filler";
|
import { Filler } from '~/components/containers/Filler';
|
||||||
import { Group } from "~/components/containers/Group";
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Button } from "~/components/input/Button";
|
import { Button } from '~/components/input/Button';
|
||||||
import { NoteCard } from "~/components/notes/NoteCard";
|
import { NoteCard } from '~/components/notes/NoteCard';
|
||||||
import { NoteCreationForm } from "~/components/notes/NoteCreationForm";
|
import { NoteCreationForm } from '~/components/notes/NoteCreationForm';
|
||||||
import { useConfirmation } from "~/hooks/dom/useConfirmation";
|
import { useConfirmation } from '~/hooks/dom/useConfirmation';
|
||||||
import { NoteProvider, useNotesContext } from "~/utils/providers/NoteProvider";
|
import { NoteProvider, useNotesContext } from '~/utils/providers/NoteProvider';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface SettingsNotesProps {}
|
interface SettingsNotesProps {}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ const List = () => {
|
||||||
|
|
||||||
const onRemove = useCallback(
|
const onRemove = useCallback(
|
||||||
async (id: number) => {
|
async (id: number) => {
|
||||||
confirm("Удалить? Это удалит заметку навсегда", () => remove(id));
|
confirm('Удалить? Это удалит заметку навсегда', () => remove(id));
|
||||||
},
|
},
|
||||||
[remove],
|
[remove],
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import { FC } from "react";
|
import { FC } from 'react';
|
||||||
|
|
||||||
import { Superpower } from "~/components/boris/Superpower";
|
import { Superpower } from '~/components/boris/Superpower';
|
||||||
import { Filler } from "~/components/containers/Filler";
|
import { Filler } from '~/components/containers/Filler';
|
||||||
import { Group } from "~/components/containers/Group";
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Zone } from "~/components/containers/Zone";
|
import { Zone } from '~/components/containers/Zone';
|
||||||
import { InputText } from "~/components/input/InputText";
|
import { InputText } from '~/components/input/InputText';
|
||||||
import { Textarea } from "~/components/input/Textarea";
|
import { Textarea } from '~/components/input/Textarea';
|
||||||
import { ERROR_LITERAL } from "~/constants/errors";
|
import { ERROR_LITERAL } from '~/constants/errors';
|
||||||
import { ProfileAccounts } from "~/containers/profile/ProfileAccounts";
|
import { ProfileAccounts } from '~/containers/profile/ProfileAccounts';
|
||||||
import { useWindowSize } from "~/hooks/dom/useWindowSize";
|
import { useWindowSize } from '~/hooks/dom/useWindowSize';
|
||||||
import { useSettings } from "~/utils/providers/SettingsProvider";
|
import { useSettings } from '~/utils/providers/SettingsProvider';
|
||||||
import { has } from "~/utils/ramda";
|
import { has } from '~/utils/ramda';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface UserSettingsViewProps {}
|
interface UserSettingsViewProps {}
|
||||||
|
|
||||||
|
@ -39,14 +39,14 @@ const UserSettingsView: FC<UserSettingsViewProps> = () => {
|
||||||
<Group>
|
<Group>
|
||||||
<InputText
|
<InputText
|
||||||
value={values.fullname}
|
value={values.fullname}
|
||||||
handler={handleChange("fullname")}
|
handler={handleChange('fullname')}
|
||||||
title="Полное имя"
|
title="Полное имя"
|
||||||
error={getError(errors.fullname)}
|
error={getError(errors.fullname)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Textarea
|
<Textarea
|
||||||
value={values.description}
|
value={values.description}
|
||||||
handler={handleChange("description")}
|
handler={handleChange('description')}
|
||||||
title="Описание"
|
title="Описание"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@ -77,21 +77,21 @@ const UserSettingsView: FC<UserSettingsViewProps> = () => {
|
||||||
<Group>
|
<Group>
|
||||||
<InputText
|
<InputText
|
||||||
value={values.username}
|
value={values.username}
|
||||||
handler={handleChange("username")}
|
handler={handleChange('username')}
|
||||||
title="Логин"
|
title="Логин"
|
||||||
error={getError(errors.username)}
|
error={getError(errors.username)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<InputText
|
<InputText
|
||||||
value={values.email}
|
value={values.email}
|
||||||
handler={handleChange("email")}
|
handler={handleChange('email')}
|
||||||
title="E-mail"
|
title="E-mail"
|
||||||
error={getError(errors.email)}
|
error={getError(errors.email)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<InputText
|
<InputText
|
||||||
value={values.newPassword}
|
value={values.newPassword}
|
||||||
handler={handleChange("newPassword")}
|
handler={handleChange('newPassword')}
|
||||||
title="Новый пароль"
|
title="Новый пароль"
|
||||||
type="password"
|
type="password"
|
||||||
error={getError(errors.newPassword)}
|
error={getError(errors.newPassword)}
|
||||||
|
@ -99,7 +99,7 @@ const UserSettingsView: FC<UserSettingsViewProps> = () => {
|
||||||
|
|
||||||
<InputText
|
<InputText
|
||||||
value={values.password}
|
value={values.password}
|
||||||
handler={handleChange("password")}
|
handler={handleChange('password')}
|
||||||
title="Старый пароль"
|
title="Старый пароль"
|
||||||
type="password"
|
type="password"
|
||||||
error={getError(errors.password)}
|
error={getError(errors.password)}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import React, { useCallback, useEffect, useMemo, VFC } from "react";
|
import React, { useCallback, useEffect, useMemo, VFC } from 'react';
|
||||||
|
|
||||||
import { isNil } from "ramda";
|
import { isNil } from 'ramda';
|
||||||
|
|
||||||
import { CoverBackdrop } from "~/components/containers/CoverBackdrop";
|
import { CoverBackdrop } from '~/components/containers/CoverBackdrop';
|
||||||
import { ProfileSidebarNotes } from "~/components/profile/ProfileSidebarNotes";
|
import { ProfileSidebarNotes } from '~/components/profile/ProfileSidebarNotes';
|
||||||
import { ProfileSidebarSettings } from "~/components/profile/ProfileSidebarSettings";
|
import { ProfileSidebarSettings } from '~/components/profile/ProfileSidebarSettings';
|
||||||
import { SidebarStack } from "~/components/sidebar/SidebarStack";
|
import { SidebarStack } from '~/components/sidebar/SidebarStack';
|
||||||
import { SidebarStackCard } from "~/components/sidebar/SidebarStackCard";
|
import { SidebarStackCard } from '~/components/sidebar/SidebarStackCard';
|
||||||
import { SidebarName } from "~/constants/sidebar";
|
import { SidebarName } from '~/constants/sidebar';
|
||||||
import { ProfileSidebarMenu } from "~/containers/profile/ProfileSidebarMenu";
|
import { ProfileSidebarMenu } from '~/containers/profile/ProfileSidebarMenu';
|
||||||
import { SidebarWrapper } from "~/containers/sidebars/SidebarWrapper";
|
import { SidebarWrapper } from '~/containers/sidebars/SidebarWrapper';
|
||||||
import { useAuth } from "~/hooks/auth/useAuth";
|
import { useAuth } from '~/hooks/auth/useAuth';
|
||||||
import type { SidebarComponentProps } from "~/types/sidebar";
|
import { useUser } from '~/hooks/auth/useUser';
|
||||||
import { useUser } from "~/hooks/auth/useUser";
|
import type { SidebarComponentProps } from '~/types/sidebar';
|
||||||
|
|
||||||
const tabs = ["profile", "bookmarks"] as const;
|
const tabs = ['profile', 'bookmarks'] as const;
|
||||||
type TabName = typeof tabs[number];
|
type TabName = typeof tabs[number];
|
||||||
|
|
||||||
interface ProfileSidebarProps
|
interface ProfileSidebarProps
|
||||||
|
@ -28,7 +28,9 @@ const ProfileSidebar: VFC<ProfileSidebarProps> = ({
|
||||||
openSidebar,
|
openSidebar,
|
||||||
}) => {
|
}) => {
|
||||||
const { isUser } = useAuth();
|
const { isUser } = useAuth();
|
||||||
const { user: { cover }} = useUser();
|
const {
|
||||||
|
user: { cover },
|
||||||
|
} = useUser();
|
||||||
|
|
||||||
const tab = useMemo(
|
const tab = useMemo(
|
||||||
() => (page ? Math.max(tabs.indexOf(page), 0) : undefined),
|
() => (page ? Math.max(tabs.indexOf(page), 0) : undefined),
|
||||||
|
@ -55,7 +57,10 @@ const ProfileSidebar: VFC<ProfileSidebarProps> = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarWrapper onClose={onRequestClose} backdrop={cover && <CoverBackdrop cover={cover} />}>
|
<SidebarWrapper
|
||||||
|
onClose={onRequestClose}
|
||||||
|
backdrop={cover && <CoverBackdrop cover={cover} />}
|
||||||
|
>
|
||||||
<SidebarStack tab={tab} onTabChange={onTabChange}>
|
<SidebarStack tab={tab} onTabChange={onTabChange}>
|
||||||
<SidebarStackCard
|
<SidebarStackCard
|
||||||
headerFeature="close"
|
headerFeature="close"
|
||||||
|
|
|
@ -6,19 +6,19 @@ import React, {
|
||||||
useMemo,
|
useMemo,
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from 'react';
|
||||||
|
|
||||||
import { TagAutocomplete } from "~/components/tags/TagAutocomplete";
|
import { TagAutocomplete } from '~/components/tags/TagAutocomplete';
|
||||||
import { TagWrapper } from "~/components/tags/TagWrapper";
|
import { TagWrapper } from '~/components/tags/TagWrapper';
|
||||||
import { useTagAutocomplete } from "~/hooks/tag/useTagAutocomplete";
|
import { useTagAutocomplete } from '~/hooks/tag/useTagAutocomplete';
|
||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
const placeholder = "Добавить";
|
const placeholder = 'Добавить';
|
||||||
|
|
||||||
const prepareInput = (input: string): string[] => {
|
const prepareInput = (input: string): string[] => {
|
||||||
return input
|
return input
|
||||||
.split(",")
|
.split(',')
|
||||||
.map((title: string) =>
|
.map((title: string) =>
|
||||||
title
|
title
|
||||||
.trim()
|
.trim()
|
||||||
|
@ -37,7 +37,7 @@ interface IProps {
|
||||||
|
|
||||||
const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
const [focused, setFocused] = useState(false);
|
const [focused, setFocused] = useState(false);
|
||||||
const [input, setInput] = useState("");
|
const [input, setInput] = useState('');
|
||||||
const ref = useRef<HTMLInputElement>(null);
|
const ref = useRef<HTMLInputElement>(null);
|
||||||
const wrapper = useRef<HTMLDivElement>(null);
|
const wrapper = useRef<HTMLDivElement>(null);
|
||||||
const options = useTagAutocomplete(input, exclude);
|
const options = useTagAutocomplete(input, exclude);
|
||||||
|
@ -45,7 +45,7 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
const onInput = useCallback(
|
const onInput = useCallback(
|
||||||
({ target: { value } }: ChangeEvent<HTMLInputElement>) => {
|
({ target: { value } }: ChangeEvent<HTMLInputElement>) => {
|
||||||
if (!value.trim()) {
|
if (!value.trim()) {
|
||||||
setInput(value || "");
|
setInput(value || '');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,32 +55,32 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
onAppend(items.slice(0, items.length - 1));
|
onAppend(items.slice(0, items.length - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
setInput(items[items.length - 1] || "");
|
setInput(items[items.length - 1] || '');
|
||||||
},
|
},
|
||||||
[onAppend],
|
[onAppend],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onKeyDown = useCallback(
|
const onKeyDown = useCallback(
|
||||||
({ key }) => {
|
({ key }) => {
|
||||||
if (key === "Escape" && ref.current) {
|
if (key === 'Escape' && ref.current) {
|
||||||
setInput("");
|
setInput('');
|
||||||
ref.current.blur();
|
ref.current.blur();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === "Backspace" && input === "") {
|
if (key === 'Backspace' && input === '') {
|
||||||
setInput(onClearTag() || "");
|
setInput(onClearTag() || '');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === "," || key === "Comma") {
|
if (key === ',' || key === 'Comma') {
|
||||||
const created = prepareInput(input);
|
const created = prepareInput(input);
|
||||||
|
|
||||||
if (created.length) {
|
if (created.length) {
|
||||||
onAppend(created);
|
onAppend(created);
|
||||||
}
|
}
|
||||||
|
|
||||||
setInput("");
|
setInput('');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[input, setInput, onClearTag, onAppend],
|
[input, setInput, onClearTag, onAppend],
|
||||||
|
@ -101,7 +101,7 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
setFocused(false);
|
setFocused(false);
|
||||||
|
|
||||||
if (input.trim()) {
|
if (input.trim()) {
|
||||||
setInput("");
|
setInput('');
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit([]);
|
onSubmit([]);
|
||||||
|
@ -111,7 +111,7 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
|
|
||||||
const onAutocompleteSelect = useCallback(
|
const onAutocompleteSelect = useCallback(
|
||||||
(val: string) => {
|
(val: string) => {
|
||||||
setInput("");
|
setInput('');
|
||||||
|
|
||||||
if (!val.trim()) {
|
if (!val.trim()) {
|
||||||
return;
|
return;
|
||||||
|
@ -122,15 +122,15 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
[onAppend, setInput],
|
[onAppend, setInput],
|
||||||
);
|
);
|
||||||
|
|
||||||
const feature = useMemo(() => (input?.substr(0, 1) === "/" ? "green" : ""), [
|
const feature = useMemo(() => (input?.substr(0, 1) === '/' ? 'green' : ''), [
|
||||||
input,
|
input,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!focused) return;
|
if (!focused) return;
|
||||||
|
|
||||||
document.addEventListener("click", onBlur);
|
document.addEventListener('click', onBlur);
|
||||||
return () => document.removeEventListener("click", onBlur);
|
return () => document.removeEventListener('click', onBlur);
|
||||||
}, [onBlur, focused]);
|
}, [onBlur, focused]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import React, { VFC } from "react";
|
import React, { VFC } from 'react';
|
||||||
|
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
import { PageTitle } from "~/components/common/PageTitle";
|
import { PageTitle } from '~/components/common/PageTitle';
|
||||||
import { useBoris } from "~/hooks/boris/useBoris";
|
import { useBoris } from '~/hooks/boris/useBoris';
|
||||||
import { useNodeComments } from "~/hooks/comments/useNodeComments";
|
import { useNodeComments } from '~/hooks/comments/useNodeComments';
|
||||||
import { useImageModal } from "~/hooks/navigation/useImageModal";
|
import { useImageModal } from '~/hooks/navigation/useImageModal';
|
||||||
import { useLoadNode } from "~/hooks/node/useLoadNode";
|
import { useLoadNode } from '~/hooks/node/useLoadNode';
|
||||||
import { BorisLayout } from "~/layouts/BorisLayout";
|
import { BorisLayout } from '~/layouts/BorisLayout';
|
||||||
import { CommentContextProvider } from "~/utils/context/CommentContextProvider";
|
import { CommentContextProvider } from '~/utils/context/CommentContextProvider';
|
||||||
import { NodeContextProvider } from "~/utils/context/NodeContextProvider";
|
import { NodeContextProvider } from '~/utils/context/NodeContextProvider';
|
||||||
import { getPageTitle } from "~/utils/ssr/getPageTitle";
|
import { getPageTitle } from '~/utils/ssr/getPageTitle';
|
||||||
|
|
||||||
const BorisPage: VFC = observer(() => {
|
const BorisPage: VFC = observer(() => {
|
||||||
const { node, isLoading, update } = useLoadNode(696);
|
const { node, isLoading, update } = useLoadNode(696);
|
||||||
|
@ -39,7 +39,7 @@ const BorisPage: VFC = observer(() => {
|
||||||
onLoadMoreComments={onLoadMoreComments}
|
onLoadMoreComments={onLoadMoreComments}
|
||||||
onDeleteComment={onDeleteComment}
|
onDeleteComment={onDeleteComment}
|
||||||
>
|
>
|
||||||
<PageTitle title={getPageTitle("Борис")} />
|
<PageTitle title={getPageTitle('Борис')} />
|
||||||
|
|
||||||
<BorisLayout
|
<BorisLayout
|
||||||
title={title}
|
title={title}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { createContext, FC, useContext } from "react";
|
import { createContext, FC, useContext } from 'react';
|
||||||
|
|
||||||
import { useNotes } from "~/hooks/notes/useNotes";
|
import { useNotes } from '~/hooks/notes/useNotes';
|
||||||
|
|
||||||
const NoteContext = createContext<ReturnType<typeof useNotes>>({
|
const NoteContext = createContext<ReturnType<typeof useNotes>>({
|
||||||
notes: [],
|
notes: [],
|
||||||
|
@ -13,7 +13,7 @@ const NoteContext = createContext<ReturnType<typeof useNotes>>({
|
||||||
});
|
});
|
||||||
|
|
||||||
export const NoteProvider: FC = ({ children }) => {
|
export const NoteProvider: FC = ({ children }) => {
|
||||||
const notes = useNotes("");
|
const notes = useNotes('');
|
||||||
|
|
||||||
return <NoteContext.Provider value={notes}>{children}</NoteContext.Provider>;
|
return <NoteContext.Provider value={notes}>{children}</NoteContext.Provider>;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,15 +6,15 @@ import {
|
||||||
useCallback,
|
useCallback,
|
||||||
useContext,
|
useContext,
|
||||||
useMemo,
|
useMemo,
|
||||||
} from "react";
|
} from 'react';
|
||||||
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from 'next/router';
|
||||||
import { has, omit } from "ramda";
|
import { has, omit } from 'ramda';
|
||||||
|
|
||||||
import { ModalWrapper } from "~/components/dialogs/ModalWrapper";
|
import { ModalWrapper } from '~/components/dialogs/ModalWrapper';
|
||||||
import { SidebarName } from "~/constants/sidebar";
|
import { SidebarName } from '~/constants/sidebar';
|
||||||
import { sidebarComponents } from "~/constants/sidebar/components";
|
import { sidebarComponents } from '~/constants/sidebar/components';
|
||||||
import { SidebarComponent, SidebarProps } from "~/types/sidebar";
|
import { SidebarComponent, SidebarProps } from '~/types/sidebar';
|
||||||
|
|
||||||
type ContextValue = typeof SidebarContext extends Context<infer U> ? U : never;
|
type ContextValue = typeof SidebarContext extends Context<infer U> ? U : never;
|
||||||
|
|
||||||
|
@ -36,12 +36,12 @@ export const SidebarProvider = <T extends SidebarComponent>({
|
||||||
|
|
||||||
const open = useCallback(
|
const open = useCallback(
|
||||||
<T extends SidebarComponent>(name: T, props: SidebarProps<T>) => {
|
<T extends SidebarComponent>(name: T, props: SidebarProps<T>) => {
|
||||||
const [path] = router.asPath.split("?");
|
const [path] = router.asPath.split('?');
|
||||||
const query = Object.entries(props as {})
|
const query = Object.entries(props as {})
|
||||||
.filter(([, val]) => val)
|
.filter(([, val]) => val)
|
||||||
.map(([name, val]) => `${name}=${val}`)
|
.map(([name, val]) => `${name}=${val}`)
|
||||||
.join("&");
|
.join('&');
|
||||||
const url = path + "?sidebar=" + name + (query && `&${query}`);
|
const url = path + '?sidebar=' + name + (query && `&${query}`);
|
||||||
|
|
||||||
// don't store history inside the same sidebar
|
// don't store history inside the same sidebar
|
||||||
if (router.query?.sidebar === name) {
|
if (router.query?.sidebar === name) {
|
||||||
|
@ -62,7 +62,7 @@ export const SidebarProvider = <T extends SidebarComponent>({
|
||||||
);
|
);
|
||||||
|
|
||||||
const close = useCallback(() => {
|
const close = useCallback(() => {
|
||||||
const [path] = router.asPath.split("?");
|
const [path] = router.asPath.split('?');
|
||||||
|
|
||||||
void router.replace(path, path, {
|
void router.replace(path, path, {
|
||||||
shallow: true,
|
shallow: true,
|
||||||
|
@ -87,7 +87,7 @@ export const SidebarProvider = <T extends SidebarComponent>({
|
||||||
{createElement(sidebarComponents[current], {
|
{createElement(sidebarComponents[current], {
|
||||||
onRequestClose: close,
|
onRequestClose: close,
|
||||||
openSidebar: open,
|
openSidebar: open,
|
||||||
...omit(["sidebar"], router.query),
|
...omit(['sidebar'], router.query),
|
||||||
} as any)}
|
} as any)}
|
||||||
</ModalWrapper>
|
</ModalWrapper>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -2260,10 +2260,10 @@ prelude-ls@^1.2.1:
|
||||||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
|
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
|
||||||
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
|
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
|
||||||
|
|
||||||
prettier@^1.18.2:
|
prettier@^2.7.1:
|
||||||
version "1.19.1"
|
version "2.7.1"
|
||||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64"
|
||||||
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
|
integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==
|
||||||
|
|
||||||
pretty-format@^26.6.2:
|
pretty-format@^26.6.2:
|
||||||
version "26.6.2"
|
version "26.6.2"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue