Skip to content

Commit 4e20fc2

Browse files
christophidespPanos Christophides
andauthored
Add title support in dropdown (#448)
* add title support in dropdown * replace text with flex --------- Co-authored-by: Panos Christophides <[email protected]>
1 parent 39c993e commit 4e20fc2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/components/drops/menu/dropdown.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useVirtualizer } from "@tanstack/react-virtual"
44
import Flex from "src/components/templates/flex"
55
import Search from "src/components/search"
66
import Box from "src/components/templates/box"
7+
import { TextSmall } from "src/components/typography"
78

89
const Container = styled(Flex)`
910
${({ hideShadow }) =>
@@ -19,6 +20,8 @@ const Dropdown = ({
1920
itemProps,
2021
items,
2122
onItemClick,
23+
dropTitle,
24+
dropTitlePadding = [3, 3, 0],
2225
Item,
2326
value,
2427
hasSearch,
@@ -71,6 +74,7 @@ const Dropdown = ({
7174
width="auto"
7275
{...rest}
7376
>
77+
{dropTitle && <Flex padding={dropTitlePadding}>{dropTitle}</Flex>}
7478
{hasSearch && (
7579
<Box margin={searchMargin}>
7680
<Search

src/components/drops/menu/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const Menu = forwardRef(
2828
Item = DropdownItem,
2929
Dropdown = DefaultDropdown,
3030
animation,
31+
dropTitle,
32+
dropTitlePadding,
3133
hasSearch = false,
3234
...rest
3335
},
@@ -96,6 +98,8 @@ const Menu = forwardRef(
9698
{...dropProps}
9799
>
98100
<Dropdown
101+
dropTitle={dropTitle}
102+
dropTitlePadding={dropTitlePadding}
99103
value={value}
100104
onItemClick={onItemClick}
101105
items={items}

src/components/drops/menu/index.stories.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import Flex from "src/components/templates/flex"
77
import Tooltip from "src/components/drops/tooltip"
88
import { Button } from "src/components/button"
99
import { Icon } from "src/components/icon"
10+
import { Text } from "src/components/typography"
11+
1012
import readme from "./README.md"
1113
import Menu from "./index"
1214

@@ -18,9 +20,10 @@ const subData = {
1820
},
1921
jest: ["index.test.js"],
2022
}
21-
2223
const Simple = props => (
2324
<Menu
25+
dropTitle={<Text>Fight Club characters</Text>}
26+
dropTitlePadding={[2]}
2427
label="Character"
2528
items={[
2629
{ value: "narrator", label: "The Narrator", onClick: action("narrator") },

0 commit comments

Comments
 (0)