playbook_ui 14.18.0.pre.rc.3 → 14.18.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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +56 -2
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +1 -2
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +29 -19
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expand_by_depth.jsx +66 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expand_by_depth.md +10 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_advanced_table/index.js +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +1 -1
- data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.scss +39 -1
- data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.tsx +4 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.rb +9 -1
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.test.js +14 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_size.html.erb +28 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_size.jsx +42 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_size.md +1 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_hook_rails.html.erb +14 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_hook_rails.md +3 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_copy_button/index.js +46 -20
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +10 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.rb +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_turbo_frames.html.erb +117 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_turbo_frames_rails.md +9 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_dialog/index.js +106 -14
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_event_listeners.html.erb +42 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_event_listeners.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +1 -1
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +1 -1
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_pb_styles.jsx +31 -0
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_pb_styles.md +1 -0
- data/app/pb_kits/playbook/pb_gauge/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_gauge/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_gauge/gaugeTheme.ts +83 -0
- data/app/pb_kits/playbook/pb_overlay/_overlay.scss +34 -0
- data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +25 -4
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_background.jsx +49 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_background.md +1 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_opacity.jsx +81 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_opacity.md +1 -0
- data/app/pb_kits/playbook/pb_overlay/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_overlay/docs/index.js +2 -0
- data/dist/chunks/_typeahead-C_FX7o_S.js +22 -0
- data/dist/chunks/_weekday_stacked-B4RLTeDo.js +45 -0
- data/dist/chunks/lazysizes-DHz07jlL.js +1 -0
- data/dist/chunks/lib-ySl8uEpT.js +29 -0
- data/dist/chunks/{pb_form_validation-nsvkJU2J.js → pb_form_validation-BRjyJrKh.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +2 -2
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +25 -7
- data/dist/chunks/_typeahead-DUI-4yjJ.js +0 -22
- data/dist/chunks/_weekday_stacked-q9YP0zaF.js +0 -45
- data/dist/chunks/lazysizes-B7xYodB-.js +0 -1
- data/dist/chunks/lib-BV_AF_eh.js +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94ec449a03aebe3006ca1edc972e4632eb4ce67276e4e2a575dd54e4a26d87be
|
4
|
+
data.tar.gz: 6843d0fe6728e70935869341db3aa00e22eaa987e935ff80c502629f841fee9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4f7a5ceff1a63c95bfea4df95fcc16a633fd926d6a521cf812062292da2cc73ddaf8b3e010311bcedd20b962a7558855c44895d236ab5db3b0015cda458fb1c
|
7
|
+
data.tar.gz: ed2800f912e35e9e0c2e457613ad19d58e9801b9fc8ce8a322c38d0d0609b28138eaeb9dcce449e441ceb93983697c628b49790eccc930c9264e4e9c11fbc505
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useContext } from "react"
|
2
2
|
import classnames from "classnames"
|
3
|
-
import { flexRender, Header, Table } from "@tanstack/react-table"
|
3
|
+
import { flexRender, Header, Table, RowModel } from "@tanstack/react-table"
|
4
4
|
|
5
5
|
import { GenericObject } from "../../types"
|
6
6
|
|
@@ -8,9 +8,16 @@ import { GlobalProps } from "../../utilities/globalProps"
|
|
8
8
|
|
9
9
|
import Flex from "../../pb_flex/_flex"
|
10
10
|
import Checkbox from "../../pb_checkbox/_checkbox"
|
11
|
+
import Dropdown from "../../pb_dropdown/_dropdown"
|
12
|
+
import DropdownTrigger from "../../pb_dropdown/subcomponents/DropdownTrigger"
|
13
|
+
import DropdownOption from "../../pb_dropdown/subcomponents/DropdownOption"
|
14
|
+
import DropdownContainer from "../../pb_dropdown/subcomponents/DropdownContainer"
|
15
|
+
import Icon from "../../pb_icon/_icon"
|
11
16
|
|
12
17
|
import { SortIconButton } from "./SortIconButton"
|
13
18
|
import { ToggleIconButton } from "./ToggleIconButton"
|
19
|
+
import { displayIcon } from "../Utilities/IconHelpers"
|
20
|
+
import { updateExpandAndCollapseState } from "../Utilities/ExpansionControlHelpers"
|
14
21
|
|
15
22
|
import { isChrome } from "../Utilities/BrowserCheck"
|
16
23
|
|
@@ -40,6 +47,11 @@ export const TableHeaderCell = ({
|
|
40
47
|
table
|
41
48
|
}: TableHeaderCellProps) => {
|
42
49
|
const {
|
50
|
+
expanded,
|
51
|
+
setExpanded,
|
52
|
+
expandByDepth,
|
53
|
+
onExpandByDepthClick,
|
54
|
+
toggleExpansionIcon,
|
43
55
|
sortControl,
|
44
56
|
responsive,
|
45
57
|
selectableRows,
|
@@ -107,6 +119,21 @@ const isToggleExpansionEnabled =
|
|
107
119
|
justifyHeader = isLeafColumn ? "end" : "center";
|
108
120
|
}
|
109
121
|
|
122
|
+
const handleExpandDepth = (depth: number) => {
|
123
|
+
if (onExpandByDepthClick) {
|
124
|
+
const flatRows = table?.getRowModel().flatRows
|
125
|
+
onExpandByDepthClick(depth, flatRows)
|
126
|
+
}
|
127
|
+
const updated = updateExpandAndCollapseState(
|
128
|
+
table.getRowModel(),
|
129
|
+
expanded,
|
130
|
+
undefined,
|
131
|
+
depth
|
132
|
+
)
|
133
|
+
setExpanded(updated)
|
134
|
+
}
|
135
|
+
|
136
|
+
|
110
137
|
return (
|
111
138
|
<th
|
112
139
|
align="right"
|
@@ -143,9 +170,36 @@ const isToggleExpansionEnabled =
|
|
143
170
|
/>
|
144
171
|
)
|
145
172
|
}
|
146
|
-
{isToggleExpansionEnabled && hasAnySubRows && (
|
173
|
+
{isToggleExpansionEnabled && hasAnySubRows && !expandByDepth && (
|
147
174
|
<ToggleIconButton onClick={handleExpandOrCollapse} />
|
148
175
|
)}
|
176
|
+
{isToggleExpansionEnabled && hasAnySubRows && expandByDepth && (
|
177
|
+
<Dropdown className="expand-by-depth-dropdown-wrapper"
|
178
|
+
options={expandByDepth}
|
179
|
+
>
|
180
|
+
<DropdownTrigger className="gray-icon toggle-all-icon">
|
181
|
+
<Icon icon={displayIcon(toggleExpansionIcon)[0]} />
|
182
|
+
</DropdownTrigger>
|
183
|
+
<DropdownContainer className="expand-by-depth-dropdown">
|
184
|
+
{expandByDepth.map((option:{ [key: string]: any }, index: number) => (
|
185
|
+
<DropdownOption
|
186
|
+
key={index}
|
187
|
+
option={option}
|
188
|
+
padding="none"
|
189
|
+
>
|
190
|
+
<Flex
|
191
|
+
alignItems="center"
|
192
|
+
htmlOptions={{onClick: () => {handleExpandDepth(option.depth)} }}
|
193
|
+
paddingX="sm"
|
194
|
+
paddingY="xs"
|
195
|
+
>
|
196
|
+
{option.label}
|
197
|
+
</Flex>
|
198
|
+
</DropdownOption>
|
199
|
+
))}
|
200
|
+
</DropdownContainer>
|
201
|
+
</Dropdown>
|
202
|
+
)}
|
149
203
|
|
150
204
|
{isToggleExpansionEnabledLoading &&(
|
151
205
|
<div className="loading-toggle-icon header-toggle-icon" />
|
@@ -22,10 +22,9 @@ export function useTableActions({
|
|
22
22
|
// Handle expand/collapse
|
23
23
|
const handleExpandOrCollapse = useCallback(async (row: Row<GenericObject>) => {
|
24
24
|
onToggleExpansionClick && onToggleExpansionClick(row);
|
25
|
-
|
26
25
|
const expandedState = expanded;
|
27
26
|
const targetParent = row?.parentId;
|
28
|
-
const updatedRows = await updateExpandAndCollapseState(table.getRowModel(), expandedState, targetParent);
|
27
|
+
const updatedRows = await updateExpandAndCollapseState(table.getRowModel(), expandedState, targetParent, undefined);
|
29
28
|
setExpanded(updatedRows);
|
30
29
|
}, [expanded, setExpanded, onToggleExpansionClick, table]);
|
31
30
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { RowModel } from "@tanstack/react-table"
|
1
|
+
import { RowModel, Row } from "@tanstack/react-table"
|
2
2
|
import { ExpandedStateObject } from "./types"
|
3
3
|
import { GenericObject } from "../../types"
|
4
4
|
|
@@ -14,30 +14,40 @@ const filterExpandableRows = (expandedState: Record<string, boolean>) => {
|
|
14
14
|
export const updateExpandAndCollapseState = (
|
15
15
|
tableRows: RowModel<GenericObject>,
|
16
16
|
expanded: Record<string, boolean>,
|
17
|
-
targetParent
|
17
|
+
targetParent?: string,
|
18
|
+
targetDepth?: number,
|
18
19
|
) => {
|
19
20
|
const updateExpandedRows: Record<string, boolean> = {};
|
20
|
-
const rows = tableRows.rows;
|
21
|
+
const rows = targetDepth !== undefined ? tableRows.flatRows : tableRows.rows;
|
21
22
|
|
22
|
-
|
23
|
-
const areRowsExpanded = new Set<boolean>();
|
23
|
+
const rowsToToggle: Row<GenericObject>[] = [];
|
24
24
|
|
25
25
|
for (const row of rows) {
|
26
|
-
const shouldBeUpdated =
|
27
|
-
|
26
|
+
const shouldBeUpdated =
|
27
|
+
targetDepth !== undefined
|
28
|
+
? row.depth <= targetDepth
|
29
|
+
: targetParent === undefined
|
30
|
+
? row.depth === 0
|
31
|
+
: targetParent === row.parentId;
|
32
|
+
|
28
33
|
if (shouldBeUpdated) {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
rowsToToggle.push(row);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
// Check if we are expanding or collapsing
|
39
|
+
const anyCollapsed = rowsToToggle.some((row) => !row.getIsExpanded());
|
40
|
+
const isExpandAction = anyCollapsed;
|
41
|
+
|
42
|
+
|
43
|
+
for (const row of rowsToToggle) {
|
44
|
+
const shouldUpdate =
|
45
|
+
isExpandAction || targetDepth === undefined
|
46
|
+
? true
|
47
|
+
: row.depth === targetDepth;
|
48
|
+
|
49
|
+
if (shouldUpdate) {
|
50
|
+
updateExpandedRows[row.id] = isExpandAction;
|
41
51
|
}
|
42
52
|
}
|
43
53
|
|
@@ -130,6 +130,13 @@
|
|
130
130
|
box-sizing: border-box !important;
|
131
131
|
}
|
132
132
|
}
|
133
|
+
.expand-by-depth-dropdown-wrapper {
|
134
|
+
position: unset !important;
|
135
|
+
}
|
136
|
+
.expand-by-depth-dropdown {
|
137
|
+
width: unset !important;
|
138
|
+
text-align: left;
|
139
|
+
}
|
133
140
|
}
|
134
141
|
|
135
142
|
.pb_advanced_table_body {
|
@@ -38,6 +38,8 @@ type AdvancedTableProps = {
|
|
38
38
|
data?: { [key: string]: string }
|
39
39
|
enableToggleExpansion?: "all" | "header" | "none"
|
40
40
|
expandedControl?: GenericObject
|
41
|
+
expandByDepth?: { [key: string]: string | number }
|
42
|
+
onExpandByDepthClick?: (arg: number, arg1: any) => void
|
41
43
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
42
44
|
id?: string
|
43
45
|
initialLoadingRowsCount?: number
|
@@ -73,6 +75,8 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
73
75
|
data = {},
|
74
76
|
enableToggleExpansion = "header",
|
75
77
|
expandedControl,
|
78
|
+
expandByDepth,
|
79
|
+
onExpandByDepthClick,
|
76
80
|
htmlOptions = {},
|
77
81
|
id,
|
78
82
|
initialLoadingRowsCount = 10,
|
@@ -280,6 +284,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
280
284
|
columnDefinitions={columnDefinitions}
|
281
285
|
enableToggleExpansion={enableToggleExpansion}
|
282
286
|
enableVirtualization={virtualizedRows}
|
287
|
+
expandByDepth={expandByDepth}
|
283
288
|
expanded={expanded}
|
284
289
|
expandedControl={expandedControl}
|
285
290
|
handleExpandOrCollapse={handleExpandOrCollapse}
|
@@ -288,6 +293,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
288
293
|
isActionBarVisible={isActionBarVisible}
|
289
294
|
isFullscreen={isFullscreen}
|
290
295
|
loading={loading}
|
296
|
+
onExpandByDepthClick={onExpandByDepthClick}
|
291
297
|
responsive={responsive}
|
292
298
|
selectableRows={selectableRows}
|
293
299
|
setExpanded={setExpanded}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import AdvancedTable from '../../pb_advanced_table/_advanced_table'
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
4
|
+
|
5
|
+
const AdvancedTableExpandByDepth = (props) => {
|
6
|
+
const columnDefinitions = [
|
7
|
+
{
|
8
|
+
accessor: "year",
|
9
|
+
label: "Year",
|
10
|
+
cellAccessors: ["quarter", "month", "day"],
|
11
|
+
},
|
12
|
+
{
|
13
|
+
accessor: "newEnrollments",
|
14
|
+
label: "New Enrollments",
|
15
|
+
},
|
16
|
+
{
|
17
|
+
accessor: "scheduledMeetings",
|
18
|
+
label: "Scheduled Meetings",
|
19
|
+
},
|
20
|
+
{
|
21
|
+
accessor: "attendanceRate",
|
22
|
+
label: "Attendance Rate",
|
23
|
+
},
|
24
|
+
{
|
25
|
+
accessor: "completedClasses",
|
26
|
+
label: "Completed Classes",
|
27
|
+
},
|
28
|
+
{
|
29
|
+
accessor: "classCompletionRate",
|
30
|
+
label: "Class Completion Rate",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
accessor: "graduatedStudents",
|
34
|
+
label: "Graduated Students",
|
35
|
+
},
|
36
|
+
]
|
37
|
+
|
38
|
+
const expandByDepth = [
|
39
|
+
{
|
40
|
+
depth: 0,
|
41
|
+
label: "Year",
|
42
|
+
},
|
43
|
+
{
|
44
|
+
depth: 1,
|
45
|
+
label: "Quarter",
|
46
|
+
},
|
47
|
+
{
|
48
|
+
depth: 2,
|
49
|
+
label: "Month",
|
50
|
+
}
|
51
|
+
]
|
52
|
+
|
53
|
+
return (
|
54
|
+
<div>
|
55
|
+
<AdvancedTable
|
56
|
+
columnDefinitions={columnDefinitions}
|
57
|
+
expandByDepth={expandByDepth}
|
58
|
+
onExpandByDepthClick={(depth, rows) => {console.log(depth, rows)}}
|
59
|
+
tableData={MOCK_DATA}
|
60
|
+
{...props}
|
61
|
+
/>
|
62
|
+
</div>
|
63
|
+
)
|
64
|
+
}
|
65
|
+
|
66
|
+
export default AdvancedTableExpandByDepth
|
@@ -0,0 +1,10 @@
|
|
1
|
+
The `expandByDepth` prop enables users to expand or collapse table rows by specific levels of nesting. When provided, it renders a dropdown that appears when the toggle icon in the header is clicked.
|
2
|
+
|
3
|
+
`expandByDepth` accepts an array of objects, where each object defines the depth level to target and the label to display in the dropdown. When a user selects an option:
|
4
|
+
|
5
|
+
**Expanding a depth**: Expands all rows at the selected depth AND all parent levels above it (if parent levels were closed), ensuring nested content is visible.
|
6
|
+
|
7
|
+
**Collapsing a depth**: Only collapses rows at the selected depth, keeping parent rows expanded for context.
|
8
|
+
|
9
|
+
If you want to attach further logic to each option click, the **optional** `onExpandByDepthClick` prop can be used. This click event provides 2 arguments that can be hooked into: the depth level of the clicked item AND all flattened table rows. Any additional functionality provided through this onClick will be applied in addition to the default.
|
10
|
+
|
@@ -22,6 +22,7 @@ examples:
|
|
22
22
|
- advanced_table_sort: Enable Sorting
|
23
23
|
- advanced_table_sort_control: Sort Control
|
24
24
|
- advanced_table_expanded_control: Expanded Control
|
25
|
+
- advanced_table_expand_by_depth: Expand by Depth
|
25
26
|
- advanced_table_subrow_headers: SubRow Headers
|
26
27
|
- advanced_table_collapsible_trail: Collapsible Trail
|
27
28
|
- advanced_table_table_options: Table Options
|
@@ -25,4 +25,5 @@ export { default as AdvancedTableInlineEditing } from './_advanced_table_inline_
|
|
25
25
|
export { default as AdvancedTableFullscreen } from './_advanced_table_fullscreen.jsx'
|
26
26
|
export { default as AdvancedTableStickyColumns } from './_advanced_table_sticky_columns.jsx'
|
27
27
|
export { default as AdvancedTableStickyHeader } from './_advanced_table_sticky_header.jsx'
|
28
|
-
export { default as AdvancedTableStickyColumnsAndHeader } from './_advanced_table_sticky_columns_and_header.jsx'
|
28
|
+
export { default as AdvancedTableStickyColumnsAndHeader } from './_advanced_table_sticky_columns_and_header.jsx'
|
29
|
+
export { default as AdvancedTableExpandByDepth } from './_advanced_table_expand_by_depth.jsx'
|
@@ -31,6 +31,8 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
31
31
|
this.toggleElement(this.target);
|
32
32
|
}
|
33
33
|
});
|
34
|
+
|
35
|
+
this.hideCloseIcon()
|
34
36
|
|
35
37
|
const nestedButtons = this.element
|
36
38
|
.closest("table")
|
@@ -49,6 +51,11 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
49
51
|
});
|
50
52
|
}
|
51
53
|
|
54
|
+
hideCloseIcon() {
|
55
|
+
const closeIcon = this.element.querySelector(UP_ARROW_SELECTOR);
|
56
|
+
closeIcon.style.display = "none";
|
57
|
+
}
|
58
|
+
|
52
59
|
showElement(elements) {
|
53
60
|
elements.forEach((elem) => {
|
54
61
|
elem.style.display = "table-row";
|
@@ -30,7 +30,7 @@
|
|
30
30
|
class="gray-icon expand-toggle-icon"
|
31
31
|
data-advanced-table="true">
|
32
32
|
<%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
|
33
|
-
<%= pb_rails("icon", props: { id: "advanced-table_close_icon",
|
33
|
+
<%= pb_rails("icon", props: { id: "advanced-table_close_icon", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
|
34
34
|
</button>
|
35
35
|
<% end %>
|
36
36
|
<% end %>
|
@@ -53,4 +53,42 @@ $pb_button_styles: (
|
|
53
53
|
}
|
54
54
|
}
|
55
55
|
}
|
56
|
-
|
56
|
+
&.size_small {
|
57
|
+
@each $style in $pb_button_styles {
|
58
|
+
[class^=pb_button_kit][class*=_#{$style}] {
|
59
|
+
width: 20px;
|
60
|
+
height: 20px;
|
61
|
+
min-height: 20px;
|
62
|
+
border-radius: 10px;
|
63
|
+
line-height: 20px;
|
64
|
+
flex-basis: 20px;
|
65
|
+
min-width: 20px;
|
66
|
+
padding: 0;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
// centering small icon svg
|
70
|
+
.pb_button_content {
|
71
|
+
display: flex;
|
72
|
+
align-items: center;
|
73
|
+
justify-content: center;
|
74
|
+
// rails
|
75
|
+
svg.pb_custom_icon {
|
76
|
+
height: 14px;
|
77
|
+
width: 14px;
|
78
|
+
vertical-align: middle;
|
79
|
+
}
|
80
|
+
// react (nested within an additional span)
|
81
|
+
> span {
|
82
|
+
display: flex;
|
83
|
+
align-items: center;
|
84
|
+
justify-content: center;
|
85
|
+
> svg.pb_custom_icon {
|
86
|
+
height: 14px;
|
87
|
+
width: 14px;
|
88
|
+
vertical-align: middle;
|
89
|
+
display: inline-block;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
@@ -22,6 +22,7 @@ type CircleIconButtonProps = {
|
|
22
22
|
type?: 'button' | 'submit' | 'reset' | undefined,
|
23
23
|
target?: string
|
24
24
|
variant?: 'primary' | 'secondary' | 'link',
|
25
|
+
size?: 'default' | 'sm',
|
25
26
|
}
|
26
27
|
|
27
28
|
const CircleIconButton = (props: CircleIconButtonProps): React.ReactElement => {
|
@@ -41,13 +42,16 @@ const CircleIconButton = (props: CircleIconButtonProps): React.ReactElement => {
|
|
41
42
|
link,
|
42
43
|
newWindow,
|
43
44
|
variant,
|
45
|
+
size = 'default',
|
44
46
|
} = props
|
45
47
|
|
46
48
|
const ariaProps = buildAriaProps(aria)
|
47
49
|
const dataProps = buildDataProps(data)
|
48
50
|
const htmlProps = buildHtmlProps(htmlOptions)
|
51
|
+
const sizeClass = size === 'sm' ? 'size_small' : ''
|
49
52
|
const classes = classnames(
|
50
53
|
buildCss('pb_circle_icon_button_kit'),
|
54
|
+
sizeClass,
|
51
55
|
globalProps(props),
|
52
56
|
className
|
53
57
|
)
|
@@ -18,8 +18,16 @@ module Playbook
|
|
18
18
|
prop :new_window, type: Playbook::Props::Boolean,
|
19
19
|
default: false
|
20
20
|
prop :target
|
21
|
+
prop :size, type: Playbook::Props::Enum,
|
22
|
+
values: %w[default sm],
|
23
|
+
default: "default"
|
24
|
+
|
21
25
|
def classname
|
22
|
-
generate_classname("pb_circle_icon_button_kit")
|
26
|
+
generate_classname("pb_circle_icon_button_kit") + size_class
|
27
|
+
end
|
28
|
+
|
29
|
+
def size_class
|
30
|
+
size == "sm" ? " size_small" : ""
|
23
31
|
end
|
24
32
|
end
|
25
33
|
end
|
@@ -30,3 +30,17 @@ test('passes loading prop to button', () => {
|
|
30
30
|
|
31
31
|
expect(button).toBeInTheDocument()
|
32
32
|
})
|
33
|
+
|
34
|
+
test('adds size_small class when size is sm', () => {
|
35
|
+
render(
|
36
|
+
<CircleIconButton
|
37
|
+
data={{ testid: 'small-size-test' }}
|
38
|
+
icon="plus"
|
39
|
+
size="sm"
|
40
|
+
/>
|
41
|
+
)
|
42
|
+
|
43
|
+
const kit = screen.getByTestId('small-size-test')
|
44
|
+
|
45
|
+
expect(kit).toHaveClass('pb_circle_icon_button_kit size_small')
|
46
|
+
})
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%= pb_rails("flex", props: { orientation: "column", gap: "sm" }) do %>
|
2
|
+
<%= pb_rails("circle_icon_button", props: {
|
3
|
+
icon: "plus",
|
4
|
+
size: "sm",
|
5
|
+
variant: "primary"
|
6
|
+
}) %>
|
7
|
+
|
8
|
+
<%= pb_rails("circle_icon_button", props: {
|
9
|
+
icon: "pen",
|
10
|
+
loading: true,
|
11
|
+
size: "sm",
|
12
|
+
variant: "secondary"
|
13
|
+
}) %>
|
14
|
+
|
15
|
+
<%= pb_rails("circle_icon_button", props: {
|
16
|
+
disabled: true,
|
17
|
+
icon: "times",
|
18
|
+
size: "sm"
|
19
|
+
}) %>
|
20
|
+
|
21
|
+
<%= pb_rails("circle_icon_button", props: {
|
22
|
+
icon: "info",
|
23
|
+
link: "https://playbook.powerapp.cloud/",
|
24
|
+
size: "sm",
|
25
|
+
target: "child",
|
26
|
+
variant: "link"
|
27
|
+
}) %>
|
28
|
+
<% end %>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import CircleIconButton from '../_circle_icon_button'
|
4
|
+
import Flex from '../../pb_flex/_flex'
|
5
|
+
|
6
|
+
const CircleIconButtonSize = (props) => (
|
7
|
+
<>
|
8
|
+
<Flex gap="sm"
|
9
|
+
orientation="column"
|
10
|
+
>
|
11
|
+
<CircleIconButton
|
12
|
+
icon="plus"
|
13
|
+
size="sm"
|
14
|
+
variant="primary"
|
15
|
+
{...props}
|
16
|
+
/>
|
17
|
+
<CircleIconButton
|
18
|
+
icon="pen"
|
19
|
+
loading
|
20
|
+
size="sm"
|
21
|
+
variant="secondary"
|
22
|
+
{...props}
|
23
|
+
/>
|
24
|
+
<CircleIconButton
|
25
|
+
disabled
|
26
|
+
icon="times"
|
27
|
+
size="sm"
|
28
|
+
{...props}
|
29
|
+
/>
|
30
|
+
<CircleIconButton
|
31
|
+
icon="info"
|
32
|
+
link="https://playbook.powerapp.cloud/"
|
33
|
+
size="sm"
|
34
|
+
target="child"
|
35
|
+
variant="link"
|
36
|
+
{...props}
|
37
|
+
/>
|
38
|
+
</Flex>
|
39
|
+
</>
|
40
|
+
)
|
41
|
+
|
42
|
+
export default CircleIconButtonSize
|
@@ -0,0 +1 @@
|
|
1
|
+
The `size` prop accepts "sm" as a value to make the Circle Icon Button 20px x 20px instead of the default 40px x 40px size.
|
@@ -4,9 +4,11 @@ examples:
|
|
4
4
|
- circle_icon_button_default: Default
|
5
5
|
- circle_icon_button_link: Link
|
6
6
|
- circle_icon_button_loading: Loading
|
7
|
+
- circle_icon_button_size: Size
|
7
8
|
|
8
9
|
react:
|
9
10
|
- circle_icon_button_default: Default
|
10
11
|
- circle_icon_button_click: Click Handler
|
11
12
|
- circle_icon_button_link: Link
|
12
13
|
- circle_icon_button_loading: Loading
|
14
|
+
- circle_icon_button_size: Size
|
@@ -2,3 +2,4 @@ export { default as CircleIconButtonDefault } from './_circle_icon_button_defaul
|
|
2
2
|
export { default as CircleIconButtonClick } from './_circle_icon_button_click.jsx'
|
3
3
|
export { default as CircleIconButtonLink } from './_circle_icon_button_link.jsx'
|
4
4
|
export { default as CircleIconButtonLoading } from './_circle_icon_button_loading.jsx'
|
5
|
+
export { default as CircleIconButtonSize } from './_circle_icon_button_size.jsx'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= pb_rails("body", props: { cursor: "pointer", data: { "external-copy-from": "hookbody"} }) do %>
|
2
|
+
<span id="hookbody">I'm a custom copy hook! Click this body to copy this text!</span>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<%= pb_rails("tooltip", props: {
|
6
|
+
trigger_element_selector: "#hookbody",
|
7
|
+
tooltip_id: "hookbody_tooltip",
|
8
|
+
position: 'top',
|
9
|
+
trigger_method: "click"
|
10
|
+
}) do %>
|
11
|
+
Copied!
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= pb_rails("textarea", props: { margin_top: "xs", placeholder: "Paste here" }) %>
|
@@ -0,0 +1,3 @@
|
|
1
|
+
You can use any external control (like the text itself or an icon) to copy. To use this hook, set the `data-external-copy-from` attribute on the external control to the copying ID. This will grab the `innerText` from `your_id` element, or `value` if it is an input element. Alternatively, you can set a `data-external-copy-value` attribute and copy custom text.
|
2
|
+
|
3
|
+
See the code example for details.
|