playbook_ui 12.30.1.pre.alpha.PLAY802responsivetitlekit909 → 12.30.1.pre.alpha.PLAY906multilevelselectedidsprop912
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +7 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +0 -18
- data/app/pb_kits/playbook/pb_title/_title.tsx +2 -20
- data/app/pb_kits/playbook/pb_title/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_title/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_title/title.rb +4 -21
- data/app/pb_kits/playbook/pb_title/title.test.js +29 -42
- data/dist/playbook-rails.js +2 -2
- data/lib/playbook/version.rb +1 -1
- metadata +1 -4
- data/app/pb_kits/playbook/pb_title/docs/_title_responsive.html.erb +0 -1
- data/app/pb_kits/playbook/pb_title/docs/_title_responsive.jsx +0 -16
- data/app/pb_kits/playbook/pb_title/docs/_title_responsive.md +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bb99bff289e00a7d9a4304de6118e54be2349a7d705bd69f07307940b277db5
|
4
|
+
data.tar.gz: 34b932013c8f26a6c25afe95e725fc4bac6f62b323e49e134ab0020a312107f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 245aac90b727280ef79d58a04569cc93f559d09b5ad2bd1350260c1eea9c4b02030de75e6ec7ff9a7d6751006c0c32bb7be946bc1ad813032d00a5ced8e240e0
|
7
|
+
data.tar.gz: af04cb501838d28a314d6de419fd6a5ca7782ce2f0973f80ba24ca048d82fdbad61041c56d43783f38ec1f77a6b7a56fd5b09eff85528ddab775557d6a0f2a9f
|
@@ -28,6 +28,7 @@ type MultiLevelSelectProps = {
|
|
28
28
|
returnAllSelected?: boolean
|
29
29
|
treeData?: { [key: string]: string }[]
|
30
30
|
onSelect?: (prop: { [key: string]: any }) => void
|
31
|
+
selectedIds?: string[]
|
31
32
|
} & GlobalProps
|
32
33
|
|
33
34
|
const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
@@ -41,6 +42,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
41
42
|
returnAllSelected = false,
|
42
43
|
treeData,
|
43
44
|
onSelect = () => {},
|
45
|
+
selectedIds
|
44
46
|
} = props
|
45
47
|
|
46
48
|
const ariaProps = buildAriaProps(aria)
|
@@ -70,8 +72,8 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
70
72
|
|
71
73
|
|
72
74
|
useEffect(() => {
|
73
|
-
setFormattedData(addCheckedAndParentProperty(treeData))
|
74
|
-
}, [treeData])
|
75
|
+
setFormattedData(addCheckedAndParentProperty(treeData, selectedIds))
|
76
|
+
}, [treeData, selectedIds])
|
75
77
|
|
76
78
|
useEffect(() => {
|
77
79
|
if (returnAllSelected) {
|
@@ -160,6 +162,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
160
162
|
//function to map over data and add parent_id + depth property to each item
|
161
163
|
const addCheckedAndParentProperty = (
|
162
164
|
treeData: { [key: string]: any }[],
|
165
|
+
selectedIds: string[],
|
163
166
|
parent_id: string = null,
|
164
167
|
depth: number = 0,
|
165
168
|
) => {
|
@@ -169,6 +172,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
169
172
|
return treeData.map((item: { [key: string]: any } | any) => {
|
170
173
|
const newItem = {
|
171
174
|
...item,
|
175
|
+
checked: selectedIds && selectedIds.length && selectedIds.includes(item.id),
|
172
176
|
parent_id,
|
173
177
|
depth,
|
174
178
|
}
|
@@ -179,6 +183,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
179
183
|
: item.children
|
180
184
|
newItem.children = addCheckedAndParentProperty(
|
181
185
|
children,
|
186
|
+
selectedIds,
|
182
187
|
newItem.id,
|
183
188
|
depth + 1
|
184
189
|
)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
@import "../tokens/titles";
|
2
2
|
@import "../tokens/colors";
|
3
|
-
@import "../tokens/screen_sizes";
|
4
3
|
@import './title_mixin';
|
5
4
|
|
6
5
|
[class^=pb_title_kit]{
|
@@ -34,21 +33,4 @@
|
|
34
33
|
&[class*=_thin] {
|
35
34
|
@include pb_title_thin;
|
36
35
|
}
|
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
|
-
}
|
54
36
|
}
|
@@ -3,9 +3,6 @@ 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
|
-
|
9
6
|
type TitleProps = {
|
10
7
|
aria?: {[key: string]: string},
|
11
8
|
bold?: boolean,
|
@@ -14,7 +11,7 @@ type TitleProps = {
|
|
14
11
|
color?: "default" | "light" | "lighter" | "success" | "error" | "link",
|
15
12
|
data?: {[key: string]: string},
|
16
13
|
id?: string,
|
17
|
-
size?:
|
14
|
+
size?: 1 | 2| 3| 4 | "1" | "2" | "3" | "4",
|
18
15
|
tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span",
|
19
16
|
text?: string,
|
20
17
|
variant?: null | "link",
|
@@ -39,24 +36,9 @@ const Title = (props: TitleProps): React.ReactElement => {
|
|
39
36
|
const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
|
40
37
|
const dataProps: {[key: string]: string | number} = buildDataProps(data)
|
41
38
|
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
|
-
|
56
39
|
const classes = classnames(
|
57
|
-
buildCss('pb_title_kit',
|
40
|
+
buildCss('pb_title_kit', `size_${size}`, variant, color, getBold),
|
58
41
|
globalProps(props),
|
59
|
-
buildResponsiveSizeCss(),
|
60
42
|
className
|
61
43
|
)
|
62
44
|
const Tag: React.ReactElement | any = `${tag}`
|
@@ -3,10 +3,8 @@ examples:
|
|
3
3
|
- title_default: Default UI
|
4
4
|
- title_light_weight: Light Weight UI
|
5
5
|
- title_colors: Colors
|
6
|
-
- title_responsive: Responsive
|
7
6
|
|
8
7
|
react:
|
9
8
|
- title_default: Default UI
|
10
9
|
- title_light_weight: Light Weight UI
|
11
10
|
- title_colors: Colors
|
12
|
-
- title_responsive: Responsive
|
@@ -6,7 +6,9 @@ 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,
|
9
|
+
prop :size, type: Playbook::Props::Enum,
|
10
|
+
values: [1, 2, 3, 4],
|
11
|
+
default: 3
|
10
12
|
prop :tag, type: Playbook::Props::Enum,
|
11
13
|
values: %w[h1 h2 h3 h4 h5 h6 p div span],
|
12
14
|
default: "h3"
|
@@ -18,31 +20,12 @@ module Playbook
|
|
18
20
|
prop :bold, type: Playbook::Props::Boolean, default: true
|
19
21
|
|
20
22
|
def classname
|
21
|
-
|
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
|
23
|
+
generate_classname("pb_title_kit", size, variant, color, is_bold)
|
26
24
|
end
|
27
25
|
|
28
26
|
def is_bold
|
29
27
|
bold ? nil : "thin"
|
30
28
|
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
|
46
29
|
end
|
47
30
|
end
|
48
31
|
end
|
@@ -4,52 +4,39 @@ import { render, screen } from '../utilities/test-utils'
|
|
4
4
|
import Title from './_title'
|
5
5
|
|
6
6
|
test('returns namespaced class name', () => {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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')
|
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')
|
55
42
|
})
|