web: remove unused modules & components

This commit is contained in:
Abdullah Atta
2024-11-12 13:33:43 +05:00
committed by Abdullah Atta
parent eb92989478
commit d30bb56e75
3 changed files with 0 additions and 284 deletions

View File

@@ -1,129 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
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/>.
*/
import ReactDOM from "react-dom";
import { Box, Button, Flex, Text } from "@theme-ui/components";
import Config from "../../utils/config";
import { getDownloadLink, getPlatform } from "../../utils/platform";
import DropdownButton from "../dropdown-button";
import { BaseThemeProvider } from "../theme-provider";
import { strings } from "@notesnook/intl";
const platform = getPlatform();
const isMobile = platform === "Android" || platform === "iOS";
function getOptions(onClose) {
return getDownloadLink(platform).map((item) => ({
key: item.type || item.link,
title: () => {
return `${item.type}`;
},
onClick: () => {
window.open(item.link, "_blank");
onClose();
Config.set("installNotice", false);
}
}));
}
export default function InstallNotice({ onClose }) {
return (
<Flex
sx={{
position: "absolute",
top: ["initial", 2],
right: [0, 2],
left: [2, "initial"],
bottom: [2, "initial"],
zIndex: 2,
bg: "background",
borderRadius: "default",
border: "1px solid var(--border)",
width: ["95%", 400],
flexDirection: "column"
}}
p={2}
>
<Text variant={"title"}>{strings.installNotesnook()}</Text>
<Text variant={"body"}>{strings.installNotesnookDesc(platform)}.</Text>
{isMobile && (
<Box
sx={{
display: "grid",
gridTemplateColumns: "1fr 1fr",
columnGap: 1,
rowGap: 1,
mt: 1
}}
>
{strings.nativeFeatures().map((feature) => (
<Flex
key={feature}
p={1}
sx={{
borderRadius: "default",
border: "1px solid var(--border)"
}}
>
<Text variant="body" ml={1}>
{feature}
</Text>
</Flex>
))}
</Box>
)}
<Flex mt={[4, 1]} sx={{ alignItems: "center" }}>
<DropdownButton title={"Options"} options={getOptions(onClose)} />
<Button
variant={"secondary"}
ml={1}
onClick={() => {
onClose();
Config.set("installNotice", false);
}}
sx={{ alignSelf: "start" }}
>
{strings.dontShowAgain()}
</Button>
</Flex>
</Flex>
);
}
export function showInstallNotice() {
if (!Config.get("installNotice", true)) return;
const root = document.getElementById("floatingViewContainer");
if (root) {
return new Promise((resolve) => {
const perform = (result) => {
ReactDOM.unmountComponentAtNode(root);
resolve(result);
};
ReactDOM.render(
<BaseThemeProvider>
<InstallNotice onClose={perform} />
</BaseThemeProvider>,
root
);
});
}
return Promise.reject("No element with id 'floatingViewContainer'");
}

View File

@@ -1,39 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
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/>.
*/
import { memo } from "react";
import Skeleton from "react-loading-skeleton";
import { Box, Flex } from "@theme-ui/components";
import "react-loading-skeleton/dist/skeleton.css";
import { ListLoader } from "./list-loader";
export const ViewLoader = memo(function ViewLoader() {
return (
<Box sx={{ my: 1 }}>
<Flex sx={{ justifyContent: "space-between", py: 0, px: 1 }}>
<Skeleton height={35} width={100} borderRadius={5} />
<Flex>
<Skeleton height={35} width={35} circle style={{ marginRight: 5 }} />
<Skeleton height={35} width={35} circle />
</Flex>
</Flex>
<ListLoader />
</Box>
);
});

View File

@@ -1,116 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
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/>.
*/
import { useState, useEffect } from "react";
type TextScrambleProps = {
text: string;
className?: string;
letterSpeed?: number;
nextLetterSpeed?: number;
paused?: boolean;
pauseTime?: number;
};
const randomItem = (array: Array<any>) =>
array[Math.floor(Math.random() * array.length)];
const nextItem = (array: Array<any>, currentItem: any) => {
const currentIndex = array.indexOf(currentItem);
const bound = array.length;
const nextIndex = (currentIndex + bound + 1) % bound;
return array[nextIndex];
};
const symbols: string[] = "-=_+/.,<>;'!@#$%^&*()".split("");
export function TextScramble(props: TextScrambleProps) {
const {
text,
className,
letterSpeed = 5,
nextLetterSpeed = 100,
paused = false,
pauseTime = 1500
} = props;
const initSymbols: string[] = Array(text.length)
.fill(0)
.map(() => randomItem(symbols));
const [displayedText, setDisplayedText] = useState<string[]>(initSymbols);
const leftIndexes: number[] = [];
const defaultLeftIndexes = (): void => {
text.split("").forEach((_, i) => {
leftIndexes.push(i);
});
};
let bakeLetterInterval: any = 0;
let bakeTextInterval: any = 0;
const bakeLetter = () => {
bakeLetterInterval = setInterval(() => {
if (!paused) {
const updatedText: string[] = [];
text.split("").forEach((_, i) => {
if (!leftIndexes.includes(i)) {
updatedText[i] = text[i];
return;
}
const randomSymbol = randomItem(symbols);
updatedText[i] = randomSymbol;
});
setDisplayedText(updatedText);
}
}, letterSpeed);
};
const bakeText = () => {
defaultLeftIndexes();
bakeLetter();
bakeTextInterval = setInterval(() => {
if (!paused) {
if (leftIndexes.length === 0) {
clearInterval(bakeLetterInterval);
clearInterval(bakeTextInterval);
setTimeout(() => {
// setCurrentText(text);
defaultLeftIndexes();
}, pauseTime);
}
leftIndexes.shift();
}
}, nextLetterSpeed);
};
useEffect(() => {
if (!paused) bakeText();
}, [text, paused]); // eslint-disable-line react-hooks/exhaustive-deps
return <div className={className}>{displayedText}</div>;
}