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.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/index.js +2 -1
  3. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +145 -0
  4. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +17 -1
  5. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.html.erb +62 -0
  6. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.jsx +86 -0
  7. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.md +17 -0
  8. data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +2 -0
  9. data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
  10. data/app/pb_kits/playbook/pb_button/_button.scss +6 -0
  11. data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +4 -4
  12. data/app/pb_kits/playbook/pb_button/docs/_button_default.jsx +18 -17
  13. data/app/pb_kits/playbook/pb_circle_chart/ChartsTypes.ts +2 -0
  14. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +216 -0
  15. data/app/pb_kits/playbook/pb_circle_chart/circle_chart.html.erb +9 -21
  16. data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +23 -47
  17. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.html.erb +86 -0
  18. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.jsx +114 -0
  19. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.md +17 -0
  20. data/app/pb_kits/playbook/pb_circle_chart/docs/example.yml +2 -0
  21. data/app/pb_kits/playbook/pb_circle_chart/docs/index.js +1 -0
  22. data/app/pb_kits/playbook/pb_dashboard/pbChartsColorsHelper.ts +16 -0
  23. data/app/pb_kits/playbook/pb_dashboard/{pbChartsDarkTheme.js → pbChartsDarkTheme.ts} +6 -21
  24. data/app/pb_kits/playbook/pb_dashboard/{pbChartsLightTheme.js → pbChartsLightTheme.ts} +6 -21
  25. data/app/pb_kits/playbook/pb_dashboard/themeTypes.ts +16 -0
  26. data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +50 -50
  27. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.jsx +1 -0
  28. data/app/pb_kits/playbook/pb_date_picker/plugins/timeSelect.ts +89 -89
  29. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_time_selection_styles.scss +15 -0
  30. data/app/pb_kits/playbook/pb_dialog/_dialog.scss +30 -1
  31. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +28 -0
  32. data/app/pb_kits/playbook/pb_dialog/dialog.rb +7 -35
  33. data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +21 -0
  34. data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +7 -0
  35. data/app/pb_kits/playbook/pb_dialog/dialog_body.rb +13 -0
  36. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +13 -0
  37. data/app/pb_kits/playbook/pb_dialog/dialog_footer.rb +16 -0
  38. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +13 -0
  39. data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +3 -20
  40. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +12 -0
  41. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.md +3 -1
  42. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.html.erb +11 -0
  43. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.md +3 -0
  44. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.html.erb +29 -0
  45. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +3 -0
  46. data/app/pb_kits/playbook/pb_gauge/_gauge.scss +4 -0
  47. data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +213 -0
  48. data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.html.erb +1 -1
  49. data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.jsx +8 -8
  50. data/app/pb_kits/playbook/pb_gauge/gauge.html.erb +1 -11
  51. data/app/pb_kits/playbook/pb_gauge/gauge.rb +3 -8
  52. data/app/pb_kits/playbook/pb_icon/_icon.tsx +3 -1
  53. data/app/pb_kits/playbook/pb_icon/icon.rb +8 -1
  54. data/app/pb_kits/playbook/pb_icon/icon.test.js +155 -0
  55. data/app/pb_kits/playbook/pb_legend/{_legend.jsx → _legend.tsx} +6 -6
  56. data/app/pb_kits/playbook/pb_legend/legend.test.js +29 -0
  57. data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +148 -0
  58. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.html.erb +62 -0
  59. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.jsx +83 -0
  60. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.md +17 -0
  61. data/app/pb_kits/playbook/pb_line_graph/docs/example.yml +2 -0
  62. data/app/pb_kits/playbook/pb_line_graph/docs/index.js +1 -0
  63. data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +17 -1
  64. data/app/pb_kits/playbook/pb_radio/_radio.scss +1 -1
  65. data/app/pb_kits/playbook/pb_title/_title.scss +5 -0
  66. data/app/pb_kits/playbook/pb_title/_title.tsx +4 -1
  67. data/app/pb_kits/playbook/pb_title/docs/{_title_light.html.erb → _title_default.html.erb} +3 -3
  68. data/app/pb_kits/playbook/pb_title/docs/{_title_light.jsx → _title_default.jsx} +14 -14
  69. data/app/pb_kits/playbook/pb_title/docs/{_title_light.md → _title_default.md} +0 -0
  70. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.html.erb +1 -0
  71. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.jsx +19 -0
  72. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.md +4 -0
  73. data/app/pb_kits/playbook/pb_title/docs/example.yml +4 -2
  74. data/app/pb_kits/playbook/pb_title/docs/index.js +2 -1
  75. data/app/pb_kits/playbook/pb_title/title.rb +6 -1
  76. data/app/pb_kits/playbook/pb_title/title.test.js +13 -0
  77. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +111 -0
  78. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +1 -1
  79. data/app/pb_kits/playbook/playbook-rails-react-bindings.js +4 -0
  80. data/app/pb_kits/playbook/playbook-rails.js +4 -4
  81. data/app/pb_kits/playbook/tokens/_titles.scss +10 -1
  82. data/app/pb_kits/playbook/tokens/_typography.scss +2 -2
  83. data/lib/playbook/version.rb +2 -2
  84. metadata +42 -17
  85. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +0 -91
  86. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +0 -136
  87. data/app/pb_kits/playbook/pb_dialog/_dialog.html.erb +0 -10
  88. data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +0 -112
  89. data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +0 -93
  90. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +0 -79
  91. data/app/pb_kits/playbook/plugins/pb_chart.js +0 -309
@@ -1,9 +1,11 @@
1
1
  import colors from '../tokens/exports/_colors.scss'
2
2
  import typography from '../tokens/exports/_typography.scss'
3
3
 
4
+ import { ThemeProps } from './themeTypes'
5
+
4
6
  import Highcharts from 'highcharts'
5
7
 
6
- const highchartsTheme = {
8
+ const highchartsTheme: ThemeProps = {
7
9
  lang: {
8
10
  thousandsSep: ',',
9
11
  },
@@ -150,26 +152,6 @@ const highchartsTheme = {
150
152
  },
151
153
  threshold: null,
152
154
  },
153
-
154
- // GAUGE STYLES
155
- solidgauge: {
156
- borderColor: colors.primary,
157
- borderWidth: 20,
158
- radius: 90,
159
- innerRadius: '90%',
160
- dataLabels: {
161
- borderWidth: 0,
162
- color: colors.text_lt_default,
163
- enabled: true,
164
- style: {
165
- fontFamily: typography.font_family_base,
166
- fontWeight: typography.regular,
167
- fontSize: typography.heading_2,
168
- },
169
- y: -26,
170
- },
171
- },
172
-
173
155
  // PIE STYLES
174
156
  pie: {
175
157
  colors: [
@@ -247,6 +229,9 @@ const highchartsTheme = {
247
229
  }
248
230
  },
249
231
  },
232
+ credits: {
233
+ enabled: false
234
+ },
250
235
  }
251
236
 
252
237
  export { highchartsTheme }
@@ -0,0 +1,16 @@
1
+ export type ThemeProps = {
2
+ lang?: {[key: string]: string}
3
+ credits?: {[key: string]: boolean}
4
+ colors?: string[]
5
+ chart?: {[key: string]: any}
6
+ title?: {[key: string]: string | {}}
7
+ subtitle?: {[key: string]: string | {};}
8
+ xAxis?: {[key: string]: any;}
9
+ yAxis?: {[key: string]: any;}
10
+ legend?: {[key: string]: string | {};}
11
+ labels?: {[key: string]: {};}
12
+ tooltip?: {[key: string]: any;}
13
+ pane?: {[key: string]: {};}
14
+ plotOptions?: {[key: string]: any;}
15
+ colorKey?: string
16
+ }
@@ -108,54 +108,54 @@ describe('DatePicker Kit', () => {
108
108
  })
109
109
  })
110
110
 
111
- test('shows DatePicker meridiem toggle', async () => {
112
- const testId = 'datepicker-meridiem'
113
- render(
114
- <DatePicker
115
- data={{ testid: testId }}
116
- defaultDate={DEFAULT_DATE}
117
- enableTime
118
- pickerId="date-picker-meridiem"
119
- />
120
- )
121
-
122
- const kit = screen.getByTestId(testId)
123
- const input = within(kit).getByPlaceholderText('Select Date')
124
-
125
- fireEvent(
126
- input,
127
- new MouseEvent('click', {
128
- bubbles: true,
129
- cancelable: true,
130
- }),
131
- )
132
- const meridiemToggleAM = within(kit).getByLabelText('AM')
133
- const meridiemTogglePM = within(kit).getByLabelText('PM')
134
- await waitFor(() => {
135
- expect(meridiemToggleAM).toBeInTheDocument()
136
- expect(meridiemTogglePM).toBeInTheDocument()
137
- })
138
-
139
- fireEvent(
140
- meridiemToggleAM,
141
- new MouseEvent('click', {
142
- bubbles: true,
143
- cancelable: true,
144
- }),
145
- )
146
- await waitFor(() => {
147
- expect(input).toHaveValue('01/01/2020 at 12:00 AM')
148
- })
149
-
150
- fireEvent(
151
- meridiemTogglePM,
152
- new MouseEvent('click', {
153
- bubbles: true,
154
- cancelable: true,
155
- }),
156
- )
157
- await waitFor(() => {
158
- expect(input).toHaveValue('01/01/2020 at 12:00 PM')
159
- })
160
- })
111
+ // test('shows DatePicker meridiem toggle', async () => {
112
+ // const testId = 'datepicker-meridiem'
113
+ // render(
114
+ // <DatePicker
115
+ // data={{ testid: testId }}
116
+ // defaultDate={DEFAULT_DATE}
117
+ // enableTime
118
+ // pickerId="date-picker-meridiem"
119
+ // />
120
+ // )
121
+
122
+ // const kit = screen.getByTestId(testId)
123
+ // const input = within(kit).getByPlaceholderText('Select Date')
124
+
125
+ // fireEvent(
126
+ // input,
127
+ // new MouseEvent('click', {
128
+ // bubbles: true,
129
+ // cancelable: true,
130
+ // }),
131
+ // )
132
+ // const meridiemToggleAM = within(kit).getByLabelText('AM')
133
+ // const meridiemTogglePM = within(kit).getByLabelText('PM')
134
+ // await waitFor(() => {
135
+ // expect(meridiemToggleAM).toBeInTheDocument()
136
+ // expect(meridiemTogglePM).toBeInTheDocument()
137
+ // })
138
+
139
+ // fireEvent(
140
+ // meridiemToggleAM,
141
+ // new MouseEvent('click', {
142
+ // bubbles: true,
143
+ // cancelable: true,
144
+ // }),
145
+ // )
146
+ // await waitFor(() => {
147
+ // expect(input).toHaveValue('01/01/2020 at 12:00 AM')
148
+ // })
149
+
150
+ // fireEvent(
151
+ // meridiemTogglePM,
152
+ // new MouseEvent('click', {
153
+ // bubbles: true,
154
+ // cancelable: true,
155
+ // }),
156
+ // )
157
+ // await waitFor(() => {
158
+ // expect(input).toHaveValue('01/01/2020 at 12:00 PM')
159
+ // })
160
+ // })
161
161
  })
@@ -15,6 +15,7 @@ const DatePickerTime = (props) => (
15
15
  showTimezone
16
16
  {...props}
17
17
  />
18
+
18
19
  </div>
19
20
  )
20
21
 
@@ -41,96 +41,96 @@ export const getTimezoneText = (inputDate: {
41
41
 
42
42
  function timeSelectPlugin(props: { caption: string; showTimezone: boolean }) {
43
43
  return function (fp: FpTypes) {
44
- const generateMeridiemCard = (text: string) => {
45
- const selectableCard = document.createElement("div");
46
- selectableCard.className = "pb_selectable_card_kit_enabled";
47
-
48
- const cardInput = document.createElement("input"),
49
- cardInputId = `datePicker${text}`;
50
-
51
- cardInput.id = cardInputId;
52
- cardInput.name = "datepicker-ampm";
53
- cardInput.type = "radio";
54
- cardInput.value = text;
55
-
56
- const cardLabel = document.createElement("label"),
57
- cardLabelBuffer = document.createElement("div");
58
- cardLabel.className = `label-${text.toLowerCase()}`;
59
- cardLabel.setAttribute("for", cardInputId);
60
- cardLabelBuffer.className = "buffer";
61
- cardLabelBuffer.innerHTML = text;
62
-
63
- cardLabel.append(cardLabelBuffer);
64
- selectableCard.prepend(cardInput);
65
- selectableCard.append(cardLabel);
66
-
67
- return selectableCard;
68
- };
69
-
70
- const generateMeridiemToggle = () => {
71
- fp.amPM.style.display = "none";
72
- const formGroupKit = document.createElement("div");
73
- formGroupKit.className = "pb_form_group_kit";
74
-
75
- const amCard = generateMeridiemCard("AM");
76
- amCard.addEventListener("click", () => {
77
- fp.selectedDates[0].setHours(
78
- (fp.selectedDates[0].getHours() % 12) + 12 * 0
79
- );
80
- fp.setDate(fp.selectedDates[0], true);
81
- });
82
-
83
- const pmCard = generateMeridiemCard("PM");
84
- pmCard.addEventListener("click", () => {
85
- fp.selectedDates[0].setHours(
86
- (fp.selectedDates[0].getHours() % 12) + 12 * 1
87
- );
88
- fp.setDate(fp.selectedDates[0], true);
89
- });
90
-
91
- formGroupKit.prepend(amCard);
92
- formGroupKit.append(pmCard);
93
-
94
- const meridiemContainer = document.createElement("div");
95
- meridiemContainer.className = "meridiem";
96
- meridiemContainer.append(formGroupKit);
97
- document.querySelector(".pb_time_selection").append(meridiemContainer);
98
- };
99
-
100
- const getMeridiem = (dateObj: string | any[]) => {
101
- return dateObj[0].getHours() < 12 ? "AM" : "PM";
102
- };
103
-
104
- const updateMeridiemToggle = (forceClick: boolean) => {
105
- if (!fp.selectedDates.length) return;
106
-
107
- const uncheckedClass = "pb_selectable_card_kit_enabled",
108
- checkedClass = "pb_selectable_card_kit_checked_enabled",
109
- pickerAM: HTMLElement & { [x: string]: any } =
110
- document.getElementById("datePickerAM"),
111
- pickerPM: HTMLElement & { [x: string]: any } =
112
- document.getElementById("datePickerPM"),
113
- meridiem = getMeridiem(fp.selectedDates);
114
-
115
- if (forceClick) {
116
- pickerAM.checked = false;
117
- pickerPM.checked = false;
118
- pickerPM.checked = meridiem === "PM";
119
- pickerAM.checked = meridiem === "AM";
120
- }
121
-
122
- if (meridiem === "PM") {
123
- pickerPM.parentElement.className = checkedClass;
124
- pickerAM.parentElement.className = uncheckedClass;
125
- } else if (meridiem === "AM") {
126
- pickerAM.parentElement.className = checkedClass;
127
- pickerPM.parentElement.className = uncheckedClass;
128
- }
129
- };
44
+ // const generateMeridiemCard = (text: string) => {
45
+ // const selectableCard = document.createElement("div");
46
+ // selectableCard.className = "pb_selectable_card_kit_enabled";
47
+
48
+ // const cardInput = document.createElement("input"),
49
+ // cardInputId = `datePicker${text}`;
50
+
51
+ // cardInput.id = cardInputId;
52
+ // cardInput.name = "datepicker-ampm";
53
+ // cardInput.type = "radio";
54
+ // cardInput.value = text;
55
+
56
+ // const cardLabel = document.createElement("label"),
57
+ // cardLabelBuffer = document.createElement("div");
58
+ // cardLabel.className = `label-${text.toLowerCase()}`;
59
+ // cardLabel.setAttribute("for", cardInputId);
60
+ // cardLabelBuffer.className = "buffer";
61
+ // cardLabelBuffer.innerHTML = text;
62
+
63
+ // cardLabel.append(cardLabelBuffer);
64
+ // selectableCard.prepend(cardInput);
65
+ // selectableCard.append(cardLabel);
66
+
67
+ // return selectableCard;
68
+ // };
69
+
70
+ // const generateMeridiemToggle = () => {
71
+ // fp.amPM.style.display = "none";
72
+ // const formGroupKit = document.createElement("div");
73
+ // formGroupKit.className = "pb_form_group_kit";
74
+
75
+ // const amCard = generateMeridiemCard("AM");
76
+ // amCard.addEventListener("click", () => {
77
+ // fp.selectedDates[0].setHours(
78
+ // (fp.selectedDates[0].getHours() % 12) + 12 * 0
79
+ // );
80
+ // fp.setDate(fp.selectedDates[0], true);
81
+ // });
82
+
83
+ // const pmCard = generateMeridiemCard("PM");
84
+ // pmCard.addEventListener("click", () => {
85
+ // fp.selectedDates[0].setHours(
86
+ // (fp.selectedDates[0].getHours() % 12) + 12 * 1
87
+ // );
88
+ // fp.setDate(fp.selectedDates[0], true);
89
+ // });
90
+
91
+ // formGroupKit.prepend(amCard);
92
+ // formGroupKit.append(pmCard);
93
+
94
+ // const meridiemContainer = document.createElement("div");
95
+ // meridiemContainer.className = "meridiem";
96
+ // meridiemContainer.append(formGroupKit);
97
+ // document.querySelector(".pb_time_selection").append(meridiemContainer);
98
+ // };
99
+
100
+ // const getMeridiem = (dateObj: string | any[]) => {
101
+ // return dateObj[0].getHours() < 12 ? "AM" : "PM";
102
+ // };
103
+
104
+ // const updateMeridiemToggle = (forceClick: boolean) => {
105
+ // if (!fp.selectedDates.length) return;
106
+
107
+ // const uncheckedClass = "pb_selectable_card_kit_enabled",
108
+ // checkedClass = "pb_selectable_card_kit_checked_enabled",
109
+ // pickerAM: HTMLElement & { [x: string]: any } =
110
+ // document.getElementById("datePickerAM"),
111
+ // pickerPM: HTMLElement & { [x: string]: any } =
112
+ // document.getElementById("datePickerPM"),
113
+ // meridiem = getMeridiem(fp.selectedDates);
114
+
115
+ // if (forceClick) {
116
+ // pickerAM.checked = false;
117
+ // pickerPM.checked = false;
118
+ // pickerPM.checked = meridiem === "PM";
119
+ // pickerAM.checked = meridiem === "AM";
120
+ // }
121
+
122
+ // if (meridiem === "PM") {
123
+ // pickerPM.parentElement.className = checkedClass;
124
+ // pickerAM.parentElement.className = uncheckedClass;
125
+ // } else if (meridiem === "AM") {
126
+ // pickerAM.parentElement.className = checkedClass;
127
+ // pickerPM.parentElement.className = uncheckedClass;
128
+ // }
129
+ // };
130
130
 
131
131
  return {
132
132
  onValueUpdate() {
133
- updateMeridiemToggle(true);
133
+ // updateMeridiemToggle(true);
134
134
  },
135
135
  onReady() {
136
136
  const id = fp.input.id;
@@ -151,8 +151,8 @@ function timeSelectPlugin(props: { caption: string; showTimezone: boolean }) {
151
151
  }
152
152
 
153
153
  // add meridiem toggle
154
- generateMeridiemToggle();
155
- updateMeridiemToggle(true);
154
+ // generateMeridiemToggle();
155
+ // updateMeridiemToggle(true);
156
156
 
157
157
  // add timezone text
158
158
  if (props.showTimezone) {
@@ -7,6 +7,21 @@
7
7
  color: inherit;
8
8
  text-align: left;
9
9
  margin-left: $space_sm;
10
+
11
+ span.flatpickr-am-pm {
12
+ margin-left: $space_sm;
13
+ border-radius: 5px;
14
+ color: $primary;
15
+ &:hover{
16
+ background-color: rgba($primary, 0.03);
17
+ }
18
+ &:focus{
19
+ background-color: unset;
20
+ &:hover{
21
+ background-color: rgba($primary, 0.03);
22
+ }
23
+ }
24
+ }
10
25
  .numInputWrapper {
11
26
  width: auto;
12
27
  input.numInput {
@@ -68,7 +68,7 @@
68
68
  $opacity_visible: 1;
69
69
  $opacity_hidden: 0;
70
70
 
71
- @include pb_card;
71
+ // @include pb_card;
72
72
  background-color: $white;
73
73
  box-shadow: $shadow_deepest;
74
74
  border: 0;
@@ -167,4 +167,33 @@
167
167
  }
168
168
  }
169
169
  }
170
+
171
+ .dialog-button-class {
172
+ background-color: unset;
173
+ border: none;
174
+ cursor: pointer;
175
+ }
176
+
177
+ }
178
+
179
+ .pb_dialog_wrapper_rails {
180
+ .pb_dialog_rails {
181
+ top: 0 !important;
182
+ padding: unset !important;
183
+ margin: auto;
184
+
185
+ }
186
+ dialog::backdrop {
187
+ position: fixed;
188
+ top: 0;
189
+ left: 0;
190
+ right: 0;
191
+ bottom: 0;
192
+ display: flex;
193
+ align-items: center;
194
+ justify-content: center;
195
+ background-color: rgba($bg_dark, $opacity_4);
196
+ animation-name: overlayFade;
197
+ animation-duration: 0.2s;
198
+ }
170
199
  }
@@ -0,0 +1,28 @@
1
+ <div class="pb_dialog_wrapper_rails">
2
+ <%= content_tag(:dialog,
3
+ aria: object.aria,
4
+ data: object.data,
5
+ id: object.id,
6
+ class: object.classname) do %>
7
+ <% if object.title %>
8
+ <%= pb_rails("dialog/dialog_header", props: {title: object.title, id: object.id }) %>
9
+ <% end %>
10
+ <% if object.text %>
11
+ <%= pb_rails("dialog/dialog_body", props: { text: object.text }) %>
12
+ <% end %>
13
+ <% if object.cancel_button && object.confirm_button %>
14
+ <%= pb_rails("dialog/dialog_footer", props: {
15
+ cancel_button: object.cancel_button,
16
+ confirm_button: object.confirm_button,
17
+ id: object.id
18
+ }) %>
19
+ <% end %>
20
+ <%= content %>
21
+ <% end %>
22
+ </div>
23
+
24
+ <%= javascript_tag do %>
25
+ window.addEventListener("DOMContentLoaded", () => {
26
+ dialogHelper()
27
+ })
28
+ <% end %>
@@ -2,45 +2,17 @@
2
2
 
3
3
  module Playbook
4
4
  module PbDialog
5
- class Dialog
6
- include Playbook::Props
7
-
8
- partial "pb_dialog/dialog"
9
-
10
- prop :ref
11
- prop :cancel_button
12
- prop :closeable, type: Playbook::Props::Boolean, default: true
13
- prop :confirm_button
14
- prop :oncancel
15
- prop :onchange
16
- prop :onclose
17
- prop :onconfirm
18
- prop :opened, type: Playbook::Props::Boolean, default: false
5
+ class Dialog < Playbook::KitBase
19
6
  prop :size, type: Playbook::Props::Enum,
20
- values: %w[sm md lg content],
7
+ values: %w[sm md lg xl status_size content],
21
8
  default: "md"
22
- prop :text
23
9
  prop :title
24
- prop :trigger
10
+ prop :text
11
+ prop :confirm_button
12
+ prop :cancel_button
25
13
 
26
- def dialog_options
27
- {
28
- id: id,
29
- ref: ref,
30
- trigger: trigger,
31
- className: classname,
32
- cancelButton: cancel_button,
33
- closeable: closeable,
34
- confirmButton: confirm_button,
35
- onCancel: oncancel,
36
- onChange: onchange,
37
- onClose: onclose,
38
- onConfirm: onconfirm,
39
- opened: opened,
40
- size: size,
41
- text: text,
42
- title: title,
43
- }
14
+ def classname
15
+ generate_classname("pb_dialog pb_dialog_rails pb_dialog_#{size}")
44
16
  end
45
17
  end
46
18
  end
@@ -0,0 +1,21 @@
1
+ const dialogHelper = () => {
2
+ const openTrigger = document.querySelectorAll("[data-open-dialog]");
3
+ const closeTrigger = document.querySelectorAll("[data-close-dialog]");
4
+
5
+ openTrigger.forEach((open) => {
6
+ open.addEventListener("click", () => {
7
+ var openTriggerData = open.dataset.openDialog;
8
+ if (document.getElementById(openTriggerData).open) return;
9
+ document.getElementById(openTriggerData).showModal();
10
+ });
11
+ });
12
+
13
+ closeTrigger.forEach((close) => {
14
+ close.addEventListener("click", () => {
15
+ var closeTriggerData = close.dataset.closeDialog;
16
+ document.getElementById(closeTriggerData).close();
17
+ });
18
+ });
19
+ };
20
+
21
+ export default dialogHelper;
@@ -0,0 +1,7 @@
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ aria: object.aria) do %>
6
+ <%= content.presence || object.text %>
7
+ <% end %>
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbDialog
5
+ class DialogBody < Playbook::KitBase
6
+ prop :text
7
+
8
+ def classname
9
+ generate_classname("dialog_body p_sm")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ aria: object.aria) do %>
5
+ <%= pb_rails("flex", props: { classname:object.classname, spacing:"between", padding_x:"sm", padding:"sm", padding_bottom:"sm" }) do %>
6
+ <%= pb_rails("button", props: { type: "submit", id: object.confirm_button_id }) do %>
7
+ <%= object.confirm_button %>
8
+ <% end %>
9
+ <%= pb_rails("button", props: { data: {"close-dialog": "#{object.id}" }, id: object.cancel_button_id, variant: "link"}) do %>
10
+ <%= object.cancel_button %>
11
+ <% end %>
12
+ <% end %>
13
+ <% end %>
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbDialog
5
+ class DialogFooter < Playbook::KitBase
6
+ prop :cancel_button
7
+ prop :confirm_button
8
+ prop :confirm_button_id
9
+ prop :cancel_button_id
10
+
11
+ def classname
12
+ generate_classname("dialog_footer")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ aria: object.aria) do %>
5
+ <%= pb_rails("flex", props: {classname:object.classname, spacing:"between", padding:"sm", align:"center"}) do %>
6
+ <%= content.presence || object.title %>
7
+
8
+ <button class="dialog-button-class" data-close-dialog= <%= object.id %> >
9
+ <%= pb_rails("icon", props:{icon: "times"}) %>
10
+ </button>
11
+ <% end %>
12
+ <%= pb_rails("section_separator") %>
13
+ <% end %>
@@ -2,28 +2,11 @@
2
2
 
3
3
  module Playbook
4
4
  module PbDialog
5
- class DialogHeader
6
- include Playbook::Props
7
-
8
- partial "pb_dialog/child_kits/dialog_header"
9
-
10
- prop :closeable, type: Playbook::Props::Boolean, default: true
11
- prop :padding
12
- prop :separator, type: Playbook::Props::Boolean, default: true
13
- prop :spacing
14
- prop :text
5
+ class DialogHeader < Playbook::KitBase
15
6
  prop :title
16
7
 
17
- def dialog_header_options
18
- {
19
- id: id,
20
- closeable: closeable,
21
- padding: padding,
22
- separator: separator,
23
- spacing: spacing,
24
- text: text,
25
- title: title,
26
- }
8
+ def classname
9
+ generate_classname("dialog_header")
27
10
  end
28
11
  end
29
12
  end
@@ -0,0 +1,12 @@
1
+ <%= pb_rails("button", props: { text: "Open Complex Dialog", data:{"open-dialog": "dialog-complex"} }) %>
2
+
3
+ <%= pb_rails("dialog", props: { id:"dialog-complex", size: "lg" }) do %>
4
+ <%= pb_rails("dialog/dialog_header", props: { id: "dialog-complex" } ) do %>
5
+ <%= pb_rails("caption", props: { text: "This is a complex dialog" }) %>
6
+ <% end %>
7
+ <%= pb_rails("dialog/dialog_body") do %>
8
+ <%= pb_rails("caption", props: { text: "Description", margin_bottom: "xs" }) %>
9
+ <%= pb_rails("rich_text_editor", props: {id: "default", value: "Add your text here"}) %>
10
+ <% end %>
11
+ <%= pb_rails("dialog/dialog_footer", props: {cancel_button: "Cancel", confirm_button: "Confirm", confirm_button_id:"confirm-complex", id: "dialog-complex"}) %>
12
+ <% end %>