playbook_ui 14.13.0.pre.alpha.PBNTR457formtimezoneselect6219 → 14.13.0.pre.alpha.PBNTR5596029
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/_playbook.scss +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +5 -6
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +1 -8
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_rails.md +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.scss +66 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.tsx +98 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +28 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb +42 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.html.erb +19 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.jsx +26 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.html.erb +10 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.jsx +17 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_on_click.jsx +19 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_onclick.html.erb +16 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.html.erb +35 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.jsx +42 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_tooltip.html.erb +13 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/example.yml +15 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/docs/index.js +4 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/pb_avatar_action_button.test.js +31 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +8 -17
- data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +0 -16
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_checkbox/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +1 -3
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.md +1 -4
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.jsx +0 -1
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +0 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +0 -1
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.html.erb +2 -1
- data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb +1 -1
- data/app/pb_kits/playbook/pb_icon_button/icon_button.rb +0 -3
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +6 -1
- data/app/pb_kits/playbook/pb_nav/item.html.erb +19 -7
- data/app/pb_kits/playbook/pb_nav/nav.html.erb +8 -3
- data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +6 -1
- data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +0 -4
- data/app/pb_kits/playbook/pb_overlay/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_overlay/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_token.tsx +10 -48
- data/app/pb_kits/playbook/pb_popover/popover.html.erb +6 -1
- data/app/pb_kits/playbook/pb_progress_pills/_progress_pills.scss +1 -6
- data/app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx +5 -7
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.html.erb +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.jsx +0 -7
- data/app/pb_kits/playbook/pb_progress_pills/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_progress_pills/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +7 -2
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.rb +0 -6
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.test.js +1 -26
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +5 -1
- data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +5 -1
- data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +5 -1
- data/app/pb_kits/playbook/pb_radio/radio.html.erb +11 -6
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.jsx +1 -1
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -5
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -3
- data/app/pb_kits/playbook/pb_table/index.ts +9 -41
- data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +0 -4
- data/app/pb_kits/playbook/pb_table/table_body.html.erb +7 -13
- data/app/pb_kits/playbook/pb_table/table_body.rb +0 -2
- data/app/pb_kits/playbook/pb_table/table_row.html.erb +7 -14
- data/app/pb_kits/playbook/pb_table/table_row.rb +1 -14
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.html.erb +0 -14
- data/app/pb_kits/playbook/pb_text_input/index.js +0 -9
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +2 -5
- data/dist/chunks/{_typeahead-PqkcDf1H.js → _typeahead-TUUtEUg8.js} +3 -3
- data/dist/chunks/_weekday_stacked--GSH9pBR.js +45 -0
- data/dist/chunks/{lib-D3us1bGD.js → lib-DjpLC8uO.js} +2 -2
- data/dist/chunks/{pb_form_validation-BpihMSOQ.js → pb_form_validation-S56UaHZl.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +7 -0
- 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/forms/builder.rb +0 -1
- data/lib/playbook/version.rb +1 -1
- metadata +23 -32
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_custom_cell.jsx +0 -75
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb +0 -33
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +0 -3
- data/app/pb_kits/playbook/pb_bar_graph/BarGraphStyles.scss +0 -58
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.jsx +0 -64
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.md +0 -1
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.jsx +0 -69
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.md +0 -1
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.html.erb +0 -27
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.jsx +0 -37
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional_react.md +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.md +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width.html.erb +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width.jsx +0 -18
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width_rails.md +0 -1
- data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width_react.md +0 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.html.erb +0 -47
- data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.jsx +0 -88
- data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.md +0 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click.html.erb +0 -51
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click_rails.md +0 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +0 -96
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.jsx +0 -101
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.md +0 -1
- data/dist/chunks/_weekday_stacked-C7J0S4f7.js +0 -45
- data/lib/playbook/forms/builder/time_zone_select_field.rb +0 -19
- /data/app/pb_kits/playbook/pb_table/docs/{_table_with_collapsible_with_custom_click_react.md → _table_with_collapsible_with_custom_click.md} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 520a725d004f38fd119945b399c5e1dc6bcf5ca9929821965555ac8f72c3ffa1
|
4
|
+
data.tar.gz: '0490ed67775bcb53cefe0bbedcaca9d2482cf47e899b5cd0e16fc382f0bb014c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 479d29aca4903e65fbaff26957ab48561ebd5a1d59e032c299a83cff41aae40e20ff195eb6d70e1fada990b7a79611ebfe19ec6984fc38e90fb058bc545ab05a
|
7
|
+
data.tar.gz: 17394761a8b8756c5bbb557c7245d28f597514f5e301a5857e56bb860f233a4b23224d58f122c64c6488a0ab766e97c7e0936958f36e20236942b2e5f00585c4
|
@@ -116,7 +116,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
116
116
|
const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
|
117
117
|
|
118
118
|
//Create cells for columns, with customization for first column
|
119
|
-
const createCellFunction = (cellAccessors: string[], customRenderer?: (row: Row<GenericObject>, value: any) => JSX.Element,
|
119
|
+
const createCellFunction = (cellAccessors: string[], customRenderer?: (row: Row<GenericObject>, value: any) => JSX.Element, index?: number) => {
|
120
120
|
const columnCells = ({
|
121
121
|
row,
|
122
122
|
getValue,
|
@@ -126,7 +126,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
126
126
|
}) => {
|
127
127
|
const rowData = row.original
|
128
128
|
|
129
|
-
if (
|
129
|
+
if (index === 0) {
|
130
130
|
switch (row.depth) {
|
131
131
|
case 0: {
|
132
132
|
return (
|
@@ -164,16 +164,15 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
164
164
|
return columnCells
|
165
165
|
}
|
166
166
|
|
167
|
-
const buildColumns = (columnDefinitions: GenericObject[]
|
167
|
+
const buildColumns = (columnDefinitions: GenericObject[]): any => {
|
168
168
|
return (
|
169
169
|
columnDefinitions &&
|
170
170
|
columnDefinitions.map((column, index) => {
|
171
|
-
const isFirstColumn = isRoot && index === 0;
|
172
171
|
//Checking to see if grouped column or not
|
173
172
|
if (column.columns && column.columns.length > 0) {
|
174
173
|
return {
|
175
174
|
header: column.label || "",
|
176
|
-
columns: buildColumns(column.columns
|
175
|
+
columns: buildColumns(column.columns),
|
177
176
|
};
|
178
177
|
} else {
|
179
178
|
// Define the base column structure
|
@@ -187,7 +186,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
187
186
|
columnStructure.cell = createCellFunction(
|
188
187
|
column.cellAccessors,
|
189
188
|
column.customRenderer,
|
190
|
-
|
189
|
+
index
|
191
190
|
);
|
192
191
|
}
|
193
192
|
|
@@ -17,21 +17,14 @@ module Playbook
|
|
17
17
|
default: "scroll"
|
18
18
|
prop :table_props, type: Playbook::Props::HashProp,
|
19
19
|
default: {}
|
20
|
-
prop :max_height, type: Playbook::Props::Enum,
|
21
|
-
values: %w[auto xs sm md lg xl xxl xxxl],
|
22
|
-
default: "auto"
|
23
20
|
|
24
21
|
def classname
|
25
|
-
generate_classname("pb_advanced_table", responsive_classname,
|
22
|
+
generate_classname("pb_advanced_table", responsive_classname, separator: " ")
|
26
23
|
end
|
27
24
|
|
28
25
|
def responsive_classname
|
29
26
|
responsive == "scroll" ? "advanced-table-responsive-scroll" : "advanced-table-responsive-none"
|
30
27
|
end
|
31
|
-
|
32
|
-
def max_height_classname
|
33
|
-
max_height.present? ? "advanced-table-max-height-#{max_height}" : ""
|
34
|
-
end
|
35
28
|
end
|
36
29
|
end
|
37
30
|
end
|
@@ -30,4 +30,4 @@
|
|
30
30
|
}
|
31
31
|
] %>
|
32
32
|
|
33
|
-
<%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions,
|
33
|
+
<%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions, table_props: { container: false, sticky: true }}) %>
|
@@ -1,3 +1 @@
|
|
1
|
-
This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table) under the hood which comes with
|
2
|
-
|
3
|
-
This doc example showcases how to set a sticky header for a nonresponsive table. To achieve sticky header AND responsive functionality, see the ["Table Props Sticky Header"](https://playbook.powerapp.cloud/kits/advanced_table#table-props-sticky-header) doc example below.
|
1
|
+
This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table) under the hood which comes with it's own set of props. If you want to apply certain Table props to that underlying kit, you can do so by using the optional `table_props` prop. This prop must be an object that contains valid Table props. For a full list of Table props, see [here](https://playbook.powerapp.cloud/kits/table).
|
@@ -1,3 +1,3 @@
|
|
1
|
-
This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table/react) under the hood which comes with
|
1
|
+
This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table/react) under the hood which comes with it's own set of props. If you want to apply certain Table props to that underlying kit, you can do so by using the optional `tableProps` prop. This prop must be an object that contains valid Table props. For a full list of Table props, see [here](https://playbook.powerapp.cloud/kits/table/react).
|
2
2
|
|
3
3
|
This doc example showcases how to set a sticky header for a nonresponsive table. To achieve sticky header AND responsive functionality, see the ["Table Props Sticky Header"](https://playbook.powerapp.cloud/kits/advanced_table/react#table-props-sticky-header) doc example below.
|
@@ -5,7 +5,6 @@ examples:
|
|
5
5
|
- advanced_table_beta_subrow_headers: SubRow Headers
|
6
6
|
- advanced_table_collapsible_trail_rails: Collapsible Trail
|
7
7
|
- advanced_table_table_props: Table Props
|
8
|
-
- advanced_table_table_props_sticky_header: Table Props Sticky Header
|
9
8
|
- advanced_table_beta_sort: Enable Sorting
|
10
9
|
- advanced_table_responsive: Responsive Tables
|
11
10
|
- advanced_table_custom_cell_rails: Custom Components for Cells
|
@@ -31,7 +30,6 @@ examples:
|
|
31
30
|
- advanced_table_pagination_with_props: Pagination Props
|
32
31
|
- advanced_table_column_headers: Multi-Header Columns
|
33
32
|
- advanced_table_column_headers_multiple: Multi-Header Columns (Multiple Levels)
|
34
|
-
- advanced_table_column_headers_custom_cell: Multi-Header Columns with Custom Cells
|
35
33
|
# - advanced_table_no_subrows: Table with No Subrows
|
36
34
|
- advanced_table_selectable_rows: Selectable Rows
|
37
35
|
- advanced_table_selectable_rows_no_subrows: Selectable Rows (No Subrows)
|
@@ -19,5 +19,4 @@ export { default as AdvancedTableSelectableRowsNoSubrows } from './_advanced_tab
|
|
19
19
|
export { default as AdvancedTableNoSubrows } from './_advanced_table_no_subrows.jsx'
|
20
20
|
export { default as AdvancedTableSelectableRowsHeader } from './_advanced_table_selectable_rows_header.jsx'
|
21
21
|
export { default as AdvancedTableSelectableRowsActions } from './_advanced_table_selectable_rows_actions.jsx'
|
22
|
-
export { default as AdvancedTableTablePropsStickyHeader } from './_advanced_table_table_props_sticky_header.jsx'
|
23
|
-
export { default as AdvancedTableColumnHeadersCustomCell } from './_advanced_table_column_headers_custom_cell.jsx'
|
22
|
+
export { default as AdvancedTableTablePropsStickyHeader } from './_advanced_table_table_props_sticky_header.jsx'
|
@@ -0,0 +1,66 @@
|
|
1
|
+
[class^=pb_avatar_action_button_kit] {
|
2
|
+
|
3
|
+
$icon_size: 0px;
|
4
|
+
$border_size: 0px;
|
5
|
+
|
6
|
+
$action-colors: (
|
7
|
+
"add": $primary,
|
8
|
+
"remove": $error,
|
9
|
+
);
|
10
|
+
|
11
|
+
@each $key, $value in $action-colors {
|
12
|
+
&[class*=_#{$key}] a {
|
13
|
+
color: $value;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
@mixin icon-base {
|
18
|
+
&.dark{
|
19
|
+
background-color: $bg_dark
|
20
|
+
}
|
21
|
+
width: $icon_size;
|
22
|
+
height: $icon_size;
|
23
|
+
position: absolute;
|
24
|
+
background-color: $white;
|
25
|
+
border-radius: $icon_size;
|
26
|
+
font-size: ($icon_size - $border_size * 2);
|
27
|
+
display: flex;
|
28
|
+
justify-content: center;
|
29
|
+
align-items: center;
|
30
|
+
z-index: 1;
|
31
|
+
}
|
32
|
+
|
33
|
+
@each $name, $size in $avatar-sizes {
|
34
|
+
|
35
|
+
&[class*=_#{$name}] {
|
36
|
+
|
37
|
+
$avatar_size: map-get($avatar-sizes, $name);
|
38
|
+
$icon_size: $avatar_size / 2;
|
39
|
+
$border_size: $icon_size / 10;
|
40
|
+
|
41
|
+
position: relative;
|
42
|
+
width: $avatar_size * 1.25;
|
43
|
+
height: $avatar_size * 1.1;
|
44
|
+
display: flex;
|
45
|
+
|
46
|
+
[class^=pb_tooltip_kit] {
|
47
|
+
justify-self: center;
|
48
|
+
}
|
49
|
+
|
50
|
+
&[class*=_bottom] .icon {
|
51
|
+
@include icon-base;
|
52
|
+
top: $icon_size * 1.27;
|
53
|
+
}
|
54
|
+
&[class*=_top] .icon {
|
55
|
+
@include icon-base;
|
56
|
+
bottom: $icon_size * 1.27;
|
57
|
+
}
|
58
|
+
&[class*=_right] .icon {
|
59
|
+
left: $icon_size * 1.5;
|
60
|
+
}
|
61
|
+
&[class*=_left] [class^=pb_avatar_kit] {
|
62
|
+
padding-left: $icon_size / 2;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import classnames from 'classnames'
|
3
|
+
|
4
|
+
import {
|
5
|
+
buildAriaProps,
|
6
|
+
buildCss,
|
7
|
+
buildDataProps,
|
8
|
+
buildHtmlProps } from '../utilities/props'
|
9
|
+
import { globalProps } from '../utilities/globalProps'
|
10
|
+
|
11
|
+
import Avatar from '../pb_avatar/_avatar'
|
12
|
+
import Icon from '../pb_icon/_icon'
|
13
|
+
|
14
|
+
type AvatarActionButtonProps = {
|
15
|
+
action?: "add" | "remove",
|
16
|
+
aria?: {[key: string]: string},
|
17
|
+
linkAriaLabel?: string,
|
18
|
+
className?: string,
|
19
|
+
dark?: boolean,
|
20
|
+
data?: {[key: string]: string},
|
21
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
22
|
+
id?: string,
|
23
|
+
imageAlt?: string,
|
24
|
+
imageUrl?: string,
|
25
|
+
linkUrl?: string,
|
26
|
+
name?: string,
|
27
|
+
onClick?: React.MouseEventHandler<HTMLSpanElement>,
|
28
|
+
placement?: string,
|
29
|
+
size?: "md" | "lg" | "sm" | "xl" | "xs" | "xxs",
|
30
|
+
}
|
31
|
+
|
32
|
+
const AvatarActionButton = (props: AvatarActionButtonProps): React.ReactElement => {
|
33
|
+
const {
|
34
|
+
action = 'add',
|
35
|
+
aria = {},
|
36
|
+
linkAriaLabel,
|
37
|
+
className,
|
38
|
+
dark = false,
|
39
|
+
data = {},
|
40
|
+
htmlOptions = {},
|
41
|
+
id,
|
42
|
+
imageAlt = '',
|
43
|
+
imageUrl,
|
44
|
+
linkUrl,
|
45
|
+
name,
|
46
|
+
onClick,
|
47
|
+
placement = 'bottom left',
|
48
|
+
size = 'md',
|
49
|
+
} = props
|
50
|
+
|
51
|
+
const ariaProps = buildAriaProps(aria)
|
52
|
+
const dataProps = buildDataProps(data)
|
53
|
+
const htmlProps = buildHtmlProps(htmlOptions)
|
54
|
+
|
55
|
+
const classes = classnames(buildCss(
|
56
|
+
'pb_avatar_action_button_kit',
|
57
|
+
action,
|
58
|
+
placement,
|
59
|
+
size),
|
60
|
+
globalProps(props),
|
61
|
+
className)
|
62
|
+
|
63
|
+
const icons = {
|
64
|
+
add: 'plus-circle',
|
65
|
+
remove: 'times-circle',
|
66
|
+
}
|
67
|
+
|
68
|
+
return (
|
69
|
+
<div
|
70
|
+
{...ariaProps}
|
71
|
+
{...dataProps}
|
72
|
+
{...htmlProps}
|
73
|
+
className={classes}
|
74
|
+
id={id}
|
75
|
+
>
|
76
|
+
<a
|
77
|
+
aria-label={linkAriaLabel}
|
78
|
+
href={linkUrl}
|
79
|
+
onClick={onClick}
|
80
|
+
>
|
81
|
+
<Avatar
|
82
|
+
imageAlt={imageAlt}
|
83
|
+
imageUrl={imageUrl}
|
84
|
+
name={name}
|
85
|
+
size={size}
|
86
|
+
/>
|
87
|
+
<div className={`icon ${dark ? 'dark' : ''}`}>
|
88
|
+
<Icon
|
89
|
+
dark={dark}
|
90
|
+
icon={icons[action]}
|
91
|
+
/>
|
92
|
+
</div>
|
93
|
+
</a>
|
94
|
+
</div>
|
95
|
+
)
|
96
|
+
}
|
97
|
+
|
98
|
+
export default AvatarActionButton
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%= pb_content_tag do %>
|
2
|
+
<% if object.tooltip_text.present? %>
|
3
|
+
<%= pb_rails("tooltip", props: {
|
4
|
+
trigger_element_id: object.tooltip_id,
|
5
|
+
tooltip_id: "tooltip-2",
|
6
|
+
position: 'top'
|
7
|
+
}) do %>
|
8
|
+
<%= object.tooltip_text %>
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= link_to object.link_url, id: object.tooltip_id, 'aria-label': object.link_aria_label do %>
|
13
|
+
<%= pb_rails("avatar", props: {
|
14
|
+
dark: object.dark,
|
15
|
+
name: object.name,
|
16
|
+
size: object.size,
|
17
|
+
image_alt: object.image_alt,
|
18
|
+
image_url: object.image_url,
|
19
|
+
class: "avatar_action"
|
20
|
+
}) %>
|
21
|
+
<div class="icon <%= object.dark ? 'dark' : '' %> ">
|
22
|
+
<%= pb_rails("icon", props: {
|
23
|
+
dark: object.dark,
|
24
|
+
icon: object.action_icons
|
25
|
+
}) %>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Playbook
|
4
|
+
module PbAvatarActionButton
|
5
|
+
class AvatarActionButton < Playbook::KitBase
|
6
|
+
prop :action, type: Playbook::Props::String,
|
7
|
+
default: "add"
|
8
|
+
prop :link_aria_label, type: Playbook::Props::String
|
9
|
+
prop :image_alt, type: Playbook::Props::String
|
10
|
+
prop :image_url, type: Playbook::Props::String
|
11
|
+
prop :link_url, type: Playbook::Props::String, default: "#"
|
12
|
+
prop :tooltip_text, type: Playbook::Props::String
|
13
|
+
prop :tooltip_id, type: Playbook::Props::String
|
14
|
+
prop :name, type: Playbook::Props::String,
|
15
|
+
default: ""
|
16
|
+
prop :size, type: Playbook::Props::Enum,
|
17
|
+
values: %w[xs sm md lg xl],
|
18
|
+
default: "md"
|
19
|
+
prop :placement, type: Playbook::Props::Enum,
|
20
|
+
values: %w[bottom_left bottom_right top_left top_right],
|
21
|
+
default: "bottom_left"
|
22
|
+
|
23
|
+
def classname
|
24
|
+
generate_classname("pb_avatar_action_button_kit", action, size, placement)
|
25
|
+
end
|
26
|
+
|
27
|
+
def action_icons
|
28
|
+
icon_hash = {
|
29
|
+
add: "plus-circle",
|
30
|
+
remove: "times-circle",
|
31
|
+
}
|
32
|
+
# if an 'action' prop is passed that isn't
|
33
|
+
# in the icon_hash an empty string is returned
|
34
|
+
# instead of a null value, which would break the page
|
35
|
+
|
36
|
+
# double pipe ruby syntax below is essentially a reduced if-else statement
|
37
|
+
# if icon_hash[action.to_sym] returns a falsey value, return "" instead
|
38
|
+
icon_hash[action.to_sym] ||= ""
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<div class="pb--doc-demo-row">
|
2
|
+
|
3
|
+
<%= pb_rails("avatar_action_button", props: {
|
4
|
+
link_aria_label: "Add Sophia Carden",
|
5
|
+
name: "Sophia Carden",
|
6
|
+
image_alt: "Add Sophia Carden",
|
7
|
+
image_url: "https://randomuser.me/api/portraits/women/8.jpg",
|
8
|
+
action: "add",
|
9
|
+
}) %>
|
10
|
+
|
11
|
+
<%= pb_rails("avatar_action_button", props: {
|
12
|
+
link_aria_label: "Remove Sophia Carden",
|
13
|
+
name: "Sophia Carden",
|
14
|
+
image_alt: "Remove Sophia Carden",
|
15
|
+
image_url: "https://randomuser.me/api/portraits/women/8.jpg",
|
16
|
+
action: "remove",
|
17
|
+
}) %>
|
18
|
+
|
19
|
+
</div>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import AvatarActionButton from '../_avatar_action_button'
|
4
|
+
|
5
|
+
const AvatarActionButtonActions = (props) => (
|
6
|
+
<div className="pb--doc-demo-row">
|
7
|
+
<AvatarActionButton
|
8
|
+
action="add"
|
9
|
+
imageAlt="Add Sophia Carden"
|
10
|
+
imageUrl="https://randomuser.me/api/portraits/women/8.jpg"
|
11
|
+
linkAriaLabel="Add Sophia Carden"
|
12
|
+
name="Sophia Carden"
|
13
|
+
{...props}
|
14
|
+
/>
|
15
|
+
<AvatarActionButton
|
16
|
+
action="remove"
|
17
|
+
imageAlt="Remove Sophia Carden"
|
18
|
+
imageUrl="https://randomuser.me/api/portraits/women/8.jpg"
|
19
|
+
linkAriaLabel="Remove Sophia Carden"
|
20
|
+
name="Sophia Carden"
|
21
|
+
{...props}
|
22
|
+
/>
|
23
|
+
</div>
|
24
|
+
)
|
25
|
+
|
26
|
+
export default AvatarActionButtonActions
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import AvatarActionButton from '../_avatar_action_button'
|
4
|
+
|
5
|
+
const AvatarActionButtonDefault = (props) => (
|
6
|
+
<div className="pb--doc-demo-row">
|
7
|
+
<AvatarActionButton
|
8
|
+
imageAlt="Sophia Carden"
|
9
|
+
imageUrl="https://randomuser.me/api/portraits/women/8.jpg"
|
10
|
+
linkAriaLabel="Sophia Carden"
|
11
|
+
name="Sophia Carden"
|
12
|
+
{...props}
|
13
|
+
/>
|
14
|
+
</div>
|
15
|
+
)
|
16
|
+
|
17
|
+
export default AvatarActionButtonDefault
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import AvatarActionButton from '../_avatar_action_button'
|
4
|
+
|
5
|
+
const AvatarActionButtonOnClick = (props) => (
|
6
|
+
<div className="pb--doc-demo-row">
|
7
|
+
<AvatarActionButton
|
8
|
+
imageAlt="Sophia Carden"
|
9
|
+
imageUrl="https://randomuser.me/api/portraits/women/8.jpg"
|
10
|
+
linkAriaLabel="Alert Sophia Carden"
|
11
|
+
linkUrl="https://www.google.com"
|
12
|
+
name="Sophia Carden"
|
13
|
+
onClick={() => alert('clicked!')}
|
14
|
+
{...props}
|
15
|
+
/>
|
16
|
+
</div>
|
17
|
+
)
|
18
|
+
|
19
|
+
export default AvatarActionButtonOnClick
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="pb--doc-demo-row">
|
2
|
+
|
3
|
+
<%= pb_rails("avatar_action_button", props: {
|
4
|
+
link_aria_label: "Alert Sophia Carden",
|
5
|
+
name: "Sophia Carden",
|
6
|
+
id: "clickable",
|
7
|
+
link_url: "http://www.google.com",
|
8
|
+
image_alt: "Sophia Carden",
|
9
|
+
image_url: "https://randomuser.me/api/portraits/women/8.jpg",
|
10
|
+
}) %>
|
11
|
+
|
12
|
+
<%= javascript_tag do %>
|
13
|
+
document.querySelector('#clickable').addEventListener('click', () => alert('clickable clicked!'))
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
</div>
|
data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.html.erb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
<div class="pb--doc-demo-row">
|
2
|
+
|
3
|
+
<%= pb_rails("avatar_action_button", props: {
|
4
|
+
link_aria_label: "Sophia Carden",
|
5
|
+
name: "Sophia Carden",
|
6
|
+
image_alt: "Sophia Carden",
|
7
|
+
image_url: "https://randomuser.me/api/portraits/women/8.jpg",
|
8
|
+
placement: "bottom_left"
|
9
|
+
}) %>
|
10
|
+
|
11
|
+
<%= pb_rails("avatar_action_button", props: {
|
12
|
+
link_aria_label: "Sophia Carden",
|
13
|
+
name: "Sophia Carden",
|
14
|
+
image_alt: "Sophia Carden",
|
15
|
+
image_url: "https://randomuser.me/api/portraits/women/8.jpg",
|
16
|
+
placement: "bottom_right"
|
17
|
+
}) %>
|
18
|
+
|
19
|
+
<%= pb_rails("avatar_action_button", props: {
|
20
|
+
link_aria_label: "Sophia Carden",
|
21
|
+
name: "Sophia Carden",
|
22
|
+
image_alt: "Sophia Carden",
|
23
|
+
image_url: "https://randomuser.me/api/portraits/women/8.jpg",
|
24
|
+
placement: "top_left"
|
25
|
+
}) %>
|
26
|
+
|
27
|
+
<%= pb_rails("avatar_action_button", props: {
|
28
|
+
link_aria_label: "Sophia Carden",
|
29
|
+
name: "Sophia Carden",
|
30
|
+
image_alt: "Sophia Carden",
|
31
|
+
image_url: "https://randomuser.me/api/portraits/women/8.jpg",
|
32
|
+
placement: "top_right"
|
33
|
+
}) %>
|
34
|
+
|
35
|
+
</div>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import AvatarActionButton from '../_avatar_action_button'
|
4
|
+
|
5
|
+
const AvatarActionButtonPlacement = (props) => (
|
6
|
+
<div className="pb--doc-demo-row">
|
7
|
+
<AvatarActionButton
|
8
|
+
imageAlt="Sophia Carden"
|
9
|
+
imageUrl="https://randomuser.me/api/portraits/women/8.jpg"
|
10
|
+
linkAriaLabel="Sophia Carden"
|
11
|
+
name="Sophia Carden"
|
12
|
+
placement="bottom_left"
|
13
|
+
{...props}
|
14
|
+
/>
|
15
|
+
<AvatarActionButton
|
16
|
+
imageAlt="Sophia Carden"
|
17
|
+
imageUrl="https://randomuser.me/api/portraits/women/8.jpg"
|
18
|
+
linkAriaLabel="Sophia Carden"
|
19
|
+
name="Sophia Carden"
|
20
|
+
placement="bottom_right"
|
21
|
+
{...props}
|
22
|
+
/>
|
23
|
+
<AvatarActionButton
|
24
|
+
imageAlt="Sophia Carden"
|
25
|
+
imageUrl="https://randomuser.me/api/portraits/women/8.jpg"
|
26
|
+
linkAriaLabel="Sophia Carden"
|
27
|
+
name="Sophia Carden"
|
28
|
+
placement="top_left"
|
29
|
+
{...props}
|
30
|
+
/>
|
31
|
+
<AvatarActionButton
|
32
|
+
imageAlt="Sophia Carden"
|
33
|
+
imageUrl="https://randomuser.me/api/portraits/women/8.jpg"
|
34
|
+
linkAriaLabel="Sophia Carden"
|
35
|
+
name="Sophia Carden"
|
36
|
+
placement="top_right"
|
37
|
+
{...props}
|
38
|
+
/>
|
39
|
+
</div>
|
40
|
+
)
|
41
|
+
|
42
|
+
export default AvatarActionButtonPlacement
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="pb--doc-demo-row">
|
2
|
+
|
3
|
+
<%= pb_rails("avatar_action_button", props: {
|
4
|
+
link_aria_label: "Sophia Carden",
|
5
|
+
name: "Sophia Carden",
|
6
|
+
link_url: "http://www.google.com",
|
7
|
+
image_alt: "Sophia Carden",
|
8
|
+
image_url: "https://randomuser.me/api/portraits/women/8.jpg",
|
9
|
+
tooltip_text: "Tooltip Text",
|
10
|
+
tooltip_id: "avatar_1",
|
11
|
+
}) %>
|
12
|
+
|
13
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
examples:
|
2
|
+
|
3
|
+
rails:
|
4
|
+
- avatar_action_button_default: Default
|
5
|
+
- avatar_action_button_placement: Placement
|
6
|
+
- avatar_action_button_actions: Actions
|
7
|
+
- avatar_action_button_onclick: On Click
|
8
|
+
- avatar_action_button_tooltip: Tooltip
|
9
|
+
|
10
|
+
|
11
|
+
react:
|
12
|
+
- avatar_action_button_default: Default
|
13
|
+
- avatar_action_button_placement: Placement
|
14
|
+
- avatar_action_button_actions: Actions
|
15
|
+
- avatar_action_button_on_click: On Click
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export { default as AvatarActionButtonDefault } from './_avatar_action_button_default.jsx'
|
2
|
+
export { default as AvatarActionButtonPlacement } from './_avatar_action_button_placement.jsx'
|
3
|
+
export { default as AvatarActionButtonActions } from './_avatar_action_button_actions.jsx'
|
4
|
+
export { default as AvatarActionButtonOnClick } from './_avatar_action_button_on_click.jsx'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render, screen } from '../utilities/test-utils'
|
3
|
+
|
4
|
+
import AvatarActionButton from './_avatar_action_button'
|
5
|
+
|
6
|
+
const imageUrl = 'https://randomuser.me/api/portraits/women/8.jpg',
|
7
|
+
testId = 'scarden',
|
8
|
+
name = 'Sophia Carden',
|
9
|
+
imageAlt = 'Sophia Carden Profile'
|
10
|
+
|
11
|
+
test('loads the given image url and name', () => {
|
12
|
+
render(
|
13
|
+
<AvatarActionButton
|
14
|
+
data={{ testid: testId }}
|
15
|
+
imageAlt={imageAlt}
|
16
|
+
imageUrl={imageUrl}
|
17
|
+
linkAriaLabel={name}
|
18
|
+
name={name}
|
19
|
+
/>
|
20
|
+
)
|
21
|
+
|
22
|
+
const kit = screen.getByTestId(testId)
|
23
|
+
const image = screen.getByAltText(imageAlt)
|
24
|
+
const link = kit.children[0]
|
25
|
+
|
26
|
+
expect(kit).toHaveClass('pb_avatar_action_button_kit_add_bottom_left_md')
|
27
|
+
expect(image).toHaveAttribute('data-src', imageUrl)
|
28
|
+
expect(image).toHaveAttribute('src', imageUrl)
|
29
|
+
expect(image).toHaveAttribute('alt', imageAlt)
|
30
|
+
expect(link).toHaveAttribute('aria-label', name)
|
31
|
+
})
|