playbook_ui 12.15.0 → 12.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_background/_background.tsx +1 -1
  3. data/app/pb_kits/playbook/pb_background/background.rb +1 -1
  4. data/app/pb_kits/playbook/pb_badge/_badge.scss +1 -0
  5. data/app/pb_kits/playbook/pb_badge/_badge.tsx +1 -1
  6. data/app/pb_kits/playbook/pb_badge/badge.rb +5 -1
  7. data/app/pb_kits/playbook/pb_badge/badge.test.js +16 -1
  8. data/app/pb_kits/playbook/pb_body/_body_mixins.scss +3 -3
  9. data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +2 -2
  10. data/app/pb_kits/playbook/pb_enhanced_element/index.ts +1 -1
  11. data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.tsx +5 -5
  12. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +1 -1
  13. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +0 -5
  14. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +0 -4
  15. data/app/pb_kits/playbook/pb_table/{_table.jsx → _table.tsx} +9 -11
  16. data/app/pb_kits/playbook/pb_table/{_table_row.jsx → _table_row.tsx} +7 -8
  17. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +41 -0
  18. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +62 -0
  19. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  20. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  21. data/app/pb_kits/playbook/pb_table/{index.js → index.ts} +4 -4
  22. data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +129 -0
  23. data/app/pb_kits/playbook/pb_textarea/{index.js → index.tsx} +2 -0
  24. data/app/pb_kits/playbook/pb_textarea/textarea.test.js +213 -0
  25. data/app/pb_kits/playbook/tokens/_colors.scss +16 -1
  26. data/lib/playbook/version.rb +2 -2
  27. metadata +10 -8
  28. data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +0 -41
  29. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +0 -135
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '03281cc1b427fa58d12d5fdda8a4c4d2cc8084c2bb8b57d1f8eab0666b833571'
4
- data.tar.gz: 6b12d9e8c14770af46560d1c47600ae8866973a96dbde010998f86de8fad929d
3
+ metadata.gz: '09b7fe35bd640bdcbba17570366775211743d1f85c44a5dcb00db8013936743a'
4
+ data.tar.gz: 1a1a2f1936efa02380ca89c963f98f6aff52288a929430ff67c7b1e71e2e61da
5
5
  SHA512:
6
- metadata.gz: 9711f9bbac20056a5d7e66a5f2ce1385c520ab8a25d7d4505f23ab04e015d251f7eda1f561d7e9becaf8eefd9d04d9cf35dd5fabba5711397240f79318ce39ca
7
- data.tar.gz: d8d4f3c94fe38322ebbf9c14e607cb35f0834bd064795a235664551c56ee593b5ee5d9a0f1d175a826f93a50e5733e18ebef507281015c1e3eb88010ced4942c
6
+ metadata.gz: 20f0ff15258af1f924fe0ca2233e296fa5b6ce1678c6151f3289daab6f0580b9bcd2b4647f98a1a926230f9ac6af6ec1e634f3e82a55ad5bf38e752074b193da
7
+ data.tar.gz: ac0008d312f15ddefaf2f012684a4bcd2f05a33c54c95f913421fe5784dbc85c6efaf2ba52b7b9b96259e1dc318e3f4482677cd900b3166d59d7b7d8a6fc73bf
@@ -24,7 +24,7 @@ type BackgroundProps = {
24
24
  id?: string,
25
25
  imageUrl?: string,
26
26
  padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl',
27
- tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
27
+ tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div' | 'tr' | 'th' | 'td',
28
28
  transition?: 'fade' | 'blur' | 'scale',
29
29
  } & GlobalProps
30
30
 
@@ -91,7 +91,7 @@ module Playbook
91
91
  prop :image_url
92
92
 
93
93
  prop :tag, type: Playbook::Props::Enum,
94
- values: %w[h1 h2 h3 h4 h5 h6 p div span],
94
+ values: %w[h1 h2 h3 h4 h5 h6 p div span tr th td],
95
95
  default: "div"
96
96
 
97
97
  prop :transition, type: Playbook::Props::Enum,
@@ -43,6 +43,7 @@
43
43
  @each $color_name, $color_value in $status_colors {
44
44
  &[class*=_#{$color_name}] {
45
45
  background: rgba(mix($bg_dark, $color_value, 10%), $opacity_2);
46
+ color: map-get($status_color_text_dark, $color_name);
46
47
  }
47
48
  }
48
49
  }
@@ -42,7 +42,7 @@ const Badge = (props: BadgeProps) => {
42
42
  const ariaProps = buildAriaProps(aria)
43
43
  const dataProps = buildDataProps(data)
44
44
  const css = classnames(
45
- buildCss('pb_badge_kit', variant, rounded ? 'rounded' : null),
45
+ buildCss('pb_badge_kit', variant === "success" ? "success_sm" : variant, rounded ? 'rounded' : null),
46
46
  globalProps(props),
47
47
  className
48
48
  )
@@ -10,11 +10,15 @@ module Playbook
10
10
  default: "neutral"
11
11
 
12
12
  def classname
13
- generate_classname("pb_badge_kit", variant, rounded_class)
13
+ generate_classname("pb_badge_kit", variant_class, rounded_class)
14
14
  end
15
15
 
16
16
  private
17
17
 
18
+ def variant_class
19
+ variant === "success" ? "success_sm" : variant
20
+ end
21
+
18
22
  def rounded_class
19
23
  rounded ? "rounded" : nil
20
24
  end
@@ -60,7 +60,6 @@ test('displays rounded corners', () => {
60
60
 
61
61
  test('displays color variants', () => {
62
62
  [
63
- "success",
64
63
  "warning",
65
64
  "error",
66
65
  "info"
@@ -78,3 +77,19 @@ test('displays color variants', () => {
78
77
  cleanup()
79
78
  })
80
79
  })
80
+
81
+ test('displays success variant', () => {
82
+ render(
83
+ <Badge
84
+ data={{ testid: testId }}
85
+ text={"success"}
86
+ variant={"success"}
87
+ />
88
+ )
89
+ const kit = screen.getByTestId(testId)
90
+ expect(kit).toHaveClass(`pb_badge_kit_success_sm
91
+ `)
92
+
93
+ cleanup()
94
+
95
+ })
@@ -8,7 +8,7 @@ $pb_body_colors: (
8
8
  lighter: $text_lt_lighter,
9
9
  link: $primary,
10
10
  error: $error,
11
- success: $success,
11
+ success: $text_lt_success_sm,
12
12
  );
13
13
 
14
14
  $pb_dark_body_colors: (
@@ -16,7 +16,7 @@ $pb_dark_body_colors: (
16
16
  light: $text_dk_light,
17
17
  lighter: $text_dk_lighter,
18
18
  error: $error,
19
- success: $success,
19
+ success: $text_dk_success_sm,
20
20
  );
21
21
 
22
22
  // Order is important here!
@@ -24,7 +24,7 @@ $pb_body_status: (
24
24
  default: $text_lt_default,
25
25
  negative: $error,
26
26
  dark_error: $error_dark_body,
27
- positive: $success,
27
+ positive: $text_lt_success_sm,
28
28
  );
29
29
 
30
30
  @mixin pb_body($color: $text_lt_default) {
@@ -6,7 +6,7 @@ $pb_caption_colors: (
6
6
  light: $text_lt_light,
7
7
  link: $primary,
8
8
  lighter: $text_lt_lighter,
9
- success: $success,
9
+ success: $text_lt_success_sm,
10
10
  error: $error,
11
11
  );
12
12
 
@@ -14,7 +14,7 @@ $pb_dark_caption_colors: (
14
14
  default: $text_dk_default,
15
15
  light: $text_dk_light,
16
16
  link: $primary,
17
- success: $success,
17
+ success: $text_dk_success_sm,
18
18
  error: $error,
19
19
  );
20
20
 
@@ -7,7 +7,7 @@ export default class PbEnhancedElement {
7
7
  static _observer: ElementObserver
8
8
  element: Element
9
9
 
10
- constructor(element: Element) {
10
+ constructor(element?: Element) {
11
11
  this.element = element
12
12
  }
13
13
 
@@ -94,13 +94,13 @@ const IconStatValue = (props: IconStatValueProps) => {
94
94
 
95
95
  <div>
96
96
  <Flex
97
- vertical="bottom"
97
+ align="baseline"
98
98
  >
99
- {titleSize(size)}
99
+ {titleSize(size)}
100
100
  &nbsp;
101
- <Body
102
- text={unit}
103
- />
101
+ <Body
102
+ text={unit}
103
+ />
104
104
  </Flex>
105
105
  <Caption text={text} />
106
106
  </div>
@@ -10,7 +10,7 @@
10
10
  variant: object.variant } %>
11
11
 
12
12
  <div>
13
- <%= pb_rails("flex", props: { vertical: "bottom" }) do %>
13
+ <%= pb_rails("flex", props: { align: "baseline" }) do %>
14
14
  <%= pb_rails "title", props: {
15
15
  tag: "span",
16
16
  text: object.value_string,
@@ -1,7 +1,6 @@
1
1
  @import "../tokens/colors";
2
2
 
3
3
  $transform-rotate-deg: 135deg;
4
- $input-max-width: 284px;
5
4
  $dropdown-min-width: 340px;
6
5
  $flag-min-resolution: 192dpi;
7
6
 
@@ -10,10 +9,6 @@ $flag-min-resolution: 192dpi;
10
9
  color: $focus_input_light;
11
10
  }
12
11
 
13
- .text_input {
14
- max-width: $input-max-width;
15
- }
16
-
17
12
  .dropdown_open {
18
13
  .text_input {
19
14
  border-color: $primary !important;
@@ -7,12 +7,10 @@ module Playbook
7
7
  default: false
8
8
  prop :initial_country, type: Playbook::Props::String,
9
9
  default: ""
10
- prop :is_valid
11
10
  prop :label, type: Playbook::Props::String,
12
11
  default: ""
13
12
  prop :name, type: Playbook::Props::String,
14
13
  default: ""
15
- prop :onchange
16
14
  prop :only_countries, type: Playbook::Props::Array,
17
15
  default: []
18
16
  prop :preferred_countries, type: Playbook::Props::Array,
@@ -30,10 +28,8 @@ module Playbook
30
28
  dark: dark,
31
29
  disabled: disabled,
32
30
  initialCountry: initial_country,
33
- isValid: is_valid,
34
31
  label: label,
35
32
  name: name,
36
- onChange: onchange,
37
33
  onlyCountries: only_countries,
38
34
  preferredCountries: preferred_countries,
39
35
  value: value,
@@ -1,19 +1,17 @@
1
- /* @flow */
2
-
3
- import React, { useEffect, type Node } from 'react'
1
+ import React, { useEffect } from 'react'
4
2
  import classnames from 'classnames'
5
3
  import { buildAriaProps, buildDataProps } from '../utilities/props'
6
4
  import { globalProps } from '../utilities/globalProps'
7
- import PbTable from './'
5
+ import PbTable from '.'
8
6
 
9
7
  type TableProps = {
10
- aria?: object,
11
- children: array<Node> | Node,
8
+ aria?: { [key: string]: string },
9
+ children: React.ReactNode[] | React.ReactNode,
12
10
  className: string,
13
11
  collapse?: "sm" | "md" | "lg",
14
12
  container: boolean,
15
13
  dark?: boolean,
16
- data?: object,
14
+ data?: { [key: string]: string },
17
15
  dataTable: boolean,
18
16
  disableHover: boolean,
19
17
  id?: string,
@@ -52,9 +50,9 @@ const Table = (props: TableProps) => {
52
50
 
53
51
  return (
54
52
  <table
55
- {...ariaProps}
56
- {...dataProps}
57
- className={classnames(
53
+ {...ariaProps}
54
+ {...dataProps}
55
+ className={classnames(
58
56
  'pb_table',
59
57
  `table-${size}`,
60
58
  `table-responsive-${responsive}`,
@@ -70,7 +68,7 @@ const Table = (props: TableProps) => {
70
68
  tableCollapseCss,
71
69
  className
72
70
  )}
73
- id={id}
71
+ id={id}
74
72
  >
75
73
  {children}
76
74
  </table>
@@ -1,14 +1,13 @@
1
- /* @flow */
2
1
  import React from 'react'
3
2
  import classnames from 'classnames'
4
3
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
4
  import { globalProps } from '../utilities/globalProps'
6
5
 
7
6
  type TableRowPropTypes = {
8
- aria?: object,
9
- children: array<React.ReactNode> | React.ReactNode,
7
+ aria?: { [key: string]: string },
8
+ children: React.ReactNode[] | React.ReactNode,
10
9
  className: string,
11
- data?: object,
10
+ data?: { [key: string]: string },
12
11
  id?: string,
13
12
  sideHighlightColor: string,
14
13
  }
@@ -31,10 +30,10 @@ const TableRow = (props: TableRowPropTypes) => {
31
30
 
32
31
  return (
33
32
  <tr
34
- {...ariaProps}
35
- {...dataProps}
36
- className={classes}
37
- id={id}
33
+ {...ariaProps}
34
+ {...dataProps}
35
+ className={classes}
36
+ id={id}
38
37
  >
39
38
  {children}
40
39
  </tr>
@@ -0,0 +1,41 @@
1
+ <%= pb_rails("table", props: { size: "sm", margin_bottom: "lg" }) do %>
2
+ <thead>
3
+ <tr>
4
+ <th>Column 1</th>
5
+ <th>Column 2</th>
6
+ <th>Column 3</th>
7
+ </tr>
8
+ </thead>
9
+ <tbody>
10
+ <tr>
11
+ <td>Value 1</td>
12
+ <td>Value 2</td>
13
+ <td>Value 3</td>
14
+ </tr>
15
+ <%= pb_rails("background", props: { background_color: "error_subtle", tag: "tr" }) do %>
16
+ <td>Value 1</td>
17
+ <td>Value 2</td>
18
+ <td>Value 3</td>
19
+ <% end %>
20
+ <tr>
21
+ <td>Value 1</td>
22
+ <td>Value 2</td>
23
+ <td>Value 3</td>
24
+ </tr>
25
+ <tr>
26
+ <td>Value 1</td>
27
+ <td>Value 2</td>
28
+ <td>Value 3</td>
29
+ </tr>
30
+ <%= pb_rails("background", props: { background_color: "warning_subtle", tag: "tr" }) do %>
31
+ <td>Value 1</td>
32
+ <td>Value 2</td>
33
+ <td>Value 3</td>
34
+ <% end %>
35
+ <tr>
36
+ <td>Value 1</td>
37
+ <td>Value 2</td>
38
+ <td>Value 3</td>
39
+ </tr>
40
+ </tbody>
41
+ <% end %>
@@ -0,0 +1,62 @@
1
+ import React from 'react'
2
+
3
+ import Table from '../_table'
4
+ import Background from "../../pb_background/_background"
5
+
6
+ const TableWithBackgroundKit = (props) => {
7
+ return (
8
+ <div>
9
+ <Table
10
+ {...props}
11
+ >
12
+ <thead>
13
+ <tr>
14
+ <th>{'Column 1'}</th>
15
+ <th>{'Column 2'}</th>
16
+ <th>{'Column 3'}</th>
17
+ </tr>
18
+ </thead>
19
+ <tbody>
20
+ <tr>
21
+ <td>{'Value 1'}</td>
22
+ <td>{'Value 2'}</td>
23
+ <td>{'Value 3'}</td>
24
+ </tr>
25
+ <Background
26
+ backgroundColor="error_subtle"
27
+ tag='tr'
28
+ >
29
+ <td>{'Value 1'}</td>
30
+ <td>{'Value 2'}</td>
31
+ <td>{'Value 3'}</td>
32
+ </Background>
33
+ <tr>
34
+ <td>{'Value 1'}</td>
35
+ <td>{'Value 2'}</td>
36
+ <td>{'Value 3'}</td>
37
+ </tr>
38
+ <tr>
39
+ <td>{'Value 1'}</td>
40
+ <td>{'Value 2'}</td>
41
+ <td>{'Value 3'}</td>
42
+ </tr>
43
+ <Background
44
+ backgroundColor="warning_subtle"
45
+ tag='tr'
46
+ >
47
+ <td>{'Value 1'}</td>
48
+ <td>{'Value 2'}</td>
49
+ <td>{'Value 3'}</td>
50
+ </Background>
51
+ <tr>
52
+ <td>{'Value 1'}</td>
53
+ <td>{'Value 2'}</td>
54
+ <td>{'Value 3'}</td>
55
+ </tr>
56
+ </tbody>
57
+ </Table>
58
+ </div>
59
+ )
60
+ }
61
+
62
+ export default TableWithBackgroundKit
@@ -20,6 +20,7 @@ examples:
20
20
  - table_two_plus_actions: Table with 2+ Actions
21
21
  - table_action_middle: Table with Actions in the Middle
22
22
  - table_icon_buttons: Table with Icon Buttons
23
+ - table_with_background_kit: Table With Background Kit
23
24
 
24
25
 
25
26
  react:
@@ -43,4 +44,5 @@ examples:
43
44
  - table_two_plus_actions: Table with 2+ Actions
44
45
  - table_action_middle: Table with Actions in the Middle
45
46
  - table_icon_buttons: Table with Icon Buttons
47
+ - table_with_background_kit: Table With Background Kit
46
48
 
@@ -18,3 +18,4 @@ export { default as TableAlignmentColumn } from './_table_alignment_column.jsx'
18
18
  export { default as TableAlignmentRow } from './_table_alignment_row.jsx'
19
19
  export { default as TableAlignmentShiftRow } from './_table_alignment_shift_row.jsx'
20
20
  export { default as TableAlignmentShiftData } from './_table_alignment_shift_data.jsx'
21
+ export { default as TableWithBackgroundKit } from './_table_with_background_kit.jsx'
@@ -9,16 +9,16 @@ export default class PbTable extends PbEnhancedElement {
9
9
  const tables = document.querySelectorAll('.table-responsive-collapse');
10
10
 
11
11
  // Each Table
12
- [].forEach.call(tables, (table) => {
12
+ [].forEach.call(tables, (table: HTMLTableElement) => {
13
13
  // Header Titles
14
- var headers = [].map.call(table.querySelectorAll('th'), (header) => {
14
+ var headers = [].map.call(table.querySelectorAll('th'), (header: Element) => {
15
15
  return header.textContent.replace(/\r?\n|\r/, '')
16
16
  });
17
17
 
18
18
  // for each row in tbody
19
- [].forEach.call(table.querySelectorAll('tbody tr'), (row) => {
19
+ [].forEach.call(table.querySelectorAll('tbody tr'), (row: HTMLTableRowElement) => {
20
20
  // for each cell
21
- [].forEach.call(row.cells, (cell, headerIndex) => {
21
+ [].forEach.call(row.cells, (cell: HTMLTableCellElement, headerIndex: number) => {
22
22
  // apply the attribute
23
23
  cell.setAttribute('data-title', headers[headerIndex])
24
24
  })
@@ -0,0 +1,129 @@
1
+ /* eslint-disable react-hooks/rules-of-hooks */
2
+
3
+ import React, { forwardRef, useEffect, useRef } from 'react'
4
+ import classnames from 'classnames'
5
+
6
+ import PbTextarea from '.'
7
+ import type { InputCallback } from '../types'
8
+
9
+ import { buildAriaProps, buildDataProps } from '../utilities/props'
10
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
11
+
12
+ import Body from '../pb_body/_body'
13
+ import Caption from '../pb_caption/_caption'
14
+ import Flex from '../pb_flex/_flex'
15
+ import FlexItem from '../pb_flex/_flex_item'
16
+
17
+ type TextareaProps = {
18
+ aria?: {[key: string]: string},
19
+ characterCount?: string,
20
+ className?: string,
21
+ children?: React.ReactChild[],
22
+ data?: {[key: string]: string},
23
+ disabled?: boolean,
24
+ error?: string,
25
+ id?: string,
26
+ inline?: boolean,
27
+ object?: string,
28
+ method?: string,
29
+ label?: string,
30
+ maxCharacters?: string,
31
+ placeholder?: string,
32
+ value?: string,
33
+ name?: string,
34
+ required?: boolean,
35
+ rows?: number,
36
+ resize: "none" | "both" | "horizontal" | "vertical" | "auto",
37
+ onChange?: InputCallback<HTMLTextAreaElement>,
38
+ } & GlobalProps
39
+
40
+ const Textarea = ({
41
+ aria = {},
42
+ characterCount,
43
+ className,
44
+ children,
45
+ data = {},
46
+ disabled,
47
+ inline = false,
48
+ resize = 'none',
49
+ error,
50
+ label,
51
+ maxCharacters,
52
+ name,
53
+ onChange = () => {},
54
+ placeholder,
55
+ required,
56
+ rows = 4,
57
+ value,
58
+ ...props
59
+ }: TextareaProps, ref: any) => {
60
+ ref = useRef<HTMLTextAreaElement>(null)
61
+ useEffect(() => {
62
+ if (ref.current && resize === 'auto') {
63
+ PbTextarea.addMatch(ref.current)
64
+ }
65
+ })
66
+
67
+ const errorClass = error ? 'error' : null
68
+ const inlineClass = inline ? 'inline' : ''
69
+ const resizeClass = `resize_${resize}`
70
+ const classes = classnames('pb_textarea_kit', errorClass, inlineClass, resizeClass, globalProps(props), className)
71
+ const noCount = typeof characterCount !== 'undefined'
72
+ const ariaProps: {[key: string]: any} = buildAriaProps(aria)
73
+ const dataProps: {[key: string]: any} = buildDataProps(data)
74
+
75
+ const characterCounter = () => {
76
+ return maxCharacters && characterCount ? `${checkIfZero(characterCount)} / ${maxCharacters}` : `${checkIfZero(characterCount)}`
77
+ }
78
+
79
+ const checkIfZero = (characterCount: string | number) => {
80
+ return characterCount == 0 ? characterCount.toString() : characterCount
81
+ }
82
+
83
+ return (
84
+ <div
85
+ {...ariaProps}
86
+ {...dataProps}
87
+ className={classes}
88
+ >
89
+ <Caption text={label} />
90
+ {children || (
91
+ <textarea
92
+ className="pb_textarea_kit"
93
+ disabled={disabled}
94
+ name={name}
95
+ onChange={onChange}
96
+ placeholder={placeholder}
97
+ ref={ref}
98
+ required={required}
99
+ rows={rows}
100
+ value={value}
101
+ {...props}
102
+ />
103
+ )}
104
+
105
+ {error ? (
106
+ <>
107
+ {characterCount ? (
108
+ <Flex spacing="between" vertical="center">
109
+ <FlexItem>
110
+ <Body margin="none" status="negative" text={error} />
111
+ </FlexItem>
112
+ <FlexItem>
113
+ <Caption margin="none" size="xs" text={characterCounter()} />
114
+ </FlexItem>
115
+ </Flex>
116
+ ) : (
117
+ <Body status="negative" text={error} />
118
+ )}
119
+ </>
120
+ ) : (
121
+ noCount && (
122
+ <Caption margin="none" size="xs" text={characterCounter()} />
123
+ )
124
+ )}
125
+ </div>
126
+ );
127
+ }
128
+
129
+ export default forwardRef(Textarea)
@@ -1,6 +1,8 @@
1
1
  import PbEnhancedElement from '../pb_enhanced_element'
2
2
 
3
3
  export default class PbTextarea extends PbEnhancedElement {
4
+ style: {[key: string]: string}
5
+ scrollHeight: string
4
6
  static get selector() {
5
7
  return '.resize_auto textarea'
6
8
  }
@@ -0,0 +1,213 @@
1
+ import React from "react"
2
+ import { render, screen } from "../utilities/test-utils"
3
+
4
+ import Textarea from "./_textarea"
5
+
6
+ const testId = "textarea-kit"
7
+
8
+ describe("TextArea Kit Props", () => {
9
+ test("Expects to have correct classname", () => {
10
+ render(
11
+ <Textarea
12
+ data={{ testid: testId }}
13
+ label="Label"
14
+ />
15
+ )
16
+
17
+ const kit = screen.getByTestId(testId)
18
+ expect(kit).toHaveClass("pb_textarea_kit")
19
+ })
20
+
21
+ test("should render aria-label", () => {
22
+ render(
23
+ <Textarea
24
+ aria={{ label: testId }}
25
+ data={{ testid: testId }}
26
+ />
27
+ )
28
+
29
+ const kit = screen.getByTestId(testId)
30
+ expect(kit).toHaveAttribute("aria-label", testId)
31
+ })
32
+
33
+ test("should render custom classname", () => {
34
+ render(
35
+ <Textarea
36
+ className={"text_class"}
37
+ data={{ testid: testId }}
38
+ />
39
+ )
40
+
41
+ const kit = screen.getByTestId(testId)
42
+
43
+ expect(kit).toHaveClass("text_class")
44
+ })
45
+
46
+ test("should render value", () => {
47
+ render(
48
+ <Textarea
49
+ data={{ testid: testId }}
50
+ value={"Default Value"}
51
+ />
52
+ )
53
+
54
+ const kit = screen.getByTestId(testId)
55
+ const textarea = kit.querySelector("textarea")
56
+
57
+ expect(textarea.innerHTML).toBe("Default Value")
58
+ })
59
+
60
+ test("should render disabled", () => {
61
+ render(
62
+ <Textarea
63
+ data={{ testid: testId }}
64
+ disabled={false}
65
+ />
66
+ )
67
+
68
+ const kit = screen.getByTestId(testId)
69
+ const textarea = kit.querySelector("textarea")
70
+
71
+ expect(textarea.disabled).toBe(false)
72
+ })
73
+
74
+ test("should render rows", () => {
75
+ render(
76
+ <Textarea
77
+ data={{ testid: testId }}
78
+ rows={7}
79
+ />
80
+ )
81
+
82
+ const kit = screen.getByTestId(testId)
83
+ const textarea = kit.querySelector("textarea")
84
+
85
+ expect(textarea.rows).toBe(7)
86
+ })
87
+
88
+ test("should render character count", () => {
89
+ render(
90
+ <Textarea
91
+ characterCount={50}
92
+ data={{ testid: testId }}
93
+ />
94
+ )
95
+
96
+ const kit = screen.getByTestId(testId)
97
+ const counter = kit.querySelector(".pb_caption_kit_xs")
98
+
99
+ expect(counter.innerHTML).toBe("50")
100
+ })
101
+
102
+ test("should have inline class", () => {
103
+ render(
104
+ <Textarea
105
+ data={{ testid: testId }}
106
+ inline
107
+ />
108
+ )
109
+
110
+ const kit = screen.getByTestId(testId)
111
+
112
+ expect(kit).toHaveClass("inline")
113
+ })
114
+
115
+ test("should have resize class", () => {
116
+ render(
117
+ <Textarea
118
+ data={{ testid: testId }}
119
+ resize={"none"}
120
+ />
121
+ )
122
+
123
+ const kit = screen.getByTestId(testId)
124
+
125
+ expect(kit).toHaveClass("resize_none")
126
+ })
127
+
128
+ test("should render error", () => {
129
+ render(
130
+ <Textarea
131
+ data={{ testid: testId }}
132
+ error={"error message"}
133
+ />
134
+ )
135
+
136
+ const kit = screen.getByTestId(testId)
137
+ const error = kit.querySelector(".pb_body_kit_negative")
138
+
139
+ expect(kit).toHaveClass("error")
140
+ expect(error.innerHTML).toBe("error message")
141
+ })
142
+
143
+ test("should render label", () => {
144
+ render(
145
+ <Textarea
146
+ data={{ testid: testId }}
147
+ label={"Test Label"}
148
+ />
149
+ )
150
+
151
+ const kit = screen.getByTestId(testId)
152
+ const error = kit.querySelector(".pb_caption_kit_md")
153
+
154
+ expect(error.innerHTML).toBe("Test Label")
155
+ })
156
+
157
+ test("should render max character display", () => {
158
+ render(
159
+ <Textarea
160
+ characterCount={"11"}
161
+ data={{ testid: testId }}
162
+ maxCharacters={"10"}
163
+ />
164
+ )
165
+
166
+ const kit = screen.getByTestId(testId)
167
+ const error = kit.querySelector(".pb_caption_kit_xs")
168
+
169
+ expect(error.innerHTML).toBe("11 / 10")
170
+ })
171
+
172
+ test("should render max character display", () => {
173
+ render(
174
+ <Textarea
175
+ data={{ testid: testId }}
176
+ name={"TestName"}
177
+ />
178
+ )
179
+
180
+ const kit = screen.getByTestId(testId)
181
+ const textarea = kit.querySelector("textarea")
182
+
183
+ expect(textarea.name).toBe("TestName")
184
+ })
185
+
186
+ test("should render placeholder", () => {
187
+ render(
188
+ <Textarea
189
+ data={{ testid: testId }}
190
+ placeholder={"Test Placeholder"}
191
+ />
192
+ )
193
+
194
+ const kit = screen.getByTestId(testId)
195
+ const textarea = kit.querySelector("textarea")
196
+
197
+ expect(textarea.placeholder).toBe("Test Placeholder")
198
+ })
199
+
200
+ test("should be required", () => {
201
+ render(
202
+ <Textarea
203
+ data={{ testid: testId }}
204
+ required
205
+ />
206
+ )
207
+
208
+ const kit = screen.getByTestId(testId)
209
+ const textarea = kit.querySelector("textarea")
210
+
211
+ expect(textarea.required).toBeTruthy()
212
+ })
213
+ })
@@ -63,7 +63,7 @@ $bg_dark_card: #231E3D !default;
63
63
  $background_colors: (
64
64
  bg_light: $bg_light,
65
65
  bg_dark: $bg_dark,
66
- bg_dark_card: $bg_dark_card
66
+ bg_dark_card: $bg_dark_card
67
67
  );
68
68
 
69
69
  /* Card colors ------------------*/
@@ -125,9 +125,11 @@ $shadow_colors: (
125
125
  $text_lt_default: $charcoal !default;
126
126
  $text_lt_light: #687887 !default;
127
127
  $text_lt_lighter: $slate !default;
128
+ $text_lt_success_sm: #157F48 !default;
128
129
  $text_dk_default: $white !default;
129
130
  $text_dk_light: rgba($white, $opacity_6) !default;
130
131
  $text_dk_lighter: rgba($white, $opacity_4) !default;
132
+ $text_dk_success_sm: #00CA74 !default;
131
133
  $text_colors: (
132
134
  text_lt_default: $text_lt_default,
133
135
  text_lt_light: $text_lt_light,
@@ -181,6 +183,7 @@ $primary_secondary: lighten($primary, 10%) !default;
181
183
  $status_colors: (
182
184
  success: $success,
183
185
  success_secondary: $success_secondary,
186
+ success_sm: $text_lt_success_sm,
184
187
  success_subtle: $success_subtle,
185
188
  warning: $warning,
186
189
  warning_secondary: $warning_secondary,
@@ -202,6 +205,18 @@ $status_colors: (
202
205
 
203
206
  $status_color_text: (
204
207
  success: $success,
208
+ success_sm: $text_lt_success_sm,
209
+ warning: darken($warning, 10%),
210
+ error: $error,
211
+ info: $info,
212
+ neutral: darken($neutral, 15%),
213
+ primary: $primary
214
+ );
215
+
216
+ // as we add more dark text colors we can update this variable
217
+ $status_color_text_dark: (
218
+ success: $success,
219
+ success_sm: $text_dk_success_sm,
205
220
  warning: darken($warning, 10%),
206
221
  error: $error,
207
222
  info: $info,
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playbook
4
- PREVIOUS_VERSION = "12.14.0"
5
- VERSION = "12.15.0"
4
+ PREVIOUS_VERSION = "12.15.0"
5
+ VERSION = "12.16.0"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.15.0
4
+ version: 12.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-04-12 00:00:00.000000000 Z
12
+ date: 2023-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -979,7 +979,6 @@ files:
979
979
  - app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
980
980
  - app/pb_kits/playbook/pb_flex/_flex.scss
981
981
  - app/pb_kits/playbook/pb_flex/_flex.tsx
982
- - app/pb_kits/playbook/pb_flex/_flex_item.jsx
983
982
  - app/pb_kits/playbook/pb_flex/_flex_item.scss
984
983
  - app/pb_kits/playbook/pb_flex/_flex_item.tsx
985
984
  - app/pb_kits/playbook/pb_flex/docs/_description.md
@@ -1916,9 +1915,9 @@ files:
1916
1915
  - app/pb_kits/playbook/pb_stat_value/stat_value.html.erb
1917
1916
  - app/pb_kits/playbook/pb_stat_value/stat_value.rb
1918
1917
  - app/pb_kits/playbook/pb_stat_value/stat_value.test.js
1919
- - app/pb_kits/playbook/pb_table/_table.jsx
1920
1918
  - app/pb_kits/playbook/pb_table/_table.scss
1921
- - app/pb_kits/playbook/pb_table/_table_row.jsx
1919
+ - app/pb_kits/playbook/pb_table/_table.tsx
1920
+ - app/pb_kits/playbook/pb_table/_table_row.tsx
1922
1921
  - app/pb_kits/playbook/pb_table/docs/_description.md
1923
1922
  - app/pb_kits/playbook/pb_table/docs/_table_action_middle.html.erb
1924
1923
  - app/pb_kits/playbook/pb_table/docs/_table_action_middle.jsx
@@ -1973,9 +1972,11 @@ files:
1973
1972
  - app/pb_kits/playbook/pb_table/docs/_table_two_plus_actions.html.erb
1974
1973
  - app/pb_kits/playbook/pb_table/docs/_table_two_plus_actions.jsx
1975
1974
  - app/pb_kits/playbook/pb_table/docs/_table_two_plus_actions.md
1975
+ - app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb
1976
+ - app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx
1976
1977
  - app/pb_kits/playbook/pb_table/docs/example.yml
1977
1978
  - app/pb_kits/playbook/pb_table/docs/index.js
1978
- - app/pb_kits/playbook/pb_table/index.js
1979
+ - app/pb_kits/playbook/pb_table/index.ts
1979
1980
  - app/pb_kits/playbook/pb_table/styles/_alignment.scss
1980
1981
  - app/pb_kits/playbook/pb_table/styles/_all.scss
1981
1982
  - app/pb_kits/playbook/pb_table/styles/_content.scss
@@ -2024,8 +2025,8 @@ files:
2024
2025
  - app/pb_kits/playbook/pb_text_input/text_input.html.erb
2025
2026
  - app/pb_kits/playbook/pb_text_input/text_input.rb
2026
2027
  - app/pb_kits/playbook/pb_text_input/text_input.test.js
2027
- - app/pb_kits/playbook/pb_textarea/_textarea.jsx
2028
2028
  - app/pb_kits/playbook/pb_textarea/_textarea.scss
2029
+ - app/pb_kits/playbook/pb_textarea/_textarea.tsx
2029
2030
  - app/pb_kits/playbook/pb_textarea/_textarea_mixin.scss
2030
2031
  - app/pb_kits/playbook/pb_textarea/docs/_description.md
2031
2032
  - app/pb_kits/playbook/pb_textarea/docs/_footer.md
@@ -2044,9 +2045,10 @@ files:
2044
2045
  - app/pb_kits/playbook/pb_textarea/docs/_textarea_resize.jsx
2045
2046
  - app/pb_kits/playbook/pb_textarea/docs/example.yml
2046
2047
  - app/pb_kits/playbook/pb_textarea/docs/index.js
2047
- - app/pb_kits/playbook/pb_textarea/index.js
2048
+ - app/pb_kits/playbook/pb_textarea/index.tsx
2048
2049
  - app/pb_kits/playbook/pb_textarea/textarea.html.erb
2049
2050
  - app/pb_kits/playbook/pb_textarea/textarea.rb
2051
+ - app/pb_kits/playbook/pb_textarea/textarea.test.js
2050
2052
  - app/pb_kits/playbook/pb_time/_time.scss
2051
2053
  - app/pb_kits/playbook/pb_time/_time.tsx
2052
2054
  - app/pb_kits/playbook/pb_time/docs/_description.md
@@ -1,41 +0,0 @@
1
- /* @flow */
2
- import React from 'react'
3
- import classnames from 'classnames'
4
- import { buildCss } from '../utilities/props'
5
- import { globalProps } from '../utilities/globalProps'
6
- type FlexItemPropTypes = {
7
- children: array<React.ReactNode> | React.ReactNode,
8
- fixedSize: string,
9
- grow: boolean,
10
- shrink: boolean,
11
- flex: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 'none',
12
- className: string,
13
- overflow?: "auto" | "hidden" | "initial" | "inherit" | "scroll" | "visible",
14
- order?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 'first' | 'none',
15
- alignSelf?: "start" | "end" | "center" | "stretch",
16
- displayFlex: boolean
17
- }
18
-
19
- const FlexItem = (props: FlexItemPropTypes) => {
20
- const { children, className, fixedSize, grow, overflow = null, shrink, flex = 'none', order = 'none', alignSelf = null, displayFlex } = props
21
- const growClass = grow === true ? 'grow' : ''
22
- const displayFlexClass = displayFlex === true ? `display_flex_${displayFlex}` : ''
23
- const flexClass = flex !== 'none' ? `flex_${flex}` : ''
24
- const overflowClass = overflow ? `overflow_${overflow}` : ''
25
- const shrinkClass = shrink === true ? 'shrink' : ''
26
- const alignSelfClass = alignSelf ? `align_self_${alignSelf}` : ''
27
- const fixedStyle =
28
- fixedSize !== undefined ? { flexBasis: `${fixedSize}` } : null
29
- const orderClass = order !== 'none' ? `order_${order}` : null
30
-
31
- return (
32
- <div
33
- className={classnames(buildCss('pb_flex_item_kit', growClass, shrinkClass, flexClass, displayFlexClass), overflowClass, orderClass, alignSelfClass, globalProps(props), className)}
34
- style={fixedStyle}
35
- >
36
- {children}
37
- </div>
38
- )
39
- }
40
-
41
- export default FlexItem
@@ -1,135 +0,0 @@
1
- /* @flow */
2
- /* eslint-disable react-hooks/rules-of-hooks */
3
-
4
- import React, { forwardRef, useEffect, useRef } from 'react'
5
- import classnames from 'classnames'
6
-
7
- import PbTextarea from './'
8
- import type { InputCallback } from '../types.js'
9
-
10
- import { globalProps } from '../utilities/globalProps'
11
-
12
- import Body from '../pb_body/_body'
13
- import Caption from '../pb_caption/_caption'
14
- import Flex from '../pb_flex/_flex'
15
- import FlexItem from '../pb_flex/_flex_item'
16
-
17
- type TextareaProps = {
18
- characterCount?: string,
19
- className?: string,
20
- children?: array<React.ReactChild>,
21
- disabled?: boolean,
22
- error?: string,
23
- id?: string,
24
- inline?: boolean,
25
- object?: string,
26
- method?: string,
27
- label?: string,
28
- maxCharacters?: string,
29
- placeholder?: string,
30
- value?: string,
31
- name?: string,
32
- required?: boolean,
33
- rows?: number,
34
- resize: 'none' | 'both' | 'horizontal' | 'vertical' | 'auto',
35
- onChange?: InputCallback<HTMLTextAreaElement>,
36
- }
37
-
38
- const Textarea = ({
39
- characterCount,
40
- className,
41
- children,
42
- disabled,
43
- inline = false,
44
- resize = 'none',
45
- error,
46
- label,
47
- maxCharacters,
48
- name,
49
- onChange = () => {},
50
- placeholder,
51
- required,
52
- rows = 4,
53
- value,
54
- ...props
55
- }: TextareaProps, ref: React.ElementRef<"textarea">) => {
56
- ref = ref || useRef(false)
57
- useEffect(() => {
58
- if (ref.current && resize === 'auto') {
59
- PbTextarea.addMatch(ref.current)
60
- }
61
- })
62
-
63
- const errorClass = error ? 'error' : null
64
- const inlineClass = inline ? 'inline' : ''
65
- const resizeClass = `resize_${resize}`
66
- const classes = classnames('pb_textarea_kit', errorClass, inlineClass, resizeClass, globalProps(props), className)
67
-
68
- const characterCounter = () => {
69
- return maxCharacters && characterCount ? `${checkIfZero(characterCount)} / ${maxCharacters}` : checkIfZero(characterCount)
70
- }
71
-
72
- const checkIfZero = (characterCount) => {
73
- return characterCount == 0 ? characterCount.toString() : characterCount
74
- }
75
-
76
- return (
77
- <div className={classes}>
78
- <Caption
79
- text={label}
80
- />
81
- <If condition={children}>
82
- {children}
83
- <Else />
84
- <textarea
85
- className="pb_textarea_kit"
86
- disabled={disabled}
87
- name={name}
88
- onChange={onChange}
89
- placeholder={placeholder}
90
- ref={ref}
91
- required={required}
92
- rows={rows}
93
- value={value}
94
- {...props}
95
- />
96
- <If condition={error}>
97
- <If condition={characterCount}>
98
- <Flex
99
- spacing="between"
100
- vertical="center"
101
- >
102
- <FlexItem>
103
- <Body
104
- margin="none"
105
- status="negative"
106
- text={error}
107
- />
108
- </FlexItem>
109
- <FlexItem>
110
- <Caption
111
- margin="none"
112
- size="xs"
113
- text={characterCounter()}
114
- />
115
- </FlexItem>
116
- </Flex>
117
- <Else />
118
- <Body
119
- status="negative"
120
- text={error}
121
- />
122
- </If>
123
- <Else />
124
- <Caption
125
- margin="none"
126
- size="xs"
127
- text={characterCounter()}
128
- />
129
- </If>
130
- </If>
131
- </div>
132
- )
133
- }
134
-
135
- export default forwardRef(Textarea)