0
Fork 0
mirror of https://github.com/stonith404/pingvin-share.git synced 2025-02-19 01:55:48 -05:00

performance: replace tabler-icons-react with react-icons to reduce bundle size

This commit is contained in:
Elias Schneider 2022-10-14 11:59:40 +02:00
parent 247ce92744
commit d906d56b9f
11 changed files with 44 additions and 51 deletions

View file

@ -26,7 +26,7 @@
"next-pwa": "^5.6.0", "next-pwa": "^5.6.0",
"react": "18.0.0", "react": "18.0.0",
"react-dom": "18.0.0", "react-dom": "18.0.0",
"tabler-icons-react": "^1.44.0", "react-icons": "^4.4.0",
"yup": "^0.32.11" "yup": "^0.32.11"
}, },
"devDependencies": { "devDependencies": {
@ -6381,6 +6381,14 @@
"react": ">= 16.8 || 18.0.0" "react": ">= 16.8 || 18.0.0"
} }
}, },
"node_modules/react-icons": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.4.0.tgz",
"integrity": "sha512-fSbvHeVYo/B5/L4VhB7sBA1i2tS8MkT0Hb9t2H1AVPkwGfVHLJCqyr2Py9dKMxsyM63Eng1GkdZfbWj+Fmv8Rg==",
"peerDependencies": {
"react": "*"
}
},
"node_modules/react-is": { "node_modules/react-is": {
"version": "16.13.1", "version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
@ -6971,14 +6979,6 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/tabler-icons-react": {
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/tabler-icons-react/-/tabler-icons-react-1.44.0.tgz",
"integrity": "sha512-AYQQGl55yVe1KHZl+zyDAAwDOcPknKZNC7vgwmjyvpmz4P5Gjb7DtpsOPa1nB0qMYW5Orsrt+1e4qnRoCKgo6A==",
"peerDependencies": {
"react": ">= 16.8.0"
}
},
"node_modules/tapable": { "node_modules/tapable": {
"version": "2.2.1", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
@ -12479,6 +12479,12 @@
"prop-types": "^15.8.1" "prop-types": "^15.8.1"
} }
}, },
"react-icons": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.4.0.tgz",
"integrity": "sha512-fSbvHeVYo/B5/L4VhB7sBA1i2tS8MkT0Hb9t2H1AVPkwGfVHLJCqyr2Py9dKMxsyM63Eng1GkdZfbWj+Fmv8Rg==",
"requires": {}
},
"react-is": { "react-is": {
"version": "16.13.1", "version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
@ -12910,12 +12916,6 @@
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w=="
}, },
"tabler-icons-react": {
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/tabler-icons-react/-/tabler-icons-react-1.44.0.tgz",
"integrity": "sha512-AYQQGl55yVe1KHZl+zyDAAwDOcPknKZNC7vgwmjyvpmz4P5Gjb7DtpsOPa1nB0qMYW5Orsrt+1e4qnRoCKgo6A==",
"requires": {}
},
"tapable": { "tapable": {
"version": "2.2.1", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",

View file

@ -27,7 +27,7 @@
"next-pwa": "^5.6.0", "next-pwa": "^5.6.0",
"react": "18.0.0", "react": "18.0.0",
"react-dom": "18.0.0", "react-dom": "18.0.0",
"tabler-icons-react": "^1.44.0", "react-icons": "^4.4.0",
"yup": "^0.32.11" "yup": "^0.32.11"
}, },
"devDependencies": { "devDependencies": {

View file

@ -1,6 +1,6 @@
import { ActionIcon, Avatar, Menu } from "@mantine/core"; import { ActionIcon, Avatar, Menu } from "@mantine/core";
import { NextLink } from "@mantine/next"; import { NextLink } from "@mantine/next";
import { DoorExit, Link } from "tabler-icons-react"; import { TbDoorExit, TbLink } from "react-icons/tb";;
import authService from "../../services/auth.service"; import authService from "../../services/auth.service";
const ActionAvatar = () => { const ActionAvatar = () => {
@ -15,7 +15,7 @@ const ActionAvatar = () => {
<Menu.Item <Menu.Item
component={NextLink} component={NextLink}
href="/account/shares" href="/account/shares"
icon={<Link size={14} />} icon={<TbLink size={14} />}
> >
My shares My shares
</Menu.Item> </Menu.Item>
@ -23,7 +23,7 @@ const ActionAvatar = () => {
onClick={async () => { onClick={async () => {
authService.signOut(); authService.signOut();
}} }}
icon={<DoorExit size={14} />} icon={<TbDoorExit size={14} />}
> >
Sign out Sign out
</Menu.Item> </Menu.Item>

View file

@ -1,5 +1,5 @@
import { ActionIcon, Loader, Skeleton, Table } from "@mantine/core"; import { ActionIcon, Loader, Skeleton, Table } from "@mantine/core";
import { CircleCheck, Download } from "tabler-icons-react"; import { TbCircleCheck, TbDownload } from "react-icons/tb";;
import shareService from "../../services/share.service"; import shareService from "../../services/share.service";
import { byteStringToHumanSizeString } from "../../utils/math/byteStringToHumanSizeString.util"; import { byteStringToHumanSizeString } from "../../utils/math/byteStringToHumanSizeString.util";
@ -39,7 +39,7 @@ const FileList = ({
file.uploadingState != "finished" ? ( file.uploadingState != "finished" ? (
<Loader size={22} /> <Loader size={22} />
) : ( ) : (
<CircleCheck color="green" size={22} /> <TbCircleCheck color="green" size={22} />
) )
) : ( ) : (
<ActionIcon <ActionIcon
@ -48,7 +48,7 @@ const FileList = ({
await shareService.downloadFile(shareId, file.id); await shareService.downloadFile(shareId, file.id);
}} }}
> >
<Download /> <TbDownload />
</ActionIcon> </ActionIcon>
)} )}
</td> </td>

View file

@ -2,7 +2,7 @@ import { Button, Center, createStyles, Group, Text } from "@mantine/core";
import { Dropzone as MantineDropzone } from "@mantine/dropzone"; import { Dropzone as MantineDropzone } from "@mantine/dropzone";
import getConfig from "next/config"; import getConfig from "next/config";
import { Dispatch, ForwardedRef, SetStateAction, useRef } from "react"; import { Dispatch, ForwardedRef, SetStateAction, useRef } from "react";
import { CloudUpload, Upload } from "tabler-icons-react"; import { TbCloudUpload, TbUpload } from "react-icons/tb";;;
import { FileUpload } from "../../types/File.type"; import { FileUpload } from "../../types/File.type";
import { byteStringToHumanSizeString } from "../../utils/math/byteStringToHumanSizeString.util"; import { byteStringToHumanSizeString } from "../../utils/math/byteStringToHumanSizeString.util";
import toast from "../../utils/toast.util"; import toast from "../../utils/toast.util";
@ -67,7 +67,7 @@ const Dropzone = ({
> >
<div style={{ pointerEvents: "none" }}> <div style={{ pointerEvents: "none" }}>
<Group position="center"> <Group position="center">
<CloudUpload size={50} /> <TbCloudUpload size={50} />
</Group> </Group>
<Text align="center" weight={700} size="lg" mt="xl"> <Text align="center" weight={700} size="lg" mt="xl">
Upload files Upload files
@ -89,7 +89,7 @@ const Dropzone = ({
disabled={isUploading} disabled={isUploading}
onClick={() => openRef.current && openRef.current()} onClick={() => openRef.current && openRef.current()}
> >
{<Upload />} {<TbUpload />}
</Button> </Button>
</Center> </Center>
</div> </div>

View file

@ -1,6 +1,6 @@
import { ActionIcon, Table } from "@mantine/core"; import { ActionIcon, Table } from "@mantine/core";
import { Dispatch, SetStateAction } from "react"; import { Dispatch, SetStateAction } from "react";
import { Trash } from "tabler-icons-react"; import { TbTrash } from "react-icons/tb";;
import { FileUpload } from "../../types/File.type"; import { FileUpload } from "../../types/File.type";
import { byteStringToHumanSizeString } from "../../utils/math/byteStringToHumanSizeString.util"; import { byteStringToHumanSizeString } from "../../utils/math/byteStringToHumanSizeString.util";
import UploadProgressIndicator from "./UploadProgressIndicator"; import UploadProgressIndicator from "./UploadProgressIndicator";
@ -28,7 +28,7 @@ const FileList = ({
size={25} size={25}
onClick={() => remove(i)} onClick={() => remove(i)}
> >
<Trash /> <TbTrash />
</ActionIcon> </ActionIcon>
) : ( ) : (
<UploadProgressIndicator progress={file.uploadingProgress} /> <UploadProgressIndicator progress={file.uploadingProgress} />

View file

@ -1,5 +1,5 @@
import { RingProgress } from "@mantine/core"; import { RingProgress } from "@mantine/core";
import { CircleCheck, CircleX } from "tabler-icons-react"; import { TbCircleCheck, TbCircleX } from "react-icons/tb";;
const UploadProgressIndicator = ({ progress }: { progress: number }) => { const UploadProgressIndicator = ({ progress }: { progress: number }) => {
if (progress > 0 && progress < 100) { if (progress > 0 && progress < 100) {
@ -11,9 +11,9 @@ const UploadProgressIndicator = ({ progress }: { progress: number }) => {
/> />
); );
} else if (progress == 100) { } else if (progress == 100) {
return <CircleCheck color="green" size={22} />; return <TbCircleCheck color="green" size={22} />;
} else { } else {
return <CircleX color="red" size={22} />; return <TbCircleX color="red" size={22} />;
} }
}; };

View file

@ -1,25 +1,20 @@
import { import {
ActionIcon, ActionIcon,
Button, Button,
Group,
Stack, Stack,
Text, Text,
TextInput, TextInput,
Title Title,
} from "@mantine/core"; } from "@mantine/core";
import { useClipboard } from "@mantine/hooks"; import { useClipboard } from "@mantine/hooks";
import { useModals } from "@mantine/modals"; import { useModals } from "@mantine/modals";
import { ModalsContextProps } from "@mantine/modals/lib/context"; import { ModalsContextProps } from "@mantine/modals/lib/context";
import moment from "moment"; import moment from "moment";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { Copy } from "tabler-icons-react"; import { TbCopy } from "react-icons/tb";
import { Share } from "../../types/share.type"; import { Share } from "../../types/share.type";
import toast from "../../utils/toast.util"; import toast from "../../utils/toast.util";
const showCompletedUploadModal = (modals: ModalsContextProps, share: Share) => {
const showCompletedUploadModal = (
modals: ModalsContextProps,
share: Share,
) => {
return modals.openModal({ return modals.openModal({
closeOnClickOutside: false, closeOnClickOutside: false,
withCloseButton: false, withCloseButton: false,
@ -39,7 +34,7 @@ const Body = ({ share }: { share: Share }) => {
const router = useRouter(); const router = useRouter();
const link = `${window.location.origin}/share/${share.id}`; const link = `${window.location.origin}/share/${share.id}`;
return ( return (
<Stack align="stretch"> <Stack align="stretch">
<TextInput <TextInput
variant="filled" variant="filled"
value={link} value={link}
@ -50,7 +45,7 @@ const Body = ({ share }: { share: Share }) => {
toast.success("Your link was copied to the keyboard."); toast.success("Your link was copied to the keyboard.");
}} }}
> >
<Copy /> <TbCopy />
</ActionIcon> </ActionIcon>
} }
/> />

View file

@ -16,7 +16,7 @@ import { NextLink } from "@mantine/next";
import moment from "moment"; import moment from "moment";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Link, Trash } from "tabler-icons-react"; import { TbLink, TbTrash } from "react-icons/tb";;
import Meta from "../../components/Meta"; import Meta from "../../components/Meta";
import useUser from "../../hooks/user.hook"; import useUser from "../../hooks/user.hook";
import shareService from "../../services/share.service"; import shareService from "../../services/share.service";
@ -89,7 +89,7 @@ const MyShares = () => {
); );
}} }}
> >
<Link /> <TbLink />
</ActionIcon> </ActionIcon>
<ActionIcon <ActionIcon
color="red" color="red"
@ -116,7 +116,7 @@ const MyShares = () => {
}); });
}} }}
> >
<Trash /> <TbTrash />
</ActionIcon> </ActionIcon>
</Group> </Group>
</td> </td>

View file

@ -12,10 +12,9 @@ import { NextLink } from "@mantine/next";
import getConfig from "next/config"; import getConfig from "next/config";
import Image from "next/image"; import Image from "next/image";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { Check } from "tabler-icons-react"; import { TbCheck } from "react-icons/tb";
import Meta from "../components/Meta"; import Meta from "../components/Meta";
import useUser from "../hooks/user.hook"; import useUser from "../hooks/user.hook";
const { publicRuntimeConfig } = getConfig(); const { publicRuntimeConfig } = getConfig();
const useStyles = createStyles((theme) => ({ const useStyles = createStyles((theme) => ({
@ -101,7 +100,7 @@ export default function Home() {
size="sm" size="sm"
icon={ icon={
<ThemeIcon size={20} radius="xl"> <ThemeIcon size={20} radius="xl">
<Check size={12} /> <TbCheck size={12} />
</ThemeIcon> </ThemeIcon>
} }
> >

View file

@ -1,19 +1,18 @@
import { showNotification } from "@mantine/notifications"; import { showNotification } from "@mantine/notifications";
import { Check, X } from "tabler-icons-react"; import { TbCheck, TbX } from "react-icons/tb";
const error = (message: string) => const error = (message: string) =>
showNotification({ showNotification({
icon: <X />, icon: <TbX />,
color: "red", color: "red",
radius: "md", radius: "md",
title: "Error", title: "Error",
message: message, message: message,
}); });
const success = (message: string) => const success = (message: string) =>
showNotification({ showNotification({
icon: <Check />, icon: <TbCheck />,
color: "green", color: "green",
radius: "md", radius: "md",
title: "Success", title: "Success",