playbook_ui 12.30.0.pre.alpha.PLAY906multilevelselectedidsprop902 → 12.30.1.pre.alpha.PLAY802responsivetitlekit909

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8d8c8cd4aa096608acbf4eed675c36c238baa86d159aaefbc0f757084a5a4a4
4
- data.tar.gz: 287dd12a2a579011dd57ae22d51ee874b1d3823647e3d95701a201507afb02e7
3
+ metadata.gz: 721bb127babde220f239ae7ba3a8fc3bbbff5c8078e6d58ed0fa3cebd33724db
4
+ data.tar.gz: c896e6c5fae4da4004ef5fa234ae930013d31a68b84f93cb3da36f9e31a1f21c
5
5
  SHA512:
6
- metadata.gz: 18f3b68f512177e50e2146c9018e52535928c142d69f3e54b2c368d7655d1c638c5432d2e23ade2f4de5c41862a349dbf6b8325cd4d7cd9515ea0ea2b242a6fe
7
- data.tar.gz: 2a44c4ecbf272b2ae90b49616048b8bbc6f7f641e0741dbdb26cfc92c5dce5b49724611c4b9aacb7f74017c89d1f891d2d54a148279322b80e54d455cb674738
6
+ metadata.gz: 65acd0c7af39e80e7157b87e2544216cce50c8ef582a002912d8f56d7a31ce802a543df41d5a31854649bddad6b9bb1def1d3e8eb088866252d4528d9a0926f5
7
+ data.tar.gz: d124637fac9f1a5601490420173f81909efcd40f3abeea66f9f2bcb7a1ef97f6211108ebf37cfe3974a6e9f1ed8f2c25cbbe5b1756b59a5ac4ff0ea81e50e813
@@ -28,7 +28,6 @@ type MultiLevelSelectProps = {
28
28
  returnAllSelected?: boolean
29
29
  treeData?: { [key: string]: string }[]
30
30
  onSelect?: (prop: { [key: string]: any }) => void
31
- selectedIds?: string[]
32
31
  } & GlobalProps
33
32
 
34
33
  const MultiLevelSelect = (props: MultiLevelSelectProps) => {
@@ -42,7 +41,6 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
42
41
  returnAllSelected = false,
43
42
  treeData,
44
43
  onSelect = () => {},
45
- selectedIds
46
44
  } = props
47
45
 
48
46
  const ariaProps = buildAriaProps(aria)
@@ -72,8 +70,8 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
72
70
 
73
71
 
74
72
  useEffect(() => {
75
- setFormattedData(addCheckedAndParentProperty(treeData, selectedIds))
76
- }, [treeData, selectedIds])
73
+ setFormattedData(addCheckedAndParentProperty(treeData))
74
+ }, [treeData])
77
75
 
78
76
  useEffect(() => {
79
77
  if (returnAllSelected) {
@@ -162,7 +160,6 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
162
160
  //function to map over data and add parent_id + depth property to each item
163
161
  const addCheckedAndParentProperty = (
164
162
  treeData: { [key: string]: any }[],
165
- selectedIds: string[],
166
163
  parent_id: string = null,
167
164
  depth: number = 0,
168
165
  ) => {
@@ -172,7 +169,6 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
172
169
  return treeData.map((item: { [key: string]: any } | any) => {
173
170
  const newItem = {
174
171
  ...item,
175
- checked: selectedIds && selectedIds.length && selectedIds.includes(item.id),
176
172
  parent_id,
177
173
  depth,
178
174
  }
@@ -183,7 +179,6 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
183
179
  : item.children
184
180
  newItem.children = addCheckedAndParentProperty(
185
181
  children,
186
- selectedIds,
187
182
  newItem.id,
188
183
  depth + 1
189
184
  )
@@ -9,8 +9,6 @@ module Playbook
9
9
  default: []
10
10
  prop :return_all_selected, type: Playbook::Props::Boolean,
11
11
  default: false
12
- prop :selected_ids, type: Playbook::Props::Array,
13
- default: []
14
12
  prop :input_display, type: Playbook::Props::Enum,
15
13
  values: %w[pills none],
16
14
  default: "pills"
@@ -26,7 +24,6 @@ module Playbook
26
24
  name: name,
27
25
  treeData: tree_data,
28
26
  returnAllSelected: return_all_selected,
29
- selectedIds: selected_ids,
30
27
  }
31
28
  end
32
29
  end
@@ -1,5 +1,6 @@
1
1
  @import "../tokens/titles";
2
2
  @import "../tokens/colors";
3
+ @import "../tokens/screen_sizes";
3
4
  @import './title_mixin';
4
5
 
5
6
  [class^=pb_title_kit]{
@@ -33,4 +34,21 @@
33
34
  &[class*=_thin] {
34
35
  @include pb_title_thin;
35
36
  }
37
+
38
+ @each $size, $size_value in $breakpoints_grid {
39
+ @each $title_size_value in [1, 2, 3, 4] {
40
+ $min_size: map-get($size_value, "min");
41
+ $max_size: map-get($size_value, "max");
42
+ &[class*=_#{$size}_#{$title_size_value}] {
43
+ @include break_on($min_size, $max_size) {
44
+ @if $title_size_value == 1 { @include pb_title_1; }
45
+ @else if $title_size_value == 2 { @include pb_title_2; }
46
+ @else if $title_size_value == 3 { @include pb_title_3; }
47
+ @else if $title_size_value == 4 { @include pb_title_4; }
48
+ @include title_colors;
49
+ @if $title_size_value != 4 { @include pb_title_bold; }
50
+ }
51
+ }
52
+ }
53
+ }
36
54
  }
@@ -3,6 +3,9 @@ import classnames from 'classnames'
3
3
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
4
4
  import { deprecatedProps, GlobalProps, globalProps } from '../utilities/globalProps'
5
5
 
6
+ type SizeType = 1 | 2 | 3 | 4 | "1" | "2" | "3" | "4"
7
+ type SizeResponsiveType = {[key: string]: SizeType}
8
+
6
9
  type TitleProps = {
7
10
  aria?: {[key: string]: string},
8
11
  bold?: boolean,
@@ -11,7 +14,7 @@ type TitleProps = {
11
14
  color?: "default" | "light" | "lighter" | "success" | "error" | "link",
12
15
  data?: {[key: string]: string},
13
16
  id?: string,
14
- size?: 1 | 2| 3| 4 | "1" | "2" | "3" | "4",
17
+ size?: SizeType | SizeResponsiveType,
15
18
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span",
16
19
  text?: string,
17
20
  variant?: null | "link",
@@ -36,9 +39,24 @@ const Title = (props: TitleProps): React.ReactElement => {
36
39
  const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
37
40
  const dataProps: {[key: string]: string | number} = buildDataProps(data)
38
41
  const getBold = bold ? '' : 'thin'
42
+ const isSizeNumberOrString = typeof size === "number" || typeof size === "string"
43
+
44
+ const buildResponsiveSizeCss = () => {
45
+ let css = ''
46
+
47
+ if (!isSizeNumberOrString) {
48
+ Object.entries(size).forEach((sizeObj) => {
49
+ css += `pb_title_kit_${sizeObj[0]}_${sizeObj[1]} `
50
+ })
51
+ }
52
+
53
+ return css.trim()
54
+ }
55
+
39
56
  const classes = classnames(
40
- buildCss('pb_title_kit', `size_${size}`, variant, color, getBold),
57
+ buildCss('pb_title_kit', isSizeNumberOrString ? `size_${size}` : "", variant, color, getBold),
41
58
  globalProps(props),
59
+ buildResponsiveSizeCss(),
42
60
  className
43
61
  )
44
62
  const Tag: React.ReactElement | any = `${tag}`
@@ -0,0 +1 @@
1
+ <%= pb_rails("title", props: { text: "Responsive Title", tag: "h1", size: {xs: 3, sm: 2, md: 1} }) %>
@@ -0,0 +1,16 @@
1
+ import React from 'react'
2
+ import Title from '../_title'
3
+
4
+ const TitleResponsive = (props) => {
5
+ return (
6
+ <>
7
+ <Title
8
+ size={{xs: "3", sm: "2", md: "1"}}
9
+ text="Responsive Title"
10
+ {...props}
11
+ />
12
+ </>
13
+ )
14
+ }
15
+
16
+ export default TitleResponsive
@@ -0,0 +1 @@
1
+ The `size` prop supports responsive sizes. To use them, pass an object to the size prop containing your size values relative to responsive break points (show code below). To test this here, resize your browser window to responsively change this Title's size.
@@ -3,8 +3,10 @@ examples:
3
3
  - title_default: Default UI
4
4
  - title_light_weight: Light Weight UI
5
5
  - title_colors: Colors
6
+ - title_responsive: Responsive
6
7
 
7
8
  react:
8
9
  - title_default: Default UI
9
10
  - title_light_weight: Light Weight UI
10
11
  - title_colors: Colors
12
+ - title_responsive: Responsive
@@ -1,3 +1,4 @@
1
1
  export { default as TitleDefault } from './_title_default.jsx'
2
2
  export { default as TitleLightWeight } from './_title_light_weight.jsx'
3
3
  export { default as TitleColors } from './_title_colors.jsx'
4
+ export { default as TitleResponsive } from './_title_responsive.jsx'
@@ -6,9 +6,7 @@ module Playbook
6
6
  prop :color, type: Playbook::Props::Enum,
7
7
  values: [nil, "default", "light", "lighter", "success", "error", "link"],
8
8
  default: nil
9
- prop :size, type: Playbook::Props::Enum,
10
- values: [1, 2, 3, 4],
11
- default: 3
9
+ prop :size, default: 3
12
10
  prop :tag, type: Playbook::Props::Enum,
13
11
  values: %w[h1 h2 h3 h4 h5 h6 p div span],
14
12
  default: "h3"
@@ -20,12 +18,31 @@ module Playbook
20
18
  prop :bold, type: Playbook::Props::Boolean, default: true
21
19
 
22
20
  def classname
23
- generate_classname("pb_title_kit", size, variant, color, is_bold)
21
+ if is_size_responsive
22
+ generate_classname("pb_title_kit", variant, color, is_bold) + generate_responsive_size_classname
23
+ else
24
+ generate_classname("pb_title_kit", size, variant, color, is_bold)
25
+ end
24
26
  end
25
27
 
26
28
  def is_bold
27
29
  bold ? nil : "thin"
28
30
  end
31
+
32
+ def is_size_responsive
33
+ try(:size).is_a?(::Hash)
34
+ end
35
+
36
+ def generate_responsive_size_classname
37
+ css = ""
38
+ if is_size_responsive
39
+ size.each do |key, value|
40
+ css += " pb_title_kit_#{key}_#{value}"
41
+ end
42
+ end
43
+
44
+ css unless css.blank?
45
+ end
29
46
  end
30
47
  end
31
48
  end
@@ -4,39 +4,52 @@ import { render, screen } from '../utilities/test-utils'
4
4
  import Title from './_title'
5
5
 
6
6
  test('returns namespaced class name', () => {
7
- render(
8
- <Title
9
- data={{ testid: 'primary-test' }}
10
- text="Test colors"
11
- />
12
- )
13
-
14
- const kit = screen.getByTestId('primary-test')
15
- expect(kit).toHaveClass('pb_title_kit_size_3')
7
+ render(
8
+ <Title
9
+ data={{ testid: 'primary-test' }}
10
+ text="Test colors"
11
+ />
12
+ )
13
+
14
+ const kit = screen.getByTestId('primary-test')
15
+ expect(kit).toHaveClass('pb_title_kit_size_3')
16
16
  })
17
17
 
18
18
  test('with thin font weight', () => {
19
- render(
20
- <Title
21
- bold={false}
22
- data={{ testid: 'primary-test' }}
23
- text="Test thin font weight"
24
- />
25
- )
26
-
27
- const kit = screen.getByTestId('primary-test')
28
- expect(kit).toHaveClass('pb_title_kit_size_3_thin')
19
+ render(
20
+ <Title
21
+ bold={false}
22
+ data={{ testid: 'primary-test' }}
23
+ text="Test thin font weight"
24
+ />
25
+ )
26
+
27
+ const kit = screen.getByTestId('primary-test')
28
+ expect(kit).toHaveClass('pb_title_kit_size_3_thin')
29
29
  })
30
30
 
31
31
  test('with colors', () => {
32
- render(
33
- <Title
34
- color="success"
35
- data={{ testid: 'primary-test' }}
36
- text="Test colors"
37
- />
38
- )
39
-
40
- const kit = screen.getByTestId('primary-test')
41
- expect(kit).toHaveClass('pb_title_kit_size_3_success')
32
+ render(
33
+ <Title
34
+ color="success"
35
+ data={{ testid: 'primary-test' }}
36
+ text="Test colors"
37
+ />
38
+ )
39
+
40
+ const kit = screen.getByTestId('primary-test')
41
+ expect(kit).toHaveClass('pb_title_kit_size_3_success')
42
+ })
43
+
44
+ test('with responsive title', () => {
45
+ render(
46
+ <Title
47
+ data={{ testid: 'primary-test' }}
48
+ size={{ xs: "3", sm: "2", md: "1" }}
49
+ text="Responsive Title"
50
+ />
51
+ )
52
+
53
+ const kit = screen.getByTestId('primary-test')
54
+ expect(kit).toHaveClass('pb_title_kit pb_title_kit_xs_3 pb_title_kit_sm_2 pb_title_kit_md_1')
42
55
  })