diff --git a/app/Header.tsx b/app/Header.tsx index 3eddf0d..9b942db 100644 --- a/app/Header.tsx +++ b/app/Header.tsx @@ -1,24 +1,40 @@ +'use client'; + import React from 'react'; import ThemeSwitcher from '@/Components/ThemeSwitcher'; import Link from 'next/link'; +import { usePathname } from 'next/navigation'; +import { urlList } from '@/app/urlList'; + +const searchPageName = (url: string) => { + const page = urlList.find((it) => it.url === url); + + return page && page.name; +}; const Header = () => { + const path = usePathname(); + const currModule = searchPageName(path); return ( -
+
-
-
+
LMTLab - +

+ { currModule } +

+
+ +
diff --git a/app/globals.css b/app/globals.css index f3bd93b..d8ee889 100644 --- a/app/globals.css +++ b/app/globals.css @@ -2,6 +2,10 @@ @tailwind components; @tailwind utilities; +.text-weak { + @apply text-zinc-500 dark:text-zinc-400; +} + html.light { --background: #ffffff; --foreground: #171717; diff --git a/app/page.tsx b/app/page.tsx index adbb039..25259d8 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,13 +1,7 @@ import { Card, CardBody } from '@nextui-org/card'; import Link from 'next/link'; +import { urlList } from '@/app/urlList'; -const urlList = [ - { - name: 'Json Parser', - desc: 'Parse a Json file, with formatter and syntax highlighting', - url: '/jsonparser' - } -]; export default function Home() { diff --git a/app/strcoder/algorithms.ts b/app/strcoder/algorithms.ts new file mode 100644 index 0000000..7b928f2 --- /dev/null +++ b/app/strcoder/algorithms.ts @@ -0,0 +1,56 @@ +import { enc, MD5, SHA1, SHA256, SHA512 } from 'crypto-js'; + +export const hashAlgorithms = { + 'SHA-1': (input: string) => { + return SHA1(input); + }, + 'SHA-256': (input: string) => { + return SHA256(input); + }, + 'SHA-512': (input: string) => { + return SHA512(input); + }, + 'MD5': (input: string) => { + return MD5(input); + } +}; + +export const encodeAlgorithms = { + 'Base64': (input: string) => { + const wordArray = enc.Utf8.parse(input); + return enc.Base64.stringify(wordArray); + }, + 'URI': (input: string) => { + return encodeURI(input).toString(); + }, + 'URI Component': (input: string) => { + return encodeURIComponent(input).toString(); + } +}; + +export const decodeAlgorithms = { + 'Base64': (input: string) => { + return enc.Base64.parse(input).toString(enc.Utf8); + }, + 'URI': (input: string) => { + return decodeURI(input).toString(); + }, + 'URI Component': (input: string) => { + return decodeURIComponent(input).toString(); + } +}; + +export const algorithms = { + 'hash': { + list: hashAlgorithms, + color: 'primary' + }, + 'encode': { + list: encodeAlgorithms, + color: 'secondary' + }, + 'decode': { + list: decodeAlgorithms, + color: 'success' + } +}; diff --git a/app/strcoder/page.tsx b/app/strcoder/page.tsx new file mode 100644 index 0000000..e4ba894 --- /dev/null +++ b/app/strcoder/page.tsx @@ -0,0 +1,127 @@ +'use client'; + +import React, { useState } from 'react'; +import { Button, Textarea } from '@nextui-org/react'; +import { toast } from 'react-toastify'; +import { HiOutlineBackspace, HiOutlineDuplicate } from 'react-icons/hi'; +import { algorithms } from '@/app/strcoder/algorithms'; +import { useTheme } from 'next-themes'; + +type ButtonColor = 'primary' | 'secondary' | 'success' | 'default' | 'warning' | 'danger' | undefined; + +const Page = () => { + const [ input, setInput ] = useState(''); + const [ output, setOutput ] = useState(''); + const { theme } = useTheme(); + return ( + <> +
+
+
+