Skip to content

Instantly share code, notes, and snippets.

View H-ymt's full-sized avatar
👋

Yamato Handai H-ymt

👋
View GitHub Profile
@H-ymt
H-ymt / AGENTS.md
Last active September 21, 2025 10:31
フロントエンド開発の AGENT.md のサンプル

AGENTS.md

Dev environment tips

  • Use npm install in the project root to install all dependencies.
  • Check the name field in each package's package.json to confirm the correct name—ignore the top-level one.
  • Use npm run dev to start the local development server.
  • Use npm run build to create a production build.
  • Use npm run lint to check code quality and TypeScript types.
  • Use npm run typecheck to run TypeScript type checking independently (if configured).
@H-ymt
H-ymt / react-button.md
Last active March 23, 2025 11:08
React x CSS Modulesでつくる汎用性の高いボタンコンポーネント
import clsx from "clsx";
import styles from "./index.module.css";
import Link from "next/link";

type ButtonProps = {
  children: React.ReactNode;
  className?: string;
  visual?: "primary" | "secondary";
  size?: "sm" | "md" | "lg";
@H-ymt
H-ymt / infinite-scroll.md
Last active May 11, 2025 02:04
CSSだけでテキストの無限スクロール
<div class="loop">
  <p aria-hidden="true">A Future of Smiles and Growth</p>
  <p aria-hidden="true">A Future of Smiles and Growth</p>
</div>
.loop {
 position: absolute;
@H-ymt
H-ymt / index.html
Last active July 22, 2025 09:21
<dialog>タグを使用したモーダル
<button type="button" class="openModal js-modalTrigger" data-modal-id="dialog1">Open Modal</button>
<dialog id="dialog1" aria-label="Modal name" class="dialog scrollControl js-modal">
<div class="modal__inner js-modalContent">
<h1 class="modal__title">Lorem ipsum dolor sit.</h1>
<p class="modal__text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Culpa cumque odit quaerat libero, facere tempora placeat molestias eum sed
error rerum quisquam veritatis. Excepturi beatae ut vitae autem saepe expedita!
</p>
<button type="button" class="closeModal js-modalClose">Close Modal</button>
</div>
@H-ymt
H-ymt / accordion.js
Last active January 3, 2025 14:12
<details/>タグを使用した排他的アコーディオン
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".js-details").forEach((el) => {
const summary = el.querySelector(".js-summary")
const content = el.querySelector(".js-content")
summary.addEventListener("click", (event) => toggleContent(el, content, event))
})
})
const animTiming = {
@H-ymt
H-ymt / initializeViewport.js
Last active November 23, 2024 11:03
ビューポートを固定させて狭小デバイスのレスポンシブ対応をするJS
// ビューポートのサイズを取得する
const viewportSize = () => {
const vw = window.innerWidth * 0.01
const vh = window.innerHeight * 0.01
document.documentElement.style.setProperty("--vw", `${vw}px`)
document.documentElement.style.setProperty("--vh", `${vh}px`)
}
// 375px以下のビューポートを固定
@H-ymt
H-ymt / _mixin.scss
Last active November 23, 2024 11:03
Sassでよく使用するmixin
// 三点リーダー
@mixin line-clamp($num, $num-sp: null) {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: $num;
overflow: hidden;
@if $num-sp {
@include sp {
-webkit-line-clamp: $num-sp;
@H-ymt
H-ymt / global.css
Created August 7, 2024 13:21
CSS でフォントを可変させる
*,
::before,
::after {
--clamp-root-font-size: 16;
--clamp-slope: calc(
(var(--clamp-max) - var(--clamp-min)) /
(var(--clamp-viewport-max) - var(--clamp-viewport-min))
);
--clamp-y-axis-intersection: calc(
var(--clamp-min) - (var(--clamp-slope) * var(--clamp-viewport-min))
@H-ymt
H-ymt / index.html
Last active September 7, 2024 13:26
アクセシビリティを考慮したタブUI
<div class="tabs-container">
<div class="tabs-list" role="tablist" aria-label="サンプルタブ">
<button class="tab" role="tab" aria-selected="true" aria-controls="panel-1" id="tab-1" tabindex="0">
タブ1
</button>
<button class="tab" role="tab" aria-selected="false" aria-controls="panel-2" id="tab-2" tabindex="-1">
タブ2
</button>
<button class="tab" role="tab" aria-selected="false" aria-controls="panel-3" id="tab-3" tabindex="-1">
タブ3
@H-ymt
H-ymt / internalScroll.js
Last active November 23, 2024 10:59
ヘッダーの高さを取得してスムーススクロールさせるJS
document.addEventListener("DOMContentLoaded", () => {
const handleInternalLink = (e) => {
e.preventDefault()
const targetId = e.currentTarget.getAttribute("href").slice(1)
const targetElement = document.getElementById(targetId)
if (targetElement) {
const headerHeight = document.querySelector("header")?.offsetHeight || 0
const scrollToPosition = targetElement.offsetTop - headerHeight
window.scrollTo({
top: scrollToPosition,