Skip to content

Commit

Permalink
lazy importing icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahuletto committed Jul 24, 2023
1 parent 1f4b3ab commit d3c2eaf
Show file tree
Hide file tree
Showing 45 changed files with 611 additions and 4,936 deletions.
3 changes: 2 additions & 1 deletion components/AddFile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Icons
import { FaPlus } from 'react-icons-ng/fa';
import dynamic from 'next/dynamic';
const FaPlus = dynamic(() => import('react-icons-ng/fa').then(mod => mod.FaPlus), { ssr: false })

const AddFile = ({ files, limit = 2 }) => {
function showDialog() {
Expand Down
1 change: 1 addition & 0 deletions components/CodeBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import dynamic from 'next/dynamic';
import React, { Suspense, useEffect, memo } from 'react';

// Lazy import
const CodeMirror = dynamic(() => import('@uiw/react-codemirror'), {
loading: () => <BoardLoader />,
ssr: false,
Expand Down
19 changes: 14 additions & 5 deletions components/CodeMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import dynamic from 'next/dynamic';
import {
Menu,
Item,
Expand All @@ -7,11 +8,19 @@ import {
} from 'react-contexify';

import 'react-contexify/dist/ReactContexify.css';
import { BiCommand, BiSearch, BiSolidCopy } from 'react-icons-ng/bi';
import { CoExpand } from 'react-icons-ng/co';
import { FlFillIcFluentWindow24Filled, FlFillIcFluentCut24Filled } from 'react-icons-ng/fl';
import { LuClipboardPaste } from 'react-icons-ng/lu';
import { SiPrettier } from 'react-icons-ng/si';

const BiCommand = dynamic(() => import('react-icons-ng/bi').then(mod => mod.BiCommand ), { ssr: false })
const BiSearch = dynamic(() => import('react-icons-ng/bi').then(mod => mod.BiSearch ), { ssr: false })
const BiSolidCopy = dynamic(() => import('react-icons-ng/bi').then(mod => mod.BiSolidCopy ), { ssr: false })

const CoExpand = dynamic(() => import('react-icons-ng/co').then(mod => mod.CoExpand ), { ssr: false })

const FlFillIcFluentWindow24Filled = dynamic(() => import('react-icons-ng/fl').then(mod => mod.FlFillIcFluentWindow24Filled ), { ssr: false })
const FlFillIcFluentCut24Filled = dynamic(() => import('react-icons-ng/fl').then(mod => mod.FlFillIcFluentCut24Filled ), { ssr: false })

const LuClipboardPaste = dynamic(() => import('react-icons-ng/lu').then(mod => mod.LuClipboardPaste ), { ssr: false })

const SiPrettier = dynamic(() => import('react-icons-ng/si').then(mod => mod.SiPrettier ), { ssr: false })

const CodeMenu = ({ readOnly }) => {

Expand Down
4 changes: 2 additions & 2 deletions components/Command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { Md2RobotExcited } from "react-icons-ng/md2";
import { PiStarFourFill } from "react-icons-ng/pi";
import { SiPrettier } from "react-icons-ng/si";
import { HiEye, HiFlag, HiHome, HiLifebuoy, HiMoon, HiPlus, HiSun } from 'react-icons-ng/hi'
import { IconType } from "react-icons-ng";

import { IconType } from "react-icons-ng";

const Command = ({ router }) => {
const [cmd, setCmd] = useState(false);
Expand Down Expand Up @@ -257,7 +257,7 @@ const Command = ({ router }) => {
style={{
textAlign: 'center',
margin: '25px',
fontFamily: 'var(--mono-font)',
fontFamily: "var(--mono-font)",
color: 'var(--special-color)',
}}>
No Results
Expand Down
4 changes: 3 additions & 1 deletion components/CreateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { ChangeEvent, FormEvent } from 'react';
import styles from '../styles/Index.module.css';

// Icons
import { FaBackward, FaCloudUploadAlt } from 'react-icons-ng/fa';
const FaBackward = dynamic(() => import('react-icons-ng/fa').then(mod => mod.FaBackward), { ssr: false })
const FaCloudUploadAlt = dynamic(() => import('react-icons-ng/fa').then(mod => mod.FaCloudUploadAlt), { ssr: false })

// Our Imports
import { extensions } from '../utils/extensions';
import { BoardFile } from '../utils/types/board';
import dynamic from 'next/dynamic';

type CreateModalProps = {
files: BoardFile[];
Expand Down
4 changes: 3 additions & 1 deletion components/DropZone.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Styles
import dynamic from 'next/dynamic';
import styles from '../styles/Index.module.css';

// Icons
import { FaCloudUploadAlt, FaWindowClose } from 'react-icons-ng/fa';
const FaCloudUploadAlt = dynamic(() => import('react-icons-ng/fa').then(mod => mod.FaCloudUploadAlt), { ssr: false })
const FaWindowClose = dynamic(() => import('react-icons-ng/fa').then(mod => mod.FaWindowClose), { ssr: false })

// Our Imports
import { BoardFile } from '../utils/types/board';
Expand Down
6 changes: 4 additions & 2 deletions components/Feature.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Styles
import dynamic from 'next/dynamic';
import styles from '../styles/Index.module.css';
import feature from './styles/Feature.module.css';

import { McCheckCircleFill, McForbidCircleLine } from 'react-icons-ng/mc';
const McCheckCircleFill = dynamic(() => import('react-icons-ng/mc').then(mod => mod.McCheckCircleFill), { ssr: false })
const McForbidCircleLine = dynamic(() => import('react-icons-ng/mc').then(mod => mod.McForbidCircleLine), { ssr: false })

const Features = ({ session }) => {
return (
Expand Down Expand Up @@ -116,7 +118,7 @@ const Features = ({ session }) => {
<h4>
<span
style={{
fontFamily: 'var(--mono-font)',
fontFamily: "var(--mono-font)",
color: 'var(--purple-dark)',
fontSize: '22px',
}}>
Expand Down
4 changes: 3 additions & 1 deletion components/FileSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Icons
import { FaCaretDown } from 'react-icons-ng/fa';
import dynamic from 'next/dynamic';
const FaCaretDown = dynamic(() => import('react-icons-ng/fa').then(mod => mod.FaCaretDown), { ssr: false })


// Our Imports
import { BoardFile } from '../utils/types/board';
Expand Down
6 changes: 5 additions & 1 deletion components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Styles
import dynamic from 'next/dynamic';
import styles from './styles/Header.module.css';

// NextJS
Expand All @@ -8,12 +9,15 @@ import Link from 'next/link';
import ThemeSwitch from './ThemeSwitch';

// Icons
import { FaPlus, FaUserAlt } from 'react-icons-ng/fa';

const FaPlus = dynamic(() => import('react-icons-ng/fa').then(mod => mod.FaPlus), { ssr: false })
const FaUserAlt = dynamic(() => import('react-icons-ng/fa').then(mod => mod.FaUserAlt), { ssr: false })

import { useRouter } from 'next/router';
import { useSession } from '@supabase/auth-helpers-react';
import { memo } from 'react';


type HeaderProps = {
theme?: string;
setTheme?: Function;
Expand Down
4 changes: 3 additions & 1 deletion components/InfoButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

// Icons
import { GoGear } from 'react-icons-ng/go';
import dynamic from 'next/dynamic';

const GoGear = dynamic(() => import('react-icons-ng/go').then(mod => mod.GoGear), { ssr: false })

interface MetaTagsProps {
metadata?: boolean;
Expand Down
4 changes: 3 additions & 1 deletion components/PrettierButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Icons
import { SiPrettier } from 'react-icons-ng/si';
import dynamic from 'next/dynamic';
const SiPrettier = dynamic(() => import('react-icons-ng/si').then(mod => mod.SiPrettier), { ssr: false })


// Styles
import styles from '../styles/Index.module.css';
Expand Down
3 changes: 2 additions & 1 deletion components/Save.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import styles from '../styles/Index.module.css';

// Icons
import { BiSolidSave } from 'react-icons-ng/bi';
import dynamic from 'next/dynamic';
const BiSolidSave = dynamic(() => import('react-icons-ng/bi').then(mod => mod.BiSolidSave), { ssr: false })

const Save = () => {
return (
Expand Down
6 changes: 4 additions & 2 deletions components/Warning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import generalStyles from '../styles/General.module.css'

// Icons
import { IoCloseCircleSharp } from 'react-icons-ng/io5';
import { TiWarning } from 'react-icons-ng/ti';
import dynamic from 'next/dynamic';
const IoCloseCircleSharp = dynamic(() => import('react-icons-ng/io5').then(mod => mod.IoCloseCircleSharp), { ssr: false })
const TiWarning = dynamic(() => import('react-icons-ng/ti').then(mod => mod.TiWarning), { ssr: false })


const Warning: React.FC<{}> = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion components/styles/Feature.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

.card h2 {
color: var(--special-color);
font-family: 'var(--mono-font)';
font-family: var(--mono-font);
}

.card h3 {
Expand Down
6 changes: 3 additions & 3 deletions components/styles/Header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.newProject {
font-size: 18px;
background: var(--background-dark);
font-family: 'var(--mono-font)';
font-family: var(--mono-font);
color: var(--special-color);
padding: 6px 24px;
border-radius: 50px;
Expand All @@ -19,7 +19,7 @@

.title {
margin: 0px;
font-family: 'var(--mono-font)';
font-family: var(--mono-font);
font-size: 36px;
color: var(--special-color);
}
Expand Down Expand Up @@ -51,7 +51,7 @@
background: var(--purple);
border-radius: 10px;
border-right: 4px solid var(--purple-dark);
font-family: 'var(--mono-font)';
font-family: var(--mono-font);
height: 34px;
display: flex;
align-items: center;
Expand Down
2 changes: 1 addition & 1 deletion components/styles/Loader.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
}

.loadTitle {
font-family: 'var(--mono-font)';
font-family: var(--mono-font);
color: var(--special-color);
opacity: 0.8;
font-weight: 600;
Expand Down
2 changes: 1 addition & 1 deletion components/utils/DarkTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const DarkTheme = atomoneInit({
selection: '#646464',
selectionMatch: '#646464',
caret: '#C6C6C6',
fontFamily: 'var(--mono-font)',
fontFamily: "var(--mono-font)",
},
styles: [
{ tag: t.content, color: '#7D8799' },
Expand Down
Loading

0 comments on commit d3c2eaf

Please sign in to comment.