Skip to content

Full Toolkit for Next-Level Domain Analysis

Show resolver selector while results are loading 👆

Felix Wotschofsky010ce1eeb4bb
diff --git a/app/lookup/[domain]/(dns)/_components/location-selector.tsx b/app/lookup/[domain]/(dns)/_components/location-selector.tsx
deleted file mode 100644
index e410828..0000000
--- a/app/lookup/[domain]/(dns)/_components/location-selector.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-'use client';
-
-import { Label } from '@radix-ui/react-label';
-import { usePathname, useRouter, useSearchParams } from 'next/navigation';
-import { type FC, useCallback } from 'react';
-
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from '@/components/ui/select';
-
-import { useAnalytics } from '@/lib/analytics';
-import { REGIONS } from '@/lib/data';
-
-type LocationSelectorProps = {
- initialValue?: string;
- disabled?: boolean;
-};
-
-export const LocationSelector: FC<LocationSelectorProps> = ({
- initialValue,
- disabled,
-}) => {
- const { reportEvent } = useAnalytics();
-
- const router = useRouter();
- const pathname = usePathname();
- const searchParams = useSearchParams();
-
- const onValueChange = useCallback(
- (value: string) => {
- const current = new URLSearchParams(Array.from(searchParams.entries()));
-
- if (!value || value === 'auto') {
- current.delete('location');
- } else {
- current.set('location', value);
- }
-
- const search = current.size ? `?${current.toString()}` : '';
- router.push(`${pathname}${search}`);
-
- reportEvent('Location Selector: Change', { location: value });
- },
- [router, pathname, searchParams, reportEvent],
- );
-
- return (
- <Label className="flex flex-col gap-1">
- <span className="text-sm text-zinc-500 dark:text-zinc-400">Location</span>
-
- <Select
- defaultValue={initialValue || 'auto'}
- onValueChange={onValueChange}
- disabled={disabled}
- >
- <SelectTrigger>
- <SelectValue placeholder="Location" />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="auto">Auto</SelectItem>
- {Object.entries(REGIONS).map(([id, details]) => (
- <SelectItem key={id} value={id}>
- {details.name}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </Label>
- );
-};
diff --git a/app/lookup/[domain]/(dns)/_components/resolver-selector.tsx b/app/lookup/[domain]/(dns)/_components/resolver-selector.tsx
index ac252d1..0153088 100644
--- a/app/lookup/[domain]/(dns)/_components/resolver-selector.tsx
+++ b/app/lookup/[domain]/(dns)/_components/resolver-selector.tsx
@@ -13,14 +13,13 @@ import {
} from '@/components/ui/select';
import { useAnalytics } from '@/lib/analytics';
+import { REGIONS } from '@/lib/data';
-type ResolverSelectorProps = {
+type ProviderSelectorProps = {
initialValue?: string;
};
-export const ResolverSelector: FC<ResolverSelectorProps> = ({
- initialValue,
-}) => {
+const ProviderSelector: FC<ProviderSelectorProps> = ({ initialValue }) => {
const { reportEvent } = useAnalytics();
const router = useRouter();
@@ -66,3 +65,82 @@ export const ResolverSelector: FC<ResolverSelectorProps> = ({
</Label>
);
};
+
+type LocationSelectorProps = {
+ initialValue?: string;
+ disabled?: boolean;
+};
+
+const LocationSelector: FC<LocationSelectorProps> = ({
+ initialValue,
+ disabled,
+}) => {
+ const { reportEvent } = useAnalytics();
+
+ const router = useRouter();
+ const pathname = usePathname();
+ const searchParams = useSearchParams();
+
+ const onValueChange = useCallback(
+ (value: string) => {
+ const current = new URLSearchParams(Array.from(searchParams.entries()));
+
+ if (!value || value === 'auto') {
+ current.delete('location');
+ } else {
+ current.set('location', value);
+ }
+
+ const search = current.size ? `?${current.toString()}` : '';
+ router.push(`${pathname}${search}`);
+
+ reportEvent('Location Selector: Change', { location: value });
+ },
+ [router, pathname, searchParams, reportEvent],
+ );
+
+ return (
+ <Label className="flex flex-col gap-1">
+ <span className="text-sm text-zinc-500 dark:text-zinc-400">Location</span>
+
+ <Select
+ defaultValue={initialValue || 'auto'}
+ onValueChange={onValueChange}
+ disabled={disabled}
+ >
+ <SelectTrigger>
+ <SelectValue placeholder="Location" />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="auto">Auto</SelectItem>
+ {Object.entries(REGIONS).map(([id, details]) => (
+ <SelectItem key={id} value={id}>
+ {details.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </Label>
+ );
+};
+
+export const ResolverSelector: FC = () => {
+ const searchParams = useSearchParams();
+
+ const resolverName = searchParams.get('resolver') ?? undefined;
+ const locationName = searchParams.get('location') ?? undefined;
+
+ return (
+ <div className="flex flex-col gap-4 min-[450px]:flex-row">
+ <div className="w-full flex-1 min-[450px]:max-w-52">
+ <ProviderSelector initialValue={resolverName} />
+ </div>
+ <div className="w-full flex-1 min-[450px]:max-w-52">
+ <LocationSelector
+ initialValue={locationName}
+ disabled={!resolverName}
+ />
+ </div>
+ </div>
+ );
+};
diff --git a/app/lookup/[domain]/(dns)/layout.tsx b/app/lookup/[domain]/(dns)/layout.tsx
new file mode 100644
index 0000000..a2d7062
--- /dev/null
+++ b/app/lookup/[domain]/(dns)/layout.tsx
@@ -0,0 +1,16 @@
+import type { FC, ReactNode } from 'react';
+
+import { ResolverSelector } from './_components/resolver-selector';
+
+type DnsResultsLayoutProps = {
+ children: ReactNode;
+};
+
+const DnsResultsLayout: FC<DnsResultsLayoutProps> = async ({ children }) => (
+ <>
+ <ResolverSelector />
+ {children}
+ </>
+);
+
+export default DnsResultsLayout;
diff --git a/app/lookup/[domain]/(dns)/page.tsx b/app/lookup/[domain]/(dns)/page.tsx
index d67cbbc..cf064a6 100644
--- a/app/lookup/[domain]/(dns)/page.tsx
+++ b/app/lookup/[domain]/(dns)/page.tsx
@@ -1,5 +1,5 @@
import type { Metadata } from 'next';
-import { redirect, RedirectType } from 'next/navigation';
+import { notFound, redirect, RedirectType } from 'next/navigation';
import type { FC } from 'react';
import { ALL_RECORD_TYPES } from '@/lib/data';
@@ -7,8 +7,6 @@ import { getRecordContextEntries } from '@/lib/record-context';
import { getResolverFromName } from '@/lib/resolvers/utils';
import { DnsTable } from './_components/dns-table';
-import { LocationSelector } from './_components/location-selector';
-import { ResolverSelector } from './_components/resolver-selector';
type LookupDomainProps = {
params: Promise<{
@@ -70,28 +68,14 @@ const LookupDomain: FC<LookupDomainProps> = async ({
0,
) > 0;
- return (
- <>
- <div className="flex flex-col gap-4 min-[450px]:flex-row">
- <div className="w-full flex-1 min-[450px]:max-w-52">
- <ResolverSelector initialValue={resolverName} />
- </div>
- <div className="w-full flex-1 min-[450px]:max-w-52">
- <LocationSelector
- initialValue={locationName}
- disabled={!resolverName}
- />
- </div>
- </div>
+ if (hasResults) {
+ return <DnsTable records={records} subvalues={subvalues} />;
+ }
- {hasResults ? (
- <DnsTable records={records} subvalues={subvalues} />
- ) : (
- <p className="mt-24 text-center text-zinc-500 dark:text-zinc-400">
- No DNS records found!
- </p>
- )}
- </>
+ return (
+ <div className="flex h-screen flex-col items-center justify-center">
+ <p className="text-zinc-500 dark:text-zinc-400">No DNS records found!</p>
+ </div>
);
};
diff --git a/components/ui/select.tsx b/components/ui/select.tsx
index 23a3d48..d5ac14d 100644
--- a/components/ui/select.tsx
+++ b/components/ui/select.tsx
@@ -29,7 +29,7 @@ const SelectTrigger = React.forwardRef<
<SelectPrimitive.Trigger
ref={ref}
className={cn(
- 'relative block w-full appearance-none rounded-lg px-3 py-1.5',
+ 'relative box-border block h-10 w-full appearance-none rounded-lg px-3 py-1.5',
'text-sm/6 text-zinc-950 placeholder:text-zinc-500 dark:text-white',
'border border-zinc-950/10 data-[hover]:border-zinc-950/20 dark:border-white/10 dark:data-[hover]:border-white/20',
'bg-transparent dark:bg-white/5',