Skip to content

Commit 0d8a31e

Browse files
committed
docs: Consolidate duplicate Category 3 sections (#2054)
1 parent 3cf5be3 commit 0d8a31e

File tree

1 file changed

+0
-102
lines changed

1 file changed

+0
-102
lines changed

docs/dev-notes/2026-01-02/migrate-from-svelte-5-ui-lib-to-flowbite-svelte/component-mapping.md

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -830,105 +830,3 @@ import { Heading, Button, Label } from 'flowbite-svelte';
830830

831831
- [メイン計画ドキュメント](./plan.md)
832832
- [テスト戦略](./testing-strategy.md)
833-
834-
---
835-
836-
## カテゴリ3:外部ライブラリ復帰(⭐⭐ 難易度中)
837-
838-
| コンポーネント | 変更内容 | 詳細 |
839-
| -------------- | ------------------------------------------------ | --------------------------------------------------- |
840-
| **Carousel** | embla-carousel-svelte → Flowbite Svelte Carousel | Plugin-based → Prop-based API、自動スケーリング無し |
841-
842-
### Carousel プロパティ対応表
843-
844-
| 項目 | embla-carousel-svelte | Flowbite Carousel | 説明 |
845-
| ---------------------- | ------------------------------------------------ | -------------------------------------------- | ------------------------------------------------------------- |
846-
| **基本API** | `use:emblaCarouselSvelte={{ options, plugins }}` | `<Carousel {images} duration={3000}>` | embla: action directive / Flowbite: component-based |
847-
| **自動スライド** | `Autoplay()` plugin | `duration` prop | embla: plugin系 / Flowbite: prop単位で制御 |
848-
| **ループ動作** | `options = { loop: true }` | デフォルト有効 | Flowbite は常にループ(設定不可) |
849-
| **画像配列形式** | `[{ src: '...', alt: '...' }]` | `[{ src: '...', alt: '...', title: '...' }]` | **互換性あり**(同一形式) |
850-
| **画像スケーリング** | `imgClass="object-contain h-full w-fit"` | `slideFit="contain"` | embla: CSS class管理 / Flowbite: prop制御 |
851-
| **レスポンシブ高さ** | 外側div に手動で class 設定 | `class="min-h-[300px] xs:min-h-[400px]..."` | どちらも外側divで制御必須 |
852-
| **Overflow 処理** | 外側 div に `overflow-hidden` | 内部処理あり + 明示的推奨 | Flowbite内部処理だが、CSS overrides対応のため明示的指定が安全 |
853-
| **Alt 属性** | 手動設定(`imgClass` 別管理) | `images` 配列内に `alt` 含める | **自動適用**(Slide.svelte で自動反映) |
854-
| **インジケータ表示** | 手動実装が必要 | `<CarouselIndicators />` | Flowbite が提供(コンポーネント化) |
855-
| **ナビゲーション矢印** | 手動実装が必要 | `<Controls />` (任意) | Flowbite が提供(optional) |
856-
857-
### 移行実装例
858-
859-
**Before (embla-carousel-svelte v8.6.0)**
860-
861-
```svelte
862-
<script>
863-
import emblaCarouselSvelte from 'embla-carousel-svelte';
864-
import Autoplay from 'embla-carousel-autoplay';
865-
866-
let options = { loop: true };
867-
let plugins = [Autoplay()];
868-
const problemImages = [
869-
{ src: '...', alt: 'Image 1', title: 'sample' },
870-
// ...
871-
];
872-
</script>
873-
874-
<div class="overflow-hidden m-4" use:emblaCarouselSvelte={{ options, plugins }}>
875-
<div class="flex min-h-[300px] xs:min-h-[400px] md:min-h-[540px] mb-8 xs:mb-12">
876-
{#each problemImages as image}
877-
<div class="flex flex-shrink-0 w-full min-w-0 items-center justify-center">
878-
<Img src={image.src} alt={image.alt} imgClass="object-contain h-full w-fit" />
879-
</div>
880-
{/each}
881-
</div>
882-
</div>
883-
```
884-
885-
**After (Flowbite Carousel v1.31.0)**
886-
887-
```svelte
888-
<script>
889-
import { Carousel, CarouselIndicators } from 'flowbite-svelte';
890-
891-
const problemImages = [
892-
{ src: '...', alt: 'Image 1', title: 'sample' }, // alt は自動適用
893-
// ...
894-
];
895-
</script>
896-
897-
<div class="m-4 mb-8 xs:mb-12 overflow-hidden">
898-
<Carousel
899-
images={problemImages}
900-
duration={3000}
901-
slideFit="contain"
902-
class="min-h-[300px] xs:min-h-[400px] md:min-h-[540px]"
903-
>
904-
<CarouselIndicators />
905-
</Carousel>
906-
</div>
907-
```
908-
909-
### 移行時の注意点
910-
911-
1. **Plugin-based → Prop-based への設計変更**
912-
- `Autoplay()` plugin → `duration` prop(ミリ秒単位)
913-
- 簡潔だが、細かい制御が必要な場合は Flowbite API では対応不可
914-
915-
2. **自動スケーリング不可**
916-
- embla: `imgClass` で自動管理
917-
- Flowbite: `slideFit` prop で明示的に指定が必要
918-
919-
3. **レスポンシブクラスは手動指定**
920-
- 外側 div の `class` prop に`min-h-[300px] xs:min-h-[400px]` など記載必須
921-
- embla同様、Flowbite も内部では自動生成されない
922-
923-
4. **Alt 属性は自動適用**
924-
- `images` 配列の各オブジェクトに `alt` を含める
925-
- Slide.svelte 内で `{...image}` で展開されるため自動で反映
926-
927-
5. **Overflow 処理は明示的に指定**
928-
- Flowbite 内部で処理される可能性だが、CSS overrides に対応するため外側 div に `overflow-hidden` を追加推奨
929-
930-
### 教訓
931-
932-
- **API 設計の違いを理解することの重要性**: Plugin-based と Prop-based では柔軟性が異なる
933-
- **ドキュメント不足時はソースコード確認が必須**: alt属性の自動適用はドキュメント未記載だったが GitHub で確認可能
934-
- **Canonical CSS classes の使用**: Tailwind v4 では `min-h-[300px]` 形式が推奨される(VSCode拡張で警告あり)

0 commit comments

Comments
 (0)