basic card component

This commit is contained in:
Alexandr Andreyev 2025-08-14 23:56:30 +03:00
parent 735bf856ec
commit bf00a968a8
4 changed files with 1234 additions and 38 deletions

View File

@ -6,11 +6,33 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Lit + TS</title> <title>Vite + Lit + TS</title>
<link rel="stylesheet" href="./src/index.css" /> <link rel="stylesheet" href="./src/index.css" />
<script type="module" src="/src/my-element.ts"></script> <script type="module" src="/src/fab-card.ts"></script>
</head> </head>
<body> <body>
<my-element> <div class="cards-list">
<h1>Vite + Lit</h1> <fab-card
</my-element> cardSetId="ROS154"
cardName="Arcane Cussing"
cardColor="Blue"
cardImageSrc="http://localhost:8000/p/ROS154/w400"
cardComment="A comment about the card"
></fab-card>
<fab-card
cardSetId="ROS154"
cardName="Arcane Cussing"
cardColor="Blue"
cardImageSrc="http://localhost:8000/p/ROS154/w400"
cardComment="A comment about the card"
foiling="R"
></fab-card>
<fab-card
cardSetId="ROS154"
cardName="Arcane Cussing"
cardColor="Blue"
cardImageSrc="http://localhost:8000/p/ROS154/w400"
cardComment="A comment about the card"
foiling="C"
></fab-card>
</div>
</body> </body>
</html> </html>

1099
fab-ui/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

99
fab-ui/src/fab-card.ts Normal file
View File

@ -0,0 +1,99 @@
import { LitElement, css, html } from 'lit'
import { customElement, property } from 'lit/decorators.js'
@customElement('fab-card')
export class FabCard extends LitElement {
@property({ type: String })
cardSetId = '';
@property({ type: String })
cardName = '';
@property({ type: String })
cardColor = '';
@property({ type: String })
cardComment = '';
@property({ type: String })
foiling = 'S';
render() {
return html`
<div class="card ${this.foiling != 'S' ? (this.foiling == 'R' ? 'rainbow-foiling' : 'cold-foiling') : ''}">
<div class="card-img">
<img class="single-card-img" src="http://localhost:8000/p/${this.cardSetId}/w400" alt="${this.cardName}">
</div>
<div class="card-details">
<span class="printing-id">${this.cardSetId}</span>
<span class="card-name">${this.cardName}</span>
<span class="card-color color-${this.cardColor}">(${this.cardColor})</span>
<span class="card-foiling">${this.foiling == "S" ? '' : this.foiling }</span>
<!--<span class="comment">${this.cardComment}</span>-->
</div>
</div>
`;
}
static styles = css`
.card {
width: 220px;
border-radius: 10px;
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
}
.card-img {
position: relative;
width: 100%;
height: 0;
padding-bottom: 140%;
}
.card-details {
padding: 10px;
font-size: 12px;
}
.card-img img {
position: absolute;
top: 0;
left: 0;
border-radius: 8px;
box-shadow: rgba(0,0,0,0.18) 0px 2px 8px;
transition: box-shadow 0.2s, z-index 0.2s, opacity 0.2s;
}
.card-img img.single-card-img {
width: 100%;
left: 0;
top: 0;
position: absolute;
transform: none;
z-index: 2;
}
.printing-id {
font-family: "Geist Mono", monospace;
font-weight: bold;
color: #666;
}
.rainbow-foiling {
background: linear-gradient(90deg, #ffb347, #ffcc33, #b4ffb3, #b3d1ff, #e0b3ff, #ffb3d1, #ffb347);
background-size: 200% 200%;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0 1px 2px rgba(0,0,0,0.08);
animation: rainbow-move 3s linear infinite alternate;
font-weight: bold;
}
@keyframes rainbow-move {
0% { background-position: 0% 50%; }
100% { background-position: 100% 50%; }
}
.cold-foiling {
background: linear-gradient(90deg, #b3e0ff, #e6e6e6, #b3e0ff, #e6e6e6, #b3e0ff);
background-size: 200% 200%;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0 1px 2px rgba(0,0,0,0.08);
animation: cold-move 2.5s linear infinite alternate;
font-weight: bold;
}
@keyframes cold-move {
0% { background-position: 0% 50%; }
100% { background-position: 100% 50%; }
}
`;
}

View File

@ -1,38 +1,14 @@
:root { @import url('https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif; @import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@100..900&family=Geist:wght@100..900&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body { body {
margin: 0; font-family: Geist, sans-serif;
display: flex; font-optical-sizing: auto;
place-items: center;
min-width: 320px;
min-height: 100vh;
} }
@media (prefers-color-scheme: light) { .cards-list {
:root { display: flex;
color: #213547; flex-wrap: wrap;
background-color: #ffffff; gap: 12px;
} justify-content: center;
} }