Skip to content

Full Toolkit for Next-Level Domain Analysis

Migrate landing page to shadcn/ui 🏡

Felix Wotschofskyaeac8740dd03
diff --git a/app/page.tsx b/app/page.tsx
index 3b5332c..ecad068 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -1,62 +1,35 @@
-'use client';
-
-import { Container, Heading, Text, useColorModeValue } from '@chakra-ui/react';
-
import BookmarkletLink from '@/components/BookmarkletLink';
import SearchForm from '@/components/SearchForm';
-// Based on simple newsletter template from https://chakra-templates.dev
+import { Card } from '@/components/ui/card';
+
+export const metadata = {
+ title: 'Domain Digger',
+};
const Home = () => {
return (
<>
- <title>Domain Digger</title>
-
- <Container
- maxW="lg"
- bg={useColorModeValue('white', 'whiteAlpha.100')}
- boxShadow="xl"
- rounded="lg"
- my={16}
- p={6}
- flexDirection="column"
- >
- <Heading
- as="h2"
- fontSize={{ base: 'xl', sm: '2xl' }}
- textAlign="center"
- mb={5}
- >
+ <Card className="max-w-lg mx-auto my-16 p-6">
+ <h2 className="text-center text-xl sm:text-2xl font-semibold tracking-tight mb-5">
Get details about any Domain
- </Heading>
+ </h2>
<SearchForm />
- </Container>
+ </Card>
- <Container
- maxW="lg"
- bg={useColorModeValue('white', 'whiteAlpha.100')}
- boxShadow="xl"
- rounded="lg"
- my={16}
- p={6}
- flexDirection="column"
- >
- <Heading
- as="h2"
- fontSize={{ base: 'xl', sm: '2xl' }}
- textAlign="center"
- mb={5}
- >
+ <Card className="max-w-lg mx-auto my-16 p-6">
+ <h2 className="text-center text-xl sm:text-2xl font-semibold tracking-tight mb-5">
Quickly inspect any Website
- </Heading>
+ </h2>
- <Text mt={2} mb={5} textAlign="center" color={'gray.500'}>
+ <p className="text-sm text-center text-muted-foreground mt-2 mb-5">
Drag this link to your bookmarks bar to quickly go to the results page
for the site you are currently on!
- </Text>
+ </p>
+
<BookmarkletLink />
- </Container>
+ </Card>
</>
);
};
diff --git a/components/BookmarkletLink.tsx b/components/BookmarkletLink.tsx
index a77274c..70b610d 100644
--- a/components/BookmarkletLink.tsx
+++ b/components/BookmarkletLink.tsx
@@ -1,4 +1,5 @@
-import { Center, Link, Progress } from '@chakra-ui/react';
+'use client';
+
import { useEffect, useState } from 'react';
const BookmarkletLink = () => {
@@ -22,14 +23,16 @@ const BookmarkletLink = () => {
setTarget(`javascript:${minifiedScript}`);
}, []);
- if (!target) {
- return <Progress size="xs" isIndeterminate />;
- }
-
return (
- <Center>
- <Link href={target}>Inspect Domain</Link>
- </Center>
+ <div className="flex justify-center">
+ {target ? (
+ <a className="text-center" href={target}>
+ Inspect Domain
+ </a>
+ ) : (
+ <span className="text-center">Loading...</span>
+ )}
+ </div>
);
};
diff --git a/components/SearchForm.tsx b/components/SearchForm.tsx
index 696b606..7a2a281 100644
--- a/components/SearchForm.tsx
+++ b/components/SearchForm.tsx
@@ -1,9 +1,14 @@
+'use client';
+
import { ChangeEvent, FormEvent, useEffect, useState } from 'react';
-import { Stack, FormControl, Input, Button, Text } from '@chakra-ui/react';
+import { Loader2 } from 'lucide-react';
import { toASCII } from 'punycode';
import { useRouter } from 'next/navigation';
import isValidDomain from 'is-valid-domain';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+
enum FormStates {
Initial,
Submitting,
@@ -45,44 +50,44 @@ const SearchForm = (props: SearchFormProps) => {
return (
<>
- <Stack
- direction={{ base: 'column', md: 'row' }}
- as="form"
- spacing="12px"
- onSubmit={handleSubmit}
- >
- <FormControl>
- <Input
- borderWidth={1}
- id="email"
- type="text"
- required
- placeholder="example.com"
- aria-label="Domain"
- value={domain}
- disabled={state !== FormStates.Initial}
- onInput={(event: ChangeEvent<HTMLInputElement>) =>
- setDomain(event.target.value)
- }
- />
- </FormControl>
- <FormControl w={{ base: '100%', md: '40%' }}>
- <Button
- colorScheme="blue"
- isLoading={state === FormStates.Submitting}
- w="100%"
- type="submit"
- >
- Lookup
- </Button>
- </FormControl>
- </Stack>
+ <form className="flex gap-3" onSubmit={handleSubmit}>
+ <Input
+ style={{
+ flex: 3,
+ }}
+ type="text"
+ required
+ placeholder="example.com"
+ aria-label="Domain"
+ value={domain}
+ onInput={(event: ChangeEvent<HTMLInputElement>) =>
+ setDomain(event.target.value)
+ }
+ disabled={state !== FormStates.Initial}
+ />
+ <Button
+ style={{
+ flex: 1,
+ }}
+ type="submit"
+ disabled={state !== FormStates.Initial}
+ >
+ {state === FormStates.Submitting && (
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+ )}
+ Lookup
+ </Button>
+ </form>
- <Text mt={2} textAlign="center" color={error ? 'red.500' : 'gray.500'}>
- {error
- ? 'An error occured! Please check your input or try again later.'
- : 'It can be anything! An apex or subdomain.'}
- </Text>
+ {error ? (
+ <p className="text-sm text-center text-red-600 mt-2">
+ An error occured! Please check your input or try again later.
+ </p>
+ ) : (
+ <p className="text-sm text-center text-muted-foreground mt-2">
+ It can be anything! An apex or subdomain.
+ </p>
+ )}
</>
);
};
diff --git a/components/ui/button.tsx b/components/ui/button.tsx
new file mode 100644
index 0000000..e46f96e
--- /dev/null
+++ b/components/ui/button.tsx
@@ -0,0 +1,55 @@
+import * as React from 'react';
+import { Slot } from '@radix-ui/react-slot';
+import { VariantProps, cva } from 'class-variance-authority';
+
+import { cn } from '@/lib/utils';
+
+const buttonVariants = cva(
+ 'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background',
+ {
+ variants: {
+ variant: {
+ default: 'bg-primary text-primary-foreground hover:bg-primary/90',
+ destructive:
+ 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
+ outline:
+ 'border border-input hover:bg-accent hover:text-accent-foreground',
+ secondary:
+ 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
+ ghost: 'hover:bg-accent hover:text-accent-foreground',
+ link: 'underline-offset-4 hover:underline text-primary',
+ },
+ size: {
+ default: 'h-10 py-2 px-4',
+ sm: 'h-9 px-3 rounded-md',
+ lg: 'h-11 px-8 rounded-md',
+ },
+ },
+ defaultVariants: {
+ variant: 'default',
+ size: 'default',
+ },
+ }
+);
+
+export interface ButtonProps
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
+ VariantProps<typeof buttonVariants> {
+ asChild?: boolean;
+}
+
+const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
+ const Comp = asChild ? Slot : 'button';
+ return (
+ <Comp
+ className={cn(buttonVariants({ variant, size, className }))}
+ ref={ref}
+ {...props}
+ />
+ );
+ }
+);
+Button.displayName = 'Button';
+
+export { Button, buttonVariants };
diff --git a/components/ui/card.tsx b/components/ui/card.tsx
new file mode 100644
index 0000000..67aaa31
--- /dev/null
+++ b/components/ui/card.tsx
@@ -0,0 +1,86 @@
+import * as React from 'react';
+
+import { cn } from '@/lib/utils';
+
+const Card = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn(
+ 'rounded-lg border bg-card text-card-foreground shadow-sm',
+ className
+ )}
+ {...props}
+ />
+));
+Card.displayName = 'Card';
+
+const CardHeader = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn('flex flex-col space-y-1.5 p-6', className)}
+ {...props}
+ />
+));
+CardHeader.displayName = 'CardHeader';
+
+const CardTitle = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLHeadingElement>
+>(({ className, ...props }, ref) => (
+ <h3
+ ref={ref}
+ className={cn(
+ 'text-lg font-semibold leading-none tracking-tight',
+ className
+ )}
+ {...props}
+ />
+));
+CardTitle.displayName = 'CardTitle';
+
+const CardDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLParagraphElement>
+>(({ className, ...props }, ref) => (
+ <p
+ ref={ref}
+ className={cn('text-sm text-muted-foreground', className)}
+ {...props}
+ />
+));
+CardDescription.displayName = 'CardDescription';
+
+const CardContent = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
+));
+CardContent.displayName = 'CardContent';
+
+const CardFooter = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn(' flex items-center p-6 pt-0', className)}
+ {...props}
+ />
+));
+CardFooter.displayName = 'CardFooter';
+
+export {
+ Card,
+ CardHeader,
+ CardFooter,
+ CardTitle,
+ CardDescription,
+ CardContent,
+};
diff --git a/components/ui/input.tsx b/components/ui/input.tsx
new file mode 100644
index 0000000..8a4a046
--- /dev/null
+++ b/components/ui/input.tsx
@@ -0,0 +1,25 @@
+import * as React from 'react';
+
+import { cn } from '@/lib/utils';
+
+export interface InputProps
+ extends React.InputHTMLAttributes<HTMLInputElement> {}
+
+const Input = React.forwardRef<HTMLInputElement, InputProps>(
+ ({ className, type, ...props }, ref) => {
+ return (
+ <input
+ type={type}
+ className={cn(
+ 'flex h-10 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
+ className
+ )}
+ ref={ref}
+ {...props}
+ />
+ );
+ }
+);
+Input.displayName = 'Input';
+
+export { Input };
diff --git a/package.json b/package.json
index 814e895..1d97bb8 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"@chakra-ui/react": "^2.6.1",
"@emotion/react": "^11.11.0",
"@emotion/styled": "^11.11.0",
+ "@radix-ui/react-slot": "^1.0.1",
"@types/nprogress": "^0.2.0",
"@types/punycode": "^2.1.0",
"@types/validator": "^13.7.17",
diff --git a/yarn.lock b/yarn.lock
index 2b7f370..82b05aa 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -55,6 +55,13 @@
dependencies:
regenerator-runtime "^0.13.10"
+"@babel/runtime@^7.13.10":
+ version "7.21.5"
+ resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.5.tgz#8492dddda9644ae3bda3b45eabe87382caee7200"
+ integrity sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q==
+ dependencies:
+ regenerator-runtime "^0.13.11"
+
"@babel/types@^7.18.6":
version "7.20.2"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.2.tgz#67ac09266606190f496322dbaff360fdaa5e7842"
@@ -1172,6 +1179,21 @@
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.6.tgz#cee20bd55e68a1720bdab363ecf0c821ded4cd45"
integrity sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==
+"@radix-ui/[email protected]":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.0.0.tgz#37595b1f16ec7f228d698590e78eeed18ff218ae"
+ integrity sha512-0KaSv6sx787/hK3eF53iOkiSLwAGlFMx5lotrqD2pTjB18KbybKoEIgkNZTKC60YECDQTKGTRcDBILwZVqVKvA==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+
+"@radix-ui/react-slot@^1.0.1":
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-slot/-/react-slot-1.0.1.tgz#e7868c669c974d649070e9ecbec0b367ee0b4d81"
+ integrity sha512-avutXAFL1ehGvAXtPquu0YK5oz6ctS474iM3vNGQIkswrVhdrS52e3uoMQBzZhNRAIE0jBnUyXWNmSjGHhCFcw==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/react-compose-refs" "1.0.0"
+
"@react-leaflet/core@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@react-leaflet/core/-/core-2.1.0.tgz#383acd31259d7c9ae8fb1b02d5e18fe613c2a13d"
@@ -3306,6 +3328,11 @@ regenerator-runtime@^0.13.10:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz#ed07b19616bcbec5da6274ebc75ae95634bfc2ee"
integrity sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw==
+regenerator-runtime@^0.13.11:
+ version "0.13.11"
+ resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9"
+ integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==
+
regexp.prototype.flags@^1.4.3:
version "1.4.3"
resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac"