This repository was archived by the owner on Jul 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add setting menu widget #140
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
103 changes: 103 additions & 0 deletions
103
src/widgets/new-design/SettingMenu/SettingMenu.stories.tsx
This file contains hidden or 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,103 @@ | ||
import { Meta, StoryFn } from "@storybook/react"; | ||
import { useState } from "react"; | ||
import { SettingMenu } from "./SettingMenu"; | ||
import { Button } from "@/components/Button"; | ||
|
||
export default { | ||
title: "Widgets/New Design/SettingMenu", | ||
component: SettingMenu, | ||
argTypes: { | ||
onOpenChange: { action: "open state changed" }, | ||
}, | ||
tags: ["autodocs"], | ||
} as Meta<typeof SettingMenu>; | ||
|
||
const ThemeIcon = () => ( | ||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<rect width="40" height="40" rx="20" fill="#387085" fillOpacity="0.12" /> | ||
<path | ||
d="M20 30C25.52 30 30 25.52 30 20C30 14.48 25.52 10 20 10C14.48 10 10 14.48 10 20C10 25.52 14.48 30 20 30ZM21 12.07C24.94 12.56 28 15.92 28 20C28 24.08 24.95 27.44 21 27.93V12.07Z" | ||
fill="#387085" | ||
/> | ||
</svg> | ||
); | ||
|
||
const ReportABugIcon = () => ( | ||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<rect width="40" height="40" rx="20" fill="#387085" fillOpacity="0.12" /> | ||
<path | ||
d="M23.73 11H16.27L11 16.27V23.73L16.27 29H23.73L29 23.73V16.27L23.73 11ZM20 25.3C19.28 25.3 18.7 24.72 18.7 24C18.7 23.28 19.28 22.7 20 22.7C20.72 22.7 21.3 23.28 21.3 24C21.3 24.72 20.72 25.3 20 25.3ZM21 21H19V15H21V21Z" | ||
fill="#387085" | ||
/> | ||
</svg> | ||
); | ||
|
||
export const Default: StoryFn = () => { | ||
const [selectedTheme, setSelectedTheme] = useState<"light" | "dark" | "auto">("auto"); | ||
|
||
const handleThemeChange = (theme: "light" | "dark" | "auto") => { | ||
setSelectedTheme(theme); | ||
console.log(`${theme} theme selected`); | ||
}; | ||
|
||
const getThemeDescription = () => { | ||
switch (selectedTheme) { | ||
case "light": | ||
return "Light"; | ||
case "dark": | ||
return "Dark"; | ||
case "auto": | ||
return "Auto"; | ||
default: | ||
return "Auto"; | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="p-4"> | ||
<SettingMenu> | ||
<SettingMenu.Title>Settings</SettingMenu.Title> | ||
|
||
<SettingMenu.Group background="secondary"> | ||
<SettingMenu.SubMenu icon={<ThemeIcon />}> | ||
Theme | ||
<SettingMenu.Description>{getThemeDescription()}</SettingMenu.Description> | ||
<SettingMenu.Item selected={selectedTheme === "light"} onClick={() => handleThemeChange("light")}> | ||
Light | ||
</SettingMenu.Item> | ||
<SettingMenu.Item selected={selectedTheme === "dark"} onClick={() => handleThemeChange("dark")}> | ||
Dark | ||
</SettingMenu.Item> | ||
<SettingMenu.Item selected={selectedTheme === "auto"} onClick={() => handleThemeChange("auto")}> | ||
Auto | ||
</SettingMenu.Item> | ||
</SettingMenu.SubMenu> | ||
|
||
<SettingMenu.Item icon={<ReportABugIcon />} onClick={() => console.log("Report bug clicked")}> | ||
Report a Bug | ||
</SettingMenu.Item> | ||
</SettingMenu.Group> | ||
|
||
<SettingMenu.Spacer /> | ||
|
||
<SettingMenu.Group background="secondary"> | ||
<SettingMenu.Item onClick={() => window.open("https://example.com/terms", "_blank")}> | ||
Terms of Use | ||
</SettingMenu.Item> | ||
|
||
<SettingMenu.Item onClick={() => window.open("https://example.com/privacy", "_blank")}> | ||
Privacy Policy | ||
</SettingMenu.Item> | ||
</SettingMenu.Group> | ||
|
||
<SettingMenu.Spacer /> | ||
|
||
<SettingMenu.CustomContent className="my-4 flex justify-center"> | ||
<Button className="!bg-[#D5FCE8] !text-black" variant="contained"> | ||
Switch to BABY Staking | ||
</Button> | ||
</SettingMenu.CustomContent> | ||
</SettingMenu> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.