From 4d5cd32563d97d565ce78421e5150ef476c9cc72 Mon Sep 17 00:00:00 2001 From: Stephanos Date: Thu, 28 Nov 2024 19:19:35 +0800 Subject: [PATCH] Doc: Changes to comply with Sonar Cloud --- .../{form.stories.tsx => MuiForm.stories.tsx} | 0 .../MUI-FormControl/{form.tsx => MuiForm.tsx} | 9 +++---- src/components/menu/MUI-FormControl/index.ts | 2 +- .../menu/MUI-menu/dropdown.stories.tsx | 26 +++++++++---------- src/components/menu/MUI-menu/dropdown.tsx | 5 ++-- 5 files changed, 18 insertions(+), 24 deletions(-) rename src/components/menu/MUI-FormControl/{form.stories.tsx => MuiForm.stories.tsx} (100%) rename src/components/menu/MUI-FormControl/{form.tsx => MuiForm.tsx} (94%) diff --git a/src/components/menu/MUI-FormControl/form.stories.tsx b/src/components/menu/MUI-FormControl/MuiForm.stories.tsx similarity index 100% rename from src/components/menu/MUI-FormControl/form.stories.tsx rename to src/components/menu/MUI-FormControl/MuiForm.stories.tsx diff --git a/src/components/menu/MUI-FormControl/form.tsx b/src/components/menu/MUI-FormControl/MuiForm.tsx similarity index 94% rename from src/components/menu/MUI-FormControl/form.tsx rename to src/components/menu/MUI-FormControl/MuiForm.tsx index 26dca62..07139ea 100644 --- a/src/components/menu/MUI-FormControl/form.tsx +++ b/src/components/menu/MUI-FormControl/MuiForm.tsx @@ -1,9 +1,7 @@ /** @jsxImportSource @emotion/react */ import React from 'react'; -import { Select, MenuItem, FormControl, InputLabel, SelectChangeEvent, Typography, SxProps } from '@mui/material'; +import { Select, MenuItem, FormControl, SelectChangeEvent, Typography, SxProps } from '@mui/material'; import {colors} from '../../../theme'; -import { ArrowDown } from './data'; - interface FormControlProps { fullwidth?: boolean; @@ -33,7 +31,7 @@ interface SelectFieldProps extends FormControlProps { } -export default function formComponent(props:Readonly) { +export default function MuiForm(props:Readonly) { const{ id, value, @@ -49,7 +47,6 @@ export default function formComponent(props:Readonly) { fontWeight = "700", multiple = false, sx = {}, - ...otherProps } = props; return ( @@ -179,4 +176,4 @@ export default function formComponent(props:Readonly) { ); -}; \ No newline at end of file +}; diff --git a/src/components/menu/MUI-FormControl/index.ts b/src/components/menu/MUI-FormControl/index.ts index 58ee864..01c7974 100644 --- a/src/components/menu/MUI-FormControl/index.ts +++ b/src/components/menu/MUI-FormControl/index.ts @@ -1 +1 @@ -export {default as formComponent} from './form'; \ No newline at end of file +export {default as formComponent} from './MuiForm'; \ No newline at end of file diff --git a/src/components/menu/MUI-menu/dropdown.stories.tsx b/src/components/menu/MUI-menu/dropdown.stories.tsx index 5ca1d83..fb2a83a 100644 --- a/src/components/menu/MUI-menu/dropdown.stories.tsx +++ b/src/components/menu/MUI-menu/dropdown.stories.tsx @@ -2,7 +2,7 @@ import React from "react"; import type { Meta, StoryObj } from "@storybook/react"; import MyDropdown from "./dropdown"; import { colors } from "../../../theme"; -import IconButton, { iconButtonClasses } from "@mui/material/IconButton"; +import IconButton from "@mui/material/IconButton"; import MenuRounded from "@mui/icons-material/MenuRounded"; import AccountCircleIcon from '@mui/icons-material/AccountCircle'; import SettingsIcon from '@mui/icons-material/Settings'; @@ -31,10 +31,8 @@ const meta: Meta = { menuItemProps: { control: "object" }, }, }; - export default meta; type StoryType = StoryObj; - //OpenAidDropdown export const OpenAidDropdown: StoryType = { args: { @@ -45,19 +43,19 @@ const meta: Meta = { ), items: [ - { label: "Data Summary", action: () => console.log("Item 1 clicked") }, - { label: "Disbursements Overview", action: () => console.log("Item 2 clicked") }, - { label: "Priorities", action: () => console.log("Item 3 clicked") }, - { label: "Sectors", action: () => console.log("Item 4 clicked") }, - { label: "Countries & Regions", action: () => console.log("Item 3 clicked") }, - { label: "Organisations", action: () => console.log("Item 4 clicked") }, - { label: "Activities", action: () => console.log("Item 3 clicked") }, + { label: "Data Summary", action: () => console.log("Data Summary clicked") }, + { label: "Disbursements Overview", action: () => console.log("Disbursements Overview clicked") }, + { label: "Priorities", action: () => console.log("Priorities clicked") }, + { label: "Sectors", action: () => console.log("Sectors clicked") }, + { label: "Countries & Regions", action: () => console.log("Countries & Regions clicked") }, + { label: "Organisations", action: () => console.log("Organisations clicked") }, + { label: "Activities", action: () => console.log("Activities clicked") }, {divider: true }, - { label: "About this site", action: () => console.log("Item 4 clicked") }, - { label: "About Open Aid", action: () => console.log("Item 3 clicked") }, + { label: "About this site", action: () => console.log("About this site clicked") }, + { label: "About Open Aid", action: () => console.log("About Open Aid clicked") }, { divider:true}, - { label: "Feedback", action: () => console.log("Item 4 clicked") }, - { label: "Accessibility", action: () => console.log("Item 3 clicked") }, + { label: "Feedback", action: () => console.log("Feedback clicked") }, + { label: "Accessibility", action: () => console.log("Accessibility clicked") }, ], transformOrigin:{ vertical: "top", diff --git a/src/components/menu/MUI-menu/dropdown.tsx b/src/components/menu/MUI-menu/dropdown.tsx index 1d01d21..d3ef9ef 100644 --- a/src/components/menu/MUI-menu/dropdown.tsx +++ b/src/components/menu/MUI-menu/dropdown.tsx @@ -118,7 +118,7 @@ interface DropdownProps extends MuiMenuProps { }; } -export default function MyDropdown(props:Readonly) { +export default function MuiMenu(props:Readonly) { const { id, anchorElement, @@ -134,10 +134,9 @@ menuItemProps, open, selected, ...otherProps -}=props; +}=props; const [anchorEl, setAnchorEl] = React.useState(null); -const [currentLabel, setCurrentLabel] = React.useState(""); const handleClick = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget);