playbook_ui_docs 13.24.0.pre.alpha.play1305drycontenttag2689 β 13.25.0.pre.alpha.PBNTR272Dropdownkitv42769
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_currency/docs/_currency_alignment_swift.md +43 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_props_swift.md +12 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_size_swift.md +31 -0
- data/app/pb_kits/playbook/pb_currency/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/_date_range_stacked_default_swift.md +14 -0
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/_date_range_stacked_props_swift.md +9 -0
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.jsx +38 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +87 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +102 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +104 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.md +5 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx +63 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.jsx +48 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx +77 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_external_control.jsx +62 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx +75 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.jsx +39 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +15 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +10 -0
- data/dist/menu.yml +5 -1
- data/dist/playbook-doc.js +10 -10
- metadata +28 -3
- /data/app/pb_kits/playbook/pb_dialog/docs/{_dialog_props_table.md β _dialog_props_swift.md} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 753a6f2f7b01fdac359c30fa0690b8a8864bc1cfca6c6080612af234468de89a
|
4
|
+
data.tar.gz: 9f82ae6b5501e21723c87914acd09d18fca85a2ae2c6600005f6f0edb5129c57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 691c2efe2050ffd354f8f74bab421f572c11f1e6fe977a4347bc638af87f93003e1aaa7cba672fb0ab7bac2e8554187b9143cb5254f6586954f8af5295d81332
|
7
|
+
data.tar.gz: 6523b43812ff33c699ccfc9c0383680fa78bbb58e68c7f68e7d069100160ba864d7ec50efc3539c838d92e748e5b5a31ceda22202d84103adc74c22cd1b4490a
|
@@ -0,0 +1,43 @@
|
|
1
|
+
[!Currency-Alignment](https://github.com/powerhome/playbook-swift/assets/112719604/d74a9c5a-c606-4cd0-bf70-20e9297ec246)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading, spacing: Spacing.small) {
|
5
|
+
HStack {
|
6
|
+
PBCurrency(
|
7
|
+
amount: "2,000",
|
8
|
+
decimalAmount: ".50",
|
9
|
+
label: "left",
|
10
|
+
size: .title4,
|
11
|
+
symbol: "en_US",
|
12
|
+
isEmphasized: true,
|
13
|
+
alignment: .leading
|
14
|
+
)
|
15
|
+
}
|
16
|
+
.frame(maxWidth: .infinity, alignment: .leading)
|
17
|
+
HStack {
|
18
|
+
PBCurrency(
|
19
|
+
amount: "342",
|
20
|
+
decimalAmount: ".00",
|
21
|
+
label: "center",
|
22
|
+
size: .title4,
|
23
|
+
symbol: "en_EU",
|
24
|
+
isEmphasized: true,
|
25
|
+
alignment: .center
|
26
|
+
)
|
27
|
+
}
|
28
|
+
.frame(maxWidth: .infinity, alignment: .center)
|
29
|
+
HStack {
|
30
|
+
PBCurrency(
|
31
|
+
amount: "45",
|
32
|
+
label: "right",
|
33
|
+
size: .title4,
|
34
|
+
symbol: "en_US",
|
35
|
+
unit: "/mo",
|
36
|
+
isEmphasized: true,
|
37
|
+
hasUnit: true,
|
38
|
+
alignment: .trailing
|
39
|
+
)
|
40
|
+
}
|
41
|
+
.frame(maxWidth: .infinity, alignment: .trailing)
|
42
|
+
}
|
43
|
+
```
|
@@ -0,0 +1,12 @@
|
|
1
|
+
### Props
|
2
|
+
| Name | Type | Description | Default | Values |
|
3
|
+
| --- | ----------- | --------- | --------- | --------- |
|
4
|
+
| **amount** | `String` | Allows user to enter a currency amount | | |
|
5
|
+
| **decimalAmount** | `String` | Allows user to enter a decimal amount | | |
|
6
|
+
| **label** | `String` | Allows user to a descriptive label value | | |
|
7
|
+
| **size** | `PBFont` | Allows user to choose the size of the amount that is being displayed | `.title4` | `title4` `title3` `title4` |
|
8
|
+
| **symbol** | `String` | A string value used to produce the desired currency symbol | | |
|
9
|
+
| **unit** | `String` | Allows user to add a unit of measure instead of a decimal amount | | |
|
10
|
+
| **alignment** | `Alignment` | Sets alignment of content | `.leading` | `leading` `center` `trailing` |
|
11
|
+
| **isEmphasized** | `Bool` | Determines whether or not the currency that is being displayed is emphasized | `false` | `true` `false` |
|
12
|
+
| **hasUnit** | `Bool` | Determines whether or not the currency has a decimal value or a unit of measure | `false` | `true` `false` |
|
@@ -0,0 +1,31 @@
|
|
1
|
+
![Currency-Default](https://github.com/powerhome/playbook-swift/assets/54749071/bf3810f9-6dd2-4bdd-b32a-14109f3a0b9a)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading, spacing: Spacing.small) {
|
5
|
+
PBCurrency(
|
6
|
+
amount: "2,000",
|
7
|
+
decimalAmount: ".50",
|
8
|
+
label: "small",
|
9
|
+
size: .title4,
|
10
|
+
symbol: "en_US",
|
11
|
+
isEmphasized: true
|
12
|
+
)
|
13
|
+
PBCurrency(
|
14
|
+
amount: "342",
|
15
|
+
decimalAmount: ".00",
|
16
|
+
label: "medium",
|
17
|
+
size: .title3,
|
18
|
+
symbol: "en_EU",
|
19
|
+
isEmphasized: true
|
20
|
+
)
|
21
|
+
PBCurrency(
|
22
|
+
amount: "45",
|
23
|
+
label: "large",
|
24
|
+
size: .title1,
|
25
|
+
symbol: "en_US",
|
26
|
+
unit: "/mo",
|
27
|
+
isEmphasized: true,
|
28
|
+
hasUnit: true
|
29
|
+
)
|
30
|
+
}
|
31
|
+
```
|
@@ -0,0 +1,14 @@
|
|
1
|
+
![Date-Range-Stacked-Default](https://github.com/powerhome/playbook-swift/assets/54749071/ccb85e5d-0f6d-4ced-8154-aa9dfa72a131)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading, spacing: Spacing.small) {
|
5
|
+
PBDateRangeStacked(
|
6
|
+
startDate: Date().makeDate(year: 2019, month: 6, day: 18),
|
7
|
+
endDate: Date().makeDate(year: 2020, month: 3, day: 20),
|
8
|
+
startAlignment: .trailing,
|
9
|
+
endAlignment: .leading,
|
10
|
+
startVariant: .short(showIcon: false),
|
11
|
+
endVariant: .short(showIcon: false)
|
12
|
+
)
|
13
|
+
}
|
14
|
+
```
|
@@ -0,0 +1,9 @@
|
|
1
|
+
### Props
|
2
|
+
| Name | Type | Description | Default | Values |
|
3
|
+
| --- | ----------- | --------- | --------- | --------- |
|
4
|
+
| **startDate** | `Date()` | Takes a string value to set the starting date range value | `Date()` | |
|
5
|
+
| **endDate** | `Date()` | Takes a string value to set the ending date range value | `Date()` | |
|
6
|
+
| **startAlignment** | `Alignment` | Changes the alignment of the starting date | `.leading` | `.leading` `.trailing` |
|
7
|
+
| **endAlignment** | `Alignment` | Changes the alignment of the ending date | `.leading` | `.leading` `.trailing` |
|
8
|
+
| **startVariant** | `PBDate.Variant` | Changes the style of the starting date | `.short(showIcon: false)` | `.short(showIcon: false)` `.dayDate` `.standard` `.withIcon(isStandard: true)` `withIcon(isStandard: false)` |
|
9
|
+
| **endVariant** | `PBDate.Variant` | Changes the style of the ending date | `.short(showIcon: false)` | `.short(showIcon: false)` `.dayDate` `.standard` `.withIcon(isStandard: true)` `withIcon(isStandard: false)` |
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Dropdown } from '../../'
|
3
|
+
|
4
|
+
const DropdownDefault = (props) => {
|
5
|
+
|
6
|
+
const options = [
|
7
|
+
{
|
8
|
+
label: "United States",
|
9
|
+
value: "United States",
|
10
|
+
},
|
11
|
+
{
|
12
|
+
label: "Canada",
|
13
|
+
value: "Canada",
|
14
|
+
},
|
15
|
+
{
|
16
|
+
label: "Pakistan",
|
17
|
+
value: "Pakistan",
|
18
|
+
}
|
19
|
+
];
|
20
|
+
|
21
|
+
|
22
|
+
return (
|
23
|
+
<div>
|
24
|
+
<Dropdown
|
25
|
+
options={options}
|
26
|
+
{...props}
|
27
|
+
>
|
28
|
+
{options.map((option) => (
|
29
|
+
<Dropdown.Option key={option.id}
|
30
|
+
option={option}
|
31
|
+
/>
|
32
|
+
))}
|
33
|
+
</Dropdown>
|
34
|
+
</div>
|
35
|
+
)
|
36
|
+
}
|
37
|
+
|
38
|
+
export default DropdownDefault
|
@@ -0,0 +1 @@
|
|
1
|
+
`options` for the Dropdown and `option` for the Dropdown.Option are the only required props for this kit. `options` must be an array of objects. Each object can contain any key/value pairs needed but 'label' and 'value' are required.
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { Dropdown, User, Badge, FlexItem } from '../..'
|
3
|
+
|
4
|
+
const DropdownWithAutocomplete = (props) => {
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
6
|
+
const [selectedOption, setSelectedOption] = useState();
|
7
|
+
|
8
|
+
const options = [
|
9
|
+
{
|
10
|
+
label: "Jasper Furniss",
|
11
|
+
value: "Jasper Furniss",
|
12
|
+
territory: "PHL",
|
13
|
+
title: "Senior UX Engineer",
|
14
|
+
id: "jasper-furniss",
|
15
|
+
status: "Offline"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
label: "Ramon Ruiz",
|
19
|
+
value: "Ramon Ruiz",
|
20
|
+
territory: "PHL",
|
21
|
+
title: "Senior UX Desinger",
|
22
|
+
id: "ramon-ruiz",
|
23
|
+
status: "Away"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
label: "Jason Cypret",
|
27
|
+
value: "Jason Cypret",
|
28
|
+
territory: "PHL",
|
29
|
+
title: "VP of User Experience",
|
30
|
+
id: "jason-cypret",
|
31
|
+
status: "Online"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
label: "Courtney Long",
|
35
|
+
value: "Courtney Long",
|
36
|
+
territory: "PHL",
|
37
|
+
title: "UX Design Mentor",
|
38
|
+
id: "courtney-long",
|
39
|
+
status: "Online"
|
40
|
+
}
|
41
|
+
];
|
42
|
+
|
43
|
+
|
44
|
+
return (
|
45
|
+
<div>
|
46
|
+
<Dropdown autocomplete
|
47
|
+
onSelect={(selectedItem) => setSelectedOption(selectedItem)}
|
48
|
+
options={options}
|
49
|
+
{...props}
|
50
|
+
>
|
51
|
+
{options.map((option) => (
|
52
|
+
<Dropdown.Option key={option.id}
|
53
|
+
option={option}
|
54
|
+
>
|
55
|
+
<>
|
56
|
+
<FlexItem>
|
57
|
+
<User
|
58
|
+
align="left"
|
59
|
+
avatar
|
60
|
+
name={option.label}
|
61
|
+
orientation="horizontal"
|
62
|
+
territory={option.territory}
|
63
|
+
title={option.title}
|
64
|
+
/>
|
65
|
+
</FlexItem>
|
66
|
+
<FlexItem>
|
67
|
+
<Badge
|
68
|
+
rounded
|
69
|
+
text={option.status}
|
70
|
+
variant={`${
|
71
|
+
option.status === "Offline"
|
72
|
+
? "neutral"
|
73
|
+
: option.status === "Online"
|
74
|
+
? "success"
|
75
|
+
: "warning"
|
76
|
+
}`}
|
77
|
+
/>
|
78
|
+
</FlexItem>
|
79
|
+
</>
|
80
|
+
</Dropdown.Option>
|
81
|
+
))}
|
82
|
+
</Dropdown>
|
83
|
+
</div>
|
84
|
+
)
|
85
|
+
}
|
86
|
+
|
87
|
+
export default DropdownWithAutocomplete
|
@@ -0,0 +1 @@
|
|
1
|
+
The `autocomplete` prop can be used to add autocomplete or typeahead functionality to the Dropdown's default Trigger. This prop is set to 'false' by default.
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { Dropdown, User, Badge, FlexItem, Avatar } from '../..'
|
3
|
+
|
4
|
+
const DropdownWithAutocompleteAndCustomDisplay = (props) => {
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
6
|
+
const [selectedOption, setSelectedOption] = useState();
|
7
|
+
|
8
|
+
const options = [
|
9
|
+
{
|
10
|
+
label: "Jasper Furniss",
|
11
|
+
value: "Jasper Furniss",
|
12
|
+
territory: "PHL",
|
13
|
+
title: "Senior UX Engineer",
|
14
|
+
id: "jasper-furniss",
|
15
|
+
status: "Offline"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
label: "Ramon Ruiz",
|
19
|
+
value: "Ramon Ruiz",
|
20
|
+
territory: "PHL",
|
21
|
+
title: "Senior UX Desinger",
|
22
|
+
id: "ramon-ruiz",
|
23
|
+
status: "Away"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
label: "Jason Cypret",
|
27
|
+
value: "Jason Cypret",
|
28
|
+
territory: "PHL",
|
29
|
+
title: "VP of User Experience",
|
30
|
+
id: "jason-cypret",
|
31
|
+
status: "Online"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
label: "Courtney Long",
|
35
|
+
value: "Courtney Long",
|
36
|
+
territory: "PHL",
|
37
|
+
title: "UX Design Mentor",
|
38
|
+
id: "courtney-long",
|
39
|
+
status: "Online"
|
40
|
+
}
|
41
|
+
];
|
42
|
+
|
43
|
+
const CustomDisplay = () => {
|
44
|
+
return (
|
45
|
+
<>
|
46
|
+
{
|
47
|
+
selectedOption && (
|
48
|
+
<Avatar
|
49
|
+
name={selectedOption.label}
|
50
|
+
size="xs"
|
51
|
+
/>
|
52
|
+
)
|
53
|
+
}
|
54
|
+
</>
|
55
|
+
)
|
56
|
+
};
|
57
|
+
|
58
|
+
return (
|
59
|
+
<div>
|
60
|
+
<Dropdown autocomplete
|
61
|
+
onSelect={(selectedItem) => setSelectedOption(selectedItem)}
|
62
|
+
options={options}
|
63
|
+
{...props}
|
64
|
+
>
|
65
|
+
<Dropdown.Trigger customDisplay={<CustomDisplay/>} />
|
66
|
+
{options.map((option) => (
|
67
|
+
<Dropdown.Option key={option.id}
|
68
|
+
option={option}
|
69
|
+
>
|
70
|
+
<>
|
71
|
+
<FlexItem>
|
72
|
+
<User
|
73
|
+
align="left"
|
74
|
+
avatar
|
75
|
+
name={option.label}
|
76
|
+
orientation="horizontal"
|
77
|
+
territory={option.territory}
|
78
|
+
title={option.title}
|
79
|
+
/>
|
80
|
+
</FlexItem>
|
81
|
+
<FlexItem>
|
82
|
+
<Badge
|
83
|
+
rounded
|
84
|
+
text={option.status}
|
85
|
+
variant={`${
|
86
|
+
option.status === "Offline"
|
87
|
+
? "neutral"
|
88
|
+
: option.status === "Online"
|
89
|
+
? "success"
|
90
|
+
: "warning"
|
91
|
+
}`}
|
92
|
+
/>
|
93
|
+
</FlexItem>
|
94
|
+
</>
|
95
|
+
</Dropdown.Option>
|
96
|
+
))}
|
97
|
+
</Dropdown>
|
98
|
+
</div>
|
99
|
+
)
|
100
|
+
}
|
101
|
+
|
102
|
+
export default DropdownWithAutocompleteAndCustomDisplay
|
@@ -0,0 +1 @@
|
|
1
|
+
`autocomplete` prop can also be used in conjunction with the `customDisplay` prop.
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { Dropdown, User, FlexItem, Badge, Avatar } from '../../'
|
3
|
+
|
4
|
+
const DropdownWithCustomDisplay = (props) => {
|
5
|
+
const [selectedOption, setSelectedOption] = useState();
|
6
|
+
|
7
|
+
const options = [
|
8
|
+
{
|
9
|
+
label: "Jasper Furniss",
|
10
|
+
value: "Jasper Furniss",
|
11
|
+
territory: "PHL",
|
12
|
+
title: "Senior UX Engineer",
|
13
|
+
id: "jasper-furniss",
|
14
|
+
status: "Offline"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
label: "Ramon Ruiz",
|
18
|
+
value: "Ramon Ruiz",
|
19
|
+
territory: "PHL",
|
20
|
+
title: "Senior UX Desinger",
|
21
|
+
id: "ramon-ruiz",
|
22
|
+
status: "Away"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
label: "Jason Cypret",
|
26
|
+
value: "Jason Cypret",
|
27
|
+
territory: "PHL",
|
28
|
+
title: "VP of User Experience",
|
29
|
+
id: "jason-cypret",
|
30
|
+
status: "Online"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
label: "Courtney Long",
|
34
|
+
value: "Courtney Long",
|
35
|
+
territory: "PHL",
|
36
|
+
title: "UX Design Mentor",
|
37
|
+
id: "courtney-long",
|
38
|
+
status: "Online"
|
39
|
+
}
|
40
|
+
];
|
41
|
+
|
42
|
+
const CustomDisplay = () => {
|
43
|
+
return (
|
44
|
+
<>
|
45
|
+
{
|
46
|
+
selectedOption && (
|
47
|
+
<Avatar
|
48
|
+
name={selectedOption.label}
|
49
|
+
size="xs"
|
50
|
+
/>
|
51
|
+
)
|
52
|
+
}
|
53
|
+
</>
|
54
|
+
)
|
55
|
+
};
|
56
|
+
|
57
|
+
|
58
|
+
return (
|
59
|
+
<div>
|
60
|
+
<Dropdown
|
61
|
+
onSelect={(selectedItem) => setSelectedOption(selectedItem)}
|
62
|
+
options={options}
|
63
|
+
{...props}
|
64
|
+
>
|
65
|
+
<Dropdown.Trigger customDisplay={<CustomDisplay/>}
|
66
|
+
placeholder="Select a User"
|
67
|
+
/>
|
68
|
+
{options.map((option) => (
|
69
|
+
<Dropdown.Option key={option.id}
|
70
|
+
option={option}
|
71
|
+
>
|
72
|
+
<>
|
73
|
+
<FlexItem>
|
74
|
+
<User
|
75
|
+
align="left"
|
76
|
+
avatar
|
77
|
+
name={option.label}
|
78
|
+
orientation="horizontal"
|
79
|
+
territory={option.territory}
|
80
|
+
title={option.title}
|
81
|
+
/>
|
82
|
+
</FlexItem>
|
83
|
+
<FlexItem>
|
84
|
+
<Badge dark
|
85
|
+
rounded
|
86
|
+
text={option.status}
|
87
|
+
variant={`${
|
88
|
+
option.status === "Offline"
|
89
|
+
? "neutral"
|
90
|
+
: option.status === "Online"
|
91
|
+
? "success"
|
92
|
+
: "warning"
|
93
|
+
}`}
|
94
|
+
/>
|
95
|
+
</FlexItem>
|
96
|
+
</>
|
97
|
+
</Dropdown.Option>
|
98
|
+
))}
|
99
|
+
</Dropdown>
|
100
|
+
</div>
|
101
|
+
)
|
102
|
+
}
|
103
|
+
|
104
|
+
export default DropdownWithCustomDisplay
|
@@ -0,0 +1,5 @@
|
|
1
|
+
The `customDisplay` prop can be used to customize the display of the selected item by allowing devs to pass in a component that will be rendered to the left of the default text-based display. In this example the Avatar kit is being used.
|
2
|
+
|
3
|
+
The `placeholder` prop can also be used to customize the placeholder text for the default Trigger.
|
4
|
+
|
5
|
+
The `onSelect` prop is a function that gives the dev one argument: the selected option. In this example we are using the `onSelect` to set a state with the selected option and using it to customize the `customDisplay`.
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Dropdown, Icon, Body, FlexItem, Flex } from '../..'
|
3
|
+
|
4
|
+
const DropdownWithCustomOptions = (props) => {
|
5
|
+
|
6
|
+
const options = [
|
7
|
+
{
|
8
|
+
label: "United States",
|
9
|
+
value: "United States",
|
10
|
+
areaCode: "+1",
|
11
|
+
icon: "πΊπΈ",
|
12
|
+
id: "United-states"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
label: "Canada",
|
16
|
+
value: "Canada",
|
17
|
+
areaCode: "+1",
|
18
|
+
icon: "π¨π¦",
|
19
|
+
id: "canada"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
label: "Pakistan",
|
23
|
+
value: "Pakistan",
|
24
|
+
areaCode: "+92",
|
25
|
+
icon: "π΅π°",
|
26
|
+
id: "pakistan"
|
27
|
+
}
|
28
|
+
];
|
29
|
+
|
30
|
+
|
31
|
+
return (
|
32
|
+
<div>
|
33
|
+
<Dropdown
|
34
|
+
options={options}
|
35
|
+
{...props}
|
36
|
+
>
|
37
|
+
{options.map((option) => (
|
38
|
+
<Dropdown.Option key={option.id}
|
39
|
+
option={option}
|
40
|
+
>
|
41
|
+
<>
|
42
|
+
<FlexItem>
|
43
|
+
<Flex>
|
44
|
+
<Icon icon={option.icon}
|
45
|
+
paddingRight="xs"
|
46
|
+
/>
|
47
|
+
<Body text={option.label} />
|
48
|
+
</Flex>
|
49
|
+
</FlexItem>
|
50
|
+
<FlexItem>
|
51
|
+
<Body color="light"
|
52
|
+
text={option.areaCode}
|
53
|
+
/>
|
54
|
+
</FlexItem>
|
55
|
+
</>
|
56
|
+
</Dropdown.Option>
|
57
|
+
))}
|
58
|
+
</Dropdown>
|
59
|
+
</div>
|
60
|
+
)
|
61
|
+
}
|
62
|
+
|
63
|
+
export default DropdownWithCustomOptions
|
@@ -0,0 +1 @@
|
|
1
|
+
The Dropdown also allows for custom options that can be passed in as children to the `Dropdown.Option` subcomponent. If no children are passed in the `Dropdown.Option`, the kit will render each option as text by default.
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Dropdown } from '../..'
|
3
|
+
|
4
|
+
const DropdownWithCustomPadding = (props) => {
|
5
|
+
|
6
|
+
const options = [
|
7
|
+
{
|
8
|
+
label: "United States",
|
9
|
+
value: "United States",
|
10
|
+
areaCode: "+1",
|
11
|
+
icon: "πΊπΈ",
|
12
|
+
id: "United-states"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
label: "Canada",
|
16
|
+
value: "Canada",
|
17
|
+
areaCode: "+1",
|
18
|
+
icon: "π¨π¦",
|
19
|
+
id: "canada"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
label: "Pakistan",
|
23
|
+
value: "Pakistan",
|
24
|
+
areaCode: "+92",
|
25
|
+
icon: "π΅π°",
|
26
|
+
id: "pakistan"
|
27
|
+
}
|
28
|
+
];
|
29
|
+
|
30
|
+
|
31
|
+
return (
|
32
|
+
<div>
|
33
|
+
<Dropdown
|
34
|
+
options={options}
|
35
|
+
{...props}
|
36
|
+
>
|
37
|
+
{options.map((option) => (
|
38
|
+
<Dropdown.Option key={option.id}
|
39
|
+
option={option}
|
40
|
+
padding="sm"
|
41
|
+
/>
|
42
|
+
))}
|
43
|
+
</Dropdown>
|
44
|
+
</div>
|
45
|
+
)
|
46
|
+
}
|
47
|
+
|
48
|
+
export default DropdownWithCustomPadding
|
@@ -0,0 +1 @@
|
|
1
|
+
By default, the padding on each option in the dropdown is set to `xs`. The `padding` Global Props however can be used to override this default. In this example, we are setting padding to `sm`.
|