Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/imodel-browser-react",
"comment": "Fix: favorite icon shift on hover",
"type": "patch"
}
],
"packageName": "@itwin/imodel-browser-react"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
IModelGridProps,
IModelTileProps,
} from "@itwin/imodel-browser-react";
import { SvgApple } from "@itwin/itwinui-icons-react";
import { SvgApple, SvgClose, SvgDelete } from "@itwin/itwinui-icons-react";
import {
Button,
Code,
Expand Down Expand Up @@ -349,3 +349,23 @@ DisableAddToRecents.argTypes = {
cellOverrides: { table: { disable: true } },
className: { table: { disable: true } },
};

export const Recents = Template.bind({});
Recents.args = {
apiOverrides: { serverEnvironmentPrefix: "qa" },
requestType: "recents",
};

export const RecentsWithCustomIcon = Template.bind({});
RecentsWithCustomIcon.args = {
apiOverrides: { serverEnvironmentPrefix: "qa" },
requestType: "recents",
removeFromRecentsIcon: <SvgDelete />,
};

export const RecentsWithCloseIcon = Template.bind({});
RecentsWithCloseIcon.args = {
apiOverrides: { serverEnvironmentPrefix: "qa" },
requestType: "recents",
removeFromRecentsIcon: <SvgClose />,
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

.iTwinTile:hover {
.iTwinTileFavoriteIcon {
display: block;
display: flex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export interface IModelGridProps {
sortOptions?: IModelSortOptions;
/** List of actions to build for each imodel context menu. */
iModelActions?: ContextMenuBuilderItem<IModelFull>[];
/** Custom icon for the "Remove from recents" context menu action. Only applies when requestType is "recents". */
removeFromRecentsIcon?: JSX.Element;
/** Function (can be a react hook) that returns state for an iModel, returned values will be applied as props to the IModelTile, overrides IModelGrid provided values */
useIndividualState?: (
iModel: IModelFull,
Expand Down Expand Up @@ -126,6 +128,7 @@ const ITwinGridInternal = ({
accessToken,
apiOverrides,
iModelActions,
removeFromRecentsIcon,
onThumbnailClick,
iTwinId,
sortOptions = { sortType: "name", descending: false },
Expand Down Expand Up @@ -195,6 +198,7 @@ const ITwinGridInternal = ({
const removeFromRecentsAction: ContextMenuBuilderItem<IModelFull> = {
key: "remove-from-recents",
children: strings.removeFromRecents,
...(removeFromRecentsIcon && { icon: removeFromRecentsIcon }),
onClick: async (iModel, refetchData) => {
if (!iModel || !accessToken) {
return;
Expand All @@ -208,14 +212,15 @@ const ITwinGridInternal = ({
},
};
return iModelActions
? [...iModelActions, removeFromRecentsAction]
? [removeFromRecentsAction, ...iModelActions]
: [removeFromRecentsAction];
}
return iModelActions;
}, [
requestType,
iModelActions,
strings.removeFromRecents,
removeFromRecentsIcon,
accessToken,
apiOverrides?.serverEnvironmentPrefix,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

.iModelTile:hover {
.iModelTileFavoriteIcon {
display: block;
display: flex;
}
}