Skip to content

Commit 64aff84

Browse files
author
Illia Obukhau
authored
[WC-1738]: gallery selection styles (#447)
2 parents 6afa02d + 793fb10 commit 64aff84

File tree

8 files changed

+29
-8
lines changed

8 files changed

+29
-8
lines changed

packages/modules/data-widgets/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"datagrid-web": "workspace:*",
5656
"dropdown-sort-web": "workspace:*",
5757
"gallery-web": "workspace:*",
58+
"selection-helper-web": "workspace:*",
5859
"tree-node-web": "workspace:*"
5960
},
6061
"devDependencies": {

packages/modules/data-widgets/src/themesource/datawidgets/web/_datagrid.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ $spacing-large: 24px !default;
1414
$grid-border-color: #ced0d3 !default;
1515

1616
$brand-primary: #264ae5 !default;
17+
$brand-light: #e6eaff !default;
1718

1819
.table {
1920
position: relative;

packages/modules/data-widgets/src/themesource/datawidgets/web/_gallery-design-properties.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,8 @@
9797
}
9898
}
9999
}
100+
101+
.widget-gallery-disable-selected-items-highlight {
102+
// placeholder
103+
// this class in needed to disable standard styles of highlighted items
104+
}

packages/modules/data-widgets/src/themesource/datawidgets/web/_gallery.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
}
5959
}
6060

61+
&:not(.widget-gallery-disable-selected-items-highlight) {
62+
.widget-gallery-item.widget-gallery-clickable.widget-gallery-selected {
63+
background: $brand-light;
64+
}
65+
}
66+
6167
.infinite-loading {
6268
overflow: auto;
6369
}

packages/modules/data-widgets/src/themesource/datawidgets/web/design-properties.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@
111111
"class": "widget-gallery-pagination-center"
112112
}
113113
]
114+
},
115+
{
116+
"name": "Disable selection highlight",
117+
"type": "Toggle",
118+
"description": "Disable standard styles for highlighting of selected items.",
119+
"class": "widget-gallery-disable-selected-items-highlight"
114120
}
115121
],
116122
"com.mendix.widget.web.treenode.TreeNode": [

packages/pluggableWidgets/gallery-web/src/Gallery.editorConfig.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function getProperties(
2626
hidePropertyIn(defaultProperties, values, "emptyPlaceholder");
2727
}
2828

29-
if (values.filterList?.length === 0 && values.sortList?.length === 0 && values.itemSelection !== "Multi") {
29+
if (!showHeader(values)) {
3030
hidePropertyIn(defaultProperties, values, "filtersPlaceholder");
3131
}
3232

@@ -187,15 +187,14 @@ export function getPreview(values: GalleryPreviewProps, isDarkMode: boolean): St
187187

188188
return {
189189
type: "Container",
190-
children: [
191-
titleHeader,
192-
...(values.filterList.length > 0 || values.sortList.length > 0 ? [filters] : []),
193-
content,
194-
...footer
195-
]
190+
children: [titleHeader, ...(showHeader(values) ? [filters] : []), content, ...footer]
196191
};
197192
}
198193

199194
function getSingularPlural(word: string, elements: number): string {
200195
return elements > 1 ? word + "s" : word;
201196
}
197+
198+
function showHeader(values: GalleryPreviewProps): boolean {
199+
return values.filterList?.length > 0 || values.sortList?.length > 0 || values.itemSelection === "Multi";
200+
}

packages/pluggableWidgets/selection-helper-web/src/SelectionHelper.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export function SelectionHelper(props: SelectionHelperContainerProps): ReactElem
1010
if (contextValue.hasError) {
1111
return (
1212
<Alert bootstrapStyle="danger">
13-
The Selection Helper widget must be placed inside the header of the Data grid 2.0 or Gallery widget.
13+
The Selection Helper widget must be placed inside the header of the Data grid 2.0 or Gallery widget with
14+
multi-selection.
1415
</Alert>
1516
);
1617
}

pnpm-lock.yaml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)