Skip to content

Commit

Permalink
fix: card background for both dark and light mode (#57)
Browse files Browse the repository at this point in the history
* fix: card background for both dark and light mode

* test: fix credential-card
  • Loading branch information
phoebus-84 authored Feb 20, 2024
1 parent 3ffa248 commit 4ec07fd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/components/credential-card/d-credential-card.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:host {
@apply w-full inline-flex flex-col items-start gap-2.5 px-5 py-5 rounded-lg bg-primary bg-no-repeat bg-cover;
@apply w-full inline-flex flex-col items-start gap-2.5 px-5 py-5 rounded-lg bg-no-repeat bg-cover bg-gradient-to-r from-primary to-transparent;
background-image: var(--background-card-url);
}

.between {
Expand Down
5 changes: 2 additions & 3 deletions src/components/credential-card/d-credential-card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Host, Prop, getAssetPath, h } from '@stencil/core';
import { Component, Host, Prop, h } from '@stencil/core';

const verifiedUser = (
<svg width="22" height="21" viewBox="0 0 22 21" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down Expand Up @@ -43,9 +43,8 @@ export class DCredentialCard {
@Prop() expirationDate?: string;

render() {
const imageSrc = getAssetPath('./assets/rect-dark.png');
return (
<Host style={{ 'background-image': `url(${imageSrc})` }}>
<Host>
<div class="between">
<div class="info">
<div class="heading">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('d-credential-card', () => {
html: `<d-credential-card></d-credential-card>`,
});
expect(page.root).toEqualHtml(`
<d-credential-card style="background-image: url(/assets/rect-dark.png);">
<d-credential-card>
<mock:shadow-root>
<div class="between">
<div class="info">
Expand Down
3 changes: 3 additions & 0 deletions src/global/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
--error: #ee342b;
--sans-font-family: 'Gantari Variable', 'sans-serif';
--icon-font-family: 'Material Symbols Rounded';
--background-card-url: url('/dist/didroom-components/assets/rect.png');
}

.dark {
Expand All @@ -38,6 +39,7 @@
--success: #4ecb71;
--warning: #ff9601;
--error: #ff443b;
--background-card-url: url('/dist/didroom-components/assets/rect-dark.png');
}

@media (prefers-color-scheme: dark) {
Expand All @@ -51,6 +53,7 @@
--success: #4ecb71;
--warning: #ff9601;
--error: #ff443b;
--background-card-url: url('/dist/didroom-components/assets/rect-dark.png');
}
}
}
Expand Down

0 comments on commit 4ec07fd

Please sign in to comment.