注文詳細ブロック
ViewOrderコンポーネントは、TypeScriptで構築された完全にカスタマイズ可能な注文表示コンポーネントです。ステータス、注文情報、画像、カスタマイズ可能な情報行を含む注文詳細を表示するための完全なインターフェースを、モダンなデザインパターンとともに提供します。
🚀 インストール
npm install @nodeblocks/frontend-view-order-block@0.1.0
📖 使用方法
import {ViewOrder} from '@nodeblocks/frontend-view-order-block';
- 基本的な使用方法
- 高度な使用方法
function BasicViewOrder() {
const orderInfoRows = [
{ label: '注文ID', value: '#12345' },
{ label: 'お客様', value: '田中太郎' },
{ label: '日付', value: '2024-01-15' },
{ label: '合計', value: '¥19,999' }
];
return (
<ViewOrder
headerLabel=""
statusText="処理中"
statusLabel="現在のステータス"
titleLabel=""
titleText="プレミアム製品パッケージ"
titleLink="#orders/12345"
imageSrc="/img/icon.png"
infoRows={orderInfoRows}>
<ViewOrder.Header />
<ViewOrder.DetailsRow />
<ViewOrder.InfoRowList />
</ViewOrder>
);
}
function AdvancedViewOrder() {
const orderInfoRows = [
{
label: '📦 注文ID',
value: (
<span
style={{
fontFamily: 'monospace',
background: 'rgba(105, 124, 213, 0.1)',
padding: '4px 8px',
borderRadius: '6px',
fontWeight: 'bold',
}}
>
#ORD-2024-789
</span>
),
},
{
label: '👤 お客様',
value: (
<div
style={{
display: 'flex',
alignItems: 'center',
gap: '8px',
flexWrap: 'nowrap',
}}
>
<div
style={{
width: '32px',
height: '32px',
borderRadius: '50%',
background: 'linear-gradient(135deg, rgb(105, 124, 213), rgb(85, 104, 193))',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: 'white',
fontSize: '14px',
fontWeight: 'bold',
}}
>
田中
</div>
<span
style={{
fontWeight: '600',
color: '#2c3e50',
fontSize: '16px',
}}
>
田中太郎
</span>
</div>
),
},
{
label: '📅 注文日',
value: (
<div
style={{
background: 'linear-gradient(135deg, #e8f5e8, #f0f8f0)',
padding: '8px 12px',
borderRadius: '8px',
border: '1px solid #4CAF50',
color: '#2e7d32',
fontWeight: 'bold',
}}
>
2024年1月15日
</div>
),
},
{
label: '💰 合計金額',
value: (
<div
style={{
fontSize: '24px',
fontWeight: 'bold',
color: '#27ae60',
textShadow: '0 2px 4px rgba(39, 174, 96, 0.2)',
}}
>
¥129,999
</div>
),
},
{
label: '🚚 配送先住所',
value: (
<div
style={{
background: 'rgba(52, 152, 219, 0.1)',
padding: '12px',
borderRadius: '8px',
border: '1px solid #3498db',
}}
>
<div
style={{
fontWeight: 'bold',
color: '#2980b9',
fontSize: '16px',
}}
>
東京オフィス
</div>
<div
style={{
fontSize: '14px',
color: '#7f8c8d',
marginTop: '4px',
lineHeight: '1.4',
}}
>
東京都渋谷区渋谷1-1-1
</div>
</div>
),
},
{
label: '📋 商品',
value: (
<div style={{display: 'flex', flexDirection: 'column', gap: '8px'}}>
<div
style={{
background: 'white',
padding: '8px 12px',
borderRadius: '6px',
border: '1px solid rgba(105, 124, 213, 0.2)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<span>💻 MacBook Pro 16"</span>
<span style={{fontWeight: 'bold', color: 'rgb(105, 124, 213)'}}>×1</span>
</div>
<div
style={{
background: 'white',
padding: '8px 12px',
borderRadius: '6px',
border: '1px solid rgba(105, 124, 213, 0.2)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<span>⌨️ Magic Keyboard</span>
<span style={{fontWeight: 'bold', color: 'rgb(105, 124, 213)'}}>×1</span>
</div>
</div>
),
},
];
return (
<ViewOrder
headerLabel="🎯 注文 #1"
statusText="✅ 配送済み"
statusLabel="📊 ステータス"
titleLabel="🏷️ 注文詳細"
titleText="エンタープライズテクノロジーパッケージ"
titleLink="#orders/ORD-2024-789"
imageSrc="/img/icon.png"
infoRows={orderInfoRows}
>
{({defaultBlocks, defaultBlockOrder}) => ({
blocks: {
// モダンスタイリングで強化されたヘッダー
header: {
...defaultBlocks.header,
props: {
...defaultBlocks.header.props,
style: {
background: 'rgba(255, 255, 255, 0.4)',
color: 'black',
padding: '32px',
borderRadius: '20px 20px 0 0',
marginBottom: '0',
boxShadow: '0 -4px 20px rgba(0,0,0,0.1)',
},
},
},
detailsRow: (
<>
<div
style={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
gap: '16px',
}}
>
<ViewOrder.Title style={{fontSize: '22px', width: '100%'}} />
</div>
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
background: 'rgba(255, 255, 255, 0.4)',
padding: '20px',
border: '1px solid rgba(255, 255, 255, 0.6)',
backdropFilter: 'blur(5px)',
boxShadow: '0 -4px 20px rgba(0,0,0,0.1)',
marginBottom: '20px',
}}
>
<ViewOrder.Image style={{width: '100%', height: '100%', objectFit: 'contain'}} />
</div>
</>
),
status: {
...defaultBlocks.status,
props: {
...defaultBlocks.status.props,
style: {
background: 'rgba(255, 255, 255, 0.95)',
padding: '16px 24px',
borderRadius: '50px',
display: 'inline-flex',
alignItems: 'center',
gap: '12px',
boxShadow: '0 -4px 20px rgba(0,0,0,0.1)',
border: '2px solid #4CAF50',
fontWeight: 'bold',
fontSize: '16px',
},
},
},
// 強化されたタイトルスタイリング
title: {
...defaultBlocks.title,
props: {
...defaultBlocks.title.props,
style: {
fontSize: '28px',
fontWeight: 'bold',
color: 'white',
textDecoration: 'none',
textShadow: '0 2px 4px rgba(0,0,0,0.3)',
transition: 'all 0.3s ease',
lineHeight: '1.2',
},
},
},
// 詳細行統合に最適化された強化画像
image: {
...defaultBlocks.image,
props: {
...defaultBlocks.image.props,
},
},
// カードレイアウトで強化された情報行リスト
infoRowList: {
...defaultBlocks.infoRowList,
props: {
...defaultBlocks.infoRowList.props,
style: {
background: 'white',
padding: '32px',
borderRadius: '0 0 20px 20px',
display: 'grid',
gridTemplateColumns:
'repeat(auto-fit, minmax(300px, 1fr))',
gap: '24px',
boxShadow: '0 -4px 20px rgba(0,0,0,0.1)',
},
},
},
},
blockOrder: defaultBlockOrder,
})}
</ViewOrder>
);
}
🔧 プロパティリファレンス
メインコンポーネントのプロパティ
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
headerLabel | string | undefined | 注文ヘッダーセクションのラベルテキスト |
statusText | string | undefined | 注文ステータス表示のテキストコンテンツ |
statusLabel | string | undefined | ステータスフィールドのラベルテキスト |
titleLabel | string | undefined | 注文タイトルフィールドのラベルテキスト |
titleText | string | undefined | 注文タイトルのテキストコンテンツ |
titleLink | string | undefined | 注文タイトルのURLリンク |
imageSrc | string | undefined | 注文画像のソースURL |
infoRows | Array<{label: string, value: ReactNode}> | undefined | 表示する情報行の配列 |
className | string | undefined | コンテナスタイリング用の追加CSSクラス名 |
children | BlocksOverride | undefined | デフォルトレンダリングをオーバーライドするカスタムブロックコンポーネント |
注意: このコンポーネントはすべてのHTML div要素プロパティを継承します。
サブコンポーネント
ViewOrderコンポーネントは、異なるセクション用の複数のサブコンポーネントを提供します。すべてのサブコンポーネントは、メインコンポーネントのコンテキストからデフォルト値を受け取り、プロパティを通じてこれらの値をオーバーライドできます。
ViewOrder.Header
タイトルとステータス情報を含む注文ヘッダーのコンテナ。
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
children | ReactNode | コンテキストから | デフォルトヘッダーコンテンツをオーバーライドするカスタムコンテンツ |
className | string | undefined | スタイリング用の追加CSSクラス名 |
注意: このコンポーネントはすべてのHTML div要素プロパティを継承します。
ViewOrder.DetailsRow
タイトルと画像を含むメイン注文詳細のコンテナ。
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
children | ReactNode | コンテキストから | デフォルト詳細行コンテンツをオーバーライドするカスタムコンテンツ |
className | string | undefined | スタイリング用の追加CSSクラス名 |
注意: このコンポーネントはすべてのHTML div要素プロパティを継承します。
ViewOrder.Status
注文ステータス情報を表示します。
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
children | ReactNode | コンテキストから | デフォルトステータスコンテンツをオーバーライドするカスタムコンテンツ |
className | string | undefined | スタイリング用の追加CSSクラス名 |
注意: このコンポーネントはすべてのHTML div要素プロパティを継承します。
ViewOrder.Title
クリック可能なリンクとして注文タイトルを表示します。
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
children | ReactNode | コンテキストから | デフォルトタイトルコンテンツをオーバーライドするカスタムコンテンツ |
className | string | undefined | スタイリング用の追加CSSクラス名 |
注意: このコンポーネントはすべてのHTML a要素プロパティを継承します。
ViewOrder.Image
注文画像を表示します。
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
className | string | undefined | スタイリング用の追加CSSクラス名 |
src | string | コンテキストから | 注文画像のソースURL |
注意: このコンポーネントはすべてのHTML img要素プロパティを継承します。
ViewOrder.InfoRow
ラベルと値を持つ単一の情報行を表示します。
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
label | ReactNode | 必須 | 情報行のラベルコンテンツ |
value | ReactNode | 必須 | 情報行の値コンテンツ |
className | string | undefined | スタイリング用の追加CSSクラス名 |
注意: このコンポーネントはすべてのHTML div要素プロパティを継承します。
ViewOrder.InfoRowList
infoRows配列から複数の情報行を表示するコンテナ。
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
children | ReactNode | コンテキストから | デフォルト情報行レンダリングをオーバーライドするカスタムコンテンツ |
className | string | undefined | スタイリング用の追加CSSクラス名 |
注意: このコンポーネントはすべてのHTML div要素プロパティを継承します。
🔧 TypeScriptサポート
包括的な型定義による完全なTypeScriptサポート:
import ViewOrder from '@nodeblocks/frontend-view-order-block';
import { ReactNode } from 'react';
interface OrderInfoRow {
label: string;
value: ReactNode;
}
interface ViewOrderProps {
headerLabel?: string;
statusText?: string;
statusLabel?: string;
titleLabel?: string;
titleText?: string;
titleLink?: string;
imageSrc?: string;
infoRows?: OrderInfoRow[];
className?: string;
children?: ReactNode;
}
interface CustomOrderData {
orderId: string;
customerName: string;
status: 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled';
total: number;
items: {
id: string;
name: string;
quantity: number;
price: number;
}[];
shippingAddress: {
street: string;
city: string;
country: string;
};
}
const OrderDetailsView = () => {
const orderData: CustomOrderData = {
orderId: 'ORD-2024-001',
customerName: '田中太郎',
status: 'processing',
total: 29999,
items: [
{ id: '1', name: 'プレミアムヘッドフォン', quantity: 1, price: 19999 },
{ id: '2', name: 'USBケーブル', quantity: 2, price: 5000 }
],
shippingAddress: {
street: '新宿区新宿1-2-3',
city: '東京都',
country: '日本'
}
};
const orderInfoRows: OrderInfoRow[] = [
{ label: '注文ID', value: orderData.orderId },
{ label: 'お客様', value: orderData.customerName },
{ label: '合計金額', value: `¥${orderData.total.toLocaleString()}` },
{ label: '商品数', value: orderData.items.length },
{
label: '配送先住所',
value: `${orderData.shippingAddress.street}, ${orderData.shippingAddress.city}, ${orderData.shippingAddress.country}`
}
];
return (
<ViewOrder
headerLabel="注文情報"
statusText={orderData.status.charAt(0).toUpperCase() + orderData.status.slice(1)}
statusLabel="現在のステータス"
titleLabel="注文詳細"
titleText={`注文 ${orderData.orderId}`}
titleLink={`/orders/${orderData.orderId}`}
imageSrc="/order-preview.jpg"
infoRows={orderInfoRows}
className="custom-order-view">
<ViewOrder.Header />
<ViewOrder.DetailsRow />
<ViewOrder.InfoRowList />
</ViewOrder>
);
};
React、TypeScript、モダンWebスタンダードを使用して❤️で構築されました。