Skip to content

Commit

Permalink
chore(card): add styles and tests
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 576660710
  • Loading branch information
asyncLiz authored and copybara-github committed Oct 25, 2023
1 parent cbcb891 commit 0ebd7c7
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 4 deletions.
17 changes: 17 additions & 0 deletions labs/card/elevated-card_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

// import 'jasmine'; (google3-only)

import {createTokenTests} from '../../testing/tokens.js';

import {MdElevatedCard} from './elevated-card.js';

describe('<md-elevated-card>', () => {
describe('.styles', () => {
createTokenTests(MdElevatedCard.styles);
});
});
17 changes: 17 additions & 0 deletions labs/card/filled-card_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

// import 'jasmine'; (google3-only)

import {createTokenTests} from '../../testing/tokens.js';

import {MdFilledCard} from './filled-card.js';

describe('<md-filled-card>', () => {
describe('.styles', () => {
createTokenTests(MdFilledCard.styles);
});
});
6 changes: 5 additions & 1 deletion labs/card/internal/_elevated-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@
@mixin styles() {
$tokens: tokens.md-comp-elevated-card-values();

// TODO(b/261201808): add styles
:host {
@each $token, $value in $tokens {
--_#{$token}: var(--md-elevated-card-#{$token}, #{$value});
}
}
}
6 changes: 5 additions & 1 deletion labs/card/internal/_filled-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@
@mixin styles() {
$tokens: tokens.md-comp-filled-card-values();

// TODO(b/261201808): add styles
:host {
@each $token, $value in $tokens {
--_#{$token}: var(--md-filled-card-#{$token}, #{$value});
}
}
}
10 changes: 9 additions & 1 deletion labs/card/internal/_outlined-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,13 @@
@mixin styles() {
$tokens: tokens.md-comp-outlined-card-values();

// TODO(b/261201808): add styles
:host {
@each $token, $value in $tokens {
--_#{$token}: var(--md-outlined-card-#{$token}, #{$value});
}
}

.container {
outline: var(--_outline-width) solid var(--_outline-color);
}
}
30 changes: 30 additions & 0 deletions labs/card/internal/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,38 @@
// SPDX-License-Identifier: Apache-2.0
//

// go/keep-sorted start
@use '../../../elevation/elevation';
// go/keep-sorted end

@mixin styles() {
:host {
border-radius: var(--_container-shape);
display: flex;
padding: 16px;
position: relative;
}

// Separate element will be needed for disabled opacities (b/307361748)
.container {
background: var(--_container-color);
border-radius: inherit;
inset: 0;
position: absolute;
}

md-elevation {
border-radius: inherit;

@include elevation.theme(
(
'level': var(--_container-elevation),
'shadow-color': var(--_container-shadow-color),
)
);
}

slot {
z-index: 0; // Place content above background elements
}
}
8 changes: 7 additions & 1 deletion labs/card/internal/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
* SPDX-License-Identifier: Apache-2.0
*/

import '../../../elevation/elevation.js';

import {html, LitElement} from 'lit';

/**
* A card component.
*/
export class Card extends LitElement {
protected override render() {
return html`<slot></slot>`;
return html`
<md-elevation part="elevation"></md-elevation>
<div class="container"></div>
<slot></slot>
`;
}
}
17 changes: 17 additions & 0 deletions labs/card/outlined-card_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

// import 'jasmine'; (google3-only)

import {createTokenTests} from '../../testing/tokens.js';

import {MdOutlinedCard} from './outlined-card.js';

describe('<md-outlined-card>', () => {
describe('.styles', () => {
createTokenTests(MdOutlinedCard.styles);
});
});

0 comments on commit 0ebd7c7

Please sign in to comment.