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

style(action-icon): make sure footer transform does not effect parent CSS #419

Merged
merged 4 commits into from
Dec 15, 2021
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
26 changes: 18 additions & 8 deletions src/action-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ export class ActionIcon extends LitElement {
}

render(): TemplateResult {
return html`<section>
${this.renderIcon()}<slot name="action"></slot>
</section>
return html`<header>${this.label ?? nothing}</header>
<section>${this.renderIcon()}<slot name="action"></slot></section>
<footer>${this.label ?? nothing}</footer>`;
}

Expand Down Expand Up @@ -157,26 +156,37 @@ export class ActionIcon extends LitElement {
text-overflow: ellipsis;
margin: 0px;
opacity: 1;
transition: opacity 200ms linear;
text-align: center;
align-self: center;
max-width: 64px;
transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1),
box-shadow 200ms linear;
direction: rtl;
}

:host(:focus-within) footer {
header {
position: absolute;
text-align: center;
align-self: center;
max-width: 100vw;
transform: translate(0px, -140px);
background-color: var(--mdc-theme-secondary);
font-weight: 500;
color: var(--mdc-theme-on-secondary);
padding: 4px 8px;
border-radius: 4px;
font-size: 1.2em;
opacity: 0;
transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
opacity 200ms linear;
}

:host(:focus-within) header {
display: initial;
position: absolute;
opacity: 1;
transform: translate(0, -80px);
box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14),
0 3px 14px 2px rgba(0, 0, 0, 0.12), 0 5px 5px -3px rgba(0, 0, 0, 0.2);
transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1),
opacity 250ms linear;
}
`;
}
8 changes: 6 additions & 2 deletions test/unit/__snapshots__/action-icon.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
export const snapshots = {};

snapshots["Basic component action-icon with icon property set looks like the latest snapshot"] =
`<section>
`<header>
</header>
<section>
<span>
<slot name="icon">
</slot>
Expand All @@ -16,7 +18,9 @@ snapshots["Basic component action-icon with icon property set looks like the lat
/* end snapshot Basic component action-icon with icon property set looks like the latest snapshot */

snapshots["Basic component action-icon with unset icon property looks like the latest snapshot"] =
`<section>
`<header>
</header>
<section>
<span>
<slot name="icon">
<mwc-icon>
Expand Down