From 5e7629a055e8568a0775436b1dbf5797a5640056 Mon Sep 17 00:00:00 2001 From: Blaster4385 Date: Sun, 3 Mar 2024 19:02:40 +0530 Subject: feat: formated code --- client/index.html | 9 +- .../src/components/CustomSelect/CustomSelect.jsx | 2 +- .../CustomSelect/CustomSelect.module.css | 2 +- client/src/components/Editor/Editor.jsx | 47 +++-- client/src/components/Editor/Editor.module.css | 1 - client/src/components/Header/Header.jsx | 6 +- client/src/components/Header/Header.module.css | 4 +- .../components/prism-themes/prism-gruvbox-dark.css | 227 +++++++++++---------- client/src/main.jsx | 2 +- client/src/utils/constants.js | 158 ++++++++------ client/src/variables.css | 9 +- client/vite.config.js | 4 +- server/main.go | 15 +- 13 files changed, 262 insertions(+), 224 deletions(-) diff --git a/client/index.html b/client/index.html index f95b4d2..4e9000e 100644 --- a/client/index.html +++ b/client/index.html @@ -3,9 +3,12 @@ - - - + + + Minibin diff --git a/client/src/components/CustomSelect/CustomSelect.jsx b/client/src/components/CustomSelect/CustomSelect.jsx index 2f98b34..f588d38 100644 --- a/client/src/components/CustomSelect/CustomSelect.jsx +++ b/client/src/components/CustomSelect/CustomSelect.jsx @@ -4,7 +4,7 @@ import styles from "./CustomSelect.module.css"; const CustomSelect = ({ options, onSelect }) => { const [isOpen, setIsOpen] = useState(false); const [selectedOption, setSelectedOption] = useState( - options.length > 0 ? options[0] : null + options.length > 0 ? options[0] : null, ); const toggleDropdown = () => { diff --git a/client/src/components/CustomSelect/CustomSelect.module.css b/client/src/components/CustomSelect/CustomSelect.module.css index 1cd7b64..81f9e62 100644 --- a/client/src/components/CustomSelect/CustomSelect.module.css +++ b/client/src/components/CustomSelect/CustomSelect.module.css @@ -46,7 +46,7 @@ width: 8rem; font-size: 14px; } - + .selected__option { padding: 8px; } diff --git a/client/src/components/Editor/Editor.jsx b/client/src/components/Editor/Editor.jsx index 0a78ca8..8ff2ff7 100644 --- a/client/src/components/Editor/Editor.jsx +++ b/client/src/components/Editor/Editor.jsx @@ -49,29 +49,34 @@ const Editor = () => { if (response.ok) { const isURL = URL_REGEX.test(text); if (isURL) { - navigator.clipboard.writeText(`${CLIENT_BASE_URL}/r/${data.id}`).then(function () { - alert("Short URL copied to clipboard!"); - }, function (err) { - try { - var successful = document.execCommand('copy'); + navigator.clipboard.writeText(`${CLIENT_BASE_URL}/r/${data.id}`).then( + function () { alert("Short URL copied to clipboard!"); - } catch (err) { - console.log('Oops, unable to copy'); - } - }); - } - else { - navigator.clipboard.writeText(`${CLIENT_BASE_URL}/r/${data.id}`).then(function () { - navigator.clipboard.writeText(`${CLIENT_BASE_URL}/${data.id}`); - alert("URL copied to clipboard!"); - }, function (err) { - try { - var successful = document.execCommand('copy'); + }, + function (err) { + try { + var successful = document.execCommand("copy"); + alert("Short URL copied to clipboard!"); + } catch (err) { + console.log("Oops, unable to copy"); + } + }, + ); + } else { + navigator.clipboard.writeText(`${CLIENT_BASE_URL}/r/${data.id}`).then( + function () { + navigator.clipboard.writeText(`${CLIENT_BASE_URL}/${data.id}`); alert("URL copied to clipboard!"); - } catch (err) { - console.log('Oops, unable to copy'); - } - }); + }, + function (err) { + try { + var successful = document.execCommand("copy"); + alert("URL copied to clipboard!"); + } catch (err) { + console.log("Oops, unable to copy"); + } + }, + ); } navigate(`/${data.id}`); } else { diff --git a/client/src/components/Editor/Editor.module.css b/client/src/components/Editor/Editor.module.css index 702847d..62c6759 100644 --- a/client/src/components/Editor/Editor.module.css +++ b/client/src/components/Editor/Editor.module.css @@ -69,7 +69,6 @@ } @media screen and (max-width: 768px) { - .btn__save { bottom: 2rem; right: 2rem; diff --git a/client/src/components/Header/Header.jsx b/client/src/components/Header/Header.jsx index 712696c..9682104 100644 --- a/client/src/components/Header/Header.jsx +++ b/client/src/components/Header/Header.jsx @@ -7,7 +7,11 @@ import CustomSelect from "../CustomSelect/CustomSelect"; const Header = ({ isSelectVisible, onLanguageChange }) => { return (
-

minibin

+ +

+ minibin +

+ {isSelectVisible && ( - + , ); diff --git a/client/src/utils/constants.js b/client/src/utils/constants.js index 8d409f6..adb01a3 100644 --- a/client/src/utils/constants.js +++ b/client/src/utils/constants.js @@ -1,70 +1,94 @@ export const CLIENT_BASE_URL = import.meta.env.VITE_CLIENT_BASE_URL; export const SERVER_BASE_URL = import.meta.env.VITE_SERVER_BASE_URL; export const URL_REGEX = /^(https?:\/\/)?([\w.-]+\.[a-z]{2,})(\/?[^\s]*)?$/; -export const SUPPORTED_LANGUAGES = [{ - value: "none", - label: "Plain Text", -}, { - value: "c", - label: "C", -}, { - value: "cpp", - label: "C++", -}, { - value: "css", - label: "CSS", -}, { - value: "git", - label: "Git", -}, { - value: "go", - label: "Golang", -}, { - value: "html", - label: "HTML", -}, { - value: "java", - label: "Java", -}, { - value: "js", - label: "JavaScript", -}, { - value: "json", - label: "JSON", -}, { - value: "jsx", - label: "JSX", -}, { - value: "kotlin", - label: "Kotlin", -}, { - value: "lua", - label: "Lua", -}, { - value: "md", - label: "Markdown", -}, { - value: "py", - label: "Python", -}, { - value: "rust", - label: "Rust", -}, { - value: "sh", - label: "Shell", -}, { - value: "sql", - label: "SQL", -}, { - value: "ts", - label: "TypeScript", -}, { - value: "tsx", - label: "TSX", -}, { - value: "url", - label: "URL", -}, { - value: "xml", - label: "XML", -}]; \ No newline at end of file +export const SUPPORTED_LANGUAGES = [ + { + value: "none", + label: "Plain Text", + }, + { + value: "c", + label: "C", + }, + { + value: "cpp", + label: "C++", + }, + { + value: "css", + label: "CSS", + }, + { + value: "git", + label: "Git", + }, + { + value: "go", + label: "Golang", + }, + { + value: "html", + label: "HTML", + }, + { + value: "java", + label: "Java", + }, + { + value: "js", + label: "JavaScript", + }, + { + value: "json", + label: "JSON", + }, + { + value: "jsx", + label: "JSX", + }, + { + value: "kotlin", + label: "Kotlin", + }, + { + value: "lua", + label: "Lua", + }, + { + value: "md", + label: "Markdown", + }, + { + value: "py", + label: "Python", + }, + { + value: "rust", + label: "Rust", + }, + { + value: "sh", + label: "Shell", + }, + { + value: "sql", + label: "SQL", + }, + { + value: "ts", + label: "TypeScript", + }, + { + value: "tsx", + label: "TSX", + }, + { + value: "url", + label: "URL", + }, + { + value: "xml", + label: "XML", + }, +]; + diff --git a/client/src/variables.css b/client/src/variables.css index 26d289f..7082a25 100644 --- a/client/src/variables.css +++ b/client/src/variables.css @@ -1,5 +1,6 @@ :root { - --color-dark: #282828; - --color-light: #ebdbb2; - --color-yellow: #fabd2f; -} \ No newline at end of file + --color-dark: #282828; + --color-light: #ebdbb2; + --color-yellow: #fabd2f; +} + diff --git a/client/vite.config.js b/client/vite.config.js index 7007c3b..85fa3e9 100644 --- a/client/vite.config.js +++ b/client/vite.config.js @@ -34,6 +34,6 @@ export default defineConfig({ }), ], build: { - outDir: '../server/dist' - } + outDir: "../server/dist", + }, }); diff --git a/server/main.go b/server/main.go index 4737f17..a48611f 100644 --- a/server/main.go +++ b/server/main.go @@ -1,16 +1,17 @@ package main import ( + "database/sql" "embed" "flag" - "github.com/labstack/echo/v4" - "github.com/labstack/echo/v4/middleware" - "database/sql" "log" "math/rand" "net/http" "time" + "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" + _ "github.com/mattn/go-sqlite3" ) @@ -35,9 +36,9 @@ var ( func RegisterHandlers(e *echo.Echo) { e.Use(middleware.StaticWithConfig(middleware.StaticConfig{ - Skipper: nil, - Root: "dist", - Index: "index.html", + Skipper: nil, + Root: "dist", + Index: "index.html", HTML5: true, Filesystem: http.FS(dist), })) @@ -119,4 +120,4 @@ func generateShortID() string { id[i] = shortIDCharset[rand.Intn(len(shortIDCharset))] } return string(id) -} \ No newline at end of file +} -- cgit v1.2.3-73-gaa49b