Skip to content

Commit

Permalink
fix: dropdown menu button onclick missed (#10819)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->


<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on enhancing the `DropdownMenu` component by ensuring it
correctly passes the `onClick` prop and updating the Storybook
configuration for better integration with Vite.

### Detailed summary
- Updated `DropdownMenu` component to properly pass `onClick` props.
- Modified `DropdownMenu` mock to trigger an alert on disconnect.
- Configured Storybook to use Vite with a specified configuration file.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
ChefJerry authored Oct 14, 2024
1 parent 3ee4a96 commit a0e17e0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-swans-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pancakeswap/uikit': patch
---

Fixed DropdownMenu component missed pass `onClick` props
6 changes: 5 additions & 1 deletion packages/uikit/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { mergeConfig } from "vite";
module.exports = {
framework: {
name: "@storybook/react-vite",
options: {},
options: {
builder: {
viteConfigPath: ".storybook/vite.config.ts",
},
},
},
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
Expand Down
7 changes: 7 additions & 0 deletions packages/uikit/.storybook/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [vanillaExtractPlugin()],
assetsInclude: ["/sb-preview/runtime.js"],
});
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const MenuItem: React.FC<{
return (
<StyledDropdownMenuItemContainer key={label?.toString()}>
{type === DropdownMenuItemType.BUTTON && (
<DropdownMenuItem $isActive={isActive} disabled={disabled || isDisabled} type="button">
<DropdownMenuItem $isActive={isActive} disabled={disabled || isDisabled} type="button" {...itemProps}>
{MenuItemContent}
</DropdownMenuItem>
)}
Expand Down
6 changes: 4 additions & 2 deletions packages/uikit/src/components/DropdownMenu/mock.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import noop from "lodash/noop";
import { DropdownMenuItems, DropdownMenuItemType } from "./types";

const ItemsMock: DropdownMenuItems[] = [
Expand All @@ -20,7 +19,10 @@ const ItemsMock: DropdownMenuItems[] = [
},
{
label: "Disconnect",
onClick: noop,
onClick: () => {
// eslint-disable-next-line no-alert
alert("disconnect");
},
type: DropdownMenuItemType.BUTTON,
},
];
Expand Down

0 comments on commit a0e17e0

Please sign in to comment.