diff options
-rw-r--r-- | client/index.html | 9 | ||||
-rw-r--r-- | client/src/components/CustomSelect/CustomSelect.jsx | 2 | ||||
-rw-r--r-- | client/src/components/CustomSelect/CustomSelect.module.css | 2 | ||||
-rw-r--r-- | client/src/components/Editor/Editor.jsx | 47 | ||||
-rw-r--r-- | client/src/components/Editor/Editor.module.css | 1 | ||||
-rw-r--r-- | client/src/components/Header/Header.jsx | 6 | ||||
-rw-r--r-- | client/src/components/Header/Header.module.css | 4 | ||||
-rw-r--r-- | client/src/components/prism-themes/prism-gruvbox-dark.css | 227 | ||||
-rw-r--r-- | client/src/main.jsx | 2 | ||||
-rw-r--r-- | client/src/utils/constants.js | 158 | ||||
-rw-r--r-- | client/src/variables.css | 9 | ||||
-rw-r--r-- | client/vite.config.js | 4 | ||||
-rw-r--r-- | 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 @@ <head> <meta charset="UTF-8" /> <link rel="icon" type="image/svg+xml" href="assets/icons/favicon.ico" /> - <link rel="preconnect" href="https://fonts.googleapis.com"> - <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> - <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet"> + <link rel="preconnect" href="https://fonts.googleapis.com" /> + <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> + <link + href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" + rel="stylesheet" + /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Minibin</title> </head> 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 ( <div className={styles.header}> - <Link to="/"><h1><span className={styles.header__mini}>mini</span>bin</h1></Link> + <Link to="/"> + <h1> + <span className={styles.header__mini}>mini</span>bin + </h1> + </Link> {isSelectVisible && ( <CustomSelect options={SUPPORTED_LANGUAGES} diff --git a/client/src/components/Header/Header.module.css b/client/src/components/Header/Header.module.css index 193894c..9717e14 100644 --- a/client/src/components/Header/Header.module.css +++ b/client/src/components/Header/Header.module.css @@ -19,7 +19,7 @@ color: inherit; } -.header__mini{ +.header__mini { color: var(--color-yellow); } @@ -27,7 +27,7 @@ .header { margin: 0.5rem 1rem; } - + .header h1 { font-size: 2rem; } diff --git a/client/src/components/prism-themes/prism-gruvbox-dark.css b/client/src/components/prism-themes/prism-gruvbox-dark.css index bfdd903..b0ab2b1 100644 --- a/client/src/components/prism-themes/prism-gruvbox-dark.css +++ b/client/src/components/prism-themes/prism-gruvbox-dark.css @@ -8,116 +8,117 @@ * @version 1.0 */ - code[class*="language-"], - pre[class*="language-"] { - color: #ebdbb2; /* fg1 / fg */ - direction: ltr; - text-align: left; - white-space: pre; - word-spacing: normal; - line-height: 1.5; - - -moz-tab-size: 4; - -o-tab-size: 4; - tab-size: 4; - - -webkit-hyphens: none; - -moz-hyphens: none; - -ms-hyphens: none; - hyphens: none; - } - - pre[class*="language-"]::-moz-selection, - pre[class*="language-"] ::-moz-selection, - code[class*="language-"]::-moz-selection, - code[class*="language-"] ::-moz-selection { - color: #fbf1c7; /* fg0 */ - background: #7c6f64; /* bg4 */ - } - - pre[class*="language-"]::selection, - pre[class*="language-"] ::selection, - code[class*="language-"]::selection, - code[class*="language-"] ::selection { - color: #fbf1c7; /* fg0 */ - background: #7c6f64; /* bg4 */ - } - - .token.comment, - .token.prolog, - .token.cdata { - color: #a89984; /* fg4 / gray1 */ - } - - .token.delimiter, - .token.boolean, - .token.keyword, - .token.selector, - .token.important, - .token.atrule { - color: #fb4934; /* red2 */ - } - - .token.operator, - .token.punctuation, - .token.attr-name { - color: #a89984; /* fg4 / gray1 */ - } - - .token.tag, - .token.tag .punctuation, - .token.doctype, - .token.builtin { - color: #fabd2f; /* yellow2 */ - } - - .token.entity, - .token.number, - .token.symbol { - color: #d3869b; /* purple2 */ - } - - .token.property, - .token.constant, - .token.variable { - color: #fb4934; /* red2 */ - } - - .token.string, - .token.char { - color: #b8bb26; /* green2 */ - } - - .token.attr-value, - .token.attr-value .punctuation { - color: #a89984; /* fg4 / gray1 */ - } - - .token.url { - color: #b8bb26; /* green2 */ - text-decoration: underline; - } - - .token.function { - color: #fabd2f; /* yellow2 */ - } - - .token.regex { - background: #b8bb26; /* green2 */ - } - - .token.bold { - font-weight: bold; - } - - .token.italic { - font-style: italic; - } - - .token.inserted { - background: #a89984; /* fg4 / gray1 */ - } - - .token.deleted { - background: #fb4934; /* red2 */ - }
\ No newline at end of file +code[class*="language-"], +pre[class*="language-"] { + color: #ebdbb2; /* fg1 / fg */ + direction: ltr; + text-align: left; + white-space: pre; + word-spacing: normal; + line-height: 1.5; + + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; + + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; +} + +pre[class*="language-"]::-moz-selection, +pre[class*="language-"] ::-moz-selection, +code[class*="language-"]::-moz-selection, +code[class*="language-"] ::-moz-selection { + color: #fbf1c7; /* fg0 */ + background: #7c6f64; /* bg4 */ +} + +pre[class*="language-"]::selection, +pre[class*="language-"] ::selection, +code[class*="language-"]::selection, +code[class*="language-"] ::selection { + color: #fbf1c7; /* fg0 */ + background: #7c6f64; /* bg4 */ +} + +.token.comment, +.token.prolog, +.token.cdata { + color: #a89984; /* fg4 / gray1 */ +} + +.token.delimiter, +.token.boolean, +.token.keyword, +.token.selector, +.token.important, +.token.atrule { + color: #fb4934; /* red2 */ +} + +.token.operator, +.token.punctuation, +.token.attr-name { + color: #a89984; /* fg4 / gray1 */ +} + +.token.tag, +.token.tag .punctuation, +.token.doctype, +.token.builtin { + color: #fabd2f; /* yellow2 */ +} + +.token.entity, +.token.number, +.token.symbol { + color: #d3869b; /* purple2 */ +} + +.token.property, +.token.constant, +.token.variable { + color: #fb4934; /* red2 */ +} + +.token.string, +.token.char { + color: #b8bb26; /* green2 */ +} + +.token.attr-value, +.token.attr-value .punctuation { + color: #a89984; /* fg4 / gray1 */ +} + +.token.url { + color: #b8bb26; /* green2 */ + text-decoration: underline; +} + +.token.function { + color: #fabd2f; /* yellow2 */ +} + +.token.regex { + background: #b8bb26; /* green2 */ +} + +.token.bold { + font-weight: bold; +} + +.token.italic { + font-style: italic; +} + +.token.inserted { + background: #a89984; /* fg4 / gray1 */ +} + +.token.deleted { + background: #fb4934; /* red2 */ +} + diff --git a/client/src/main.jsx b/client/src/main.jsx index 6c2299f..3707e0b 100644 --- a/client/src/main.jsx +++ b/client/src/main.jsx @@ -9,5 +9,5 @@ ReactDOM.createRoot(document.getElementById("root")).render( <Router> <App /> </Router> - </React.StrictMode> + </React.StrictMode>, ); 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 +} |