Initial commit

This commit is contained in:
Alexander Gorshkov 2024-03-12 15:02:51 +00:00
parent 1273797f6a
commit 02fc3ca102
16 changed files with 2874 additions and 22 deletions

2478
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,14 +9,23 @@
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@chakra-ui/next-js": "^2.2.0",
"@chakra-ui/pro-theme": "^0.10.0",
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"framer-motion": "^11.0.8",
"next": "14.1.3",
"quill": "^1.3.7",
"react": "^18", "react": "^18",
"react-dom": "^18", "react-dom": "^18",
"next": "14.1.3" "react-icons": "^5.0.1",
"react-quill": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^5",
"@types/node": "^20", "@types/node": "^20",
"@types/react": "^18", "@types/react": "^18",
"@types/react-dom": "^18" "@types/react-dom": "^18",
"typescript": "^5"
} }
} }

BIN
public/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>

Before

Width:  |  Height:  |  Size: 629 B

5
src/app/auth/page.tsx Normal file
View File

@ -0,0 +1,5 @@
import AuthChakraPage from "@/chakra-pages/Auth";
export default function Auth() {
return <AuthChakraPage/>
}

View File

@ -100,6 +100,17 @@ a {
text-decoration: none; text-decoration: none;
} }
.ql-editor::before {
left: 0!important;
right: 0!important;
font-size: 16px;
}
.ql-editor {
padding: 12px 0!important;
font-size: 16px;
}
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
html { html {
color-scheme: dark; color-scheme: dark;

View File

@ -1,22 +1,21 @@
import type {Metadata} from "next"; import type {Metadata} from "next";
import {Inter} from "next/font/google"; import {Inter} from "next/font/google";
import "./globals.css"; import "./globals.css";
import {Providers} from "./providers";
const inter = Inter({subsets: ["latin"]}); const inter = Inter({subsets: ["latin"]});
export const metadata: Metadata = { export const metadata: Metadata = {
title: "Create Next App", title: "QNote.app",
description: "Generated by create next app", description: "Note app",
}; };
export default function RootLayout({ export default function RootLayout({children}: Readonly<{ children: React.ReactNode; }>) {
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return ( return (
<html lang="en"> <html lang="en">
<body className={inter.className}>{children}</body> <body className={inter.className}>
<Providers>{children}</Providers>
</body>
</html> </html>
); );
} }

5
src/app/notes/page.tsx Normal file
View File

@ -0,0 +1,5 @@
import NotesChakraPage from "@/chakra-pages/Notes";
export default function Notes() {
return <NotesChakraPage/>
}

14
src/app/providers.tsx Normal file
View File

@ -0,0 +1,14 @@
'use client'
import {ChakraProvider, extendTheme} from '@chakra-ui/react'
import {theme} from "@chakra-ui/pro-theme";
export function Providers({ children }: { children: React.ReactNode }) {
const proTheme = extendTheme(theme)
const extenstion = {
colors: { ...proTheme.colors, brand: proTheme.colors.teal },
}
const myTheme = extendTheme(extenstion, proTheme)
return <ChakraProvider theme={myTheme}>{children}</ChakraProvider>
}

65
src/chakra-pages/Auth.tsx Normal file
View File

@ -0,0 +1,65 @@
"use client"
import {Box, Button, Container, Divider, Heading, HStack, Stack, Text} from "@chakra-ui/react";
import React from "react";
import {Logo} from "@/components/shared/Logo";
import {GoogleIcon} from "@/components/shared/ProviderIcons";
import {RequestInProgressProvider, useRequestInProgress} from "@/hooks/useRequestInProgress";
import LoginWithEmail from "@/components/auth/LoginWithEmail";
export function AuthChakraPage() {
const {requestInProgress, setRequestInProgress} = useRequestInProgress();
return (
<Box
bgGradient={{sm: 'linear(to-br, gray.300, gray.50)'}}
py={{base: '12', md: '24'}}
h="auto"
minH="100%"
>
<Container
maxW="md"
py={{base: '0', sm: '8'}}
px={{base: '4', sm: '10'}}
bg={{base: 'transparent', sm: 'bg.surface'}}
boxShadow={{base: 'none', sm: 'xl'}}
borderRadius={{base: 'none', sm: 'xl'}}
>
<Stack spacing="8">
<Stack spacing="6" align="center">
<Logo w={24}/>
<Stack spacing="3" textAlign="center">
<Heading size="xs">Log in to your account</Heading>
</Stack>
</Stack>
<Stack spacing="6">
<Button variant="outline" leftIcon={<GoogleIcon/>} isDisabled={requestInProgress}>
Continue with Google
</Button>
<HStack alignItems="center" justifyContent="center" spacing={{ base: 3, md: 5 }}>
<Divider/>
<Text color="fg.muted">or</Text>
<Divider/>
</HStack>
<LoginWithEmail/>
</Stack>
<Text textStyle="xs" color="fg.subtle" textAlign="center">
By continuing, you acknowledge that you have read, understood, and agree to our terms and
condition
</Text>
</Stack>
</Container>
</Box>
)
}
export default function WrappedAuthChakraPage() {
return (
<RequestInProgressProvider>
<AuthChakraPage/>
</RequestInProgressProvider>
)
}

185
src/chakra-pages/Notes.tsx Normal file
View File

@ -0,0 +1,185 @@
"use client"
import {
Box,
Button,
Container,
Divider,
Flex,
Heading,
HStack,
Input,
Link,
Text,
VStack,
Wrap
} from "@chakra-ui/react";
import {Logo} from "@/components/shared/Logo";
import {BsPlus} from "react-icons/bs";
import 'react-quill/dist/quill.snow.css';
import dynamic from "next/dynamic";
import {useState} from "react";
const QuillEditor = dynamic(() => import('react-quill'), {ssr: false});
export default function NotesChakraPage() {
const [content, setContent] = useState('');
const quillModules = {
toolbar: [
[{header: [1, 2, 3, false]}],
['bold', 'italic', 'underline', 'strike', 'blockquote'],
[{list: 'ordered'}, {list: 'bullet'}],
['link', 'image'],
[{align: []}],
[{color: []}],
['code-block'],
['clean'],
],
};
const quillFormats = [
'header',
'bold',
'italic',
'underline',
'strike',
'blockquote',
'list',
'bullet',
'link',
'image',
'align',
'color',
'code-block',
];
const handleEditorChange = (newContent) => {
setContent(newContent);
};
return (
<Box
bgGradient={{sm: 'linear(to-br, gray.300, gray.50)'}}
py={{base: '2', md: '4'}}
minH="100%"
display="flex"
flexDirection="column"
height="100%"
overflowY="hidden"
>
<Flex
px={{base: '4', sm: '10'}}
justifyContent="center"
alignItems="start"
h="auto"
minH="100%"
gap={5}>
<VStack w="100%" maxW="sm" h="100%" minH="100%">
<Link href="/" w="100%" border="none" outline="none" _before={{display: "none"}}>
<HStack justifyContent="start" alignItems="center" w="100%">
<Logo w={24}/>
<Heading size="md" color="black">QNote</Heading>
</HStack>
</Link>
<Container
display="flex"
flex={1}
flexDirection="column"
w="100%"
mx={0}
px={0}
py={4}
bg={{base: 'transparent', sm: 'bg.surface'}}
boxShadow={{base: 'none', sm: 'xl'}}
borderRadius={{base: 'none', sm: 'xl'}}
overflowY="hidden"
>
<VStack spacing={3} w="100%" h="100%" minH="100%">
<Flex w="100%" justifyContent="space-between" alignItems="center" px={4}>
<Text>Hello, Alexander 👋</Text>
<Button
backgroundColor="gray.100"
color="gray.800"
_hover={{backgroundColor: "gray.300"}}
><BsPlus/></Button>
</Flex>
<Box flex={1} w="100%" overflowY="auto" sx={{
'::-webkit-scrollbar': {
w: '2'
},
'::-webkit-scrollbar-track': {
bg: 'gray.50'
},
'::-webkit-scrollbar-thumb': {
bg: 'gray.400',
borderRadius: '4'
}
}}>
<VStack spacing={1} w="100%" px={1} py={1}>
{Array.from(Array(50).keys()).map(i => (
<Wrap key={i} w="100%">
<Box w="100%" px={4} py={2}>
<Text fontWeight="black">Note name ${i + 1}</Text>
<Text>Note text preview...</Text>
</Box>
<Divider my={2}/>
</Wrap>
))}
</VStack>
</Box>
</VStack>
</Container>
</VStack>
<Container
display="flex"
flex={1}
flexDirection="column"
w="100%"
h="auto"
minH="100%"
mx={0}
py={{base: '0', sm: '8'}}
bg={{base: 'transparent', sm: 'bg.surface'}}
boxShadow={{base: 'none', sm: 'xl'}}
borderRadius={{base: 'none', sm: 'xl'}}
>
<Input size="xl"
placeholder="Unnamed note"
px={0}
borderRadius="none"
border="none"
borderBottomWidth={1}
borderBottomStyle="solid"
borderBottomColor="gray.100"
_focus={{
boxShadow: "none",
outline: "none",
borderBottomColor: "brand.500"
}}
mb={3}
/>
<Box flex={1} w="100%" overflowY="auto" w="100%">
<QuillEditor
theme="snow"
placeholder="Write down all your thoughts..."
value={content}
onChange={handleEditorChange}
modules={quillModules}
formats={quillFormats}
style={{width: '100%', height: '100%', overflowY: 'auto' }}
/>
</Box>
</Container>
</Flex>
</Box>
)
}

View File

@ -0,0 +1,19 @@
import {Button, Input, Stack, Text} from "@chakra-ui/react";
import {Link} from "@chakra-ui/next-js";
import React from "react";
import {useRequestInProgress} from "@/hooks/useRequestInProgress";
export default function LoginWithEmail() {
const {requestInProgress} = useRequestInProgress();
return (
<Stack spacing="4">
<Input placeholder="Enter your email"/>
<Button variant="secondary" isDisabled={requestInProgress}>Continue with email</Button>
<Text textStyle="sm" color="fg.muted" textAlign="center">
Having trouble logging in? <Link href="#">Contact us</Link>
</Text>
</Stack>
)
}

View File

@ -0,0 +1,5 @@
import {Image, ImageProps} from '@chakra-ui/react'
export const Logo = (props: Omit<ImageProps, "src">) => (
<Image src="/logo.png" {...props} />
)

View File

@ -0,0 +1,45 @@
import { createIcon } from '@chakra-ui/react'
export const GoogleIcon = createIcon({
displayName: 'GoogleIcon',
path: (
<g transform="matrix(1, 0, 0, 1, 27.009001, -39.238998)">
<path
fill="#4285F4"
d="M -3.264 51.509 C -3.264 50.719 -3.334 49.969 -3.454 49.239 L -14.754 49.239 L -14.754 53.749 L -8.284 53.749 C -8.574 55.229 -9.424 56.479 -10.684 57.329 L -10.684 60.329 L -6.824 60.329 C -4.564 58.239 -3.264 55.159 -3.264 51.509 Z"
/>
<path
fill="#34A853"
d="M -14.754 63.239 C -11.514 63.239 -8.804 62.159 -6.824 60.329 L -10.684 57.329 C -11.764 58.049 -13.134 58.489 -14.754 58.489 C -17.884 58.489 -20.534 56.379 -21.484 53.529 L -25.464 53.529 L -25.464 56.619 C -23.494 60.539 -19.444 63.239 -14.754 63.239 Z"
/>
<path
fill="#FBBC05"
d="M -21.484 53.529 C -21.734 52.809 -21.864 52.039 -21.864 51.239 C -21.864 50.439 -21.724 49.669 -21.484 48.949 L -21.484 45.859 L -25.464 45.859 C -26.284 47.479 -26.754 49.299 -26.754 51.239 C -26.754 53.179 -26.284 54.999 -25.464 56.619 L -21.484 53.529 Z"
/>
<path
fill="#EA4335"
d="M -14.754 43.989 C -12.984 43.989 -11.404 44.599 -10.154 45.789 L -6.734 42.369 C -8.804 40.429 -11.514 39.239 -14.754 39.239 C -19.444 39.239 -23.494 41.939 -25.464 45.859 L -21.484 48.949 C -20.534 46.099 -17.884 43.989 -14.754 43.989 Z"
/>
</g>
),
})
export const GitHubIcon = createIcon({
displayName: 'GitHubIcon',
path: (
<path
fill="currentColor"
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"
/>
),
})
export const TwitterIcon = createIcon({
displayName: 'TwitterIcon',
path: (
<path
fill="#03A9F4"
d="M24 4.557c-.883.392-1.832.656-2.828.775 1.017-.609 1.798-1.574 2.165-2.724-.951.564-2.005.974-3.127 1.195-.897-.957-2.178-1.555-3.594-1.555-3.179 0-5.515 2.966-4.797 6.045-4.091-.205-7.719-2.165-10.148-5.144-1.29 2.213-.669 5.108 1.523 6.574-.806-.026-1.566-.247-2.229-.616-.054 2.281 1.581 4.415 3.949 4.89-.693.188-1.452.232-2.224.084.626 1.956 2.444 3.379 4.6 3.419-2.07 1.623-4.678 2.348-7.29 2.04 2.179 1.397 4.768 2.212 7.548 2.212 9.142 0 14.307-7.721 13.995-14.646.962-.695 1.797-1.562 2.457-2.549z"
/>
),
})

View File

@ -0,0 +1,26 @@
import {createContext, PropsWithChildren, useContext, useState} from "react";
interface RequestInProgressContextType {
requestInProgress: boolean
setRequestInProgress: (value: boolean) => any
}
const RequestInProgressContext = createContext<RequestInProgressContextType>({
requestInProgress: false,
setRequestInProgress: (value) => null,
})
export function RequestInProgressProvider({children}: PropsWithChildren) {
const [requestInProgress, setRequestInProgress] = useState(false)
return (
<RequestInProgressContext.Provider
value={{requestInProgress: requestInProgress, setRequestInProgress: (value) => setRequestInProgress(value)}}>
{children}
</RequestInProgressContext.Provider>
)
}
export function useRequestInProgress() {
return useContext(RequestInProgressContext)
}