From 6af5f71ddaba14511322b6ccda1582e9849d3dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 26 Jul 2022 14:19:30 +0200 Subject: [PATCH] Dropdown: New dropdown component (#52684) * Progress * Example usage in application * Add FocusScope * REmove unused type * simplify it by removing trigger property * Use new Menu.Item way to access component --- .../src/components/Dropdown/Dropdown.mdx | 35 ++++++++ .../components/Dropdown/Dropdown.story.tsx | 60 ++++++++++++++ .../src/components/Dropdown/Dropdown.tsx | 81 +++++++++++++++++++ packages/grafana-ui/src/components/index.ts | 1 + .../components/AppChrome/TopSearchBar.tsx | 23 +++++- 5 files changed, 196 insertions(+), 4 deletions(-) create mode 100644 packages/grafana-ui/src/components/Dropdown/Dropdown.mdx create mode 100644 packages/grafana-ui/src/components/Dropdown/Dropdown.story.tsx create mode 100644 packages/grafana-ui/src/components/Dropdown/Dropdown.tsx diff --git a/packages/grafana-ui/src/components/Dropdown/Dropdown.mdx b/packages/grafana-ui/src/components/Dropdown/Dropdown.mdx new file mode 100644 index 00000000000..150cf5cf653 --- /dev/null +++ b/packages/grafana-ui/src/components/Dropdown/Dropdown.mdx @@ -0,0 +1,35 @@ +import { Meta, Props } from '@storybook/addon-docs/blocks'; + +import { Dropdown } from './Dropdown'; + + + +# Dropdown + +Hook up a menu or other overlay to any trigger. + +### When to use + +When you want a button, link or icon button to open a Menu or Popover. By default the trigger is click but it can be changed to show on hover using the +trigger property. + +### Usage + +```tsx +import { Dropdown, Menu, Button } from '@grafana/ui'; + +const menu = ( + + + + +); + +return ( + + + + + + + - + + + ); } +/** + * This is just temporary, needs syncing with the backend option like DisableSignoutMenu + */ +export function ProfileMenu() { + return ( + + + + + + ); +} + const getStyles = (theme: GrafanaTheme2) => { return { searchBar: css({