playbook_ui 12.37.0 → 12.38.0.pre.alpha.PLAY966collapsiblenav41082

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +6 -0
  3. data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +3 -3
  4. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +10 -9
  5. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_color.jsx +2 -2
  6. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.jsx +2 -2
  7. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +4 -8
  8. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.md +1 -1
  9. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_size.jsx +5 -5
  10. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.jsx +75 -0
  11. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.md +3 -0
  12. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +7 -6
  13. data/app/pb_kits/playbook/pb_collapsible/docs/index.js +2 -1
  14. data/app/pb_kits/playbook/pb_date/_date.tsx +7 -8
  15. data/app/pb_kits/playbook/pb_date/docs/_date_alignment.jsx +2 -2
  16. data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +29 -5
  17. data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +2 -2
  18. data/app/pb_kits/playbook/pb_date/docs/_date_variants.jsx +5 -5
  19. data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +45 -31
  20. data/app/pb_kits/playbook/pb_date_range_stacked/_date_range_stacked.tsx +5 -3
  21. data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +24 -21
  22. data/app/pb_kits/playbook/pb_date_time/_date_time.tsx +1 -1
  23. data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +1 -1
  24. data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.tsx +2 -2
  25. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.test.js +1 -1
  26. data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.tsx +6 -8
  27. data/app/pb_kits/playbook/pb_kit/dateTime.ts +146 -63
  28. data/app/pb_kits/playbook/pb_label_value/_label_value.tsx +52 -31
  29. data/app/pb_kits/playbook/pb_message/_message.tsx +24 -24
  30. data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +280 -17
  31. data/app/pb_kits/playbook/pb_nav/_horizontal_nav.scss +6 -0
  32. data/app/pb_kits/playbook/pb_nav/_item.tsx +75 -24
  33. data/app/pb_kits/playbook/pb_nav/_mixins.scss +5 -0
  34. data/app/pb_kits/playbook/pb_nav/_nav.tsx +18 -1
  35. data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +6 -7
  36. data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
  37. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +85 -58
  38. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.md +1 -0
  39. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.jsx +58 -0
  40. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.md +1 -0
  41. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.html.erb +23 -0
  42. data/app/pb_kits/playbook/pb_nav/docs/{_collapsible_nav_custom_icons.jsx → _collapsible_nav_emphasize.jsx} +14 -5
  43. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.md +1 -0
  44. data/app/pb_kits/playbook/pb_nav/docs/example.yml +5 -3
  45. data/app/pb_kits/playbook/pb_nav/docs/index.js +2 -1
  46. data/app/pb_kits/playbook/pb_nav/item.html.erb +5 -4
  47. data/app/pb_kits/playbook/pb_nav/item.rb +29 -3
  48. data/app/pb_kits/playbook/pb_time/_time.tsx +9 -11
  49. data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +46 -49
  50. data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.tsx +4 -6
  51. data/app/pb_kits/playbook/pb_timestamp/_timestamp.tsx +11 -11
  52. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +8 -11
  53. data/dist/playbook-rails.js +7 -7
  54. data/lib/playbook/version.rb +2 -2
  55. metadata +16 -9
  56. data/app/pb_kits/playbook/pb_logistic/_logistic.jsx +0 -120
@@ -1,63 +1,90 @@
1
- import React from "react"
2
- import { Nav, NavItem, useCollapsible } from "../.."
1
+ import React from "react";
2
+ import { Nav, NavItem } from '../..'
3
3
 
4
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
-
25
5
  return (
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
- }
6
+ <Nav>
7
+ <NavItem
8
+ active
9
+ collapsible
10
+ collapsibleTrail
11
+ fontWeight="bolder"
12
+ iconLeft="city"
13
+ iconRight={["plus", "minus"]}
14
+ link="#"
15
+ text="Overview"
16
+ {...props}
17
+ >
18
+ <NavItem
19
+ link="#"
20
+ text="City"
21
+ {...props}
22
+ />
23
+ <NavItem
24
+ link="#"
25
+ text="People"
26
+ {...props}
27
+ />
28
+ <NavItem
29
+ link="#"
30
+ text="Business"
31
+ {...props}
32
+ />
33
+ </NavItem>
34
+ <NavItem
35
+ collapsible
36
+ collapsibleTrail
37
+ fontWeight="bolder"
38
+ iconLeft="theater-masks"
39
+ iconRight={["plus", "minus"]}
40
+ link="#"
41
+ text="Albums"
42
+ {...props}
43
+ >
44
+ <NavItem
45
+ link="#"
46
+ text="Entertainment"
47
+ {...props}
48
+ />
49
+ <NavItem
50
+ link="#"
51
+ text="Food"
52
+ {...props}
53
+ />
54
+ <NavItem
55
+ link="#"
56
+ text="Style"
57
+ {...props}
58
+ />
59
+ </NavItem>
60
+ <NavItem
61
+ collapsible
62
+ collapsibleTrail
63
+ fontWeight="bolder"
64
+ iconLeft="city"
65
+ iconRight={["plus", "minus"]}
66
+ link="#"
67
+ text="Similar Artists"
68
+ {...props}
69
+ >
70
+ <NavItem
71
+ link="#"
72
+ text="City"
73
+ {...props}
74
+ />
75
+ <NavItem
76
+ link="#"
77
+ text="People"
78
+ {...props}
79
+ />
80
+ <NavItem
81
+ link="#"
82
+ text="Business"
83
+ {...props}
84
+ />
85
+ </NavItem>
86
+ </Nav>
87
+ );
88
+ };
62
89
 
63
90
  export default CollapsibleNav
@@ -0,0 +1 @@
1
+ The `collapsible` prop allows users to create a nested, collapsible nav. Pass `collapsible` to NavItem and nest as many more NavItems as needed as children for that NavItem to see this in action.
@@ -0,0 +1,58 @@
1
+ import React from "react"
2
+ import { Nav, NavItem, useCollapsible } from "../.."
3
+
4
+ const CollapsibleNavCustom = (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
+ return (
20
+ <>
21
+ <Nav variant='subtle'>
22
+ {navItems.map((text, index) => {
23
+ const [collapsed] = collapsibles[index]
24
+ return (
25
+ <NavItem
26
+ collapsed={collapsed}
27
+ collapsible
28
+ collapsibleTrail
29
+ fontWeight="bolder"
30
+ iconLeft="chevron-down"
31
+ id={`collapsible-nav-item-${index + 1}`}
32
+ key={index}
33
+ link="#"
34
+ onClick={() => handleMainClick(index)}
35
+ text={text}
36
+ {...props}
37
+ >
38
+ <NavItem link="#"
39
+ text="City"
40
+ {...props}
41
+ />
42
+ <NavItem link="#"
43
+ text="People"
44
+ {...props}
45
+ />
46
+ <NavItem link="#"
47
+ text="Business"
48
+ {...props}
49
+ />
50
+ </NavItem>
51
+ );
52
+ })}
53
+ </Nav>
54
+ </>
55
+ )
56
+ }
57
+
58
+ export default CollapsibleNavCustom
@@ -0,0 +1 @@
1
+ The collapsible nav kit uses our Collapsible kit under the hood and as such the `useCollapsible` hook can be used to achieve custom toggling of the collapsible nav. To do this, you must import and declare the `useCollapsible` hook and pass it's state to the `collapsed` prop. See our code example below to see how this can be done.
@@ -0,0 +1,23 @@
1
+ <%= pb_rails("nav", props: { variant: "subtle" }) do %>
2
+ <%= pb_rails("nav/item", props: { text: "Overview", link: "#", font_weight:"bolder", font_size:"small", collapsible: true, icon_left:"city", collapsible_trail: true }) do %>
3
+ <%= pb_rails("nav", props: { variant: "subtle" }) do %>
4
+ <%= pb_rails("nav/item", props: { text: "City", link: "#" }) %>
5
+ <%= pb_rails("nav/item", props: { text: "People", link: "#" }) %>
6
+ <%= pb_rails("nav/item", props: { text: "Business", link: "#" }) %>
7
+ <% end %>
8
+ <% end %>
9
+ <%= pb_rails("nav/item", props: { text: "Albums", link: "#", font_weight:"bolder", font_size:"small", collapsible: true, icon_left: "theater-masks", collapsible_trail:true }) do %>
10
+ <%= pb_rails("nav", props: { variant: "subtle" }) do %>
11
+ <%= pb_rails("nav/item", props: { text: "Entertainment", link: "#" }) %>
12
+ <%= pb_rails("nav/item", props: { text: "Food", link: "#" }) %>
13
+ <%= pb_rails("nav/item", props: { text: "Style", link: "#" }) %>
14
+ <% end %>
15
+ <% end %>
16
+ <%= pb_rails("nav/item", props: { text: "Similar Artists", link: "#", font_weight:"bolder", font_size:"small", collapsible: true, icon_left: "city", collapsible_trail:true }) do %>
17
+ <%= pb_rails("nav", props: { variant: "subtle" }) do %>
18
+ <%= pb_rails("nav/item", props: { text: "City", link: "#" }) %>
19
+ <%= pb_rails("nav/item", props: { text: "People", link: "#" }) %>
20
+ <%= pb_rails("nav/item", props: { text: "Business", link: "#" }) %>
21
+ <% end %>
22
+ <% end %>
23
+ <% end %>
@@ -1,11 +1,15 @@
1
1
  import React from "react";
2
2
  import { Nav, NavItem } from '../..'
3
3
 
4
- const CollapsibleNavCustomIcons = (props) => {
4
+ const CollapsibleNavEmphasize = (props) => {
5
5
  return (
6
- <Nav variant="subtle">
6
+ <Nav variant="bold">
7
7
  <NavItem
8
- collapsible
8
+ active
9
+ collapsible
10
+ collapsibleTrail
11
+ fontSize="small"
12
+ fontWeight="bolder"
9
13
  iconLeft="city"
10
14
  iconRight={["plus", "minus"]}
11
15
  link="#"
@@ -29,8 +33,10 @@ const CollapsibleNavCustomIcons = (props) => {
29
33
  />
30
34
  </NavItem>
31
35
  <NavItem
32
- active
33
36
  collapsible
37
+ collapsibleTrail
38
+ fontSize="small"
39
+ fontWeight="bolder"
34
40
  iconLeft="theater-masks"
35
41
  iconRight={["plus", "minus"]}
36
42
  link="#"
@@ -55,6 +61,9 @@ const CollapsibleNavCustomIcons = (props) => {
55
61
  </NavItem>
56
62
  <NavItem
57
63
  collapsible
64
+ collapsibleTrail
65
+ fontSize="small"
66
+ fontWeight="bolder"
58
67
  iconLeft="city"
59
68
  iconRight={["plus", "minus"]}
60
69
  link="#"
@@ -81,4 +90,4 @@ const CollapsibleNavCustomIcons = (props) => {
81
90
  );
82
91
  };
83
92
 
84
- export default CollapsibleNavCustomIcons;
93
+ export default CollapsibleNavEmphasize;
@@ -0,0 +1 @@
1
+ The ` navBold` prop can be passed to NavItem
@@ -7,7 +7,8 @@ examples:
7
7
  - borderless_nav: No Borders
8
8
  - subtle_nav: Subtle Variant
9
9
  - subtle_with_icons_nav: Subtle With Icons
10
- # - collapsible_nav: Subtle With Collapsible
10
+ - collapsible_nav: Collapsible Nav
11
+ - collapsible_nav_emphasize: Collapsible Nav with Emphasize Styling
11
12
  - subtle_no_highlight_nav: Subtle No Highlight
12
13
  - bold_vertical_nav: Bold Variant
13
14
  - horizontal_nav: Horizontal Nav
@@ -25,8 +26,9 @@ examples:
25
26
  - borderless_nav: No Borders
26
27
  - subtle_nav: Subtle Variant
27
28
  - subtle_with_icons_nav: Subtle With Icons
28
- # - collapsible_nav: Subtle With Collapsible
29
- # - collapsible_nav_custom_icons: Subtle With Collapsible (No custom toggling)
29
+ - collapsible_nav: Collapsible Nav
30
+ - collapsible_nav_emphasize: Collapsible Nav with Emphasize Styling
31
+ - collapsible_nav_custom: Collapsible Nav With Custom Toggling
30
32
  - subtle_no_highlight_nav: Subtle No Highlight
31
33
  - bold_vertical_nav: Bold Variant
32
34
  - horizontal_nav: Horizontal Nav
@@ -14,4 +14,5 @@ export { default as NewTab } from './_new_tab.jsx'
14
14
  export { default as BoldHorizontalNav } from './_bold_horizontal_nav.jsx'
15
15
  export { default as BoldVerticalNav } from './_bold_vertical_nav.jsx'
16
16
  export { default as CollapsibleNav } from './_collapsible_nav.jsx'
17
- export { default as CollapsibleNavCustomIcons } from './_collapsible_nav_custom_icons.jsx'
17
+ export { default as CollapsibleNavCustom } from './_collapsible_nav_custom.jsx'
18
+ export { default as CollapsibleNavEmphasize } from "./_collapsible_nav_emphasize.jsx"
@@ -2,19 +2,20 @@
2
2
  aria: object.aria,
3
3
  class: object.classname,
4
4
  data: object.data,
5
+ dark: object.dark,
5
6
  id: object.id) do %>
6
7
  <% if object.collapsible %>
7
8
  <%= pb_rails("collapsible", props: { name: "collapsible-nav-example" }) do %>
8
- <%= pb_rails("collapsible/collapsible_main", props: { name: "default-collapsible-nav", icon: object.collapsible_icons, size: "xs" }) do %>
9
+ <%= pb_rails("collapsible/collapsible_main", props: { name: "default-collapsible-nav", icon: object.collapsible_icons, size: "xs", dark: object.dark }) do %>
9
10
  <%= content_tag(object.tag,
10
11
  object.link ? object.link_options : object.options) do %>
11
12
  <% if object.image_url %>
12
- <%= pb_rails("image", props: { url: object.image_url, classname: "pb_nav_img_wrapper" }) %>
13
+ <%= pb_rails("image", props: { url: object.image_url, classname: "pb_nav_img_wrapper_collapsible" }) %>
13
14
  <% end %>
14
15
  <% if object.icon_left %>
15
- <%= pb_rails("icon", props: { icon: object.icon_left, classname: "pb_nav_list_item_icon_left", fixed_width: true}) %>
16
+ <%= pb_rails("icon", props: { icon: object.icon_left, classname: "pb_nav_list_item_icon_left_collapsible", fixed_width: true}) %>
16
17
  <% end %>
17
- <span class="pb_nav_list_item_text">
18
+ <span class="pb_nav_list_item_text_collapsible">
18
19
  <%= object.text %>
19
20
  </span>
20
21
  <% end %>
@@ -4,9 +4,16 @@ module Playbook
4
4
  module PbNav
5
5
  class Item < Playbook::KitBase
6
6
  prop :active, type: Playbook::Props::Boolean, default: false
7
+ prop :font_size, type: Playbook::Props::Enum,
8
+ values: %w[normal small],
9
+ default: "normal"
10
+ prop :font_weight, type: Playbook::Props::Enum,
11
+ values: %w[bold regular bolder],
12
+ default: "regular"
7
13
  prop :collapsible, type: Playbook::Props::Boolean, default: false
8
14
  prop :link
9
15
  prop :text
16
+ prop :collapsible_trail, type: Playbook::Props::Boolean, default: false
10
17
  prop :icon_left
11
18
  prop :icon_right
12
19
  prop :image_url
@@ -15,9 +22,9 @@ module Playbook
15
22
  default: "_self"
16
23
  def classname
17
24
  if collapsible
18
- "pb_collapsible_nav_item #{generate_classname('pb_nav_list_kit_item', active_class)}"
25
+ "#{generate_classname('pb_nav_list_kit_item', active_class)} #{generate_classname('pb_collapsible_nav_item', active_class, collapsible_trail_class)} #{font_size_class} #{font_weight_class}"
19
26
  else
20
- generate_classname("pb_nav_list_kit_item", active_class)
27
+ "#{generate_classname('pb_nav_list_kit_item', active_class)} #{font_size_class} #{font_weight_class}"
21
28
  end
22
29
  end
23
30
 
@@ -27,7 +34,7 @@ module Playbook
27
34
 
28
35
  def options
29
36
  {
30
- class: "pb_nav_list_item_link",
37
+ class: collapsible ? "pb_nav_list_item_link_collapsible" : "pb_nav_list_item_link",
31
38
  }.compact
32
39
  end
33
40
 
@@ -47,6 +54,25 @@ module Playbook
47
54
  def active_class
48
55
  active ? "active" : nil
49
56
  end
57
+
58
+ def font_weight_class
59
+ case font_weight
60
+ when "bold"
61
+ "font_bold"
62
+ when "bolder"
63
+ "font_bolder"
64
+ else
65
+ "font_regular"
66
+ end
67
+ end
68
+
69
+ def collapsible_trail_class
70
+ collapsible_trail ? "collapsible_trail" : nil
71
+ end
72
+
73
+ def font_size_class
74
+ font_size === "small" ? "font_size_small" : "font_size_normal"
75
+ end
50
76
  end
51
77
  end
52
78
  end
@@ -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";
5
4
  import { buildCss } from "../utilities/props";
6
5
  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: string;
16
+ date: Date;
17
17
  dark?: boolean;
18
18
  id?: string;
19
19
  showIcon?: boolean;
@@ -41,8 +41,6 @@ const Time = (props: TimeProps) => {
41
41
  className
42
42
  );
43
43
 
44
- const dateTimestamp = new DateTime({ value: date, zone: timeZone });
45
-
46
44
  return (
47
45
  <div className={classes}>
48
46
  {showIcon && (
@@ -70,18 +68,18 @@ const Time = (props: TimeProps) => {
70
68
  )
71
69
  )}
72
70
 
73
- <time dateTime={date}>
71
+ <time dateTime={date.toString()}>
74
72
  <span>
75
73
  {unstyled
76
74
  ? (
77
75
  <>
78
76
  <span>
79
- {dateTimestamp.toTimeWithMeridian()}
77
+ {DateTime.toTimeWithMeridiem(date, timeZone)}
80
78
  </span>
81
79
  {" "}
82
80
  {showTimezone && (
83
81
  <span>
84
- {dateTimestamp.toTimezone()}
82
+ {DateTime.toTimeZone(date, timeZone)}
85
83
  </span>
86
84
  )}
87
85
  </>
@@ -92,13 +90,13 @@ const Time = (props: TimeProps) => {
92
90
  <Body
93
91
  className="pb_time"
94
92
  tag="span"
95
- text={dateTimestamp.toTimeWithMeridian()}
93
+ text={DateTime.toTimeWithMeridiem(date, timeZone)}
96
94
  />{" "}
97
95
  {showTimezone && (
98
96
  <Body
99
97
  color="light"
100
98
  tag="span"
101
- text={dateTimestamp.toTimezone()}
99
+ text={DateTime.toTimeZone(date, timeZone)}
102
100
  />
103
101
  )}
104
102
  </>
@@ -108,13 +106,13 @@ const Time = (props: TimeProps) => {
108
106
  <Caption
109
107
  color="light"
110
108
  tag="span"
111
- text={dateTimestamp.toTimeWithMeridian()}
109
+ text={DateTime.toTimeWithMeridiem(date, timeZone)}
112
110
  />{" "}
113
111
  {showTimezone && (
114
112
  <Caption
115
113
  color="light"
116
114
  tag="span"
117
- text={dateTimestamp.toTimezone()}
115
+ text={DateTime.toTimeZone(date, timeZone)}
118
116
  />
119
117
  )}
120
118
  </>