refactor: dayjs and tippy setting
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import dayjs from "dayjs";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import isToday from "dayjs/plugin/isToday";
|
||||
import isYesterday from "dayjs/plugin/isYesterday";
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
dayjs.extend(isToday);
|
||||
dayjs.extend(isYesterday);
|
||||
@@ -0,0 +1,7 @@
|
||||
import tippy, { followCursor } from "tippy.js";
|
||||
|
||||
tippy.setDefaultProps({
|
||||
duration: 0,
|
||||
delay: [0, 0],
|
||||
plugins: [followCursor]
|
||||
});
|
||||
@@ -1,6 +1,5 @@
|
||||
import { FC, ReactElement } from "react";
|
||||
import dayjs from "dayjs";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import Styled from "./styled";
|
||||
import {
|
||||
VideoPreview,
|
||||
@@ -14,9 +13,6 @@ import { getFileIcon, formatBytes } from "../../utils";
|
||||
import IconDownload from "../../../assets/icons/download.svg";
|
||||
import { useAppSelector } from "../../../app/store";
|
||||
|
||||
// todo: move to root file
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
interface Data {
|
||||
file_type: string;
|
||||
name: string;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { FC, useEffect, useState } from "react";
|
||||
import dayjs from "dayjs";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import Styled from "./styled";
|
||||
import ImageMessage from "./ImageMessage";
|
||||
import useRemoveLocalMessage from "../../hook/useRemoveLocalMessage";
|
||||
@@ -8,15 +7,10 @@ import useUploadFile from "../../hook/useUploadFile";
|
||||
import useSendMessage from "../../hook/useSendMessage";
|
||||
import Progress from "./Progress";
|
||||
import { getFileIcon, formatBytes, isImage, getImageSize, ImageSize } from "../../utils";
|
||||
// import { ReactComponent as IconDownload } from "../../../assets/icons/download.svg";
|
||||
// import { ReactComponent as IconClose } from "../../../assets/icons/close.circle.svg";
|
||||
import { useAppSelector } from "../../../app/store";
|
||||
import IconDownload from "../../../assets/icons/download.svg";
|
||||
import IconClose from "../../../assets/icons/close.circle.svg";
|
||||
|
||||
// todo: move to root file
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
const isLocalFile = (content: string) => {
|
||||
return content.startsWith("blob:");
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React, { useRef, useState, useEffect, FC } from "react";
|
||||
import dayjs from "dayjs";
|
||||
import isToday from "dayjs/plugin/isToday";
|
||||
import isYesterday from "dayjs/plugin/isYesterday";
|
||||
|
||||
import useInView from "./useInView";
|
||||
import Tippy from "@tippyjs/react";
|
||||
import Reaction from "./Reaction";
|
||||
@@ -18,9 +17,6 @@ import useContextMenu from "../../hook/useContextMenu";
|
||||
import usePinMessage from "../../hook/usePinMessage";
|
||||
import { useAppSelector } from "../../../app/store";
|
||||
|
||||
// todo: move to root file
|
||||
dayjs.extend(isToday);
|
||||
dayjs.extend(isYesterday);
|
||||
interface IProps {
|
||||
readOnly?: boolean;
|
||||
contextId: number;
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import tippy, { followCursor } from "tippy.js";
|
||||
|
||||
export default function TippyDefault() {
|
||||
tippy.setDefaultProps({
|
||||
duration: 0,
|
||||
delay: [0, 0],
|
||||
plugins: [followCursor]
|
||||
});
|
||||
return null;
|
||||
}
|
||||
+15
-17
@@ -1,25 +1,23 @@
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import toast, { Toaster } from 'react-hot-toast';
|
||||
import { Reset } from 'styled-reset';
|
||||
import { DndProvider } from 'react-dnd';
|
||||
import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||
import './assets/base.css';
|
||||
import 'animate.css';
|
||||
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
|
||||
import TippyDefault from './common/component/TippyDefault';
|
||||
import MarkdownStyleOverride from './common/component/MarkdownStyleOverride';
|
||||
import ReduxRoutes from './routes';
|
||||
import NewVersion from './common/component/NewVersion';
|
||||
import ReactDOM from "react-dom/client";
|
||||
import toast, { Toaster } from "react-hot-toast";
|
||||
import { Reset } from "styled-reset";
|
||||
import { DndProvider } from "react-dnd";
|
||||
import { HTML5Backend } from "react-dnd-html5-backend";
|
||||
import "./assets/base.css";
|
||||
import "animate.css";
|
||||
import "./common/DayjsSetting";
|
||||
import "./common/TippySetting";
|
||||
import * as serviceWorkerRegistration from "./serviceWorkerRegistration";
|
||||
import MarkdownStyleOverride from "./common/component/MarkdownStyleOverride";
|
||||
import ReduxRoutes from "./routes";
|
||||
import NewVersion from "./common/component/NewVersion";
|
||||
|
||||
const root = ReactDOM.createRoot(
|
||||
document.getElementById('root') as HTMLElement
|
||||
);
|
||||
const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement);
|
||||
|
||||
root.render(
|
||||
<>
|
||||
<Reset />
|
||||
<Toaster />
|
||||
<TippyDefault/>
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<ReduxRoutes />
|
||||
</DndProvider>
|
||||
@@ -39,7 +37,7 @@ serviceWorkerRegistration.register({
|
||||
};
|
||||
toast((t) => <NewVersion id={t.id} handleUpdate={handleUpdate} />, {
|
||||
duration: Infinity,
|
||||
position: 'top-right'
|
||||
position: "top-right"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,14 +5,12 @@ import { useDispatch } from "react-redux";
|
||||
import { NativeTypes } from "react-dnd-html5-backend";
|
||||
|
||||
import dayjs from "dayjs";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import Tippy from "@tippyjs/react";
|
||||
import { useReadMessageMutation } from "../../../app/services/message";
|
||||
import { removeUserSession } from "../../../app/slices/message.user";
|
||||
import useNormalizeMessage from "../../../common/hook/useNormalizeMessage";
|
||||
import useContextMenu from "../../../common/hook/useContextMenu";
|
||||
import ContextMenu from "../../../common/component/ContextMenu";
|
||||
dayjs.extend(relativeTime);
|
||||
import { renderPreviewMessage } from "../utils";
|
||||
import User from "../../../common/component/User";
|
||||
import { ContentTypes } from "../../../app/config";
|
||||
|
||||
@@ -2,20 +2,16 @@ import { useState, useEffect, FC } from "react";
|
||||
import dayjs from "dayjs";
|
||||
import { useDrop } from "react-dnd";
|
||||
import { NativeTypes } from "react-dnd-html5-backend";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import ContextMenu from "./ContextMenu";
|
||||
import getUnreadCount, { renderPreviewMessage } from "../utils";
|
||||
import User from "../../../common/component/User";
|
||||
import Avatar from "../../../common/component/Avatar";
|
||||
// import iconChannel from "../../../assets/icons/channel.svg?url";
|
||||
import IconLock from "../../../assets/icons/lock.svg";
|
||||
import useContextMenu from "../../../common/hook/useContextMenu";
|
||||
import { useNavigate, NavLink } from "react-router-dom";
|
||||
import useUploadFile from "../../../common/hook/useUploadFile";
|
||||
import { useAppSelector } from "../../../app/store";
|
||||
|
||||
// todo: move to root file
|
||||
dayjs.extend(relativeTime);
|
||||
interface IProps {
|
||||
type?: "user" | "channel";
|
||||
id: number;
|
||||
|
||||
Reference in New Issue
Block a user