playbook_ui 12.36.0.pre.alpha.PLAY936momentjs1058 → 12.36.0.pre.alpha.PLAY942collapsiblenav21035

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/index.js +2 -1
  3. data/app/pb_kits/playbook/pb_badge/docs/example.yml +0 -7
  4. data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +15 -13
  5. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +24 -8
  6. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -1
  7. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +15 -4
  8. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +2 -2
  9. data/app/pb_kits/playbook/pb_collapsible/useCollapsible.tsx +14 -0
  10. data/app/pb_kits/playbook/pb_date/_date.tsx +8 -7
  11. data/app/pb_kits/playbook/pb_date/docs/_date_alignment.jsx +2 -2
  12. data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +5 -29
  13. data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +2 -2
  14. data/app/pb_kits/playbook/pb_date/docs/_date_variants.jsx +5 -5
  15. data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +31 -45
  16. data/app/pb_kits/playbook/pb_date_range_stacked/_date_range_stacked.tsx +3 -5
  17. data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +21 -24
  18. data/app/pb_kits/playbook/pb_date_time/_date_time.tsx +1 -1
  19. data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +1 -1
  20. data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.tsx +2 -2
  21. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.test.js +1 -1
  22. data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.tsx +8 -6
  23. data/app/pb_kits/playbook/pb_kit/dateTime.ts +63 -146
  24. data/app/pb_kits/playbook/pb_label_value/_label_value.tsx +31 -52
  25. data/app/pb_kits/playbook/pb_logistic/_logistic.jsx +120 -0
  26. data/app/pb_kits/playbook/pb_message/_message.tsx +24 -24
  27. data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +22 -1
  28. data/app/pb_kits/playbook/pb_nav/_item.tsx +26 -2
  29. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +59 -79
  30. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom_icons.jsx +4 -6
  31. data/app/pb_kits/playbook/pb_nav/docs/example.yml +2 -2
  32. data/app/pb_kits/playbook/pb_nav/item.rb +5 -1
  33. data/app/pb_kits/playbook/pb_pill/docs/example.yml +0 -5
  34. data/app/pb_kits/playbook/pb_radio/docs/example.yml +0 -11
  35. data/app/pb_kits/playbook/pb_time/_time.tsx +11 -9
  36. data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +49 -46
  37. data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.tsx +6 -4
  38. data/app/pb_kits/playbook/pb_timestamp/_timestamp.tsx +11 -11
  39. data/app/pb_kits/playbook/pb_timestamp/docs/example.yml +0 -8
  40. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +11 -8
  41. data/dist/playbook-rails.js +7 -7
  42. data/lib/playbook/version.rb +1 -1
  43. metadata +4 -25
  44. data/app/pb_kits/playbook/pb_badge/docs/_badge_colors_swift.md +0 -33
  45. data/app/pb_kits/playbook/pb_badge/docs/_badge_default_swift.md +0 -9
  46. data/app/pb_kits/playbook/pb_badge/docs/_badge_notification_swift.md +0 -9
  47. data/app/pb_kits/playbook/pb_badge/docs/_badge_props_swift.md +0 -6
  48. data/app/pb_kits/playbook/pb_badge/docs/_badge_rounded_swift.md +0 -9
  49. data/app/pb_kits/playbook/pb_pill/docs/_pill_default_swift.md +0 -5
  50. data/app/pb_kits/playbook/pb_pill/docs/_pill_props_swift.md +0 -5
  51. data/app/pb_kits/playbook/pb_pill/docs/_pill_variants_swift.md +0 -10
  52. data/app/pb_kits/playbook/pb_radio/docs/_radio_alignment_swift.md +0 -16
  53. data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_swift.md +0 -18
  54. data/app/pb_kits/playbook/pb_radio/docs/_radio_default_swift.md +0 -15
  55. data/app/pb_kits/playbook/pb_radio/docs/_radio_error_swift.md +0 -14
  56. data/app/pb_kits/playbook/pb_radio/docs/_radio_orientation_swift.md +0 -15
  57. data/app/pb_kits/playbook/pb_radio/docs/_radio_padding_swift.md +0 -31
  58. data/app/pb_kits/playbook/pb_radio/docs/_radio_props_swift.md +0 -10
  59. data/app/pb_kits/playbook/pb_radio/docs/_radio_spacing_swift.md +0 -36
  60. data/app/pb_kits/playbook/pb_radio/docs/_radio_subtitle_swift.md +0 -13
  61. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_align_swift.md +0 -45
  62. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_default_swift.md +0 -26
  63. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed_swift.md +0 -25
  64. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_props_swift.md +0 -10
  65. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_timezones_swift.md +0 -67
  66. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_updated_swift.md +0 -19
@@ -25,7 +25,7 @@ type MessageProps = {
25
25
  label?: string,
26
26
  message: string,
27
27
  timestamp?: string,
28
- timestampObject?: Date,
28
+ timestampObject?: string,
29
29
  timezone?: string,
30
30
  alignTimestamp?: string,
31
31
  }
@@ -62,50 +62,50 @@ const Message = (props: MessageProps) => {
62
62
 
63
63
  return (
64
64
  <div
65
- {...ariaProps}
66
- {...dataProps}
67
- className={classes}
68
- id={id}
65
+ {...ariaProps}
66
+ {...dataProps}
67
+ className={classes}
68
+ id={id}
69
69
  >
70
70
  {shouldDisplayAvatar &&
71
71
  <Avatar
72
- imageUrl={avatarUrl}
73
- name={avatarName}
74
- size="xs"
75
- status={avatarStatus}
72
+ imageUrl={avatarUrl}
73
+ name={avatarName}
74
+ size="xs"
75
+ status={avatarStatus}
76
76
  />
77
77
  }
78
78
  <div className="content_wrapper">
79
79
  <Flex
80
- justify={alignTimestamp === 'left' ? 'none' : 'between'}
81
- orientation="row"
80
+ justify={alignTimestamp === 'left' ? 'none' : 'between'}
81
+ orientation="row"
82
82
  >
83
83
  {label &&
84
84
  <Title
85
- className="message_title"
86
- size={4}
87
- text={label}
85
+ className="message_title"
86
+ size={4}
87
+ text={label}
88
88
  />
89
89
  }
90
90
  <Timestamp
91
- className={`pull-${alignTimestamp} ${timestampObject ? 'message_humanized_time' : null}`}
92
- text={timestamp}
93
- timestamp={''}
94
- timezone={timezone}
91
+ className={`pull-${alignTimestamp} ${timestampObject ? 'message_humanized_time' : null}`}
92
+ text={timestamp}
93
+ timestamp={''}
94
+ timezone={timezone}
95
95
  />
96
96
  {timestampObject &&
97
97
  <Timestamp
98
- className={`pull-${alignTimestamp} message_timestamp`}
99
- text={''}
100
- timestamp={timestampObject}
101
- timezone={timezone}
98
+ className={`pull-${alignTimestamp} message_timestamp`}
99
+ text={''}
100
+ timestamp={timestampObject}
101
+ timezone={timezone}
102
102
  />
103
103
  }
104
104
  </Flex>
105
105
  {message &&
106
106
  <Body
107
- className="pb_message_body"
108
- text={message}
107
+ className="pb_message_body"
108
+ text={message}
109
109
  />
110
110
  }
111
111
  {children}
@@ -1,6 +1,27 @@
1
+ @import "../tokens/spacing";
2
+ @import "../tokens/colors";
3
+ @import "../tokens/border_radius";
4
+
1
5
  [class^="pb_nav_list"] {
6
+ .pb_collapsible_nav_item {
2
7
  .pb_collapsible_main_kit,
3
- .pb_collapsible_content_kit {
8
+ .pb_collapsible_content_kit,
9
+ .pb_collapsible_kit {
4
10
  padding: 0 !important;
5
11
  }
12
+
13
+ .icon_wrapper {
14
+ border-radius: $border_radius_rounded;
15
+ width: 19px;
16
+ height: 19px;
17
+ display:flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ margin-right: $space_xs;
21
+ &:hover {
22
+ background-color: rgba($primary_action, $opacity_3);
23
+
24
+ }
25
+ }
26
+ }
6
27
  }
@@ -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']} iconSize="xs">
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
- <Nav variant="subtle">
9
- <NavItem
10
- collapsible
11
- iconLeft="city"
12
- link="#"
13
- text="Overview"
14
- {...props}
15
- >
16
- <NavItem
17
- link="#"
18
- text="City"
19
- {...props}
20
- />
21
- <NavItem
22
- link="#"
23
- text="People"
24
- {...props}
25
- />
26
- <NavItem
27
- link="#"
28
- text="Business"
29
- {...props}
30
- />
31
- </NavItem>
32
- <NavItem
33
- active
34
- collapsible
35
- iconLeft="theater-masks"
36
- link="#"
37
- text="Albums"
38
- {...props}
39
- >
40
- <NavItem
41
- link="#"
42
- text="Entertainment"
43
- {...props}
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={["chevron-down", "chevron-up"]}
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={["chevron-down", "chevron-up"]}
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={["chevron-down", "chevron-up"]}
59
+ iconRight={["plus", "minus"]}
62
60
  link="#"
63
61
  text="Similar Artists"
64
62
  {...props}
@@ -25,8 +25,8 @@ examples:
25
25
  - borderless_nav: No Borders
26
26
  - subtle_nav: Subtle Variant
27
27
  - subtle_with_icons_nav: Subtle With Icons
28
- # - collapsible_nav: Subtle With Collapsible
29
- # - collapsible_nav_custom_icons: Subtle With Collapsible (Custom Toggle Icons)
28
+ - collapsible_nav: 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
- generate_classname("pb_nav_list_kit_item", active_class)
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
@@ -11,8 +11,3 @@ examples:
11
11
  - pill_default: Default
12
12
  - pill_variants: Variants
13
13
  - pill_example: Example
14
-
15
- swift:
16
- - pill_default_swift: Default
17
- - pill_variants_swift: Variants
18
- - pill_props_swift: ""
@@ -12,14 +12,3 @@ 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: ""
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import classnames from "classnames";
3
3
 
4
+ import DateTime from "../pb_kit/dateTime";
4
5
  import { buildCss } from "../utilities/props";
5
6
  import { globalProps, GlobalProps } from "../utilities/globalProps";
6
- import DateTime from '../pb_kit/dateTime';
7
7
 
8
8
  import Body from "../pb_body/_body";
9
9
  import Caption from "../pb_caption/_caption";
@@ -13,7 +13,7 @@ type TimeProps = {
13
13
  align?: "left" | "center" | "right";
14
14
  className?: string | string[];
15
15
  data?: string;
16
- date: Date;
16
+ date: string;
17
17
  dark?: boolean;
18
18
  id?: string;
19
19
  showIcon?: boolean;
@@ -41,6 +41,8 @@ const Time = (props: TimeProps) => {
41
41
  className
42
42
  );
43
43
 
44
+ const dateTimestamp = new DateTime({ value: date, zone: timeZone });
45
+
44
46
  return (
45
47
  <div className={classes}>
46
48
  {showIcon && (
@@ -68,18 +70,18 @@ const Time = (props: TimeProps) => {
68
70
  )
69
71
  )}
70
72
 
71
- <time dateTime={date.toString()}>
73
+ <time dateTime={date}>
72
74
  <span>
73
75
  {unstyled
74
76
  ? (
75
77
  <>
76
78
  <span>
77
- {DateTime.toTimeWithMeridiem(date, timeZone)}
79
+ {dateTimestamp.toTimeWithMeridian()}
78
80
  </span>
79
81
  {" "}
80
82
  {showTimezone && (
81
83
  <span>
82
- {DateTime.toTimeZone(date, timeZone)}
84
+ {dateTimestamp.toTimezone()}
83
85
  </span>
84
86
  )}
85
87
  </>
@@ -90,13 +92,13 @@ const Time = (props: TimeProps) => {
90
92
  <Body
91
93
  className="pb_time"
92
94
  tag="span"
93
- text={DateTime.toTimeWithMeridiem(date, timeZone)}
95
+ text={dateTimestamp.toTimeWithMeridian()}
94
96
  />{" "}
95
97
  {showTimezone && (
96
98
  <Body
97
99
  color="light"
98
100
  tag="span"
99
- text={DateTime.toTimeZone(date, timeZone)}
101
+ text={dateTimestamp.toTimezone()}
100
102
  />
101
103
  )}
102
104
  </>
@@ -106,13 +108,13 @@ const Time = (props: TimeProps) => {
106
108
  <Caption
107
109
  color="light"
108
110
  tag="span"
109
- text={DateTime.toTimeWithMeridiem(date, timeZone)}
111
+ text={dateTimestamp.toTimeWithMeridian()}
110
112
  />{" "}
111
113
  {showTimezone && (
112
114
  <Caption
113
115
  color="light"
114
116
  tag="span"
115
- text={DateTime.toTimeZone(date, timeZone)}
117
+ text={dateTimestamp.toTimezone()}
116
118
  />
117
119
  )}
118
120
  </>