playbook_ui 12.36.0 → 12.37.0.pre.alpha.PLAYaddingdatapropselectkit1071
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/index.js +2 -1
- data/app/pb_kits/playbook/pb_badge/docs/_badge_colors_swift.md +33 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_default_swift.md +9 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_notification_swift.md +9 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_props_swift.md +6 -0
- data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded_swift.md +9 -0
- data/app/pb_kits/playbook/pb_badge/docs/example.yml +7 -0
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +15 -13
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +24 -8
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -1
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +15 -4
- data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_collapsible/useCollapsible.tsx +14 -0
- data/app/pb_kits/playbook/pb_date/_date.tsx +7 -8
- data/app/pb_kits/playbook/pb_date/docs/_date_alignment.jsx +2 -2
- data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +29 -5
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +2 -2
- data/app/pb_kits/playbook/pb_date/docs/_date_variants.jsx +5 -5
- data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +45 -31
- data/app/pb_kits/playbook/pb_date_range_stacked/_date_range_stacked.tsx +5 -3
- data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +24 -21
- data/app/pb_kits/playbook/pb_date_time/_date_time.tsx +1 -1
- data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +1 -1
- data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.tsx +2 -2
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.test.js +1 -1
- data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.tsx +6 -8
- data/app/pb_kits/playbook/pb_kit/dateTime.ts +146 -63
- data/app/pb_kits/playbook/pb_label_value/_label_value.tsx +52 -31
- data/app/pb_kits/playbook/pb_message/_message.tsx +24 -24
- data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +22 -1
- data/app/pb_kits/playbook/pb_nav/_item.tsx +26 -2
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +59 -79
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom_icons.jsx +4 -6
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_nav/item.rb +5 -1
- data/app/pb_kits/playbook/pb_pill/docs/_pill_default_swift.md +5 -0
- data/app/pb_kits/playbook/pb_pill/docs/_pill_props_swift.md +5 -0
- data/app/pb_kits/playbook/pb_pill/docs/_pill_variants_swift.md +10 -0
- data/app/pb_kits/playbook/pb_pill/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_alignment_swift.md +16 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_swift.md +18 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_default_swift.md +15 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_error_swift.md +14 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_orientation_swift.md +15 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_padding_swift.md +31 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_props_swift.md +10 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_spacing_swift.md +36 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_subtitle_swift.md +13 -0
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +11 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_data_attributes.html.erb +24 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_data_attributes.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_select/select.html.erb +1 -1
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_options.html.erb +12 -0
- data/app/pb_kits/playbook/pb_text_input/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +1 -1
- data/app/pb_kits/playbook/pb_time/_time.tsx +9 -11
- data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +46 -49
- data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.tsx +4 -6
- data/app/pb_kits/playbook/pb_timestamp/_timestamp.tsx +11 -11
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_align_swift.md +45 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default_swift.md +26 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed_swift.md +25 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_props_swift.md +10 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_timezones_swift.md +67 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_swift.md +19 -0
- data/app/pb_kits/playbook/pb_timestamp/docs/example.yml +8 -0
- data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +8 -11
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/version.rb +2 -2
- metadata +34 -8
- data/app/pb_kits/playbook/pb_logistic/_logistic.jsx +0 -120
@@ -14,15 +14,19 @@ type NavItemProps = {
|
|
14
14
|
children?: React.ReactNode[] | React.ReactNode,
|
15
15
|
className?: string,
|
16
16
|
collapsible?: boolean,
|
17
|
+
collapsibleClick?: () => void,
|
17
18
|
data?: object,
|
18
19
|
iconLeft?: string,
|
19
20
|
iconRight?: string | string[],
|
21
|
+
iconRightClick?: () => void,
|
22
|
+
iconLeftClick?: () => void,
|
20
23
|
id?: string,
|
21
24
|
imageUrl?: string,
|
22
25
|
link?: string,
|
23
26
|
onClick?: React.MouseEventHandler<HTMLElement>,
|
24
27
|
target?: '_blank' | '_self' | '_parent' | '_top',
|
25
28
|
text: string,
|
29
|
+
toggleCollapsed?: any
|
26
30
|
} & GlobalProps
|
27
31
|
|
28
32
|
const NavItem = (props: NavItemProps) => {
|
@@ -32,22 +36,34 @@ const NavItem = (props: NavItemProps) => {
|
|
32
36
|
children,
|
33
37
|
className,
|
34
38
|
collapsible,
|
39
|
+
collapsibleClick,
|
35
40
|
data = {},
|
36
41
|
iconLeft,
|
37
42
|
iconRight,
|
43
|
+
iconRightClick,
|
44
|
+
iconLeftClick,
|
38
45
|
id,
|
39
46
|
imageUrl,
|
40
47
|
link,
|
41
48
|
onClick = () => { },
|
42
49
|
target = '_self',
|
43
50
|
text = '',
|
51
|
+
toggleCollapsed
|
44
52
|
} = props
|
45
53
|
|
46
54
|
const Tag = link ? 'a' : 'div'
|
47
55
|
const activeClass = active === true ? 'active' : ''
|
48
56
|
const ariaProps = buildAriaProps(aria)
|
49
57
|
const dataProps = buildDataProps(data)
|
50
|
-
const classes = classnames(buildCss('pb_nav_list_kit_item', activeClass), globalProps(props), className)
|
58
|
+
const classes = classnames(buildCss('pb_nav_list_kit_item', activeClass), collapsible ? 'pb_collapsible_nav_item' : '', globalProps(props), className)
|
59
|
+
|
60
|
+
|
61
|
+
const handleIconClick = (e:any) => {
|
62
|
+
if (iconLeftClick) {
|
63
|
+
e.stopPropagation();
|
64
|
+
iconLeftClick()
|
65
|
+
}
|
66
|
+
}
|
51
67
|
|
52
68
|
return (
|
53
69
|
<li
|
@@ -58,7 +74,13 @@ const NavItem = (props: NavItemProps) => {
|
|
58
74
|
>
|
59
75
|
{
|
60
76
|
collapsible ? (
|
61
|
-
<Collapsible icon={iconRight ? iconRight : ['plus','minus']}
|
77
|
+
<Collapsible icon={iconRight ? iconRight : ['plus','minus']}
|
78
|
+
iconSize="xs"
|
79
|
+
id={id}
|
80
|
+
collapsed={toggleCollapsed}
|
81
|
+
iconClick={iconRightClick}
|
82
|
+
onClick={collapsibleClick}
|
83
|
+
>
|
62
84
|
<Collapsible.Main>
|
63
85
|
<Tag
|
64
86
|
className="pb_nav_list_item_link"
|
@@ -70,6 +92,7 @@ const NavItem = (props: NavItemProps) => {
|
|
70
92
|
<div
|
71
93
|
className="pb_nav_list_item_icon_section"
|
72
94
|
key={imageUrl}
|
95
|
+
onClick={(e)=>handleIconClick(e)}
|
73
96
|
>
|
74
97
|
<Image
|
75
98
|
className="pb_nav_img_wrapper"
|
@@ -82,6 +105,7 @@ const NavItem = (props: NavItemProps) => {
|
|
82
105
|
<div
|
83
106
|
className="pb_nav_list_item_icon_section"
|
84
107
|
key={iconLeft}
|
108
|
+
onClick={(e)=>handleIconClick(e)}
|
85
109
|
>
|
86
110
|
<Icon
|
87
111
|
className="pb_nav_list_item_icon_left"
|
@@ -1,83 +1,63 @@
|
|
1
|
-
import React from "react"
|
2
|
-
|
3
|
-
import Nav from "../_nav";
|
4
|
-
import NavItem from "../_item";
|
1
|
+
import React from "react"
|
2
|
+
import { Nav, NavItem, useCollapsible } from "../.."
|
5
3
|
|
6
4
|
const CollapsibleNav = (props) => {
|
5
|
+
const navItems = ["Overview", "Albums", "Similar Artists"]
|
6
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
7
|
+
const collapsibles = navItems.map(() => useCollapsible(true))
|
8
|
+
|
9
|
+
const handleMainClick = (index) => {
|
10
|
+
collapsibles.forEach(([, , setCollapsed], idx) => {
|
11
|
+
if (idx === index) {
|
12
|
+
setCollapsed(false)
|
13
|
+
} else {
|
14
|
+
setCollapsed(true)
|
15
|
+
}
|
16
|
+
})
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
const handleIconRightClick = (index) => {
|
21
|
+
const [isCollapsed, setCollapsed] = collapsibles[index]
|
22
|
+
setCollapsed(!isCollapsed)
|
23
|
+
}
|
24
|
+
|
7
25
|
return (
|
8
|
-
|
9
|
-
<
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
/>
|
45
|
-
<NavItem
|
46
|
-
link="#"
|
47
|
-
text="Food"
|
48
|
-
{...props}
|
49
|
-
/>
|
50
|
-
<NavItem
|
51
|
-
link="#"
|
52
|
-
text="Style"
|
53
|
-
{...props}
|
54
|
-
/>
|
55
|
-
</NavItem>
|
56
|
-
<NavItem
|
57
|
-
collapsible
|
58
|
-
iconLeft="city"
|
59
|
-
link="#"
|
60
|
-
text="Similar Artists"
|
61
|
-
{...props}
|
62
|
-
>
|
63
|
-
<NavItem
|
64
|
-
link="#"
|
65
|
-
text="City"
|
66
|
-
{...props}
|
67
|
-
/>
|
68
|
-
<NavItem
|
69
|
-
link="#"
|
70
|
-
text="People"
|
71
|
-
{...props}
|
72
|
-
/>
|
73
|
-
<NavItem
|
74
|
-
link="#"
|
75
|
-
text="Business"
|
76
|
-
{...props}
|
77
|
-
/>
|
78
|
-
</NavItem>
|
79
|
-
</Nav>
|
80
|
-
);
|
81
|
-
};
|
26
|
+
<>
|
27
|
+
<Nav variant='subtle'>
|
28
|
+
{navItems.map((text, index) => {
|
29
|
+
const [collapsed] = collapsibles[index]
|
30
|
+
return (
|
31
|
+
<NavItem
|
32
|
+
collapsible
|
33
|
+
collapsibleClick={() => handleMainClick(index)}
|
34
|
+
iconLeft="chevron-down"
|
35
|
+
iconRightClick={() => handleIconRightClick(index)}
|
36
|
+
id={`collapsible-nav-item-${index + 1}`}
|
37
|
+
key={index}
|
38
|
+
link="#"
|
39
|
+
text={text}
|
40
|
+
toggleCollapsed={collapsed}
|
41
|
+
{...props}
|
42
|
+
>
|
43
|
+
<NavItem link="#"
|
44
|
+
text="City"
|
45
|
+
{...props}
|
46
|
+
/>
|
47
|
+
<NavItem link="#"
|
48
|
+
text="People"
|
49
|
+
{...props}
|
50
|
+
/>
|
51
|
+
<NavItem link="#"
|
52
|
+
text="Business"
|
53
|
+
{...props}
|
54
|
+
/>
|
55
|
+
</NavItem>
|
56
|
+
);
|
57
|
+
})}
|
58
|
+
</Nav>
|
59
|
+
</>
|
60
|
+
)
|
61
|
+
}
|
82
62
|
|
83
|
-
export default CollapsibleNav
|
63
|
+
export default CollapsibleNav
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import React from "react";
|
2
|
-
|
3
|
-
import Nav from "../_nav";
|
4
|
-
import NavItem from "../_item";
|
2
|
+
import { Nav, NavItem } from '../..'
|
5
3
|
|
6
4
|
const CollapsibleNavCustomIcons = (props) => {
|
7
5
|
return (
|
@@ -9,7 +7,7 @@ const CollapsibleNavCustomIcons = (props) => {
|
|
9
7
|
<NavItem
|
10
8
|
collapsible
|
11
9
|
iconLeft="city"
|
12
|
-
iconRight={["
|
10
|
+
iconRight={["plus", "minus"]}
|
13
11
|
link="#"
|
14
12
|
text="Overview"
|
15
13
|
{...props}
|
@@ -34,7 +32,7 @@ const CollapsibleNavCustomIcons = (props) => {
|
|
34
32
|
active
|
35
33
|
collapsible
|
36
34
|
iconLeft="theater-masks"
|
37
|
-
iconRight={["
|
35
|
+
iconRight={["plus", "minus"]}
|
38
36
|
link="#"
|
39
37
|
text="Albums"
|
40
38
|
{...props}
|
@@ -58,7 +56,7 @@ const CollapsibleNavCustomIcons = (props) => {
|
|
58
56
|
<NavItem
|
59
57
|
collapsible
|
60
58
|
iconLeft="city"
|
61
|
-
iconRight={["
|
59
|
+
iconRight={["plus", "minus"]}
|
62
60
|
link="#"
|
63
61
|
text="Similar Artists"
|
64
62
|
{...props}
|
@@ -26,7 +26,7 @@ examples:
|
|
26
26
|
- subtle_nav: Subtle Variant
|
27
27
|
- subtle_with_icons_nav: Subtle With Icons
|
28
28
|
# - collapsible_nav: Subtle With Collapsible
|
29
|
-
# - collapsible_nav_custom_icons: Subtle With Collapsible (
|
29
|
+
# - collapsible_nav_custom_icons: Subtle With Collapsible (No custom toggling)
|
30
30
|
- subtle_no_highlight_nav: Subtle No Highlight
|
31
31
|
- bold_vertical_nav: Bold Variant
|
32
32
|
- horizontal_nav: Horizontal Nav
|
@@ -14,7 +14,11 @@ module Playbook
|
|
14
14
|
values: %w[_blank _self _parent _top],
|
15
15
|
default: "_self"
|
16
16
|
def classname
|
17
|
-
|
17
|
+
if collapsible
|
18
|
+
"pb_collapsible_nav_item #{generate_classname('pb_nav_list_kit_item', active_class)}"
|
19
|
+
else
|
20
|
+
generate_classname("pb_nav_list_kit_item", active_class)
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
def tag
|
@@ -0,0 +1,5 @@
|
|
1
|
+
### Props
|
2
|
+
| Name | Type | Description | Default | Values |
|
3
|
+
| --- | ----------- | --------- | --------- | --------- |
|
4
|
+
| **title** | `String` | Specifies the value of the Pill | | |
|
5
|
+
| **variant** | `Variant` | Changes the color of the Pill | `.neutral` | `.error` `.info` `.neutral` `.primary` `.success` `.warning` |
|
@@ -0,0 +1,10 @@
|
|
1
|
+
![pill-variants](https://github.com/powerhome/playbook/assets/92755007/79ac4260-633e-4429-8b1f-0a97b8178a86)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
PBPill("success", variant: .success)
|
5
|
+
PBPill("error", variant: .error)
|
6
|
+
PBPill("warning", variant: .warning)
|
7
|
+
PBPill("info", variant: .info)
|
8
|
+
PBPill("neutral", variant: .neutral)
|
9
|
+
PBPill("primary", variant: .primary)
|
10
|
+
```
|
@@ -0,0 +1,16 @@
|
|
1
|
+
![radio-alignment](https://github.com/powerhome/playbook/assets/92755007/04b84035-8391-4de1-a33e-8964999d5c0f)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading) {
|
5
|
+
PBRadio(
|
6
|
+
items: [
|
7
|
+
PBRadioItem("Power"),
|
8
|
+
.init("Nitro"),
|
9
|
+
.init("Google")
|
10
|
+
],
|
11
|
+
orientation: .horizontal,
|
12
|
+
textAlignment: .vertical,
|
13
|
+
selected: $selectedAlignment
|
14
|
+
)
|
15
|
+
}
|
16
|
+
```
|
@@ -0,0 +1,18 @@
|
|
1
|
+
![radio-custom](https://github.com/powerhome/playbook/assets/92755007/3eab180b-0550-4d7e-b562-84a007690218)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading) {
|
5
|
+
if let selectedCustom = selectedCustom {
|
6
|
+
Text("Your choice is: \(selectedCustom.title)")
|
7
|
+
}
|
8
|
+
PBRadio(
|
9
|
+
items: [
|
10
|
+
PBRadioItem("Custom Power"),
|
11
|
+
.init("Custom Nitro"),
|
12
|
+
.init("Custom Google")
|
13
|
+
],
|
14
|
+
orientation: .vertical,
|
15
|
+
selected: $selectedCustom
|
16
|
+
)
|
17
|
+
}
|
18
|
+
```
|
@@ -0,0 +1,15 @@
|
|
1
|
+
![radio-default](https://github.com/powerhome/playbook/assets/92755007/be32852e-de70-4ae0-b8bb-c091f8cfa34b)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading) {
|
5
|
+
PBRadio(
|
6
|
+
items: [
|
7
|
+
PBRadioItem("Power"),
|
8
|
+
.init("Nitro"),
|
9
|
+
.init("Google")
|
10
|
+
],
|
11
|
+
orientation: .vertical,
|
12
|
+
selected: $selectedDefault
|
13
|
+
)
|
14
|
+
}
|
15
|
+
```
|
@@ -0,0 +1,14 @@
|
|
1
|
+
![radio-error](https://github.com/powerhome/playbook/assets/92755007/425f499b-4daf-4093-82a7-230b01723287)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading) {
|
5
|
+
PBRadio(
|
6
|
+
items: [
|
7
|
+
PBRadioItem("Power")
|
8
|
+
],
|
9
|
+
orientation: .vertical,
|
10
|
+
selected: $selectedError,
|
11
|
+
errorState: true
|
12
|
+
)
|
13
|
+
}
|
14
|
+
```
|
@@ -0,0 +1,15 @@
|
|
1
|
+
![radio-orientation](https://github.com/powerhome/playbook/assets/92755007/f1f8dac7-a7d5-43cf-ba93-92bd624a1016)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading) {
|
5
|
+
PBRadio(
|
6
|
+
items: [
|
7
|
+
PBRadioItem("Power"),
|
8
|
+
.init("Nitro"),
|
9
|
+
.init("Google")
|
10
|
+
],
|
11
|
+
orientation: .horizontal,
|
12
|
+
selected: $selectedOrientation
|
13
|
+
)
|
14
|
+
}
|
15
|
+
```
|
@@ -0,0 +1,31 @@
|
|
1
|
+
![radio-padding](https://github.com/powerhome/playbook/assets/92755007/5cb123fb-791b-43f7-a57e-336f93c1bb3a)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading) {
|
5
|
+
PBRadio(
|
6
|
+
items: [
|
7
|
+
PBRadioItem("Small")
|
8
|
+
],
|
9
|
+
orientation: .vertical,
|
10
|
+
padding: Spacing.small,
|
11
|
+
selected: $selectedPadding
|
12
|
+
)
|
13
|
+
PBRadio(
|
14
|
+
items: [
|
15
|
+
PBRadioItem("Medium")
|
16
|
+
],
|
17
|
+
orientation: .vertical,
|
18
|
+
padding: Spacing.medium,
|
19
|
+
selected: $selectedPadding
|
20
|
+
)
|
21
|
+
PBRadio(
|
22
|
+
items: [
|
23
|
+
PBRadioItem("Large")
|
24
|
+
],
|
25
|
+
orientation: .vertical,
|
26
|
+
padding: Spacing.large,
|
27
|
+
selected: $selectedPadding
|
28
|
+
)
|
29
|
+
}
|
30
|
+
|
31
|
+
```
|
@@ -0,0 +1,10 @@
|
|
1
|
+
### Props
|
2
|
+
| Name | Type | Description | Default | Values |
|
3
|
+
| --- | ----------- | --------- | --------- | --------- |
|
4
|
+
| **items** | `PBRadioItem` | Specifies the value of the Radio buttons | | |
|
5
|
+
| **orientation** | `Orientation` | Changes between stacked or inline Radio items | `.vertical` | |
|
6
|
+
| **textAlignment** | `Orientation` | Changes lable position | `.horizontal` | |
|
7
|
+
| **spacing** | `CGFloat` | Applies padding around Radio and lable | `Spacing.xSmall` | `Spacing.none` `Spacing.xxSmall` `Spacing.xSmall` `Spacing.small` `Spacing.medium` `Spacing.large` `Spacing.xLarge` |
|
8
|
+
| **padding** | `CGFloat` | Applies padding between Radio and lable | `Spacing.xSmall` | `Spacing.none` `Spacing.xxSmall` `Spacing.xSmall` `Spacing.small` `Spacing.medium` `Spacing.large` `Spacing.xLarge` |
|
9
|
+
| **errorState** | `Bool` | Changes Radio to error styling | | |
|
10
|
+
| **selected** | `PBRadioItem?` | Sets selected Radio item | | |
|
@@ -0,0 +1,36 @@
|
|
1
|
+
![radio-spacing](https://github.com/powerhome/playbook/assets/92755007/58d1bf02-0c79-4526-9e5c-ba2f631d1dfe)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
HStack(alignment: .top) {
|
5
|
+
PBRadio(
|
6
|
+
items: [
|
7
|
+
PBRadioItem("Small"),
|
8
|
+
.init("Small Spacing"),
|
9
|
+
.init("Small Power")
|
10
|
+
],
|
11
|
+
orientation: .vertical,
|
12
|
+
spacing: Spacing.small,
|
13
|
+
selected: $selectedSpacing
|
14
|
+
)
|
15
|
+
PBRadio(
|
16
|
+
items: [
|
17
|
+
PBRadioItem("Medium"),
|
18
|
+
.init("Medium Spacing"),
|
19
|
+
.init("Medium Power")
|
20
|
+
],
|
21
|
+
orientation: .vertical,
|
22
|
+
spacing: Spacing.medium,
|
23
|
+
selected: $selectedSpacing
|
24
|
+
)
|
25
|
+
PBRadio(
|
26
|
+
items: [
|
27
|
+
PBRadioItem("Large"),
|
28
|
+
.init("Large Spacing"),
|
29
|
+
.init("Large Power")
|
30
|
+
],
|
31
|
+
orientation: .vertical,
|
32
|
+
spacing: Spacing.large,
|
33
|
+
selected: $selectedSpacing
|
34
|
+
)
|
35
|
+
}
|
36
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
![radio-subtitle](https://github.com/powerhome/playbook/assets/92755007/1244f4d4-0e87-4b5a-9b20-ac2223866321)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading) {
|
5
|
+
PBRadio(
|
6
|
+
items: [
|
7
|
+
PBRadioItem("Power", subtitle: "subtitle")
|
8
|
+
],
|
9
|
+
selected: $selectedSubtitle
|
10
|
+
)
|
11
|
+
}
|
12
|
+
|
13
|
+
```
|
@@ -12,3 +12,14 @@ examples:
|
|
12
12
|
- radio_custom: Custom
|
13
13
|
- radio_error: With Error
|
14
14
|
- radio_alignment: Alignment
|
15
|
+
|
16
|
+
swift:
|
17
|
+
- radio_default_swift: Default
|
18
|
+
- radio_custom_swift: Custom
|
19
|
+
- radio_error_swift: With Error
|
20
|
+
- radio_orientation_swift: Orientation
|
21
|
+
- radio_alignment_swift: Alignment
|
22
|
+
- radio_spacing_swift: Spacing
|
23
|
+
- radio_padding_swift: Padding
|
24
|
+
- radio_subtitle_swift: Subtitle
|
25
|
+
- radio_props_swift: ""
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%= pb_rails("select", props: {
|
2
|
+
data: { options: "data_attribute" },
|
3
|
+
label: "Favorite Food",
|
4
|
+
name: "food",
|
5
|
+
options: [
|
6
|
+
{
|
7
|
+
value: "1",
|
8
|
+
value_text: "Burgers",
|
9
|
+
},
|
10
|
+
{
|
11
|
+
value: "2",
|
12
|
+
selected: true,
|
13
|
+
value_text: "Pizza",
|
14
|
+
},
|
15
|
+
{
|
16
|
+
value: "3",
|
17
|
+
value_text: "Tacos",
|
18
|
+
},
|
19
|
+
{
|
20
|
+
value: "4",
|
21
|
+
value_text: "BBQ",
|
22
|
+
},
|
23
|
+
]
|
24
|
+
}) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Inspect the element and notice the data-attribute being added to the `<select>` element
|
@@ -1,5 +1,4 @@
|
|
1
1
|
<%= content_tag(:div,
|
2
|
-
data: object.data,
|
3
2
|
aria: object.aria,
|
4
3
|
class: object.classnames) do %>
|
5
4
|
<% if object.label %>
|
@@ -24,6 +23,7 @@
|
|
24
23
|
disabled: object.disabled,
|
25
24
|
required: object.required,
|
26
25
|
multiple: object.multiple,
|
26
|
+
data: object.data,
|
27
27
|
onchange: object.onchange,
|
28
28
|
include_blank: object.include_blank,
|
29
29
|
)
|