playbook_ui 11.4.0.pre.alpha.rubytheme2 → 11.5.0.pre.alpha.datepicker1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/data/menu.yml +0 -13
  3. data/app/pb_kits/playbook/pb_badge/badge.test.js +80 -0
  4. data/app/pb_kits/playbook/pb_button/_button.tsx +7 -2
  5. data/app/pb_kits/playbook/pb_button/_button_mixins.scss +7 -0
  6. data/app/pb_kits/playbook/pb_button/button.html.erb +11 -0
  7. data/app/pb_kits/playbook/pb_button/button.rb +3 -0
  8. data/app/pb_kits/playbook/pb_button/button.test.js +6 -8
  9. data/app/pb_kits/playbook/pb_button/docs/_button_block_content.html.erb +1 -1
  10. data/app/pb_kits/playbook/pb_button/docs/_button_block_content.jsx +12 -9
  11. data/app/pb_kits/playbook/pb_button/docs/_button_block_content.md +1 -0
  12. data/app/pb_kits/playbook/pb_button/docs/_button_icon_options.html.erb +2 -0
  13. data/app/pb_kits/playbook/pb_button/docs/_button_icon_options.jsx +23 -0
  14. data/app/pb_kits/playbook/pb_button/docs/_button_icon_options.md +1 -0
  15. data/app/pb_kits/playbook/pb_button/docs/example.yml +2 -0
  16. data/app/pb_kits/playbook/pb_button/docs/index.js +1 -0
  17. data/app/pb_kits/playbook/pb_date_picker/_date_picker.jsx +13 -1
  18. data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +24 -19
  19. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -1
  20. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +9 -0
  21. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +25 -3
  22. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_positions.html.erb +44 -0
  23. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_positions.jsx +60 -0
  24. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_positions.md +9 -0
  25. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_positions_element.html.erb +33 -0
  26. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_positions_element.jsx +67 -0
  27. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +4 -0
  28. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -0
  29. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +0 -3
  30. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_overrides.scss +4 -4
  31. data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +142 -0
  32. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.test.js +116 -0
  33. data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_default.jsx +1 -1
  34. data/app/pb_kits/playbook/pb_date_year_stacked/{_date_year_stacked.jsx → _date_year_stacked.tsx} +6 -6
  35. data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.test.js +67 -0
  36. data/app/pb_kits/playbook/pb_file_upload/{_file_upload.jsx → _file_upload.tsx} +6 -10
  37. data/app/pb_kits/playbook/pb_filter/Filter/FilterDouble.jsx +2 -0
  38. data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.jsx +2 -0
  39. data/app/pb_kits/playbook/pb_filter/Filter/FiltersPopover.jsx +2 -2
  40. data/app/pb_kits/playbook/pb_filter/docs/_filter_min_width.html.erb +1 -0
  41. data/app/pb_kits/playbook/pb_filter/docs/_filter_placement.html.erb +34 -0
  42. data/app/pb_kits/playbook/pb_filter/docs/_filter_placement.jsx +66 -0
  43. data/app/pb_kits/playbook/pb_filter/docs/_filter_placement.md +4 -0
  44. data/app/pb_kits/playbook/pb_filter/docs/example.yml +2 -0
  45. data/app/pb_kits/playbook/pb_filter/docs/index.js +1 -0
  46. data/app/pb_kits/playbook/pb_filter/filter.html.erb +2 -2
  47. data/app/pb_kits/playbook/pb_filter/filter.rb +3 -0
  48. data/app/pb_kits/playbook/pb_filter/filter.test.js +76 -0
  49. data/app/pb_kits/playbook/pb_form_group/{_form_group.jsx → _form_group.tsx} +1 -4
  50. data/app/pb_kits/playbook/pb_form_group/form_group.test.js +17 -0
  51. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +129 -0
  52. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_default.jsx +1 -1
  53. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_emphasis.jsx +2 -2
  54. data/app/pb_kits/playbook/pb_home_address_street/home_adress_street.test.js +60 -0
  55. data/app/pb_kits/playbook/pb_icon_stat_value/{_icon_stat_value.jsx → _icon_stat_value.tsx} +2 -4
  56. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.test.js +154 -0
  57. data/app/pb_kits/playbook/pb_icon_value/{_icon_value.jsx → _icon_value.tsx} +2 -4
  58. data/app/pb_kits/playbook/pb_icon_value/icon_value.test.js +77 -0
  59. data/app/pb_kits/playbook/pb_label_value/_label_value.tsx +123 -0
  60. data/app/pb_kits/playbook/pb_label_value/label_value.test.js +109 -0
  61. data/app/pb_kits/playbook/pb_layout/{_layout.jsx → _layout.tsx} +13 -19
  62. data/app/pb_kits/playbook/pb_layout/layout.test.js +97 -0
  63. data/app/pb_kits/playbook/pb_lightbox/lightbox.test.jsx +23 -15
  64. data/app/pb_kits/playbook/pb_popover/popover.rb +1 -1
  65. data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +0 -1
  66. data/app/pb_kits/playbook/pb_timestamp/_timestamp.jsx +5 -2
  67. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed.html.erb +9 -0
  68. data/app/pb_kits/playbook/pb_timestamp/docs/_timestamp_elapsed.jsx +10 -0
  69. data/app/pb_kits/playbook/pb_timestamp/timestamp.rb +4 -1
  70. data/app/pb_kits/playbook/pb_timestamp/timestamp.test.js +164 -0
  71. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +0 -4
  72. data/app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx +11 -8
  73. data/app/pb_kits/playbook/utilities/_flexbox.scss +11 -11
  74. data/app/pb_kits/playbook/utilities/{_align_content.scss → flexbox_global_props/_align_content.scss} +0 -0
  75. data/app/pb_kits/playbook/utilities/{_align_items.scss → flexbox_global_props/_align_items.scss} +0 -0
  76. data/app/pb_kits/playbook/utilities/{_align_self.scss → flexbox_global_props/_align_self.scss} +0 -0
  77. data/app/pb_kits/playbook/utilities/{_flex.scss → flexbox_global_props/_flex.scss} +0 -0
  78. data/app/pb_kits/playbook/utilities/{_flex_direction.scss → flexbox_global_props/_flex_direction.scss} +0 -0
  79. data/app/pb_kits/playbook/utilities/{_flex_grow.scss → flexbox_global_props/_flex_grow.scss} +0 -0
  80. data/app/pb_kits/playbook/utilities/{_flex_shrink.scss → flexbox_global_props/_flex_shrink.scss} +0 -0
  81. data/app/pb_kits/playbook/utilities/{_flex_wrap.scss → flexbox_global_props/_flex_wrap.scss} +0 -0
  82. data/app/pb_kits/playbook/utilities/{_justify_content.scss → flexbox_global_props/_justify_content.scss} +0 -0
  83. data/app/pb_kits/playbook/utilities/{_justify_self.scss → flexbox_global_props/_justify_self.scss} +0 -0
  84. data/app/pb_kits/playbook/utilities/{_order.scss → flexbox_global_props/_order.scss} +0 -0
  85. data/app/pb_kits/playbook/utilities/props.ts +1 -1
  86. data/app/pb_kits/playbook/utilities/test-utils.js +2 -3
  87. data/app/pb_kits/playbook/utilities/text.ts +1 -1
  88. data/lib/playbook/version.rb +2 -2
  89. metadata +46 -23
  90. data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.jsx +0 -155
  91. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.jsx +0 -127
  92. data/app/pb_kits/playbook/pb_label_value/_label_value.jsx +0 -155
@@ -0,0 +1,66 @@
1
+ import React from 'react'
2
+ import { Button, Filter, Flex, Select, TextInput } from '../..'
3
+
4
+ const SortingChangeCallback = (sortOptions) => {
5
+ alert(JSON.stringify(sortOptions[0]))
6
+ }
7
+
8
+ const FilterPlacement = (props) => {
9
+ const options = [
10
+ { value: 'USA' },
11
+ { value: 'Canada' },
12
+ { value: 'Brazil' },
13
+ { value: 'Philippines' },
14
+ { value: 'A Galaxy Far Far Away Like Really Far Away' },
15
+ ]
16
+ return (
17
+
18
+ <>
19
+ <Filter
20
+ double
21
+ onSortChange={SortingChangeCallback}
22
+ placement={"right"}
23
+ results={1}
24
+ sortOptions={{
25
+ popularity: 'Popularity',
26
+ // eslint-disable-next-line
27
+ manager_title: 'Manager\'s Title',
28
+ // eslint-disable-next-line
29
+ manager_name: 'Manager\'s Name',
30
+ }}
31
+ sortValue={[{ name: 'popularity', dir: 'desc' }]}
32
+ {...props}
33
+ >
34
+ <TextInput
35
+ label="Example Text Field"
36
+ placeholder="Enter Text"
37
+ {...props}
38
+ />
39
+
40
+ <Select
41
+ blankSelection="Select One..."
42
+ label="Example Collection Select"
43
+ name="Collection Select"
44
+ options={options}
45
+ {...props}
46
+ />
47
+ <Flex
48
+ spacing="between"
49
+ {...props}
50
+ >
51
+ <Button
52
+ text="Apply"
53
+ {...props}
54
+ />
55
+ <Button
56
+ text="Clear"
57
+ variant="secondary"
58
+ {...props}
59
+ />
60
+ </Flex>
61
+ </Filter>
62
+ </>
63
+ )
64
+ }
65
+
66
+ export default FilterPlacement
@@ -0,0 +1,4 @@
1
+ Click the filter buttom above to toggle the popover.
2
+
3
+ To change the filter's popover position, use the `placement` prop with one of the positions:
4
+ `"top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end"`
@@ -8,6 +8,7 @@ examples:
8
8
  - filter_only: Filter Only
9
9
  - sort_only: Sort Only
10
10
  - filter_min_width: Min Width for Popover Inside of Filter
11
+ - filter_placement: Filter Placement
11
12
 
12
13
  react:
13
14
  - filter_default: Default
@@ -18,3 +19,4 @@ examples:
18
19
  - sort_only: Sort Only
19
20
  - filter_min_width: Min Width for Popover Inside of Filter
20
21
  - filter_close_popover: Close Popover
22
+ - filter_placement: Filter Placement
@@ -6,3 +6,4 @@ export { default as FilterOnly } from './_filter_only.jsx'
6
6
  export { default as SortOnly } from './_sort_only.jsx'
7
7
  export { default as FilterMinWidth } from './_filter_min_width.jsx'
8
8
  export { default as FilterClosePopover } from './_filter_close_popover.jsx'
9
+ export { default as FilterPlacement } from './_filter_placement.jsx'
@@ -69,13 +69,13 @@
69
69
  <% end %>
70
70
 
71
71
  <% if object.template != "sort_only"%>
72
- <%= pb_rails("popover", props: {min_width: object.min_width, close_on_click: "outside", trigger_element_id: "filter#{object.id}", tooltip_id: "filter-form#{object.id}", position: 'bottom'}) do %>
72
+ <%= pb_rails("popover", props: {min_width: object.min_width, close_on_click: "outside", trigger_element_id: "filter#{object.id}", tooltip_id: "filter-form#{object.id}", position: object.placement }) do %>
73
73
  <%= content %>
74
74
  <% end %>
75
75
  <%end%>
76
76
 
77
77
  <% if object.template != "filter_only"%>
78
- <%= pb_rails("popover", props: {classname: "pb_filter_sort_menu", close_on_click: "outside", trigger_element_id: "sort-button#{object.id}", tooltip_id: "sort-filter-btn-tooltip#{object.id}", position: 'bottom', padding: 'none'}) do %>
78
+ <%= pb_rails("popover", props: {classname: "pb_filter_sort_menu", close_on_click: "outside", trigger_element_id: "sort-button#{object.id}", tooltip_id: "sort-filter-btn-tooltip#{object.id}", position: object.placement , padding: 'none'}) do %>
79
79
  <%= pb_rails("list") do %>
80
80
  <% object.sort_menu.each do |item| %>
81
81
  <%= pb_rails("list/item") do%> <%= pb_rails("button", props: {variant: "link" ,classname: "p-0", text: item[:item], link: item[:link]}) %><% end %>
@@ -11,6 +11,9 @@ module Playbook
11
11
  default: "default"
12
12
  prop :background, type: Playbook::Props::Boolean, default: true
13
13
  prop :min_width, default: "auto"
14
+ prop :placement, type: Playbook::Props::Enum,
15
+ values: %w[top bottom left right top-start top-end bottom-start bottom-end right-start right-end left-start left-end],
16
+ default: "bottom-start"
14
17
 
15
18
  def classname
16
19
  generate_classname("pb_filter_kit")
@@ -0,0 +1,76 @@
1
+ import React from "react";
2
+ import {
3
+ render,
4
+ screen,
5
+ fireEvent,
6
+ } from "../utilities/test-utils";
7
+ import { Button, Filter, Flex, Select, TextInput } from "..";
8
+
9
+ function FilterTest(props) {
10
+ const SortingChangeCallback = (sortOptions) => {
11
+ alert(JSON.stringify(sortOptions[0]));
12
+ };
13
+
14
+ const options = [
15
+ { value: "USA" },
16
+ { value: "Canada" },
17
+ { value: "Brazil" },
18
+ { value: "Philippines" },
19
+ { value: "A Galaxy Far Far Away Like Really Far Away" },
20
+ ];
21
+ return (
22
+ <Filter
23
+ onSortChange={SortingChangeCallback}
24
+ results={1}
25
+ sortOptions={{
26
+ popularity: "Popularity",
27
+ // eslint-disable-next-line
28
+ manager_title: "Manager's Title",
29
+ // eslint-disable-next-line
30
+ manager_name: "Manager's Name",
31
+ }}
32
+ sortValue={[{ name: "popularity", dir: "desc" }]}
33
+ {...props}
34
+ >
35
+ <TextInput
36
+ label="Example Text Field"
37
+ placeholder="Enter Text"
38
+ {...props}
39
+ />
40
+
41
+ <Select
42
+ blankSelection="Select One..."
43
+ label="Example Collection Select"
44
+ name="Collection Select"
45
+ options={options}
46
+ {...props}
47
+ />
48
+ <Flex spacing="between"
49
+ {...props}>
50
+ <Button text="Apply"
51
+ {...props} />
52
+ <Button text="Clear"
53
+ variant="secondary"
54
+ {...props} />
55
+ </Flex>
56
+ </Filter>
57
+ );
58
+ }
59
+
60
+ test("triggers popover on filter button click", () => {
61
+ render(<FilterTest data={{ testid: "render-test" }}/>);
62
+
63
+ const btn = screen.getAllByRole("button")[0];
64
+
65
+ // checks if the sort menu rendered
66
+ expect(screen.getByLabelText("sort-amount-down icon")).toBeInTheDocument()
67
+ expect(screen.getByText('Popularity')).toBeInTheDocument() // check if filter/sort is rendered
68
+
69
+ // hits the filter button and triggers popover
70
+ fireEvent.click(btn);
71
+
72
+ // check if popover displays correctly by checking its tet
73
+ expect(screen.getByText("Example Text Field")).toBeInTheDocument()
74
+
75
+
76
+ });
@@ -1,12 +1,10 @@
1
- /* @flow */
2
-
3
1
  import React from 'react'
4
2
  import classnames from 'classnames'
5
3
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
6
4
  import { globalProps } from '../utilities/globalProps'
7
5
 
8
6
  type FormGroupProps = {
9
- aria?: object,
7
+ aria?: {[key: string]: string},
10
8
  children?: Node,
11
9
  className?: string,
12
10
  data?: object,
@@ -27,7 +25,6 @@ const FormGroup = (props: FormGroupProps) => {
27
25
  const ariaProps = buildAriaProps(aria)
28
26
  const dataProps = buildDataProps(data)
29
27
  const classes = classnames(buildCss('pb_form_group_kit', { full: fullWidth }), globalProps(props), className)
30
-
31
28
  return (
32
29
  <div
33
30
  {...ariaProps}
@@ -0,0 +1,17 @@
1
+ import React from 'react'
2
+ import { render } from "../utilities/test-utils";
3
+
4
+ import { Button, FormGroup } from "..";
5
+
6
+ test("should render a div with a button child", () => {
7
+ const testId = "primary-test"
8
+ const { queryByTestId } = render(
9
+ <FormGroup>
10
+ <Button
11
+ data={{ testid: testId }}
12
+ text={"some text"} />
13
+ </FormGroup>
14
+ )
15
+
16
+ expect(queryByTestId("primary-test")).not.toBeNull;
17
+ })
@@ -0,0 +1,129 @@
1
+ import React from 'react'
2
+ import classnames from 'classnames'
3
+
4
+ import { joinPresent, titleize } from '../utilities/text'
5
+ import { globalProps } from '../utilities/globalProps'
6
+
7
+ import Body from '../pb_body/_body'
8
+ import Hashtag from '../pb_hashtag/_hashtag'
9
+ import Title from '../pb_title/_title'
10
+ import { buildAriaProps, buildDataProps } from '../utilities/props'
11
+
12
+ type HomeAddressStreetProps = {
13
+ aria?: { [key: string]: string },
14
+ address: string,
15
+ addressCont: string,
16
+ city: string,
17
+ className?: string,
18
+ data?: { [key: string]: string },
19
+ dark?: boolean,
20
+ emphasis: "street" | "city",
21
+ homeId: string,
22
+ houseStyle: string,
23
+ homeUrl: string,
24
+ newWindow: boolean,
25
+ state: string,
26
+ zipcode: string,
27
+ territory: string,
28
+ }
29
+
30
+ const HomeAddressStreet = (props: HomeAddressStreetProps) => {
31
+ const {
32
+ address,
33
+ addressCont,
34
+ aria = {},
35
+ city,
36
+ className,
37
+ data = {},
38
+ dark = false,
39
+ emphasis = 'street',
40
+ homeId,
41
+ homeUrl,
42
+ newWindow,
43
+ houseStyle,
44
+ state,
45
+ zipcode,
46
+ territory,
47
+ } = props
48
+
49
+ const classes = (className: string, dark: boolean) =>
50
+ classnames(
51
+ {
52
+ 'pb_home_address_street': !dark,
53
+ 'pb_home_address_street_dark': dark,
54
+ },
55
+ globalProps(props),
56
+ className
57
+ )
58
+
59
+ const dataProps: { [key: string]: any } = buildDataProps(data)
60
+ const ariaProps: { [key: string]: any } = buildAriaProps(aria)
61
+
62
+ return (
63
+ <div className={classes(className, dark)} {...ariaProps} {...dataProps}>
64
+ {emphasis == 'street' &&
65
+ <div>
66
+ <Title
67
+ className="pb_home_address_street_address"
68
+ dark={dark}
69
+ size={4}
70
+ >
71
+ {joinPresent([titleize(address), houseStyle], ' · ')}
72
+ </Title>
73
+ <Title
74
+ className="pb_home_address_street_address"
75
+ dark={dark}
76
+ size={4}
77
+ >
78
+ {titleize(addressCont)}
79
+ </Title>
80
+ <Body color="light">
81
+ {`${titleize(city)}, ${state} ${zipcode}`}
82
+ </Body>
83
+ </div>
84
+ }
85
+ {emphasis == 'city' &&
86
+ <div>
87
+ <Body color="light">
88
+ {joinPresent([titleize(address), houseStyle], ' · ')}
89
+ </Body>
90
+ <Body color="light">{titleize(addressCont)}</Body>
91
+ <div>
92
+ <Title
93
+ className="pb_home_address_street_address"
94
+ dark={dark}
95
+ size={4}
96
+ tag="span"
97
+ >
98
+ {`${titleize(city)}, ${state}`}
99
+ </Title>
100
+ <Body
101
+ color="light"
102
+ tag="span"
103
+ >
104
+ {` ${zipcode}`}
105
+ </Body>
106
+ </div>
107
+ </div>
108
+ }
109
+ {homeId &&
110
+ <Hashtag
111
+ classname="home-hashtag"
112
+ dark={dark}
113
+ newWindow={newWindow}
114
+ text={homeId}
115
+ type="home"
116
+ url={homeUrl || '#'}
117
+ />
118
+ }
119
+ <Body
120
+ color="light"
121
+ tag="span"
122
+ >
123
+ <small>{territory}</small>
124
+ </Body>
125
+ </div>
126
+ )
127
+ }
128
+
129
+ export default HomeAddressStreet
@@ -8,7 +8,7 @@ const HomeAddressStreetDefault = (props) => {
8
8
  address="70 Prospect Ave"
9
9
  addressCont="Apt M18"
10
10
  city="West Chester"
11
- homeId={8250263}
11
+ homeId="8250263"
12
12
  homeUrl="https://powerhrg.com/"
13
13
  houseStyle="Colonial"
14
14
  state="PA"
@@ -9,7 +9,7 @@ const HomeAddressStreetEmphasis = (props) => {
9
9
  address="70 Prospect Ave"
10
10
  addressCont="Apt M18"
11
11
  city="West Chester"
12
- homeId={8250263}
12
+ homeId="8250263"
13
13
  homeUrl="https://powerhrg.com/"
14
14
  houseStyle="Colonial"
15
15
  state="PA"
@@ -24,7 +24,7 @@ const HomeAddressStreetEmphasis = (props) => {
24
24
  addressCont="Apt M18"
25
25
  city="West Chester"
26
26
  emphasis="city"
27
- homeId={8250263}
27
+ homeId="8250263"
28
28
  homeUrl="https://powerhrg.com/"
29
29
  houseStyle="Colonial"
30
30
  state="PA"
@@ -0,0 +1,60 @@
1
+ import React from 'react'
2
+ import { render, screen, cleanup } from "../utilities/test-utils";
3
+
4
+ import { HomeAddressStreet } from "..";
5
+
6
+
7
+ const testId = "primary-test"
8
+ const address = "70 Prospect Ave"
9
+ const city = "West Chester"
10
+ const homeId = "8250263"
11
+
12
+ function HomeAdressStreetTest(props) {
13
+ return (
14
+ <HomeAddressStreet
15
+ address={address}
16
+ addressCont="Apt M18"
17
+ city={city}
18
+ data={{ testid: testId }}
19
+ homeId={homeId}
20
+ homeUrl="https://powerhrg.com/"
21
+ houseStyle="Colonial"
22
+ state="PA"
23
+ territory="PHL"
24
+ zipcode="19382"
25
+ {...props}
26
+ />
27
+ );
28
+ }
29
+
30
+ test("renders the component", () => {
31
+ render(<HomeAdressStreetTest />);
32
+ const kit = screen.getByTestId("primary-test");
33
+ expect(kit).toBeInTheDocument();
34
+ expect(kit).toHaveClass("pb_home_address_street");
35
+
36
+ cleanup()
37
+ });
38
+
39
+ test("emphasize street by not setting a prop", () => {
40
+ const { container } = render(<HomeAdressStreetTest />);
41
+ expect(container.getElementsByClassName("pb_title_kit_size_4 pb_home_address_street_address")[0]).toHaveTextContent(address);
42
+
43
+ cleanup()
44
+ });
45
+
46
+ test("emphasize city", () => {
47
+ const { container } = render(<HomeAdressStreetTest emphasis="city" />);
48
+ expect(container.getElementsByClassName("pb_title_kit_size_4 pb_home_address_street_address")[0]).toHaveTextContent(city);
49
+
50
+ cleanup()
51
+ });
52
+
53
+ test("renders the hashtag kit", () => {
54
+ const { container } = render(<HomeAdressStreetTest />);
55
+ expect(container.getElementsByClassName("pb_hashtag_kit")[0]).toBeInTheDocument;
56
+ expect(container.getElementsByClassName("pb_hashtag_kit")[0].firstChild).toHaveAttribute("href");
57
+ expect(container.getElementsByClassName("pb_hashtag_kit")[0].firstChild).toHaveTextContent(homeId);
58
+
59
+ cleanup()
60
+ });
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import React from 'react'
4
2
  import classnames from 'classnames'
5
3
 
@@ -13,7 +11,7 @@ import IconCircle from '../pb_icon_circle/_icon_circle'
13
11
  import Title from '../pb_title/_title'
14
12
 
15
13
  type IconStatValueProps = {
16
- aria?: object,
14
+ aria?: { [key: string]: string },
17
15
  className?: string,
18
16
  data?: object,
19
17
  icon: string,
@@ -53,7 +51,7 @@ const IconStatValue = (props: IconStatValueProps) => {
53
51
  buildCss('pb_icon_stat_value_kit', orientation, size, variant), globalProps(props),
54
52
  className
55
53
  )
56
- const titleSize = function(size) {
54
+ const titleSize = function(size: "sm" | "md" | "lg") {
57
55
  if (size == 'lg') {
58
56
  return (
59
57
  <Title
@@ -0,0 +1,154 @@
1
+ import React from 'react'
2
+ import { cleanup, render, screen } from '../utilities/test-utils'
3
+
4
+ import IconStatValue from './_icon_stat_value'
5
+
6
+ const testId = "iconstatvalue-kit"
7
+
8
+ describe("IconStatValue Kit", () => {
9
+ test("renders IconStatValue classname", () => {
10
+ render(
11
+ <IconStatValue
12
+ data={{ testid: testId }}
13
+ icon="lightbulb-on"
14
+ text="Electric"
15
+ unit="kw"
16
+ value={64.18}
17
+ />
18
+ )
19
+
20
+ const kit = screen.getByTestId(testId)
21
+ expect(kit).toHaveClass("pb_icon_stat_value_kit_horizontal_sm_default")
22
+ })
23
+
24
+ test("renders icon", () => {
25
+ render(
26
+ <IconStatValue
27
+ data={{ testid: testId }}
28
+ icon="lightbulb-on"
29
+ text="Electric"
30
+ unit="kw"
31
+ value={64.18}
32
+ />
33
+ )
34
+
35
+ const kit = screen.getByTestId(testId)
36
+ const icon = kit.querySelector(".fa-lightbulb-on.pb_icon_kit.fa-fw")
37
+ expect(icon).toBeInTheDocument()
38
+ })
39
+
40
+ test("renders text", () => {
41
+ render(
42
+ <IconStatValue
43
+ data={{ testid: testId }}
44
+ icon="lightbulb-on"
45
+ text="Electric"
46
+ unit="kw"
47
+ value={64.18}
48
+ />
49
+ )
50
+
51
+ const kit = screen.getByTestId(testId)
52
+ const text = kit.querySelector(".pb_caption_kit_md")
53
+ expect(text.textContent).toEqual("Electric")
54
+ })
55
+
56
+ test("renders unit", () => {
57
+ render(
58
+ <IconStatValue
59
+ data={{ testid: testId }}
60
+ icon="lightbulb-on"
61
+ text="Electric"
62
+ unit="kw"
63
+ value={64.18}
64
+ />
65
+ )
66
+
67
+ const kit = screen.getByTestId(testId)
68
+ const unit = kit.querySelector(".pb_body_kit")
69
+ expect(unit.textContent).toEqual("kw")
70
+ })
71
+
72
+ test("renders value", () => {
73
+ render(
74
+ <IconStatValue
75
+ data={{ testid: testId }}
76
+ icon="lightbulb-on"
77
+ text="Electric"
78
+ unit="kw"
79
+ value={64.18}
80
+ />
81
+ )
82
+
83
+ const kit = screen.getByTestId(testId)
84
+ const value = kit.querySelector(".pb_title_kit_size_3")
85
+ expect(value.textContent).toEqual("64.18")
86
+ })
87
+
88
+ test("renders size prop", () => {
89
+ ["sm",
90
+ "md",
91
+ "lg"].forEach((sizeProp) => {
92
+ render(
93
+ <IconStatValue
94
+ data={{ testid: testId }}
95
+ icon="lightbulb-on"
96
+ size={sizeProp}
97
+ text="Electric"
98
+ unit="kw"
99
+ value={64.18}
100
+ />
101
+ )
102
+
103
+ const kit = screen.getByTestId(testId)
104
+ expect(kit).toHaveClass(`pb_icon_stat_value_kit_horizontal_${sizeProp}_default`)
105
+
106
+ cleanup()
107
+ })
108
+ })
109
+
110
+ test("renders color prop", () => {
111
+ ["default",
112
+ "royal",
113
+ "blue",
114
+ "purple",
115
+ "teal",
116
+ "red",
117
+ "yellow",
118
+ "green"].forEach(
119
+ (colorProp) => {
120
+ render(
121
+ <IconStatValue
122
+ data={{ testid: testId }}
123
+ icon="lightbulb-on"
124
+ text="Electric"
125
+ unit="kw"
126
+ value={64.18}
127
+ variant={colorProp}
128
+ />
129
+ )
130
+
131
+ const kit = screen.getByTestId(testId)
132
+ expect(kit).toHaveClass(`pb_icon_stat_value_kit_horizontal_sm_${colorProp}`)
133
+
134
+ cleanup()
135
+ })
136
+ })
137
+
138
+ test("renders vertical prop", () => {
139
+ render(
140
+ <IconStatValue
141
+ data={{ testid: testId }}
142
+ icon="lightbulb-on"
143
+ orientation="vertical"
144
+ text="Electric"
145
+ unit="kw"
146
+ value={64.18}
147
+ />
148
+ )
149
+
150
+ const kit = screen.getByTestId(testId)
151
+ expect(kit).toHaveClass("pb_icon_stat_value_kit_vertical_sm_default")
152
+ })
153
+
154
+ })
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import React from 'react'
4
2
  import classnames from 'classnames'
5
3
 
@@ -11,12 +9,12 @@ import Icon from '../pb_icon/_icon'
11
9
 
12
10
  type IconValueProps = {
13
11
  align?: "left" | "center" | "right",
14
- aria?: object,
12
+ aria?: { [key: string]: string; },
15
13
  className?: string,
16
14
  dark?: boolean,
17
15
  data?: object,
18
16
  icon: string,
19
- id?: number,
17
+ id?: string,
20
18
  text: string,
21
19
  }
22
20