Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web-components] add default hover to fluent card #15751

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,8 @@
{
"type": "minor",
"comment": "add hover and focus-within elevation change for card",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "patch",
"date": "2020-10-28T22:20:57.255Z"
}
8 changes: 8 additions & 0 deletions packages/web-components/src/card/card.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ export const CardStyles = css`
border-radius: calc(var(--elevated-corner-radius) * 1px);
${elevation}
}

:host(:hover) {
--elevation: 8;
}

:host(:focus-within) {
--elevation: 8;
}
`.withBehaviors(
neutralFillCardRestBehavior,
forcedColorsStylesheetBehavior(
Expand Down
12 changes: 7 additions & 5 deletions packages/web-components/src/card/fixtures/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
width: 300px;
}

.state-override {
--card-width: 350px;
--card-height: 300px;
--elevation: 6;
}

.state-override:hover {
--elevation: 12;
}
Expand All @@ -17,11 +23,7 @@
</style>
<div>
<fluent-card style="--card-height: 400px; --card-width: 500px;">
Card with text
</fluent-card>
<br />
<fluent-card class="class-override" style="--elevation: 12;">
Custom depth with class-based height/width
<button>Button</button>Card with text
</fluent-card>
<br />
<fluent-card class="state-override">Custom depth on hover using CSS</fluent-card>
Expand Down