+
Oops! Something went wrong😯
{snippets.error}
diff --git a/src/common/services/index.ts b/src/services/index.ts
similarity index 100%
rename from src/common/services/index.ts
rename to src/services/index.ts
diff --git a/src/styles/globals.css b/src/styles/globals.css
new file mode 100644
index 0000000..b25f9f8
--- /dev/null
+++ b/src/styles/globals.css
@@ -0,0 +1,152 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
+
+@layer base {
+ :root {
+ --background: 0 0% 100%;
+ --foreground: 222.2 84% 4.9%;
+
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+
+ --primary: 222.2 47.4% 11.2%;
+ --primary-foreground: 210 40% 98%;
+
+ --secondary: 210 40% 96.1%;
+ --secondary-foreground: 222.2 47.4% 11.2%;
+
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+
+ --blue-500: 210 40% 96.1%;
+ --blue-500-foreground: 222.2 47.4% 11.2%;
+
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 40% 98%;
+
+ --border: 214.3 31.8% 91.4%;
+ --input: 214.3 31.8% 91.4%;
+ --ring: 222.2 84% 4.9%;
+
+ --radius: 0.5rem;
+ }
+
+ .dark {
+ --background: 222.2 84% 4.9%;
+ --foreground: 210 40% 98%;
+
+ --card: 222.2 84% 4.9%;
+ --card-foreground: 210 40% 98%;
+
+ --popover: 222.2 84% 4.9%;
+ --popover-foreground: 210 40% 98%;
+
+ --primary: 210 40% 98%;
+ --primary-foreground: 222.2 47.4% 11.2%;
+
+ --secondary: 217.2 32.6% 17.5%;
+ --secondary-foreground: 210 40% 98%;
+
+ --muted: 217.2 32.6% 17.5%;
+ --muted-foreground: 215 20.2% 65.1%;
+
+ --blue-500: 217.2 32.6% 17.5%;
+ --blue-500-foreground: 210 40% 98%;
+
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 40% 98%;
+
+ --border: 217.2 32.6% 17.5%;
+ --input: 217.2 32.6% 17.5%;
+ --ring: 212.7 26.8% 83.9%;
+ }
+}
+
+@layer base {
+ * {
+ @apply border-border;
+ }
+ body {
+ @apply bg-background text-foreground;
+ }
+}
+
+@layer components {
+ .maxContainer {
+ width: 100%;
+ max-width: 1440px;
+ margin: 0 auto;
+ }
+}
+
+@layer utilities {
+ .padding {
+ @apply px-8 py-12 sm:px-16 sm:py-24;
+ }
+
+ .xPadding {
+ @apply px-8 sm:px-16;
+ }
+
+ .yPadding {
+ @apply py-12 sm:py-24;
+ }
+
+ .lPadding {
+ @apply pl-8 sm:pl-16;
+ }
+
+ .rPadding {
+ @apply pr-8 sm:pr-16;
+ }
+
+ .tPadding {
+ @apply pt-12 sm:pt-24;
+ }
+
+ .bPadding {
+ @apply pb-12 sm:pb-24;
+ }
+
+ .innerWidth {
+ @apply w-[100%] lg:w-[80%];
+ }
+
+ .flexCenter {
+ @apply flex items-center justify-center;
+ }
+
+ .flexBetween {
+ @apply flex items-center justify-between;
+ }
+
+ .flexStart {
+ @apply flex items-center justify-start;
+ }
+}
+
+::-webkit-scrollbar {
+ width: 5px;
+ height: 4px;
+}
+
+::-webkit-scrollbar-thumb {
+ background: #888;
+ border-radius: 12px;
+}
+
+.sideMenuItem {
+ @apply flex items-center rounded-lg p-2 text-gray-500 hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700;
+}
+
+.sideMenuItem.active {
+ @apply bg-primary text-white;
+}
+
+.sideDropItem {
+ @apply flex w-full items-center rounded-lg p-2 pl-11 text-primary transition duration-75 hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700;
+}
diff --git a/tailwind.config.js b/tailwind.config.js
index 2636a63..4ff1e28 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -1,20 +1,34 @@
/** @type {import('tailwindcss').Config} */
-const defaultTheme = require('tailwindcss/defaultTheme');
-
-export default {
- content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
+module.exports = {
+ darkMode: ['class'],
+ content: [
+ './pages/**/*.{ts,tsx}',
+ './components/**/*.{ts,tsx}',
+ './app/**/*.{ts,tsx}',
+ './src/**/*.{ts,tsx}',
+ ],
theme: {
- extend: {
- fontFamily: {
- sans: ['Inter var', ...defaultTheme.fontFamily.sans],
+ container: {
+ center: true,
+ padding: '2rem',
+ screens: {
+ '2xl': '1400px',
},
+ },
+ extend: {
colors: {
- 'primary-color': '#d42b63',
- 'secondary-color': '#f2c0d0',
- 'accent-color': '#be275a',
+ border: '#ECEFF1',
+ input: '#E0E0E0',
+ ring: '#2196F3',
+ background: '#FFFFFF',
+ foreground: '#333333',
+ primary: '#2196F3',
+ secondary: '#00C853',
+ destructive: '#FF5722',
+ muted: '#B0BEC5',
+ accent: '#FFC107',
},
},
},
- plugins: [],
- darkMode: 'class',
+ plugins: [require('tailwindcss-animate')],
};
diff --git a/tsconfig.json b/tsconfig.json
index a7fc6fb..ac9e4c4 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,10 +2,13 @@
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
+ "lib": [
+ "ES2020",
+ "DOM",
+ "DOM.Iterable"
+ ],
"module": "ESNext",
"skipLibCheck": true,
-
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
@@ -13,13 +16,25 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
-
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
- "noFallthroughCasesInSwitch": true
+ "noFallthroughCasesInSwitch": true,
+ /* Resolving */
+ "baseUrl": ".",
+ "paths": {
+ "@/*": [
+ "./src/*"
+ ]
+ }
},
- "include": ["src"],
- "references": [{ "path": "./tsconfig.node.json" }]
-}
+ "include": [
+ "src"
+ ],
+ "references": [
+ {
+ "path": "./tsconfig.node.json"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/vite.config.ts b/vite.config.ts
index a1d8d11..335db37 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
+import path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
@@ -10,4 +11,9 @@ export default defineConfig({
},
}),
],
+ resolve: {
+ alias: {
+ '@': path.resolve(__dirname, './src'),
+ },
+ },
});
From d59899eb4d8dddbcdbcd125be4f5dc0a2ae6a5d5 Mon Sep 17 00:00:00 2001
From: IndieCoderMM
Date: Wed, 6 Sep 2023 12:41:40 +0630
Subject: [PATCH 3/7] Create snippet form
---
README.md | 18 +--
src/app/App.tsx | 2 +
src/components/Loading.tsx | 2 +-
src/components/Modal.tsx | 47 +++++++
src/components/Navbar.tsx | 12 +-
src/components/SelectBox.tsx | 96 ++++++++++++++
src/constants/index.ts | 14 +++
src/features/snippets/SnippetForm.tsx | 118 ++++++++++++++++++
src/pages/CreateSnippet.tsx | 22 ++++
src/{components => styles}/Loading.module.css | 0
src/styles/globals.css | 67 +---------
tailwind.config.js | 2 +-
12 files changed, 325 insertions(+), 75 deletions(-)
create mode 100644 src/components/Modal.tsx
create mode 100644 src/components/SelectBox.tsx
create mode 100644 src/features/snippets/SnippetForm.tsx
create mode 100644 src/pages/CreateSnippet.tsx
rename src/{components => styles}/Loading.module.css (100%)
diff --git a/README.md b/README.md
index 54e77e2..be43563 100644
--- a/README.md
+++ b/README.md
@@ -101,12 +101,14 @@ This is an overview of the `./src` directory.
.
├── app/
│ ├── App.tsx
+│ ├── Providers.tsx
│ └── store.ts
├── assets
-├── common/
-│ ├── components
-│ ├── services
-│ └── constants
+├── components
+│ ├── Navbar.tsx
+│ └── Footer.tsx
+├── services
+├── constants
├── features/
│ ├── snippets/
│ │ ├── SnippetCard.tsx
@@ -115,14 +117,14 @@ This is an overview of the `./src` directory.
├── pages/
│ ├── Home.tsx
│ └── About.tsx
-├── index.css
+├── styles/
+│ └── global.css
└── main.tsx
```
- `app/`: App-wide setup and layout
-- `common/`: Shared code and resources
- - `components/`: Reusable components across different pages
- - `services/`: Interacting with the backend API
+- `components/`: Reusable components across different pages
+- `services/`: Interacting with the backend API
- `features/`: Feature-specific folders
- `snippets/`: Components and functions related to snippets
- `pages/`: Main pages of the app
diff --git a/src/app/App.tsx b/src/app/App.tsx
index 8902a61..3a7d345 100644
--- a/src/app/App.tsx
+++ b/src/app/App.tsx
@@ -13,6 +13,7 @@ import TagPage from '../pages/TagPage';
import Home from '../pages/Home';
import Providers from './Providers';
+import CreateSnippet from '@/pages/CreateSnippet';
function App() {
return (
@@ -43,6 +44,7 @@ function App() {
element={}
/>
+ } />
} />
} />
} />
diff --git a/src/components/Loading.tsx b/src/components/Loading.tsx
index a9d8c29..948f073 100644
--- a/src/components/Loading.tsx
+++ b/src/components/Loading.tsx
@@ -1,4 +1,4 @@
-import Style from './Loading.module.css';
+import Style from '@/styles/Loading.module.css';
const Loading = ({ title, message }: { title: string; message: string }) => {
return (
diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx
new file mode 100644
index 0000000..778211b
--- /dev/null
+++ b/src/components/Modal.tsx
@@ -0,0 +1,47 @@
+import { XMarkIcon } from '@heroicons/react/24/outline';
+import { useCallback, useRef, ReactNode } from 'react';
+import { useNavigate } from 'react-router-dom';
+
+const Modal = ({ children }: { children: ReactNode }) => {
+ const overlay = useRef(null);
+ const wrapper = useRef(null);
+ const navigate = useNavigate();
+
+ const onDismiss = useCallback(() => {
+ navigate('/');
+ }, [navigate]);
+
+ const handleClick = useCallback(
+ (e: React.MouseEvent) => {
+ if (e.target === overlay.current && onDismiss) {
+ onDismiss();
+ }
+ },
+ [onDismiss, overlay],
+ );
+
+ return (
+
+
+
+ {children}
+
+
+ );
+};
+
+export default Modal;
diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx
index cf34a74..b9fc201 100644
--- a/src/components/Navbar.tsx
+++ b/src/components/Navbar.tsx
@@ -3,9 +3,10 @@ import {
Bars3Icon,
BellIcon,
CodeBracketIcon,
+ PlusIcon,
XMarkIcon,
} from '@heroicons/react/24/outline';
-import { useLocation } from 'react-router-dom';
+import { useLocation, useNavigate } from 'react-router-dom';
import { UserButton } from '@clerk/clerk-react';
const navigation = [
@@ -22,6 +23,7 @@ function classNames({ classes = [] }: { classes?: string[] } = {}) {
const Navbar = () => {
const { pathname } = useLocation();
+ const navigate = useNavigate();
const isActive = (href: string) => href === pathname;
return (
@@ -48,6 +50,14 @@ const Navbar = () => {