playbook_ui 8.0.0.pre.alpha4 → 8.2.0.pre.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +8 -7
  3. data/app/pb_kits/playbook/data/menu.yml +1 -0
  4. data/app/pb_kits/playbook/index.js +1 -0
  5. data/app/pb_kits/playbook/pb_card/card_header.rb +7 -7
  6. data/app/pb_kits/playbook/pb_collapsible/_collapsible.jsx +84 -0
  7. data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +15 -0
  8. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.jsx +40 -0
  9. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.jsx +59 -0
  10. data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +7 -0
  11. data/app/pb_kits/playbook/pb_collapsible/collapsible.rb +11 -0
  12. data/app/pb_kits/playbook/pb_collapsible/collapsible.test.js +50 -0
  13. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +7 -0
  14. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.rb +17 -0
  15. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +16 -0
  16. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.rb +15 -0
  17. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.html.erb +10 -0
  18. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_default.jsx +19 -0
  19. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +9 -0
  20. data/app/pb_kits/playbook/pb_collapsible/docs/index.js +1 -0
  21. data/app/pb_kits/playbook/pb_collapsible/index.js +79 -0
  22. data/app/pb_kits/playbook/pb_dashboard/commonSettings.js +2 -2
  23. data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.js +2 -2
  24. data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.jsx +6 -2
  25. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +1 -1
  26. data/app/pb_kits/playbook/pb_docs/kit_example.rb +1 -1
  27. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +2 -2
  28. data/app/pb_kits/playbook/pb_form/form.rb +11 -2
  29. data/app/pb_kits/playbook/pb_form/form_builder.rb +1 -1
  30. data/app/pb_kits/playbook/pb_form/form_builder/action_area.html.erb +1 -1
  31. data/app/pb_kits/playbook/pb_form/form_with.html.erb +7 -14
  32. data/app/pb_kits/playbook/pb_form/form_with.rb +13 -6
  33. data/app/pb_kits/playbook/pb_nav/_item.jsx +2 -0
  34. data/app/pb_kits/playbook/pb_nav/_nav.jsx +2 -2
  35. data/app/pb_kits/playbook/pb_nav/item.html.erb +2 -2
  36. data/app/pb_kits/playbook/pb_nav/nav.html.erb +1 -1
  37. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.jsx +1 -1
  38. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.scss +5 -0
  39. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_variants.html.erb +5 -0
  40. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_variants.jsx +7 -0
  41. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_variants.md +1 -1
  42. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.rb +1 -1
  43. data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.jsx +43 -26
  44. data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.scss +18 -0
  45. data/app/pb_kits/playbook/pb_time_stacked/docs/_time_stacked_default.html.erb +18 -5
  46. data/app/pb_kits/playbook/pb_time_stacked/docs/_time_stacked_default.jsx +10 -5
  47. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +7 -3
  48. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.rb +8 -30
  49. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.test.js +33 -0
  50. data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +4 -3
  51. data/app/pb_kits/playbook/plugins/pb_chart.js +1 -1
  52. data/app/pb_kits/playbook/tokens/_border_radius.scss +0 -10
  53. data/app/pb_kits/playbook/tokens/_colors.scss +0 -25
  54. data/app/pb_kits/playbook/tokens/_line_height.scss +0 -9
  55. data/app/pb_kits/playbook/tokens/_opacity.scss +0 -9
  56. data/app/pb_kits/playbook/tokens/_positioning.scss +0 -9
  57. data/app/pb_kits/playbook/tokens/_screen_sizes.scss +0 -9
  58. data/app/pb_kits/playbook/tokens/_shadows.scss +0 -9
  59. data/app/pb_kits/playbook/tokens/_spacing.scss +0 -10
  60. data/app/pb_kits/playbook/tokens/_typography.scss +0 -25
  61. data/app/pb_kits/playbook/tokens/exports/_border_radius.scss +10 -0
  62. data/app/pb_kits/playbook/tokens/exports/_colors.scss +26 -0
  63. data/app/pb_kits/playbook/tokens/exports/_line_height.scss +10 -0
  64. data/app/pb_kits/playbook/tokens/exports/_opacity.scss +10 -0
  65. data/app/pb_kits/playbook/tokens/exports/_positioning.scss +10 -0
  66. data/app/pb_kits/playbook/tokens/exports/_screen_sizes.scss +10 -0
  67. data/app/pb_kits/playbook/tokens/exports/_shadows.scss +10 -0
  68. data/app/pb_kits/playbook/tokens/exports/_spacing.scss +10 -0
  69. data/app/pb_kits/playbook/tokens/exports/_typography.scss +24 -0
  70. data/app/pb_kits/playbook/vendor.js +3 -0
  71. data/dist/reset.css +1 -0
  72. data/lib/playbook/pb_doc_helper.rb +4 -0
  73. data/lib/playbook/props/base.rb +1 -1
  74. data/lib/playbook/version.rb +1 -1
  75. metadata +39 -14
  76. data/app/pb_kits/playbook/pb_form/form.html.erb +0 -7
@@ -0,0 +1,9 @@
1
+ examples:
2
+
3
+ rails:
4
+ - collapsible_default: Light
5
+
6
+ react:
7
+ - collapsible_default: Light
8
+
9
+
@@ -0,0 +1 @@
1
+ export { default as CollapsibleDefault } from './_collapsible_default.jsx'
@@ -0,0 +1,79 @@
1
+ import PbEnhancedElement from '../pb_enhanced_element'
2
+
3
+ const MAIN_SELECTOR = '[data-collapsible-main]'
4
+ const CONTENT_SELECTOR = '[data-collapsible-content]'
5
+ const DOWN_ARROW_SELECTOR = '.fa-chevron-down'
6
+ const UP_ARROW_SELECTOR = '.fa-chevron-up'
7
+
8
+ export default class PbCollapsible extends PbEnhancedElement {
9
+ static get selector() {
10
+ return MAIN_SELECTOR
11
+ }
12
+
13
+ connect() {
14
+ this.element.addEventListener('click', () => {
15
+ this.toggleElement(this.target)
16
+ })
17
+ this.displayDownArrow()
18
+ }
19
+
20
+ get target() {
21
+ return this.element.parentNode.querySelector(CONTENT_SELECTOR)
22
+ }
23
+
24
+ showElement(elem) {
25
+ // Get the natural height of the element
26
+ const getHeight = () => {
27
+ elem.style.display = 'block'
28
+ const height = elem.scrollHeight + 'px' // Get it's height
29
+ elem.style.display = '' // Hide it again
30
+ return height
31
+ }
32
+
33
+ const height = getHeight()
34
+ elem.classList.add('is-visible')
35
+ elem.style.height = height // Update the max-height
36
+
37
+ // Once the transition is complete, remove the inline max-height so the content can scale responsively
38
+ window.setTimeout(() => {
39
+ elem.style.height = ''
40
+ }, 300)
41
+ }
42
+
43
+ hideElement(elem) {
44
+ // Give the element a height to change from
45
+ elem.style.height = elem.scrollHeight + 'px'
46
+
47
+ window.setTimeout(() => {
48
+ elem.style.height = '0'
49
+ elem.style.paddingTop = '0'
50
+ elem.style.paddingBottom = '0'
51
+ }, 1)
52
+
53
+ // When the transition is complete, hide it
54
+ window.setTimeout(() => {
55
+ elem.classList.remove('is-visible')
56
+ }, 300)
57
+ }
58
+
59
+ toggleElement(elem) {
60
+ if (elem.classList.contains('is-visible')) {
61
+ this.hideElement(elem)
62
+ this.displayDownArrow()
63
+ return
64
+ }
65
+ // Otherwise, show it
66
+ this.showElement(elem)
67
+ this.displayUpArrow()
68
+ }
69
+
70
+ displayDownArrow() {
71
+ this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = 'inline-block'
72
+ this.element.querySelector(UP_ARROW_SELECTOR).style.display = 'none'
73
+ }
74
+
75
+ displayUpArrow() {
76
+ this.element.querySelector(UP_ARROW_SELECTOR).style.display = 'inline-block'
77
+ this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = 'none'
78
+ }
79
+ }
@@ -1,5 +1,5 @@
1
- import colors from '../tokens/_colors.scss'
2
- import typography from '../tokens/_typography.scss'
1
+ import colors from '../tokens/exports/_colors.scss'
2
+ import typography from '../tokens/exports/_typography.scss'
3
3
 
4
4
  const dataColors = [
5
5
  colors.data_1,
@@ -1,5 +1,5 @@
1
- import colors from '../tokens/_colors.scss'
2
- import typography from '../tokens/_typography.scss'
1
+ import colors from '../tokens/exports/_colors.scss'
2
+ import typography from '../tokens/exports/_typography.scss'
3
3
 
4
4
  import Highcharts from 'highcharts'
5
5
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  import React from 'react'
4
4
  import { DateStacked, Flex, FlexItem, TimeStacked } from '../'
5
+ import { buildDataProps } from '../utilities/props'
5
6
  import { globalProps } from '../utilities/globalProps.js'
6
7
 
7
8
  type DateTimeStackedProps = {
@@ -12,12 +13,15 @@ type DateTimeStackedProps = {
12
13
  }
13
14
 
14
15
  const DateTimeStacked = (props: DateTimeStackedProps) => {
15
- const { date, dark } = props
16
+ const { date, data = {}, dark } = props,
17
+ dataProps = buildDataProps(data)
18
+
16
19
  return (
17
20
  <Flex
18
21
  className={globalProps(props)}
19
22
  orientation="row"
20
23
  vertical="center"
24
+ {...dataProps}
21
25
  >
22
26
  <FlexItem>
23
27
  <DateStacked
@@ -32,8 +36,8 @@ const DateTimeStacked = (props: DateTimeStackedProps) => {
32
36
  <TimeStacked
33
37
  className="pb_date_time_stacked_kit"
34
38
  dark={dark}
35
- date={date}
36
39
  tag="caption"
40
+ time={date}
37
41
  />
38
42
  </FlexItem>
39
43
  </Flex>
@@ -7,7 +7,7 @@
7
7
  <%= pb_rails("date_stacked", props: { align: "right", date: object.date, reverse: true, size: "sm", dark: object.dark }) %>
8
8
  <% end %>
9
9
  <%= pb_rails("flex/flex_item") do %>
10
- <%= pb_rails("time_stacked", props: { classname: "pb_date_time_stacked_kit", date: object.date, tag: "caption" }) %>
10
+ <%= pb_rails("time_stacked", props: { classname: "pb_date_time_stacked_kit", time: object.date, tag: "caption" }) %>
11
11
  <% end %>
12
12
  <% end %>
13
13
  <% end %>
@@ -21,7 +21,7 @@ module Playbook
21
21
  end
22
22
 
23
23
  def description
24
- @description ||= read_kit_file(kit, "_#{example_key}.md")
24
+ @description ||= read_kit_file("_#{example_key}.md")
25
25
  end
26
26
 
27
27
  def highlighter
@@ -13,8 +13,8 @@
13
13
  ]
14
14
  %>
15
15
 
16
- <%= pb_rails("form", props: {
17
- form_system_options: { scope: :example, method: :get, url: "" },
16
+ <%= pb_rails("form/form_with", props: {
17
+ scope: :example, method: :get, url: "",
18
18
  validate: true
19
19
  }) do |form| %>
20
20
  <%= form.text_field :example_text_field, props: { label: true, required: true } %>
@@ -19,8 +19,17 @@ module Playbook
19
19
  end
20
20
  end
21
21
 
22
- def render_in(view_context, &_block)
23
- super(view_context, &nil)
22
+ def render_in(view_context, &block)
23
+ form_kit.render_in(view_context, &block)
24
+ end
25
+
26
+ private
27
+
28
+ def form_kit
29
+ @form_system ||= begin
30
+ ::Playbook::KitResolver.resolve("form/#{form_system}")
31
+ .new(options: form_system_options, validate: validate, children: children)
32
+ end
24
33
  end
25
34
  end
26
35
  end
@@ -21,7 +21,7 @@ module Playbook
21
21
  prepend(DatePickerField)
22
22
 
23
23
  def actions(&block)
24
- @template.render_component ActionArea.new(submit_default_value: submit_default_value), &block
24
+ @template.render_component ActionArea.new(submit_default_value: submit_default_value, children: block)
25
25
  end
26
26
  end
27
27
  end
@@ -1,3 +1,3 @@
1
1
  <ol class="pb-form-actions">
2
- <%= content %>
2
+ <%= instance_exec(self, &children) %>
3
3
  </ol>
@@ -1,18 +1,11 @@
1
- <%= form_with(id: id,
2
- aria: aria,
3
- class: classname,
4
- data: data,
5
- builder: form_builder,
6
- **options) do |form| %>
7
- <% instance_exec form, &children %>
1
+ <%= form_with(form_options, &method(:render_form)) %>
8
2
 
9
- <% if validate %>
10
- <% content_for :pb_js do %>
11
- <%= javascript_tag do %>
12
- window.addEventListener('DOMContentLoaded', function() {
13
- PbFormValidation.start()
14
- })
15
- <% end %>
3
+ <% if validate %>
4
+ <% content_for :pb_js do %>
5
+ <%= javascript_tag do %>
6
+ window.addEventListener('DOMContentLoaded', function() {
7
+ PbFormValidation.start()
8
+ })
16
9
  <% end %>
17
10
  <% end %>
18
11
  <% end %>
@@ -14,16 +14,23 @@ module Playbook
14
14
  prop(:data).merge("pb-form-validation" => validate)
15
15
  end
16
16
 
17
- def options
18
- { url: "" }.merge(Hash(prop(:options)))
17
+ def form_options
18
+ {
19
+ url: "",
20
+ id: id,
21
+ aria: aria,
22
+ class: classname,
23
+ data: data,
24
+ builder: ::Playbook::PbForm::FormWith::FormBuilder,
25
+ }.merge(options)
19
26
  end
20
27
 
21
- def classname
22
- [generate_classname("pb-form"), options[:class]].join(" ")
28
+ def render_form(builder)
29
+ view_context.capture(builder, &children)
23
30
  end
24
31
 
25
- def form_builder
26
- ::Playbook::PbForm::FormWith::FormBuilder
32
+ def classname
33
+ [generate_classname("pb-form"), options[:class]].join(" ")
27
34
  end
28
35
 
29
36
  def render_in(view_context, &_block)
@@ -75,6 +75,7 @@ const NavItem = (props: NavItemProps) => {
75
75
  key={iconLeft}
76
76
  >
77
77
  <Icon
78
+ aria={{ label: iconLeft }}
78
79
  className="pb_nav_list_item_icon_left"
79
80
  fixedWidth
80
81
  icon={iconLeft}
@@ -90,6 +91,7 @@ const NavItem = (props: NavItemProps) => {
90
91
  key={iconRight}
91
92
  >
92
93
  <Icon
94
+ aria={{ label: iconRight }}
93
95
  className="pb_nav_list_item_icon_right"
94
96
  fixedWidth
95
97
  icon={iconRight}
@@ -48,7 +48,7 @@ const Nav = (props: NavProps) => {
48
48
  )
49
49
 
50
50
  return (
51
- <div
51
+ <nav
52
52
  {...ariaProps}
53
53
  {...dataProps}
54
54
  className={cardCss}
@@ -69,7 +69,7 @@ const Nav = (props: NavProps) => {
69
69
  </div>
70
70
  </If>
71
71
  <ul>{children}</ul>
72
- </div>
72
+ </nav>
73
73
  )
74
74
  }
75
75
 
@@ -9,13 +9,13 @@
9
9
  <%= pb_rails("image", props: { url: object.image_url, classname: "pb_nav_img_wrapper" }) %>
10
10
  <% end %>
11
11
  <% if object.icon_left %>
12
- <%= pb_rails("icon", props: { icon: object.icon_left, classname: "pb_nav_list_item_icon_left", fixed_width: true}) %>
12
+ <%= pb_rails("icon", props: { aria: { label: object.icon_left }, icon: object.icon_left, classname: "pb_nav_list_item_icon_left", fixed_width: true}) %>
13
13
  <% end %>
14
14
  <span class="pb_nav_list_item_text">
15
15
  <%= object.text %><%= content.presence %>
16
16
  </span>
17
17
  <% if object.icon_right %>
18
- <%= pb_rails("icon", props: { icon: object.icon_right, classname: "pb_nav_list_item_icon_right", fixed_width: true}) %>
18
+ <%= pb_rails("icon", props: { aria: { label: object.icon_right }, icon: object.icon_right, classname: "pb_nav_list_item_icon_right", fixed_width: true}) %>
19
19
  <% end %>
20
20
  <% end %>
21
21
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= content_tag(:div,
1
+ <%= content_tag(:nav,
2
2
  aria: object.aria,
3
3
  class: object.classname,
4
4
  data: object.data,
@@ -14,7 +14,7 @@ type ProgressSimpleProps = {
14
14
  muted: boolean,
15
15
  percent: string,
16
16
  value: number,
17
- variant?: "default" | "positive" | "negative",
17
+ variant?: "default" | "positive" | "negative" | "warning",
18
18
  width: string,
19
19
  }
20
20
 
@@ -33,6 +33,11 @@ $pb_progress_simple_height: 4px;
33
33
  background: $error;
34
34
  }
35
35
  }
36
+ &[class*=_warning] {
37
+ .progress_simple_value {
38
+ background: $warning;
39
+ }
40
+ }
36
41
 
37
42
  [class^=progress_simple_value] {
38
43
  width: 0%;
@@ -7,3 +7,8 @@
7
7
  <br>
8
8
 
9
9
  <%= pb_rails("progress_simple", props: { percent: 10, variant: "negative" }) %>
10
+
11
+ <br>
12
+
13
+ <%= pb_rails("progress_simple", props: { percent: 40, variant: "warning" }) %>
14
+
@@ -19,6 +19,13 @@ const ProgressSimpleVariants = () => {
19
19
  percent={10}
20
20
  variant="negative"
21
21
  />
22
+
23
+ <br />
24
+
25
+ <ProgressSimple
26
+ percent={40}
27
+ variant="warning"
28
+ />
22
29
  </div>
23
30
  )
24
31
  }
@@ -1 +1 @@
1
- Progress Simple can pass colors - primary, green and red. Variants names are `default`, `positive`, and `negative` respectively.
1
+ Progress Simple can pass colors - primary, green, red, and yellow. Variants names are `default`, `positive`, `negative`, and `warning`, respectively.
@@ -18,7 +18,7 @@ module Playbook
18
18
  # could this possibly be [sm, md, lg]?
19
19
  prop :width, default: "100%"
20
20
  prop :variant, type: Playbook::Props::Enum,
21
- values: %w[default positive negative],
21
+ values: %w[default positive negative warning],
22
22
  default: "default"
23
23
 
24
24
  def number_value
@@ -4,50 +4,67 @@ import React from 'react'
4
4
  import classnames from 'classnames'
5
5
 
6
6
  import DateTime from '../pb_kit/dateTime.js'
7
- import { buildCss } from '../utilities/props'
8
- import { Body, Caption } from '../'
7
+ import { buildCss, buildDataProps } from '../utilities/props'
9
8
  import { deprecatedProps, globalProps } from '../utilities/globalProps.js'
10
9
 
10
+ import { Body, Caption } from '../'
11
+
11
12
  type TimeStackedProps = {
12
13
  align?: 'left' | 'center' | 'right',
13
14
  className?: string | array<string>,
14
15
  dark?: boolean,
15
- data?: string,
16
- date: string,
16
+ data?: object,
17
+ date?: string,
17
18
  id?: string,
18
- tag?: 'body' | 'caption',
19
+ time: number | Date,
20
+ timeZone?: string,
19
21
  }
20
22
 
21
- const TimeStacked = (props: TimeStackedProps) => {
22
- const { align, className, dark, date } = props
23
- deprecatedProps('TimeStacked', ['tag'])
23
+ const TimeStackedDefault = (props: TimeStackedProps) => {
24
+ if (props.date) deprecatedProps('Time Stacked', ['date']) //date prop is deprecated, use time instead
25
+
26
+ const {
27
+ align = 'left',
28
+ className,
29
+ dark,
30
+ data = {},
31
+ date,
32
+ time,
33
+ timeZone,
34
+ } = props
35
+
24
36
  const classes = classnames(
25
37
  buildCss('pb_time_stacked_kit', align),
26
38
  globalProps(props),
27
- className,
39
+ className
28
40
  )
41
+ const dataProps = buildDataProps(data)
29
42
 
30
- const dateTimestamp = new DateTime({ value: date })
43
+ const dateTimestamp = new DateTime({ value: date ? date : new Date(time), zone: timeZone })
31
44
 
32
45
  return (
33
- <div className={classes}>
34
- <div
35
- align={align}
36
- className="pb_time_stacked_day_month"
46
+ <div
47
+ className={classes}
48
+ {...dataProps}
49
+ >
50
+ <Body
51
+ className={classnames('pb_time_stacked', 'time-spacing')}
52
+ color="light"
53
+ dark={dark}
37
54
  >
38
- <Body
39
- color="light"
40
- dark={dark}
41
- text={dateTimestamp.toTimeWithMeridian()}
42
- />
43
- <Caption
44
- color="light"
45
- dark={dark}
46
- text={dateTimestamp.toTimezone()}
47
- />
48
- </div>
55
+ <time>
56
+ {dateTimestamp.toTimeWithMeridian()}
57
+ <Caption
58
+ className="pb_time_stacked"
59
+ color="light"
60
+ dark={dark}
61
+ tag="span"
62
+ text={dateTimestamp.toTimezone()}
63
+ />
64
+ </time>
65
+ </Body>
49
66
  </div>
50
67
  )
51
68
  }
52
69
 
53
- export default TimeStacked
70
+ export default TimeStackedDefault