playbook_ui 11.11.0 → 11.12.1.pre.alpha.charts1
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/index.js +2 -1
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +145 -0
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +17 -1
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.html.erb +62 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.jsx +86 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.md +17 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_button/_button.scss +6 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +4 -4
- data/app/pb_kits/playbook/pb_button/docs/_button_default.jsx +18 -17
- data/app/pb_kits/playbook/pb_circle_chart/ChartsTypes.ts +2 -0
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +216 -0
- data/app/pb_kits/playbook/pb_circle_chart/circle_chart.html.erb +9 -21
- data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +23 -47
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.html.erb +86 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.jsx +114 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.md +17 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_dashboard/pbChartsColorsHelper.ts +16 -0
- data/app/pb_kits/playbook/pb_dashboard/{pbChartsDarkTheme.js → pbChartsDarkTheme.ts} +6 -21
- data/app/pb_kits/playbook/pb_dashboard/{pbChartsLightTheme.js → pbChartsLightTheme.ts} +6 -21
- data/app/pb_kits/playbook/pb_dashboard/themeTypes.ts +16 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +50 -50
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.jsx +1 -0
- data/app/pb_kits/playbook/pb_date_picker/plugins/timeSelect.ts +89 -89
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_time_selection_styles.scss +15 -0
- data/app/pb_kits/playbook/pb_dialog/_dialog.scss +30 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +28 -0
- data/app/pb_kits/playbook/pb_dialog/dialog.rb +7 -35
- data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +21 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +7 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_body.rb +13 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +13 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.rb +16 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +13 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +3 -20
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +12 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.md +3 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.html.erb +11 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.md +3 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.html.erb +29 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_gauge/_gauge.scss +4 -0
- data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +213 -0
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.html.erb +1 -1
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.jsx +8 -8
- data/app/pb_kits/playbook/pb_gauge/gauge.html.erb +1 -11
- data/app/pb_kits/playbook/pb_gauge/gauge.rb +3 -8
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +3 -1
- data/app/pb_kits/playbook/pb_icon/icon.rb +8 -1
- data/app/pb_kits/playbook/pb_icon/icon.test.js +155 -0
- data/app/pb_kits/playbook/pb_legend/{_legend.jsx → _legend.tsx} +6 -6
- data/app/pb_kits/playbook/pb_legend/legend.test.js +29 -0
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +148 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.html.erb +62 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.jsx +83 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.md +17 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +17 -1
- data/app/pb_kits/playbook/pb_radio/_radio.scss +1 -1
- data/app/pb_kits/playbook/pb_title/_title.scss +5 -0
- data/app/pb_kits/playbook/pb_title/_title.tsx +4 -1
- data/app/pb_kits/playbook/pb_title/docs/{_title_light.html.erb → _title_default.html.erb} +3 -3
- data/app/pb_kits/playbook/pb_title/docs/{_title_light.jsx → _title_default.jsx} +14 -14
- data/app/pb_kits/playbook/pb_title/docs/{_title_light.md → _title_default.md} +0 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.html.erb +1 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.jsx +19 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.md +4 -0
- data/app/pb_kits/playbook/pb_title/docs/example.yml +4 -2
- data/app/pb_kits/playbook/pb_title/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_title/title.rb +6 -1
- data/app/pb_kits/playbook/pb_title/title.test.js +13 -0
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +111 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +1 -1
- data/app/pb_kits/playbook/playbook-rails-react-bindings.js +4 -0
- data/app/pb_kits/playbook/playbook-rails.js +4 -4
- data/app/pb_kits/playbook/tokens/_titles.scss +10 -1
- data/app/pb_kits/playbook/tokens/_typography.scss +2 -2
- data/lib/playbook/version.rb +2 -2
- metadata +42 -17
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +0 -91
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +0 -136
- data/app/pb_kits/playbook/pb_dialog/_dialog.html.erb +0 -10
- data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +0 -112
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +0 -93
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +0 -79
- data/app/pb_kits/playbook/plugins/pb_chart.js +0 -309
@@ -0,0 +1,148 @@
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
import { globalProps } from "../utilities/globalProps";
|
4
|
+
import { buildAriaProps, buildDataProps } from "../utilities/props";
|
5
|
+
|
6
|
+
import HighchartsReact from "highcharts-react-official";
|
7
|
+
import Highcharts from "highcharts";
|
8
|
+
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
9
|
+
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
10
|
+
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
11
|
+
|
12
|
+
type LineGraphProps = {
|
13
|
+
align?: "left" | "right" | "center";
|
14
|
+
axisTitle?: string;
|
15
|
+
dark?: Boolean;
|
16
|
+
xAxisCategories: [];
|
17
|
+
yAxisMin: number;
|
18
|
+
yAxisMax: number;
|
19
|
+
className?: string;
|
20
|
+
chartData: {
|
21
|
+
name: string;
|
22
|
+
data: number[];
|
23
|
+
}[];
|
24
|
+
gradient?: boolean;
|
25
|
+
id: string;
|
26
|
+
pointStart: number;
|
27
|
+
subTitle?: string;
|
28
|
+
title: string;
|
29
|
+
type?: string;
|
30
|
+
legend?: boolean;
|
31
|
+
toggleLegendClick?: boolean;
|
32
|
+
height?: string;
|
33
|
+
colors: string[];
|
34
|
+
layout?: "horizontal" | "vertical" | "proximate";
|
35
|
+
verticalAlign?: "top" | "middle" | "bottom";
|
36
|
+
x?: number;
|
37
|
+
y?: number;
|
38
|
+
aria?: { [key: string]: string };
|
39
|
+
data?: { [key: string]: string };
|
40
|
+
};
|
41
|
+
|
42
|
+
const LineGraph = ({
|
43
|
+
aria = {},
|
44
|
+
data = {},
|
45
|
+
align = "center",
|
46
|
+
className = "pb_bar_graph",
|
47
|
+
dark = false,
|
48
|
+
gradient = false,
|
49
|
+
type = "line",
|
50
|
+
id,
|
51
|
+
legend = false,
|
52
|
+
toggleLegendClick = true,
|
53
|
+
layout = "horizontal",
|
54
|
+
verticalAlign = "bottom",
|
55
|
+
x = 0,
|
56
|
+
y = 0,
|
57
|
+
axisTitle,
|
58
|
+
xAxisCategories,
|
59
|
+
yAxisMin,
|
60
|
+
yAxisMax,
|
61
|
+
chartData,
|
62
|
+
pointStart,
|
63
|
+
subTitle,
|
64
|
+
title,
|
65
|
+
height,
|
66
|
+
colors = [],
|
67
|
+
...props
|
68
|
+
}: LineGraphProps) => {
|
69
|
+
const ariaProps = buildAriaProps(aria);
|
70
|
+
const dataProps = buildDataProps(data);
|
71
|
+
const setupTheme = () => {
|
72
|
+
dark
|
73
|
+
? Highcharts.setOptions(highchartsDarkTheme)
|
74
|
+
: Highcharts.setOptions(highchartsTheme);
|
75
|
+
};
|
76
|
+
setupTheme();
|
77
|
+
|
78
|
+
const staticOptions = {
|
79
|
+
title: {
|
80
|
+
text: title,
|
81
|
+
},
|
82
|
+
chart: {
|
83
|
+
height: height,
|
84
|
+
type: type,
|
85
|
+
},
|
86
|
+
subtitle: {
|
87
|
+
text: subTitle,
|
88
|
+
},
|
89
|
+
yAxis: {
|
90
|
+
min: yAxisMin,
|
91
|
+
max: yAxisMax,
|
92
|
+
title: {
|
93
|
+
text: axisTitle,
|
94
|
+
},
|
95
|
+
},
|
96
|
+
xAxis: {
|
97
|
+
categories: xAxisCategories,
|
98
|
+
},
|
99
|
+
legend: {
|
100
|
+
enabled: legend,
|
101
|
+
align: align,
|
102
|
+
verticalAlign: verticalAlign,
|
103
|
+
layout: layout,
|
104
|
+
x: x,
|
105
|
+
y: y,
|
106
|
+
},
|
107
|
+
colors:
|
108
|
+
colors !== undefined && colors.length > 0
|
109
|
+
? mapColors(colors)
|
110
|
+
: highchartsTheme.colors,
|
111
|
+
plotOptions: {
|
112
|
+
series: {
|
113
|
+
pointStart: pointStart,
|
114
|
+
events: {},
|
115
|
+
dataLabels: {
|
116
|
+
enabled: false,
|
117
|
+
},
|
118
|
+
},
|
119
|
+
},
|
120
|
+
series: chartData,
|
121
|
+
credits: false,
|
122
|
+
};
|
123
|
+
|
124
|
+
if (!toggleLegendClick) {
|
125
|
+
staticOptions.plotOptions.series.events = { legendItemClick: () => false };
|
126
|
+
}
|
127
|
+
|
128
|
+
const [options, setOptions] = useState({});
|
129
|
+
|
130
|
+
useEffect(() => {
|
131
|
+
setOptions({ ...staticOptions });
|
132
|
+
}, [chartData]);
|
133
|
+
|
134
|
+
return (
|
135
|
+
<HighchartsReact
|
136
|
+
containerProps={{
|
137
|
+
className: classnames(globalProps(props), className),
|
138
|
+
id: id,
|
139
|
+
...ariaProps,
|
140
|
+
...dataProps,
|
141
|
+
}}
|
142
|
+
highcharts={Highcharts}
|
143
|
+
options={options}
|
144
|
+
/>
|
145
|
+
);
|
146
|
+
};
|
147
|
+
|
148
|
+
export default LineGraph;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<% data = [{
|
2
|
+
name: 'Installation',
|
3
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
|
4
|
+
}, {
|
5
|
+
name: 'Manufacturing',
|
6
|
+
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]
|
7
|
+
}, {
|
8
|
+
name: 'Sales & Distribution',
|
9
|
+
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387]
|
10
|
+
}, {
|
11
|
+
name: 'Project Development',
|
12
|
+
data: [nil, nil, 7988, 12169, 15112, 22452, 34400, 34227]
|
13
|
+
}, {
|
14
|
+
name: 'Other',
|
15
|
+
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]
|
16
|
+
}] %>
|
17
|
+
|
18
|
+
<%= pb_rails("title", props: {size: 4, text: "align | vertical_align", padding_top: "sm", padding_bottom: "sm"})%>
|
19
|
+
|
20
|
+
<%= pb_rails("line_graph", props: {
|
21
|
+
id: "legend-position-line",
|
22
|
+
gradient: false,
|
23
|
+
chart_data: data,
|
24
|
+
x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug'],
|
25
|
+
title: 'Alignment of Legend',
|
26
|
+
axis_title: 'Number of Employees',
|
27
|
+
legend: true,
|
28
|
+
align: 'right',
|
29
|
+
vertical_align: 'top',
|
30
|
+
padding_bottom: "sm",
|
31
|
+
}) %>
|
32
|
+
|
33
|
+
<%= pb_rails("title", props: {size: 4, text: "layout", padding_top: "sm", padding_bottom: "sm"})%>
|
34
|
+
|
35
|
+
<%= pb_rails("line_graph", props: {
|
36
|
+
id: "legend-position-line-1",
|
37
|
+
gradient: false,
|
38
|
+
chart_data: data,
|
39
|
+
x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug'],
|
40
|
+
title: 'Layout of Legend',
|
41
|
+
axis_title: 'Number of Employees',
|
42
|
+
legend: true,
|
43
|
+
layout: 'vertical',
|
44
|
+
padding_top: "sm",
|
45
|
+
padding_bottom: "sm",
|
46
|
+
}) %>
|
47
|
+
|
48
|
+
<%= pb_rails("title", props: {size: 4, text: "x | y", padding_top: "sm", padding_bottom: "sm"})%>
|
49
|
+
|
50
|
+
<%= pb_rails("line_graph", props: {
|
51
|
+
id: "legend-position-line-2",
|
52
|
+
gradient: false,
|
53
|
+
chart_data: data,
|
54
|
+
x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug'],
|
55
|
+
title: 'Offset of Legend',
|
56
|
+
axis_title: 'Number of Employees',
|
57
|
+
legend: true,
|
58
|
+
layout: "vertical",
|
59
|
+
x: 100,
|
60
|
+
y: 10,
|
61
|
+
padding_top: "sm",
|
62
|
+
}) %>
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { LineGraph, Title } from '../..'
|
3
|
+
|
4
|
+
const data = [{
|
5
|
+
name: 'Installation',
|
6
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
7
|
+
}, {
|
8
|
+
name: 'Manufacturing',
|
9
|
+
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
|
10
|
+
}, {
|
11
|
+
name: 'Sales & Distribution',
|
12
|
+
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387],
|
13
|
+
}, {
|
14
|
+
name: 'Project Development',
|
15
|
+
data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227],
|
16
|
+
}, {
|
17
|
+
name: 'Other',
|
18
|
+
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111],
|
19
|
+
}]
|
20
|
+
|
21
|
+
const LineGraphLegendPosition = (props) => (
|
22
|
+
<div>
|
23
|
+
<Title
|
24
|
+
paddingBottom="sm"
|
25
|
+
paddingTop="sm"
|
26
|
+
size={4}
|
27
|
+
tag="h4"
|
28
|
+
text="align | verticalAlign"
|
29
|
+
/>
|
30
|
+
<LineGraph
|
31
|
+
align='right'
|
32
|
+
axisTitle="Number of Employees"
|
33
|
+
chartData={data}
|
34
|
+
id="legend-position-line"
|
35
|
+
legend
|
36
|
+
title="Alignment of Legend"
|
37
|
+
verticalAlign="top"
|
38
|
+
xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']}
|
39
|
+
yAxisMin={0}
|
40
|
+
{...props}
|
41
|
+
/>
|
42
|
+
<Title
|
43
|
+
paddingBottom="sm"
|
44
|
+
paddingTop="sm"
|
45
|
+
size={4}
|
46
|
+
tag="h4"
|
47
|
+
text="layout"
|
48
|
+
/>
|
49
|
+
<LineGraph
|
50
|
+
axisTitle="Number of Employees"
|
51
|
+
chartData={data}
|
52
|
+
id="legend-position-line-1"
|
53
|
+
layout="vertical"
|
54
|
+
legend
|
55
|
+
title="Layout of Legend"
|
56
|
+
xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']}
|
57
|
+
yAxisMin={0}
|
58
|
+
{...props}
|
59
|
+
/>
|
60
|
+
<Title
|
61
|
+
paddingBottom="sm"
|
62
|
+
paddingTop="sm"
|
63
|
+
size={4}
|
64
|
+
tag="h4"
|
65
|
+
text="x | y"
|
66
|
+
/>
|
67
|
+
<LineGraph
|
68
|
+
axisTitle="Number of Employees"
|
69
|
+
chartData={data}
|
70
|
+
id="legend-position-line-2"
|
71
|
+
layout="vertical"
|
72
|
+
legend
|
73
|
+
title="Offset of Legend"
|
74
|
+
x={100}
|
75
|
+
xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']}
|
76
|
+
y={10}
|
77
|
+
yAxisMin={0}
|
78
|
+
{...props}
|
79
|
+
/>
|
80
|
+
</div>
|
81
|
+
)
|
82
|
+
|
83
|
+
export default LineGraphLegendPosition
|
@@ -0,0 +1,17 @@
|
|
1
|
+
##### Prop
|
2
|
+
|
3
|
+
`align` **Type**: String | **Values**: left | center | right (defaults to center)
|
4
|
+
`verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults middle)
|
5
|
+
`layout` **Type**: String | **Values**: horizontal | vertical | proximate (defaults to horizontal)
|
6
|
+
`x` **Type**: Number (defaults to 0)
|
7
|
+
`y` **Type**: Number (defaults to 0)
|
8
|
+
|
9
|
+
-
|
10
|
+
|
11
|
+
- `layout` determines the position of the legend items
|
12
|
+
`layout: proximate` will place the legend items as close as possible to the graphs they're representing. It will also determine whether to place the legend above/below or on the side of the plot area, if the legend is in a corner.
|
13
|
+
|
14
|
+
- `x` offsets the legend relative to its horizontal alignmnet. Negative x moves it to the left, positive x moves it to the right
|
15
|
+
|
16
|
+
|
17
|
+
- `y` offsets the legend relative to its vertical alignmnet. Negative y moves it up, positive y moves it down.
|
@@ -3,6 +3,7 @@ examples:
|
|
3
3
|
rails:
|
4
4
|
- line_graph_default: Default
|
5
5
|
- line_graph_legend: Legend
|
6
|
+
- line_graph_legend_position: Legend Position
|
6
7
|
- line_graph_legend_nonclickable: Legend Nonclickable
|
7
8
|
- line_graph_height: Height
|
8
9
|
- line_graph_colors: Color Overrides
|
@@ -11,6 +12,7 @@ examples:
|
|
11
12
|
react:
|
12
13
|
- line_graph_default: Default
|
13
14
|
- line_graph_legend: Legend
|
15
|
+
- line_graph_legend_position: Legend Position
|
14
16
|
- line_graph_legend_nonclickable: Legend Nonclickable
|
15
17
|
- line_graph_height: Height
|
16
18
|
- line_graph_colors: Color Overrides
|
@@ -1,5 +1,6 @@
|
|
1
1
|
export { default as LineGraphDefault } from './_line_graph_default.jsx'
|
2
2
|
export { default as LineGraphLegend } from './_line_graph_legend.jsx'
|
3
|
+
export { default as LineGraphLegendPosition } from './_line_graph_legend_position.jsx'
|
3
4
|
export { default as LineGraphLegendNonclickable } from './_line_graph_legend_nonclickable.jsx'
|
4
5
|
export { default as LineGraphHeight } from './_line_graph_height.jsx'
|
5
6
|
export { default as LineGraphColors } from './_line_graph_colors.jsx'
|
@@ -3,6 +3,9 @@
|
|
3
3
|
module Playbook
|
4
4
|
module PbLineGraph
|
5
5
|
class LineGraph < Playbook::KitBase
|
6
|
+
prop :align, type: Playbook::Props::Enum,
|
7
|
+
values: %w[left right center],
|
8
|
+
default: "center"
|
6
9
|
prop :axis_title
|
7
10
|
prop :chart_data, type: Playbook::Props::Array,
|
8
11
|
default: []
|
@@ -22,6 +25,14 @@ module Playbook
|
|
22
25
|
prop :height
|
23
26
|
prop :colors, type: Playbook::Props::Array,
|
24
27
|
default: []
|
28
|
+
prop :layout, type: Playbook::Props::Enum,
|
29
|
+
values: %w[horizontal vertical proximate],
|
30
|
+
default: "horizontal"
|
31
|
+
prop :vertical_align, type: Playbook::Props::Enum,
|
32
|
+
values: %w[top middle bottom],
|
33
|
+
default: "bottom"
|
34
|
+
prop :x, type: Playbook::Props::Numeric
|
35
|
+
prop :y, type: Playbook::Props::Numeric
|
25
36
|
|
26
37
|
def chart_type
|
27
38
|
gradient ? "area" : "line"
|
@@ -29,13 +40,14 @@ module Playbook
|
|
29
40
|
|
30
41
|
def chart_options
|
31
42
|
{
|
43
|
+
align: align,
|
32
44
|
id: id,
|
33
45
|
className: classname,
|
34
46
|
chartData: chart_data,
|
35
47
|
dark: dark ? "dark" : "",
|
36
48
|
type: chart_type,
|
37
49
|
title: title,
|
38
|
-
|
50
|
+
subTitle: subtitle,
|
39
51
|
axisTitle: axis_title,
|
40
52
|
pointStart: point_start,
|
41
53
|
xAxisCategories: x_axis_categories,
|
@@ -45,6 +57,10 @@ module Playbook
|
|
45
57
|
toggleLegendClick: toggle_legend_click,
|
46
58
|
height: height,
|
47
59
|
colors: colors,
|
60
|
+
layout: layout,
|
61
|
+
verticalAlign: vertical_align,
|
62
|
+
x: x,
|
63
|
+
y: y,
|
48
64
|
}
|
49
65
|
end
|
50
66
|
|
@@ -5,6 +5,7 @@ import { deprecatedProps, GlobalProps, globalProps } from '../utilities/globalPr
|
|
5
5
|
|
6
6
|
type TitleProps = {
|
7
7
|
aria?: {[key: string]: string},
|
8
|
+
bold?: boolean,
|
8
9
|
children?: React.ReactChild[] | React.ReactChild,
|
9
10
|
className?: string,
|
10
11
|
color?: "default" | "light" | "lighter" | "success" | "error" | "link",
|
@@ -20,6 +21,7 @@ const Title = (props: TitleProps): React.ReactElement => {
|
|
20
21
|
if (props.variant) deprecatedProps('Title', ['variant']) //variant prop is deprecated, use color instead
|
21
22
|
const {
|
22
23
|
aria = {},
|
24
|
+
bold = true,
|
23
25
|
children,
|
24
26
|
className,
|
25
27
|
color,
|
@@ -33,8 +35,9 @@ const Title = (props: TitleProps): React.ReactElement => {
|
|
33
35
|
|
34
36
|
const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
|
35
37
|
const dataProps: {[key: string]: string | number} = buildDataProps(data)
|
38
|
+
const getBold = bold ? '' : 'thin'
|
36
39
|
const classes = classnames(
|
37
|
-
buildCss('pb_title_kit', `size_${size}`, variant, color),
|
40
|
+
buildCss('pb_title_kit', `size_${size}`, variant, color, getBold),
|
38
41
|
globalProps(props),
|
39
42
|
className,
|
40
43
|
)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<br/>
|
7
7
|
|
8
|
-
<%= pb_rails("title", props: { text: "Title 4", tag: "h4", size: 4 }) %>
|
9
|
-
<%= pb_rails("title", props: { text: "Title 3", tag: "h3", size: 3 }) %>
|
10
|
-
<%= pb_rails("title", props: { text: "Title 2", tag: "h2", size: 2 }) %>
|
11
8
|
<%= pb_rails("title", props: { text: "Title 1", tag: "h1", size: 1 }) %>
|
9
|
+
<%= pb_rails("title", props: { text: "Title 2", tag: "h2", size: 2 }) %>
|
10
|
+
<%= pb_rails("title", props: { text: "Title 3", tag: "h3", size: 3 }) %>
|
11
|
+
<%= pb_rails("title", props: { text: "Title 4", tag: "h4", size: 4 }) %>
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
2
2
|
|
3
3
|
import Title from '../_title'
|
4
4
|
|
5
|
-
const
|
5
|
+
const TitleDefault = (props) => {
|
6
6
|
return (
|
7
7
|
<div>
|
8
8
|
<Title
|
@@ -11,15 +11,9 @@ const TitleLight = (props) => {
|
|
11
11
|
/>
|
12
12
|
<br />
|
13
13
|
<Title
|
14
|
-
size={
|
15
|
-
tag="
|
16
|
-
text="Title
|
17
|
-
{...props}
|
18
|
-
/>
|
19
|
-
<Title
|
20
|
-
size={3}
|
21
|
-
tag="h3"
|
22
|
-
text="Title 3"
|
14
|
+
size={1}
|
15
|
+
tag="h1"
|
16
|
+
text="Title 1"
|
23
17
|
{...props}
|
24
18
|
/>
|
25
19
|
<Title
|
@@ -29,13 +23,19 @@ const TitleLight = (props) => {
|
|
29
23
|
{...props}
|
30
24
|
/>
|
31
25
|
<Title
|
32
|
-
size={
|
33
|
-
tag="
|
34
|
-
text="Title
|
26
|
+
size={3}
|
27
|
+
tag="h3"
|
28
|
+
text="Title 3"
|
29
|
+
{...props}
|
30
|
+
/>
|
31
|
+
<Title
|
32
|
+
size={4}
|
33
|
+
tag="h4"
|
34
|
+
text="Title 4"
|
35
35
|
{...props}
|
36
36
|
/>
|
37
37
|
</div>
|
38
38
|
)
|
39
39
|
}
|
40
40
|
|
41
|
-
export default
|
41
|
+
export default TitleDefault
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= pb_rails("title", props: { text: "Title 1", tag: "h1", size: 1, bold: false }) %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import Title from '../_title'
|
4
|
+
|
5
|
+
const TitleLightWeight = (props) => {
|
6
|
+
return (
|
7
|
+
<div>
|
8
|
+
<Title
|
9
|
+
bold={false}
|
10
|
+
size={1}
|
11
|
+
tag="h1"
|
12
|
+
text="Title 1"
|
13
|
+
{...props}
|
14
|
+
/>
|
15
|
+
</div>
|
16
|
+
)
|
17
|
+
}
|
18
|
+
|
19
|
+
export default TitleLightWeight
|
@@ -0,0 +1,4 @@
|
|
1
|
+
##### Prop
|
2
|
+
Title `size 1` will use `font-weight: 700` by default, if you want a lighter font weight, use the `bold` prop set to `false`.
|
3
|
+
Title `size 2` & `size 3` uses a light font weight by default and will not accept a bold font weight.
|
4
|
+
Title `size 4` uses a heavy font weight by default and will not accept a lighter font weight.
|
@@ -1,8 +1,10 @@
|
|
1
1
|
examples:
|
2
2
|
rails:
|
3
|
-
-
|
3
|
+
- title_default: Default UI
|
4
|
+
- title_light_weight: Light Weight UI
|
4
5
|
- title_colors: Colors
|
5
6
|
|
6
7
|
react:
|
7
|
-
-
|
8
|
+
- title_default: Default UI
|
9
|
+
- title_light_weight: Light Weight UI
|
8
10
|
- title_colors: Colors
|
@@ -17,9 +17,14 @@ module Playbook
|
|
17
17
|
values: [nil, "link"],
|
18
18
|
default: nil,
|
19
19
|
deprecated: true
|
20
|
+
prop :bold, type: Playbook::Props::Boolean, default: true
|
20
21
|
|
21
22
|
def classname
|
22
|
-
generate_classname("pb_title_kit", size, variant, color)
|
23
|
+
generate_classname("pb_title_kit", size, variant, color, is_bold)
|
24
|
+
end
|
25
|
+
|
26
|
+
def is_bold
|
27
|
+
bold ? nil : "thin"
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
@@ -15,6 +15,19 @@ test('returns namespaced class name', () => {
|
|
15
15
|
expect(kit).toHaveClass('pb_title_kit_size_3')
|
16
16
|
})
|
17
17
|
|
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')
|
29
|
+
})
|
30
|
+
|
18
31
|
test('with colors', () => {
|
19
32
|
render(
|
20
33
|
<Title
|