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
1 change: 1 addition & 0 deletions src/components/CardBase/CardBase.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ a#{$block} {
@include reset-link-style();
@include reset-link-hover();
@include card($hover: true);
@include background-hover();
}
1 change: 1 addition & 0 deletions src/models/constructor-items/sub-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export interface BasicCardProps
gravityIcon?: ThemeSupporting<GravityIconProps>;
target?: string;
iconPosition?: IconPosition;
hoverBackgroundColor?: string;
}

export interface BannerCardProps {
Expand Down
11 changes: 10 additions & 1 deletion src/sub-blocks/BasicCard/BasicCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const BasicCard = (props: BasicCardProps) => {
controlPosition = 'content',
size = 's',
gravityIcon,
hoverBackgroundColor,
...cardParams
} = props;
const titleId = useUniqId();
Expand All @@ -38,7 +39,15 @@ const BasicCard = (props: BasicCardProps) => {
className={b()}
contentClassName={b('content')}
{...cardParams}
extraProps={{'aria-describedby': descriptionId, 'aria-labelledby': titleId}}
extraProps={{
'aria-describedby': descriptionId,
'aria-labelledby': titleId,
...(hoverBackgroundColor && {
style: {
'--hover-background-color': hoverBackgroundColor,
} as React.CSSProperties,
}),
}}
>
<CardBase.Content>
<IconWrapper
Expand Down
8 changes: 8 additions & 0 deletions src/sub-blocks/BasicCard/__stories__/BasicCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const WithContentList = WithContentListTemplate.bind({});
export const ControlPosition = ControlPositionTemplate.bind({});
export const Sizes = VariousTemplate.bind([]);
export const GravityIcons = VariousTemplate.bind([]);
export const HoverEffects = ListTemplate.bind({});

const DefaultArgs = data.default as BasicCardModel;

Expand Down Expand Up @@ -254,3 +255,10 @@ GravityIcons.parameters = {
include: Object.keys(GravityIcons.args),
},
};

HoverEffects.args = data.hoverEffects as BasicCardModel[];
HoverEffects.parameters = {
controls: {
include: Object.keys(HoverEffects.args),
},
};
25 changes: 25 additions & 0 deletions src/sub-blocks/BasicCard/__stories__/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,30 @@
}
]
}
],
"hoverEffects": [
{
"type": "basic-card",
"title": "Hover: Gradient Background",
"text": "Hover over this card to see gradient background effect",
"url": "/test",
"urlTitle": "Opens in a new tab",
"hoverBackgroundColor": "linear-gradient(180deg, rgba(255, 255, 255, 0.00) 36%, #DCC7FF 100%)"
},
{
"type": "basic-card",
"title": "Hover: Solid Color",
"text": "Hover over this card to see solid color background effect",
"url": "/test",
"urlTitle": "Opens in a new tab",
"hoverBackgroundColor": "#DCC7FF"
},
{
"type": "basic-card",
"title": "No Hover Effect",
"text": "This card has no hover background effect",
"url": "/test",
"urlTitle": "Opens in a new tab"
}
]
}
6 changes: 6 additions & 0 deletions styles/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@
}
}

@mixin background-hover($property: background) {
&:hover {
#{$property}: var(--hover-background-color);
}
}

@mixin image-shadow() {
box-shadow:
0 2px 8px var(--pc-color-sfx-shadow),
Expand Down