Skip to content

Instantly share code, notes, and snippets.

View lightsound's full-sized avatar
🎮
Writing code like playing game

しまぶー lightsound

🎮
Writing code like playing game
View GitHub Profile
@lightsound
lightsound / next-app-router.md
Created May 18, 2023 11:04
Next.js App Router 講座

App Router 講座

Server Components について

Getting Started: React Essentials | Next.js

React Server Components は、サーバーとクライアントを活用したハイブリッドアプリケーション構築のための新しいメンタルモデル

Why

  • JavaScript バンドルのサイズ削減
  • async コンポーネントを使える
@lightsound
lightsound / hoge.md
Last active September 2, 2022 04:39

Test

  • hoge

npm を使いこなせるようになろう

  • package.json の見方
  • scripts
  • パッケージのインストール・更新・削除
  • セマンティクスバージョニングと lock ファイル

ESLint・Prettier を入れよう

  • 最低限で良い

第 1 回

アイディア WS

💡 発散

@lightsound
lightsound / react-spectrum.md
Last active July 22, 2022 09:54
React Spectrumの講座用

React Spectrum

モチベーション

デザインシステム間の主な違いは、スタイリング。それ以外は共通の部分が多いのに各社イチから自分で実装していて大変。特にアクセシビリティ、国際化、キーボード、マウス、タッチインタラクション対応などは難しい。そこを何とかするのが React Spectrum。

基礎

React Spectrum ではコンポーネントを次の 3 つに分類する。

@lightsound
lightsound / NoAnimatedButton.tsx
Created March 23, 2022 06:29
Mantine Buttonコンポーネントの凹まない版
import type { ButtonProps } from "@mantine/core";
import { Button } from "@mantine/core";
import { cloneElement, forwardRef } from "react";
export const NoAnimatedButton = forwardRef<
HTMLButtonElement,
ButtonProps<"button">
>(({ sx, ...props }, ref) => {
return cloneElement(<Button />, {
sx: { ...sx, "&:not(:disabled):active": { transform: "none" } },
@lightsound
lightsound / study-reduce.ts
Last active February 11, 2022 04:36
Reduce関数ライブ講座で使用したコード
// 一番シンプルな例
const input = [1, 2, 3, 4];
const output = input.reduce((prev, current) => {
return prev + current;
});
console.log(output); // 10
import { Tab } from "@headlessui/react";
import type { VFC } from "react";
import { Fragment } from "react";
type Props = {
items: { label: string; content: JSX.Element }[];
};
export const HorizontalTab: VFC<Props> = (props) => {
return (
@lightsound
lightsound / createStorybookFactory.tsx
Created January 12, 2022 11:40
Storybookのテンプレートを削減するためのファクトリー関数
import { AnyFramework, ComponentTitle, StoryAnnotations } from '@storybook/csf'
import { ComponentMeta, ComponentStory } from '@storybook/react'
import { VFC } from 'react'
export const createStorybookFactory = <P extends object>(Component: VFC<P>) => {
const Template = ((args) => <Component {...args} />) as ComponentStory<
typeof Component
>
const Default = Template.bind({})
@lightsound
lightsound / Button.tsx
Last active October 27, 2022 02:05
Next.jsでボタンを良い感じに使えるようにするためのコンポーネント
import Link, { LinkProps } from 'next/link'
import { ComponentPropsWithRef, createElement, forwardRef } from 'react'
// Types
type Tag = 'button' | 'input' | 'a'
type Element = HTMLButtonElement | HTMLInputElement | HTMLAnchorElement
type Button = {
tag: 'button'
type?: ComponentPropsWithRef<'button'>['type']