-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement tabs for payload and response (#150)
- Loading branch information
1 parent
c7aa8b0
commit 804172c
Showing
10 changed files
with
189 additions
and
165 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@envyjs/webui': patch | ||
--- | ||
|
||
Implement tabs for payload and response |
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,39 @@ | ||
import useApplication from '@/hooks/useApplication'; | ||
import { tw } from '@/utils'; | ||
|
||
export function TabList({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<div className="px-4 bg-secondary border-b border-primary"> | ||
<ul className="flex flex-wrap text-sm gap-2">{children}</ul> | ||
</div> | ||
); | ||
} | ||
|
||
export function TabListItem({ id, title }: { id: string; title: string }) { | ||
const { selectedTab, setSelectedTab } = useApplication(); | ||
|
||
const className = tw( | ||
'inline-block px-4 py-3 uppercase font-semibold cursor-pointer', | ||
'border border-b-0', | ||
selectedTab === id ? 'border-green-400 bg-green-100' : 'border-primary bg-primary', | ||
); | ||
|
||
return ( | ||
<li> | ||
<a | ||
href={`#${id}`} | ||
className={className} | ||
onClick={() => { | ||
setSelectedTab(id); | ||
}} | ||
> | ||
{title} | ||
</a> | ||
</li> | ||
); | ||
} | ||
|
||
export function TabContent({ id, children }: { id: string; children: React.ReactNode }) { | ||
const { selectedTab } = useApplication(); | ||
return <div className={selectedTab === id ? 'h-full' : 'hidden'}>{children}</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
Oops, something went wrong.