1 звезда на GitHub = 1 новый компонент.

Карточки cardretro

Retro Arcade Game Card

Игровая карточка в ретро-стиле с пиксельными шрифтами и CRT-эффектом развертки.

Живое превью

INSERT COIN [1P]
STAGE 04 • VOID MATRIX

NEON RUNNER 2084

SCORE 084,320
HI-SCORE 142,000

Использование

Скопируйте и вставьте этот код на вашу страницу Astro:

astro
---
import { RetroArcadeGameCard } from 'astro-component-kit';
---

<RetroGameCard title="SUPER ASTRO" level="LVL 01" score="4820" />
--- import { RetroArcadeGameCard } from 'astro-component-kit'; --- <RetroGameCard title="SUPER ASTRO" level="LVL 01" score="4820" />

Ручная установка

Если вы не используете пакет npm, создайте файл и вставьте следующий код: src/components/lib/RetroArcadeGameCard.astro:

astro
---
/**
 * RetroGameCard — Vintage 8-bit arcade gaming card with scanlines, CRT screen, health hearts, and score telemetry.
 * 
 * @param {string} title - The retro game title. Default is 'NEON RUNNER 2084'.
 * @param {string} level - Current stage or mission string. Default is 'STAGE 04 • VOID MATRIX'.
 * @param {number|string} score - Player's active score. Default is '084,320'.
 * @param {string} highScore - Leaderboard record score. Default is '142,000'.
 * @param {number} lives - Remaining player lives. Default is 3.
 */
interface Props {
  title?: string;
  level?: string;
  score?: number | string;
  highScore?: string;
  lives?: number;
}

const {
  title = 'NEON RUNNER 2084',
  level = 'STAGE 04 • VOID MATRIX',
  score = '084,320',
  highScore = '142,000',
  lives = 3,
} = Astro.props;
---

<div class="retro-game" role="region" aria-label={`Arcade game card: ${title}`}>
  <div class="retro-game__scanlines" aria-hidden="true"></div>

  <div class="retro-game__header">
    <span class="retro-game__insert-coin">INSERT COIN [1P]</span>
    <div class="retro-game__lives" aria-label={`${lives} lives remaining`}>
      {Array.from({ length: lives }).map(() => (
        <svg class="heart-icon" width="14" height="14" viewBox="0 0 24 24" fill="#ef4444" stroke="#ef4444" stroke-width="2" aria-hidden="true">
          <path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path>
        </svg>
      ))}
    </div>
  </div>

  <div class="retro-game__screen">
    <div class="retro-game__screen-grid" aria-hidden="true"></div>
    <span class="retro-game__stage-tag">{level}</span>
    <h3 class="retro-game__title">{title}</h3>
  </div>

  <div class="retro-game__telemetry">
    <div class="telemetry-block">
      <span class="telemetry-block__label">SCORE</span>
      <span class="telemetry-block__val">{score}</span>
    </div>
    <div class="telemetry-block telemetry-block--hi">
      <span class="telemetry-block__label">HI-SCORE</span>
      <span class="telemetry-block__val">{highScore}</span>
    </div>
  </div>

  <div class="retro-game__footer">
    <span class="blink-press">PRESS START BUTTON</span>
  </div>
</div>

<style>
  .retro-game {
    background: #0d131f;
    border: 3px solid #22c55e;
    border-radius: var(--r-md, 12px);
    padding: var(--sp-4, 1.25rem);
    position: relative;
    box-shadow: 6px 6px 0 #22c55e, 0 16px 36px rgba(0, 0, 0, 0.6);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    max-width: 320px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .retro-game:hover {
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 #22c55e, 0 20px 40px rgba(34, 197, 94, 0.2);
  }

  .retro-game__scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(rgba(13, 19, 31, 0) 50%, rgba(0, 0, 0, 0.4) 50%);
    background-size: 100% 4px;
    z-index: 5;
    opacity: 0.65;
  }

  .retro-game__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
  }

  .retro-game__insert-coin {
    font-size: 0.68rem;
    font-weight: 800;
    color: #f59e0b;
    letter-spacing: 0.05em;
  }

  .retro-game__lives {
    display: flex;
    gap: 3px;
  }

  .retro-game__screen {
    background: #050a10;
    border: 2px solid rgba(34, 197, 94, 0.3);
    border-radius: 6px;
    padding: var(--sp-4, 1rem);
    text-align: center;
    position: relative;
    overflow: hidden;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
  }

  .retro-game__screen-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(to right, rgba(34, 197, 94, 0.08) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(34, 197, 94, 0.08) 1px, transparent 1px);
    background-size: 16px 16px;
    pointer-events: none;
  }

  .retro-game__stage-tag {
    font-size: 0.65rem;
    color: #22c55e;
    font-weight: 800;
    letter-spacing: 0.08em;
  }

  .retro-game__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.05em;
    text-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  }

  .retro-game__telemetry {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 2;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
  }

  .telemetry-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .telemetry-block__label {
    font-size: 0.62rem;
    color: #64748b;
    font-weight: 700;
  }

  .telemetry-block__val {
    font-size: 0.88rem;
    font-weight: 900;
    color: #22c55e;
  }

  .telemetry-block--hi .telemetry-block__val {
    color: #eab308;
  }

  .retro-game__footer {
    text-align: center;
    position: relative;
    z-index: 2;
    padding-top: 0.2rem;
  }

  .blink-press {
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.08em;
    animation: blink-anim 1.2s infinite;
  }

  @keyframes blink-anim {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0.2; }
  }
</style>
--- /** * RetroGameCard — Vintage 8-bit arcade gaming card with scanlines, CRT screen, health hearts, and score telemetry. * * @param {string} title - The retro game title. Default is 'NEON RUNNER 2084'. * @param {string} level - Current stage or mission string. Default is 'STAGE 04 • VOID MATRIX'. * @param {number|string} score - Player's active score. Default is '084,320'. * @param {string} highScore - Leaderboard record score. Default is '142,000'. * @param {number} lives - Remaining player lives. Default is 3. */ interface Props { title?: string; level?: string; score?: number | string; highScore?: string; lives?: number; } const { title = 'NEON RUNNER 2084', level = 'STAGE 04 • VOID MATRIX', score = '084,320', highScore = '142,000', lives = 3, } = Astro.props; --- <div class="retro-game" role="region" aria-label={`Arcade game card: ${title}`}> <div class="retro-game__scanlines" aria-hidden="true"></div> <div class="retro-game__header"> <span class="retro-game__insert-coin">INSERT COIN [1P]</span> <div class="retro-game__lives" aria-label={`${lives} lives remaining`}> {Array.from({ length: lives }).map(() => ( <svg class="heart-icon" width="14" height="14" viewBox="0 0 24 24" fill="#ef4444" stroke="#ef4444" stroke-width="2" aria-hidden="true"> <path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path> </svg> ))} </div> </div> <div class="retro-game__screen"> <div class="retro-game__screen-grid" aria-hidden="true"></div> <span class="retro-game__stage-tag">{level}</span> <h3 class="retro-game__title">{title}</h3> </div> <div class="retro-game__telemetry"> <div class="telemetry-block"> <span class="telemetry-block__label">SCORE</span> <span class="telemetry-block__val">{score}</span> </div> <div class="telemetry-block telemetry-block--hi"> <span class="telemetry-block__label">HI-SCORE</span> <span class="telemetry-block__val">{highScore}</span> </div> </div> <div class="retro-game__footer"> <span class="blink-press">PRESS START BUTTON</span> </div> </div> <style> .retro-game { background: #0d131f; border: 3px solid #22c55e; border-radius: var(--r-md, 12px); padding: var(--sp-4, 1.25rem); position: relative; box-shadow: 6px 6px 0 #22c55e, 0 16px 36px rgba(0, 0, 0, 0.6); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; max-width: 320px; box-sizing: border-box; overflow: hidden; display: flex; flex-direction: column; gap: 0.75rem; transition: transform 0.2s ease, box-shadow 0.2s ease; } .retro-game:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 #22c55e, 0 20px 40px rgba(34, 197, 94, 0.2); } .retro-game__scanlines { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(rgba(13, 19, 31, 0) 50%, rgba(0, 0, 0, 0.4) 50%); background-size: 100% 4px; z-index: 5; opacity: 0.65; } .retro-game__header { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 2; } .retro-game__insert-coin { font-size: 0.68rem; font-weight: 800; color: #f59e0b; letter-spacing: 0.05em; } .retro-game__lives { display: flex; gap: 3px; } .retro-game__screen { background: #050a10; border: 2px solid rgba(34, 197, 94, 0.3); border-radius: 6px; padding: var(--sp-4, 1rem); text-align: center; position: relative; overflow: hidden; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; } .retro-game__screen-grid { position: absolute; inset: 0; background-image: linear-gradient(to right, rgba(34, 197, 94, 0.08) 1px, transparent 1px), linear-gradient(to bottom, rgba(34, 197, 94, 0.08) 1px, transparent 1px); background-size: 16px 16px; pointer-events: none; } .retro-game__stage-tag { font-size: 0.65rem; color: #22c55e; font-weight: 800; letter-spacing: 0.08em; } .retro-game__title { margin: 0; font-size: 1.1rem; font-weight: 900; color: #fff; letter-spacing: 0.05em; text-shadow: 0 0 8px rgba(34, 197, 94, 0.6); } .retro-game__telemetry { display: flex; justify-content: space-between; position: relative; z-index: 2; background: rgba(0, 0, 0, 0.3); padding: 0.5rem 0.75rem; border-radius: 6px; } .telemetry-block { display: flex; flex-direction: column; gap: 2px; } .telemetry-block__label { font-size: 0.62rem; color: #64748b; font-weight: 700; } .telemetry-block__val { font-size: 0.88rem; font-weight: 900; color: #22c55e; } .telemetry-block--hi .telemetry-block__val { color: #eab308; } .retro-game__footer { text-align: center; position: relative; z-index: 2; padding-top: 0.2rem; } .blink-press { font-size: 0.72rem; font-weight: 800; color: #fff; letter-spacing: 0.08em; animation: blink-anim 1.2s infinite; } @keyframes blink-anim { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.2; } } </style>

Краткая информация

Категория
Карточки
Имя файла
RetroArcadeGameCard.astro
Зависимости
Нет — чистый Astro + CSS
Теги
cardretro