Skip to content

Commit

Permalink
fix(elevation): style for card migration (#1276)
Browse files Browse the repository at this point in the history
* fix(elevation): style for card migration

* add part

* fix alternate in popup

* fix test md

* change popup HTML wrappers

* comment
  • Loading branch information
rachelbt committed Apr 10, 2022
1 parent ec49b38 commit d186cca
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 34 deletions.
8 changes: 4 additions & 4 deletions __snapshots__/popup.md
Expand Up @@ -3,8 +3,8 @@
#### `should internal contents`

```html
<div class="popup-wrapper">
<vwc-elevation dp="2">
<vwc-elevation dp="2">
<div class="popup-wrapper">
<div
aria-hidden="true"
class="popup"
Expand All @@ -15,8 +15,8 @@
</slot>
</div>
</div>
</vwc-elevation>
</div>
</div>
</vwc-elevation>

```

6 changes: 0 additions & 6 deletions components/elevation/readme.md
Expand Up @@ -24,12 +24,6 @@ Note that this component is responsible for the perceived elevation alone and no
|--- |--- |--- |-------------------------------------------------------------------------------------------|
|dp|property/attribute|string| Level in Density-Independent Pixels (DP). Possible values: `0`,`2`,`4`,`8`,`12`,`16`,`24` |

### CSS Variables

|name|description|default|
|--- |--- |--- |
|`--vvd-elevation-background-color`|Color for the elevation surface background | defaults to theme’s surface background |
|`--vvd-elevation-border-radius`|Border radius of the elevation’s surface in pixels| 6px |

# Example:

Expand Down
10 changes: 4 additions & 6 deletions components/elevation/src/vwc-elevation.scss
Expand Up @@ -19,12 +19,10 @@ $elevation-border-radius: --elevation-border-radius;

@each $dp in $dps {
#{get-default-selector($dps, $dp)} {
background-color: var(--vvd-color-surface-#{$dp}dp);
filter: var(--vvd-shadow-surface-#{$dp}dp);
::slotted(*) {
background-color: var(--vvd-color-surface-#{$dp}dp);
filter: var(--vvd-shadow-surface-#{$dp}dp);
}
}
}

.vwc-elevation {
--elevation-border-radius: 6px;
border-radius: var(#{--elevation-border-radius});
}
2 changes: 1 addition & 1 deletion components/elevation/src/vwc-elevation.ts
Expand Up @@ -26,7 +26,7 @@ export class VWCElevation extends LitElement {
};

return html`
<div class="vwc-elevation ${classMap(classList)}">
<div class="vwc-elevation ${classMap(classList)}" part="base">
<slot></slot>
</div>
`;
Expand Down
1 change: 1 addition & 0 deletions components/elevation/stories/elevation.stories.js
Expand Up @@ -26,6 +26,7 @@ const styles = () => html`
padding: 20px;
text-align: center;
width: 500px;
border-radius: 6px;
}
</style>
`;
Expand Down
14 changes: 9 additions & 5 deletions components/popup/src/vwc-popup-base.ts
Expand Up @@ -222,21 +222,25 @@ export class VWCPopupBase extends LitElement {
}

protected override render(): TemplateResult {
const part = this.alternate ? 'vvd-scheme-alternate' : '';
const alternate = this.alternate ? 'vvd-scheme-alternate' : '';
const aria = this.open ? 'false' : 'true';

return html`
<div class="popup-wrapper">
<vwc-elevation dp="2">
<div class="popup ${classMap(this.getRenderClasses())}" aria-hidden=${aria} part=${part}>
<div class="popup-content">
<!-- 'popup-wrapper' is selected by the wrapping elevation, thus required for shadow styling -->
<!-- the reason for not applying directly to its first-child 'popup' is to avoid scenario where popup is set to alternate scheme
and affect the shadow style surfacing contrast which should still in default scheme context -->
<div class="popup-wrapper">
<div class="popup ${classMap(this.getRenderClasses())}" aria-hidden=${aria} part=${alternate}>
<div class="popup-content" >
<slot></slot>
${this.renderDismissButton()}
</div>
${this.renderArrow()}
</div>
</div>
</vwc-elevation>
</div>
`;
}
}
4 changes: 2 additions & 2 deletions components/popup/src/vwc-popup.scss
Expand Up @@ -8,17 +8,17 @@
}

.popup {
--border-radius-size: 6px;
width: min-content;
background-color: var(#{scheme-variables.$vvd-color-surface-4dp});
border-radius: var(--border-radius-size);
border-radius: inherit;
contain: layout;
&:not(.popup-open) {
display: none;
}

&-wrapper {
position: absolute;
border-radius: 6px;
}

&-content {
Expand Down
Binary file modified ui-tests/snapshots/vwc-elevation.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 11 additions & 10 deletions ui-tests/tests/vwc-elevation/index.js
@@ -1,25 +1,24 @@
import '@vonage/vwc-elevation';
import '@vonage/vwc-layout';


export async function createElementVariations(wrapper) {
const elementWrapper = document.createElement('div');
elementWrapper.innerHTML =
`
<style>
#VwcElevation {
display: inline-block;
}
vwc-elevation {
margin: 25px;
display: block;
}
.card {
width: 300px;
height: 30px;
padding: 20px;
text-align: center;
border-radius: 6px;
}
.wrapper {
width: 380px;
display: inline-block;
}
</style>
<div class="wrapper">
<vwc-layout column-basis="block" column-spacing="sm" gutters="md">
<vwc-elevation dp="0">
<div class="card">
This is the content inside the elevation with DP 0
Expand Down Expand Up @@ -61,6 +60,8 @@ export async function createElementVariations(wrapper) {
This is the content inside the elevation with DP 24
</div>
</vwc-elevation>
</<vwc-layout>
</div>
`;
wrapper.appendChild(elementWrapper);
}
Expand Down

0 comments on commit d186cca

Please sign in to comment.