import * as React from "react"; import { css } from "@emotion/css"; import { StoryFn, Meta } from "@storybook/react"; import styled from "@emotion/styled"; import Dropdownable, { Direction } from "../components/Dropdownable"; import { PrimaryButton, SecondaryButton } from "../../button"; import { themeBgPrimary, themeBorder } from "../../design-tokens/build/js/designTokens"; const DropdownContentContainer = styled.div` min-width: 250px; border: 1px solid ${themeBorder}; background-color: ${themeBgPrimary}; padding: 5px; `; export default { title: "Utils/Dropdownable", component: Dropdownable, argTypes: { preferredDirections: { options: ["bottom-start", "bottom-end", "top-start", "top-end"], control: { type: "select" } }, dropdown: { control: { disable: true } }, overlayRoot: { control: { disable: true } }, className: { control: { disable: true } }, "data-cy": { control: { disable: true } } } } as Meta; const Template: StoryFn = args => { const [isShowing, setIsShowing] = React.useState(false); const { preferredDirections } = args; function toggle( event?: React.SyntheticEvent | undefined ) { event?.preventDefault(); setIsShowing(!isShowing); event?.stopPropagation(); } const containerStyle = css` display: flex; align-items: center; justify-content: center; min-height: 400px; `; return (

Positioned relative to children.

Click outside to dismiss.

} > toggle(event)}> Change dropdown orientation using Controls
); }; const MultipleTemplate: StoryFn = args => { const [isOpen, setIsOpen] = React.useState(false); const [expanded, setExpanded] = React.useState(false); const containerStyle = css({ display: "flex", ["align-items"]: "center", ["justify-content"]: "flex-end", ["min-height"]: expanded ? "400px" : "40px" }); function toggleExpand() { setExpanded(!expanded); } function handleClose() { setIsOpen(false); } function handleOpen( event?: React.SyntheticEvent | undefined ) { event?.preventDefault(); setIsOpen(true); event?.stopPropagation(); } return (

I prefer to be positioned on the top

Click outside to dismiss

Also try resizing

Click the other button to make more vertical space

Click the other button to make more vertical space

Click the other button to make more vertical space

Click the other button to make more vertical space

Click the other button to make more vertical space

} > handleOpen(event)}> Open the dropdown before and after expanding the height
{expanded ? "Collapse" : "Expand"}
); }; export const Default = { render: Template }; export const WithMultipleDirectionPreferences = { render: MultipleTemplate };