-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(SWUI-20): Add Popover to SwaprUI Website (#17)
* chore: create PopoverSection component with examples * refactor: abstract Section component to be reused * docs: add PopoverSection to SwaprUI Website
- Loading branch information
1 parent
9dae089
commit dd5698e
Showing
6 changed files
with
134 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Section } from "@/components"; | ||
import { | ||
PopoverBasic, | ||
PopoverSlippageSettings, | ||
PopoverWithHeader, | ||
} from "./examples"; | ||
|
||
interface PopoverList { | ||
headers: Array<string>; | ||
examples: Array<() => JSX.Element>; | ||
} | ||
|
||
const popoverList: PopoverList = { | ||
headers: ["Basic", "With Header", "Settings example"], | ||
examples: [PopoverBasic, PopoverWithHeader, PopoverSlippageSettings], | ||
}; | ||
|
||
export const PopoverSection = () => ( | ||
<Section> | ||
<h2 className="text-2xl font-semibold">Popovers</h2> | ||
<div className="grid items-center space-y-2.5 lg:space-y-0 lg:grid-cols-3 lg:gap-4"> | ||
{popoverList.headers.map((header, index) => ( | ||
<div | ||
key={index} | ||
className="hidden uppercase text-xs lg:block font-semibold bg-gray-200 text-center" | ||
> | ||
{header} | ||
</div> | ||
))} | ||
{popoverList.examples.map((Example, index) => ( | ||
<div key={index} className="flex items-center justify-center"> | ||
<Example /> | ||
</div> | ||
))} | ||
</div> | ||
</Section> | ||
); |
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,87 @@ | ||
import { | ||
Button, | ||
ChipButton, | ||
Icon, | ||
IconButton, | ||
Popover, | ||
PopoverContent, | ||
PopoverContentHeader, | ||
PopoverTrigger, | ||
TabGroup, | ||
TabHeader, | ||
TabStyled, | ||
} from "swapr-ui"; | ||
import { Root as Separator } from "@radix-ui/react-separator"; | ||
|
||
const SettingsPopoverContent = () => ( | ||
<div className="space-y-2"> | ||
<div className="flex items-center mx-4 text-text-low-em"> | ||
<p className="font-bold text-xs">MAX SLIPPAGE</p> | ||
<Icon className="ml-1 text-text-low-em" name="info-fill" size={14} /> | ||
</div> | ||
<TabGroup | ||
as="div" | ||
onChange={(index: number) => | ||
console.log("Changed selected tab to:", index) | ||
} | ||
className="mx-4" | ||
> | ||
<TabHeader className="overflow-x-auto md:overflow-x-visible last:right-0 flex justify-between"> | ||
<div className="flex space-x-3"> | ||
<TabStyled>Auto</TabStyled> | ||
<TabStyled>0.1%</TabStyled> | ||
<TabStyled>0.5%</TabStyled> | ||
</div> | ||
<ChipButton>3 %</ChipButton> | ||
</TabHeader> | ||
</TabGroup> | ||
<p className="font-semibold mt-4 mx-4 text-text-primary-main text-sm"> | ||
Custom slippage: 3% | ||
</p> | ||
<div className="bg-surface-danger-accent-1 font-semibold mx-4 px-3 py-2 rounded-8 text-text-danger-em text-sm"> | ||
The slippage you selected is greater than what is required to perform this | ||
transaction. We recommend selecting the Auto Slippage option for this | ||
transaction. | ||
</div> | ||
<Separator decorative className="h-[1px] bg-outline-base-em" /> | ||
<div className="flex items-center mx-4 text-text-low-em"> | ||
<p className="font-bold text-xs">TRANSACTION DEADLINE</p> | ||
<Icon className="ml-1 text-text-low-em" name="info-fill" size={14} /> | ||
</div> | ||
<ChipButton className="mx-4">10 mins</ChipButton> | ||
</div> | ||
); | ||
|
||
export const PopoverBasic = () => ( | ||
<Popover> | ||
<PopoverTrigger> | ||
<Button>Open Popup</Button> | ||
</PopoverTrigger> | ||
<PopoverContent> | ||
<p>This is a basic content example</p> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
|
||
export const PopoverWithHeader = () => ( | ||
<Popover> | ||
<PopoverTrigger> | ||
<Button>With header</Button> | ||
</PopoverTrigger> | ||
<PopoverContent className="max-w-md px-0"> | ||
<PopoverContentHeader title="Settings" /> | ||
<SettingsPopoverContent /> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
|
||
export const PopoverSlippageSettings = () => ( | ||
<Popover> | ||
<PopoverTrigger> | ||
<IconButton name="settings" /> | ||
</PopoverTrigger> | ||
<PopoverContent className="max-w-md px-0"> | ||
<SettingsPopoverContent /> | ||
</PopoverContent> | ||
</Popover> | ||
); |
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 @@ | ||
export * from "./PopoverSection"; |
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 @@ | ||
import { PropsWithChildren } from "react"; | ||
|
||
export const Section = ({ children }: PropsWithChildren) => ( | ||
<section className="space-y-4 py-12 border-b">{children}</section> | ||
); |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from "./PopoverSection"; | ||
export * from "./Section"; | ||
export * from "./ThemeSwitch"; |