フッターブロック
Footerコンポーネントは、ReactとTypeScriptで構築された完全にカスタマイズ可能でアクセシブルなフッターセクションです。モダンなデザインパターン、ロゴ表示、コンテンツセクション、柔軟なカスタマイズオプションを備えた完全なWebサイトフッターインターフェースを提供します。
🚀 インストール
npm install @nodeblocks/frontend-footer-block@0.1.0
📖 使用法
import {Footer} from '@nodeblocks/frontend-footer-block';
- 基本的な使用法
- 高度な使用法
function BasicFooter() {
return (
<Footer
logoSrc="/img/icon-small.png"
content={
<div>
<p>Your trusted partner for business solutions.</p>
<p>Contact us: info@example.com | +1 (555) 123-4567</p>
</div>
}
copyright="© 2024 Your Company Name. All rights reserved.">
<Footer.Logo />
<Footer.Content />
<Footer.Copyright />
</Footer>
);
}
function AdvancedFooter() {
return (
<Footer
logoSrc="/img/icon-small.png"
content={
<div>
<p>Your trusted partner for business solutions.</p>
<p>Contact us: info@example.com | +1 (555) 123-4567</p>
</div>
}
copyright="© 2024 Your Company Name. All rights reserved.">
{({ defaultBlocks, defaultBlockOrder }) => ({
blocks: {
...defaultBlocks,
// 🏢 Custom Logo with props override
logo: {
...defaultBlocks.logo,
props: {
...defaultBlocks.logo.props,
className: "custom-footer-logo",
},
},
// 📝 Rich Content with full component override
content: (
<div style={{
padding: '20px',
backgroundColor: '#f8f9fa',
borderRadius: '8px',
border: '1px solid #e9ecef'
}}>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(250px, 1fr))'}}>
<div>
<h4 style={{ color: '#007bff', marginBottom: '10px' }}>🏢 Company</h4>
<ul style={{ listStyle: 'none', padding: 0 }}>
<li><a href="#about" style={{ color: '#6c757d', textDecoration: 'none' }}>About Us</a></li>
<li><a href="#careers" style={{ color: '#6c757d', textDecoration: 'none' }}>Careers</a></li>
<li><a href="#press" style={{ color: '#6c757d', textDecoration: 'none' }}>Press</a></li>
</ul>
</div>
<div>
<h4 style={{ color: '#28a745', marginBottom: '10px' }}>📞 Contact</h4>
<p style={{ color: '#6c757d', margin: '5px 0' }}>📧 info@example.com</p>
<p style={{ color: '#6c757d', margin: '5px 0' }}>📱 +1 (555) 123-4567</p>
<p style={{ color: '#6c757d', margin: '5px 0' }}>📍 123 Business St, City, State</p>
</div>
</div>
</div>
),
// ⚖️ Custom Copyright with props override
copyright: {
...defaultBlocks.copyright,
props: {
...defaultBlocks.copyright.props,
style: {
backgroundColor: '#343a40',
color: '#ffffff',
padding: '15px',
borderRadius: '4px',
textAlign: 'center',
marginTop: '20px'
},
children: (
<div>
<p style={{ margin: '0 0 8px 0' }}>© 2024 Custom Company. All rights reserved.</p>
<div style={{ fontSize: '14px', opacity: 0.8 }}>
<a href="#privacy" style={{ color: '#ffffff', marginRight: '15px' }}>Privacy Policy</a>
<a href="#terms" style={{ color: '#ffffff', marginRight: '15px' }}>Terms of Service</a>
<a href="#cookies" style={{ color: '#ffffff' }}>Cookie Policy</a>
</div>
</div>
)
},
},
},
blockOrder: defaultBlockOrder,
})}
</Footer>
);
}
🔧 プロパティリファレンス
メインコンポーネントプロパティ
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
logoSrc | string | 必須 | フッターに表示するロゴ画像のURLまたはパス |
content | ReactNode | 必須 | フッターのメインコンテンツセクション(テキスト、リンクなどを含む) |
copyright | ReactNode | 必須 | フッターの下部に表示する著作権テキストまたはコンポーネント |
className | string | undefined | フッターコンテナのスタイリング用の追加CSSクラス名 |
children | BlocksOverride | undefined | デフォルトレンダリングをオーバーライドするカスタムブロックコンポーネント |
注意: メインコンポーネントはすべてのHTML footer要素プロパティを継承します。
サブコンポーネント
Footerコンポーネントは複数のサブコンポーネントを提供します。すべてのサブコンポーネントは、メインコンポーネントのコンテキストからデフォルト値を受け取り、プロパティを通じてこれらの値をオーバーライドできます。
Footer.Logo
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
src | string | コンテキストの logoSrc | ロゴ画像の URL またはパス(コンテキストの logoSrc を上書きします) |
注意: このコンポーネントはすべてのHTML img要素プロパティを継承します。
Footer.Content
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
children | ReactNode | コンテキストの content | フッターコンテンツセクションに表示するコンテンツ(コンテキストの content を上書きします) |
注意: このコンポーネントはすべてのHTML div要素プロパティを継承します。
Footer.Copyright
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
children | ReactNode | コンテキストの copyright | 表示する著作権テキストまたはコンテンツ(コンテキストの copyright を上書きします) |
注意: このコンポーネントはすべてのHTML div要素プロパティを継承します。
🔧 TypeScriptサポート
包括的な型定義による完全なTypeScriptサポート:
import {Footer} from '@nodeblocks/frontend-footer-block';
import {ComponentProps, ReactNode} from 'react';
// Main component interface
interface FooterProps extends Omit<ComponentProps<'footer'>, 'content'> {
logoSrc: string;
content: ReactNode;
copyright: ReactNode;
children?: BlocksOverride<DefaultBlocks, CustomBlocks>;
}
// Context type (values passed to all sub-components)
interface FooterContextValue {
logoSrc: string;
copyright: ReactNode;
content: ReactNode;
}
// Example with comprehensive footer content
function CustomFooter() {
return (
<Footer
logoSrc="/assets/company-logo.svg"
content={
<div>
<div>
<h4>Contact Information</h4>
<p>Email: info@company.com</p>
<p>Phone: +1 (555) 123-4567</p>
<p>Address: 123 Business St, City, State 12345</p>
</div>
<div>
<h4>Quick Links</h4>
<ul>
<li>
<a href="#about">About Us</a>
</li>
<li>
<a href="#services">Services</a>
</li>
<li>
<a href="#contact">Contact</a>
</li>
</ul>
</div>
</div>
}
copyright="© 2024 Your Company Name. All rights reserved."
className="custom-footer">
<Footer.Logo className="company-logo" alt="Company Logo" />
<Footer.Content className="footer-main-content" />
<Footer.Copyright className="footer-copyright" style={{fontSize: '14px', color: '#666'}}>
© 2024 Custom Company. All rights reserved. | Privacy Policy | Terms of Service
</Footer.Copyright>
</Footer>
);
}
React、TypeScript、モダンWebスタンダードを使用して❤️で構築されました。