From 87ef467245bbd4f5e8c2f973c81da9e121716800 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Mon, 30 Oct 2023 09:41:27 -0600 Subject: [PATCH] Improved DropdownSelector component (#557) --- src/components/Autocomplete/Autocomplete.tsx | 1 + .../DropdownSelector.stories.tsx | 80 ++++++++++ .../DropdownSelector/DropdownSelector.tsx | 146 ++++++++++-------- .../DropdownSelector.types.ts | 3 + src/components/Select/Select.tsx | 1 + 5 files changed, 167 insertions(+), 64 deletions(-) create mode 100644 src/components/DropdownSelector/DropdownSelector.stories.tsx diff --git a/src/components/Autocomplete/Autocomplete.tsx b/src/components/Autocomplete/Autocomplete.tsx index 14fe69d9..5c226093 100644 --- a/src/components/Autocomplete/Autocomplete.tsx +++ b/src/components/Autocomplete/Autocomplete.tsx @@ -234,6 +234,7 @@ const Autocomplete: FC = ({ }} open={isOpen} anchorEl={anchorEl} + useAnchorWidth /> diff --git a/src/components/DropdownSelector/DropdownSelector.stories.tsx b/src/components/DropdownSelector/DropdownSelector.stories.tsx new file mode 100644 index 00000000..669e5225 --- /dev/null +++ b/src/components/DropdownSelector/DropdownSelector.stories.tsx @@ -0,0 +1,80 @@ +// This file is part of MinIO Design System +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import React, { useState } from "react"; +import { Meta, Story } from "@storybook/react"; + +import DropdownSelector from "./DropdownSelector"; +import { DropdownSelectorProps } from "./DropdownSelector.types"; + +import StoryThemeProvider from "../../utils/StoryThemeProvider"; +import GlobalStyles from "../GlobalStyles/GlobalStyles"; +import Box from "../Box/Box"; +import Button from "../Button/Button"; +import TestIcon from "../../utils/TestIcon"; + +export default { + title: "MDS/Forms/DropdownSelector", + component: DropdownSelector, + argTypes: {}, +} as Meta; + +const Template: Story = (args) => { + const [anchorEl, setAnchorEl] = React.useState(null); + const openDownloadMenu = Boolean(anchorEl); + + const handleCloseDownload = () => { + setAnchorEl(null); + }; + + return ( + + +