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

Секции страниц terminalmonitorthree3dportfolio

Dev Monitor 3D

3D-монитор CRT с чернильными контурами: опускается на место, покачивается за курсором и печатает строки терминала на инвертированном экране.

Живое превью

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

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

astro
---
import { DevMonitor } from 'astro-component-kit/sections';
---

<!-- npm install three -->
<DevMonitor lines={['$ npm run build', '> built in 1.2s']} />
--- import { DevMonitor } from 'astro-component-kit/sections'; --- <!-- npm install three --> <DevMonitor lines={['$ npm run build', '> built in 1.2s']} />

Примеры в контексте

Реальный код из набора: как этот элемент используется в шаблонах, секциях и других компонентах.

Шаблон Портфолио разработчика PortfolioContactPage.astro
astro
<DevMonitor
  lines={['$ ping ' + site.githubUser, '> 64 bytes: time=0.4ms', '$ status --availability', `> ${site.status.toLowerCase()}`, '$ mail --to hello', '> ready when you are']}
  prompt="guest@contact:~$"
  height="340px"
  label="Contact terminal"
/>
<DevMonitor lines={['$ ping ' + site.githubUser, '> 64 bytes: time=0.4ms', '$ status --availability', `> ${site.status.toLowerCase()}`, '$ mail --to hello', '> ready when you are']} prompt="guest@contact:~$" height="340px" label="Contact terminal" />

Используется в

Хорошо сочетается с

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

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

astro
---
/**
 * DevMonitor — 3D CRT monitor ("Keycap" design): a paper body with ink outlines that drops into
 * place, sways with the cursor and types terminal lines on an inverted screen. Use it as a visual
 * in heroes or project pages. Light/dark aware. Needs the optional `three` peer dependency.
 *
 * @param {string[]} lines - Lines typed in a loop. Lines starting with "$ " get the prompt.
 * @param {string} prompt - Shell prompt. Default 'dev@keycap:~$'.
 * @param {string} height - Canvas height. Default '420px'.
 * @param {string} label - Accessible description. Default 'Terminal on a 3D monitor'.
 * @param {string} className - Extra class.
 *
 * Accessibility: role="img" whose label includes the terminal lines; reduced motion shows every
 * line at once with no drop or typing.
 */
interface Props {
  lines?: string[];
  prompt?: string;
  height?: string;
  label?: string;
  className?: string;
}

const { lines = ['$ whoami', '> full-stack developer'], prompt = 'dev@keycap:~$', height = '420px', label = 'Terminal on a 3D monitor', className = '' } = Astro.props;
---

<div
  class:list={['dvmn', className]}
  style={`--dvmn-h:${height}`}
  data-dev-monitor
  data-lines={JSON.stringify(lines)}
  data-prompt={prompt}
  role="img"
  aria-label={`${label}: ${lines.join(' — ')}`}
></div>

<style>
  .dvmn {
    --kc-ink: var(--c-text-1);
    --kc-paper: var(--c-bg);
    --kc-muted: var(--c-text-3);
    position: relative;
    width: 100%;
    height: var(--dvmn-h);
  }
</style>

<script>
  import * as THREE from 'three';
  import { mountMonitor } from '../three/monitor-scene';

  document.querySelectorAll<HTMLElement>('[data-dev-monitor]:not([data-bound])').forEach((el) => {
    el.dataset.bound = '';
    mountMonitor(el, THREE, { lines: JSON.parse(el.dataset.lines || '[]'), prompt: el.dataset.prompt });
  });
</script>
--- /** * DevMonitor — 3D CRT monitor ("Keycap" design): a paper body with ink outlines that drops into * place, sways with the cursor and types terminal lines on an inverted screen. Use it as a visual * in heroes or project pages. Light/dark aware. Needs the optional `three` peer dependency. * * @param {string[]} lines - Lines typed in a loop. Lines starting with "$ " get the prompt. * @param {string} prompt - Shell prompt. Default 'dev@keycap:~$'. * @param {string} height - Canvas height. Default '420px'. * @param {string} label - Accessible description. Default 'Terminal on a 3D monitor'. * @param {string} className - Extra class. * * Accessibility: role="img" whose label includes the terminal lines; reduced motion shows every * line at once with no drop or typing. */ interface Props { lines?: string[]; prompt?: string; height?: string; label?: string; className?: string; } const { lines = ['$ whoami', '> full-stack developer'], prompt = 'dev@keycap:~$', height = '420px', label = 'Terminal on a 3D monitor', className = '' } = Astro.props; --- <div class:list={['dvmn', className]} style={`--dvmn-h:${height}`} data-dev-monitor data-lines={JSON.stringify(lines)} data-prompt={prompt} role="img" aria-label={`${label}: ${lines.join(' — ')}`} ></div> <style> .dvmn { --kc-ink: var(--c-text-1); --kc-paper: var(--c-bg); --kc-muted: var(--c-text-3); position: relative; width: 100%; height: var(--dvmn-h); } </style> <script> import * as THREE from 'three'; import { mountMonitor } from '../three/monitor-scene'; document.querySelectorAll<HTMLElement>('[data-dev-monitor]:not([data-bound])').forEach((el) => { el.dataset.bound = ''; mountMonitor(el, THREE, { lines: JSON.parse(el.dataset.lines || '[]'), prompt: el.dataset.prompt }); }); </script>

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

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