-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f79b77
commit 08261de
Showing
9 changed files
with
143 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use client' | ||
import React from 'react' | ||
import { Popover, PopoverContent, PopoverTrigger } from '@nextui-org/popover' | ||
import { Chip } from '@nextui-org/chip' | ||
|
||
import { UrlInputPopover } from '@/components/url-input-popover' | ||
import { useURL } from '@/components/hooks/use-url' | ||
|
||
export default function UrlChip() { | ||
const { url } = useURL() | ||
|
||
return ( | ||
<div className="flex flex-wrap gap-4"> | ||
<Popover backdrop={'blur'} offset={10} placement="bottom"> | ||
<PopoverTrigger> | ||
{url instanceof Error ? ( | ||
<Chip className="cursor-pointer " color={'warning'} variant={'light'}> | ||
{url.message} | ||
</Chip> | ||
) : ( | ||
<Chip className="cursor-pointer bg-foreground-100">{url}</Chip> | ||
)} | ||
</PopoverTrigger> | ||
<PopoverContent className="p-2 bg-foreground-100 "> | ||
<UrlInputPopover /> | ||
</PopoverContent> | ||
</Popover> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use client' | ||
|
||
import React, { FC } from 'react' | ||
import { Chip } from '@nextui-org/chip' | ||
|
||
interface UrlDetectProps { | ||
url: string | ||
} | ||
|
||
export const UrlDetect: FC<UrlDetectProps> = ({ url }) => { | ||
return ( | ||
<div className={'flex gap-1'}> | ||
<Chip className={'text-default-500'} variant={'light'}> | ||
{url} | ||
</Chip> | ||
<div /> | ||
</div> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use client' | ||
|
||
import { Input } from '@nextui-org/input' | ||
import React, { useMemo } from 'react' | ||
|
||
import { useURL } from '@/components/hooks/use-url' | ||
import { UrlDetect } from '@/components/url-detect' | ||
|
||
export const UrlInputPopover = () => { | ||
const { url, input, setInput } = useURL() | ||
|
||
const isInvalid = useMemo(() => { | ||
return url instanceof Error | ||
}, [url]) | ||
|
||
const placeholder = '8080, localhost:8080 or http://localhost:8080/debug/pprof' | ||
return ( | ||
<div className="flex flex-col justify-start items-start"> | ||
{/* to provide auto inferred width for <Input> */} | ||
<div className="text-nowrap z-10 opacity-0 select-none h-[1px]">{placeholder}6chars6chars</div> | ||
|
||
<Input | ||
fullWidth | ||
isClearable | ||
className={'w-full max-w-full'} | ||
color={isInvalid ? 'danger' : 'success'} | ||
errorMessage={url instanceof Error ? url.message : undefined} | ||
isInvalid={isInvalid} | ||
placeholder={placeholder} | ||
type="email" | ||
value={input} | ||
variant="bordered" | ||
onValueChange={setInput} | ||
/> | ||
{typeof url === 'string' && <UrlDetect url={url} />} | ||
<div className="text-nowrap z-10 opacity-0 select-none h-[1px]">{placeholder}6chars</div> | ||
</div> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.