Skip to content

Commit

Permalink
[web-components] add default hover to fluent card (microsoft#15751)
Browse files Browse the repository at this point in the history
* add hover and focus-within elevation change for card

* Change files
  • Loading branch information
chrisdholt authored and Seth Donohue committed Nov 23, 2020
1 parent 500c459 commit fd1dd39
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
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": "chhol@microsoft.com",
"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

0 comments on commit fd1dd39

Please sign in to comment.