Asagiriは一貫した命名規則を使用しています:
| パターン | 説明 | 例 |
|---|---|---|
.component |
基本コンポーネント | .btn, .card, .alert |
.component-variant |
バリエーション | .btn-primary, .alert-success |
.component-size |
サイズ | .btn-sm, .btn-lg |
.component-state |
状態 | .is-active, .is-disabled |
.component__element |
子要素(BEM) | .card__header, .card__body |
.utility-value |
ユーティリティ | .m-4, .d-flex, .opacity-50 |
各コンポーネントは以下のAPIパターンに従います:
// 基本構造
.component {
// 基本スタイル
}
.component-variant {
// バリエーション(primary, secondary, success, etc.)
}
.component-size {
// サイズ(sm, md, lg, xl)
}
.component-state {
// 状態(active, disabled, loading)
}
// 例: Button
.btn { /* 基本 */ }
.btn-primary { /* カラー */ }
.btn-lg { /* サイズ */ }
.btn[disabled] { /* 状態 */ }
asagiri/
├── scss/
│ ├── main.scss # エントリーポイント
│ ├── _Normalize.scss # リセットCSS
│ ├── _Typography.scss # タイポグラフィ
│ ├── _Accessibility.scss # アクセシビリティ
│ │
│ ├── Tokens/ # デザイントークン
│ │ ├── _Token.scss # すべてのトークン
│ │ ├── _Color.scss # カラーシステム
│ │ ├── _Spacing.scss # スペーシング
│ │ └── _Breakpoints.scss # ブレークポイント
│ │
│ ├── Components/ # UIコンポーネント
│ │ ├── _Component.scss # すべてのコンポーネント
│ │ ├── _Button.scss # ボタン
│ │ ├── _Alert.scss # アラート
│ │ ├── _Badge.scss # バッジ
│ │ ├── _Card.scss # カード
│ │ ├── _Tabs.scss # タブ
│ │ ├── _Accordion.scss # アコーディオン
│ │ ├── _Pagination.scss # ページネーション
│ │ ├── _Breadcrumb.scss # パンくず
│ │ ├── _Progress.scss # プログレスバー
│ │ ├── _Loading.scss # ローディング
│ │ ├── _Skeleton.scss # スケルトン
│ │ ├── _Avatar.scss # アバター
│ │ ├── _FormValidation.scss # フォーム検証
│ │ └── _Dropdown.scss # ドロップダウン
│ │
│ └── Utility/ # ユーティリティ
│ ├── _UtilityAll.scss # すべてのユーティリティ
│ ├── _Grid.scss # CSS Grid
│ ├── _SpacingSystem.scss # スペーシング
│ └── _Display.scss # 表示制御
│
├── css/
│ └── main.css # コンパイル済みCSS
│
├── index.d.ts # TypeScript型定義
├── index.js # CommonJS エントリー
└── index.mjs # ES Module エントリー
Asagiriは階層的なデザイントークンシステムを使用:
// Level 1: Primitive Tokens (基本値)
--primary-h: 191;
--primary-s: 47%;
--primary-l: 53%;
// Level 2: Semantic Tokens (意味のあるトークン)
--color-primary: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 100%);
// Level 3: Component Tokens (コンポーネント固有)
.btn-primary {
background: var(--color-primary);
}
| Variable | Description | Default (Light) | Default (Dark) |
|---|---|---|---|
--color-primary |
プライマリカラー | #31a9c7 | #60a5fa (lighter) |
--color-secondary |
セカンダリカラー | #5865a7 | #a78bfa (lighter) |
--color-success |
成功色 | #00a859 | #22c55e |
--color-danger |
危険色 | #e1323c | #ef4444 |
--color-warning |
警告色 | #ebbb0c | #fbbf24 |
--color-info |
情報色 | #1ec2c2 | #22d3ee |
--color-text |
テキスト色 | #4c5059 | #e4e4e7 |
--color-bg |
背景色 | #f9f9f9 | #0f0f0f |
--color-box |
ボックス背景 | #ffffff | #18181b |
--color-border |
ボーダー色 | rgba(0,0,0,0.2) | rgba(255,255,255,0.1) |
| Variable | Value | Pixels |
|---|---|---|
--spacing-1 | 0.25rem | 4px |
--spacing-2 | 0.5rem | 8px |
--spacing-3 | 0.75rem | 12px |
--spacing-4 | 1rem | 16px |
--spacing-5 | 1.25rem | 20px |
--spacing-6 | 1.5rem | 24px |
--spacing-8 | 2rem | 32px |
--spacing-10 | 2.5rem | 40px |
--spacing-12 | 3rem | 48px |
// JavaScriptでCSS変数を取得
const root = document.documentElement;
const primaryColor = getComputedStyle(root).getPropertyValue('--color-primary');
// CSS変数を動的に変更
root.style.setProperty('--color-primary', '#ff0000');
// すべてのAsagiri CSS変数を取得
const asagiriVars = Array.from(document.styleSheets)
.flatMap(sheet => Array.from(sheet.cssRules))
.filter(rule => rule.selectorText === ':root')
.flatMap(rule => Array.from(rule.style))
.filter(prop => prop.startsWith('--color-') || prop.startsWith('--spacing-'));
Asagiriは600+の型定義を提供しています:
import { AsagiriClass, ButtonClass, AlertClass, BadgeClass } from 'asagiri';
// すべてのAsagiriクラスの型
type AllClasses = AsagiriClass;
// 特定のコンポーネントの型
type ButtonClasses = ButtonClass;
// 'btn' | 'btn-primary' | 'btn-secondary' | 'btn-lg' | ...
// TypeSafeなクラス名使用
const className: ButtonClass = 'btn-primary'; // OK
const invalid: ButtonClass = 'invalid-class'; // Type Error
// React での使用
interface ButtonProps {
variant?: ButtonClass;
children: React.ReactNode;
}
function Button({ variant = 'btn', children }: ButtonProps) {
return ;
}
// 使用例
import { cn, asagiri } from 'asagiri';
// クラス名を結合
cn('btn', 'btn-primary', 'm-4'); // => 'btn btn-primary m-4'
// 条件付きクラス
cn('btn', isActive && 'active'); // => 'btn active' (if isActive is true)
// オブジェクト形式
cn('btn', {
'active': isActive,
'disabled': isDisabled
}); // => 'btn active' (if isActive is true)
// 配列形式
cn(['btn', 'btn-primary']); // => 'btn btn-primary'
// TypeScript で型安全に使用
const classes: AsagiriClass = cn('m-4', 'p-2', 'd-flex');
# リポジトリをクローン
git clone https://github.com/BoxPistols/asagiri.git
cd asagiri
# 依存関係をインストール
npm install
# 開発モード(watch)
npm run dev
# または手動でコンパイル
npx sass scss/main.scss css/main.css --watch
| Command | Description |
|---|---|
npm run build |
通常ビルド(開発用、source map付き) |
npm run build:compressed |
圧縮ビルド(本番用、minified) |
npm run dev |
開発モード(watch + live reload) |
npm test |
テスト実行(予定) |
必要なコンポーネントだけをインポートしてカスタムビルドを作成:
// custom.scss
@import 'asagiri/scss/Tokens/Token';
@import 'asagiri/scss/Normalize';
// 必要なコンポーネントだけインポート
@import 'asagiri/scss/Components/Button';
@import 'asagiri/scss/Components/Card';
@import 'asagiri/scss/Components/Alert';
// カスタムスタイルを追加
.my-custom-component {
color: var(--color-primary);
}
git clone https://github.com/YOUR_USERNAME/asagiri.git
cd asagiri
npm install
git checkout -b feature/your-feature-name
scss/ディレクトリ)npm run build
npm run build:compressed
# ブラウザで確認
python3 -m http.server 8000
git add .
git commit -m "feat: add new component"
git push origin feature/your-feature-name
# GitHubでPull Requestを作成
| Prefix | Description | Example |
|---|---|---|
feat: |
新機能 | feat: add tooltip component |
fix: |
バグ修正 | fix: button hover state |
docs: |
ドキュメント | docs: update API reference |
style: |
スタイル変更 | style: format SCSS files |
refactor: |
リファクタリング | refactor: simplify color system |
test: |
テスト追加 | test: add button tests |
chore: |
雑務 | chore: update dependencies |
// 1. 新しいSCSSファイルを作成
// scss/Components/_Tooltip.scss
.tooltip {
position: relative;
display: inline-block;
&__text {
visibility: hidden;
background-color: var(--color-dark);
color: var(--color-white);
padding: var(--spacing-2) var(--spacing-3);
border-radius: var(--border-radius);
position: absolute;
z-index: 1000;
bottom: 125%;
left: 50%;
transform: translateX(-50%);
// ダークモード対応
[data-theme="dark"] & {
background-color: var(--color-light);
color: var(--color-dark);
}
}
&:hover &__text {
visibility: visible;
}
}
// 2. _Component.scss にインポート追加
@import "Tooltip";
// 3. TypeScript型定義を追加(index.d.ts)
export type TooltipClass =
| 'tooltip'
| 'tooltip__text'
| 'tooltip-top'
| 'tooltip-bottom'
| 'tooltip-left'
| 'tooltip-right';
// 4. AsagiriClassに追加
export type AsagiriClass =
| ButtonClass
| CardClass
| TooltipClass // ← 追加
| ...;
// themes/corporate.scss
@import '../scss/Tokens/Token';
// カスタムカラーパレット
:root {
--color-primary: #003366; // コーポレートブルー
--color-secondary: #6c757d;
--color-accent: #ffc107; // ゴールド
}
// カスタムコンポーネントスタイル
.btn {
text-transform: uppercase;
letter-spacing: 0.05em;
font-weight: 600;
}
.card {
border: 2px solid var(--color-border);
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
// ビルド
// npx sass themes/corporate.scss css/corporate.css
AsagiriはSemantic Versioningに従います:
| Version | Changes | Breaking Changes |
|---|---|---|
| MAJOR (3.0.0) | 破壊的変更 | あり |
| MINOR (2.1.0) | 機能追加、下位互換性あり | なし |
| PATCH (2.0.1) | バグ修正 | なし |
| Level | Description | Components |
|---|---|---|
| Stable | 本番環境で使用可能 | Button, Card, Alert, Form, Grid |
| Beta | テスト中、APIが変更される可能性 | Dropdown, Tooltip (予定) |
| Experimental | 実験的、大幅に変更される可能性 | - |