@beyondcorp/beyond-ui 1.2.53 → 1.2.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Blog/AllBlogsView.d.ts +8 -0
- package/dist/components/Blog/AllBlogsView.js +70 -0
- package/dist/components/Blog/AllBlogsView.js.map +1 -0
- package/dist/components/Blog/BlogCommentSection.d.ts +7 -0
- package/dist/components/Blog/BlogCommentSection.js +66 -0
- package/dist/components/Blog/BlogCommentSection.js.map +1 -0
- package/dist/components/Blog/BlogLayout.d.ts +11 -0
- package/dist/components/Blog/BlogLayout.js +29 -0
- package/dist/components/Blog/BlogLayout.js.map +1 -0
- package/dist/components/Blog/BlogShowcase.d.ts +2 -0
- package/dist/components/Blog/BlogShowcase.js +74 -0
- package/dist/components/Blog/BlogShowcase.js.map +1 -0
- package/dist/components/Blog/BlogSidebar.d.ts +10 -0
- package/dist/components/Blog/BlogSidebar.js +47 -0
- package/dist/components/Blog/BlogSidebar.js.map +1 -0
- package/dist/components/Blog/SingleBlogView.d.ts +8 -0
- package/dist/components/Blog/SingleBlogView.js +78 -0
- package/dist/components/Blog/SingleBlogView.js.map +1 -0
- package/dist/components/Blog/data/sampleData.d.ts +4 -0
- package/dist/components/Blog/data/sampleData.js +388 -0
- package/dist/components/Blog/data/sampleData.js.map +1 -0
- package/dist/components/Blog/hooks/index.d.ts +3 -0
- package/dist/components/Blog/hooks/useBlog.d.ts +22 -0
- package/dist/components/Blog/hooks/useBlog.js +148 -0
- package/dist/components/Blog/hooks/useBlog.js.map +1 -0
- package/dist/components/Blog/hooks/useBlogNavigation.d.ts +12 -0
- package/dist/components/Blog/hooks/useBlogNavigation.js +75 -0
- package/dist/components/Blog/hooks/useBlogNavigation.js.map +1 -0
- package/dist/components/Blog/hooks/useComments.d.ts +20 -0
- package/dist/components/Blog/hooks/useComments.js +108 -0
- package/dist/components/Blog/hooks/useComments.js.map +1 -0
- package/dist/components/Blog/index.d.ts +8 -0
- package/dist/components/Blog/types.d.ts +82 -0
- package/dist/components/CodeHighlight/CodeHighlight.d.ts +7 -0
- package/dist/components/CodeHighlight/CodeHighlight.js +18 -0
- package/dist/components/CodeHighlight/CodeHighlight.js.map +1 -0
- package/dist/components/CodeHighlight/index.d.ts +1 -0
- package/dist/components/Marketplace/AllProductsView.d.ts +3 -0
- package/dist/components/Marketplace/AllProductsView.js +7 -18
- package/dist/components/Marketplace/AllProductsView.js.map +1 -1
- package/dist/components/Marketplace/MarketplaceComponent.js +5 -1
- package/dist/components/Marketplace/MarketplaceComponent.js.map +1 -1
- package/dist/components/Marketplace/MarketplaceSidebar.js +31 -31
- package/dist/components/Marketplace/MarketplaceSidebar.js.map +1 -1
- package/dist/components/Marketplace/SingleProductView.js +3 -0
- package/dist/components/Marketplace/SingleProductView.js.map +1 -1
- package/dist/components/Marketplace/components/MarketplaceControls.d.ts +17 -0
- package/dist/components/Marketplace/components/MarketplaceControls.js +22 -0
- package/dist/components/Marketplace/components/MarketplaceControls.js.map +1 -0
- package/dist/components/Marketplace/components/MarketplaceDashboard.d.ts +3 -0
- package/dist/components/Marketplace/components/MarketplaceDashboard.js +20 -10
- package/dist/components/Marketplace/components/MarketplaceDashboard.js.map +1 -1
- package/dist/components/Marketplace/components/MarketplaceHeader.js +2 -3
- package/dist/components/Marketplace/components/MarketplaceHeader.js.map +1 -1
- package/dist/components/Marketplace/components/ProductCard.js +9 -2
- package/dist/components/Marketplace/components/ProductCard.js.map +1 -1
- package/dist/components/Marketplace/hooks/useScrollToTop.d.ts +10 -0
- package/dist/components/Marketplace/hooks/useScrollToTop.js +22 -0
- package/dist/components/Marketplace/hooks/useScrollToTop.js.map +1 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.js +10 -4
- package/dist/styles.css +1 -1
- package/package.json +6 -1
- package/dist/components/AllProductsView/AllProductsView.d.ts +0 -14
- package/dist/components/AllProductsView/AllProductsView.js +0 -61
- package/dist/components/AllProductsView/AllProductsView.js.map +0 -1
- package/dist/components/AllProductsView/CardGroup.d.ts +0 -6
- package/dist/components/AllProductsView/CardGroup.js +0 -11
- package/dist/components/AllProductsView/CardGroup.js.map +0 -1
- package/dist/components/AllProductsView/ProductCard.d.ts +0 -11
- package/dist/components/AllProductsView/ProductCard.js +0 -13
- package/dist/components/AllProductsView/ProductCard.js.map +0 -1
- package/dist/components/AllProductsView/index.d.ts +0 -2
- package/dist/components/BlogFeedView/BlogFeedView.d.ts +0 -22
- package/dist/components/BlogFeedView/BlogFeedView.js +0 -29
- package/dist/components/BlogFeedView/BlogFeedView.js.map +0 -1
- package/dist/components/BlogFeedView/index.d.ts +0 -1
- package/dist/components/BlogLayout/BlogLayout.d.ts +0 -13
- package/dist/components/BlogLayout/BlogLayout.js +0 -20
- package/dist/components/BlogLayout/BlogLayout.js.map +0 -1
- package/dist/components/BlogLayout/index.d.ts +0 -1
- package/dist/components/BlogSidebar/BlogSidebar.d.ts +0 -19
- package/dist/components/BlogSidebar/BlogSidebar.js +0 -10
- package/dist/components/BlogSidebar/BlogSidebar.js.map +0 -1
- package/dist/components/BlogSidebar/index.d.ts +0 -1
- package/dist/components/Checkout/CheckoutPage.d.ts +0 -16
- package/dist/components/Checkout/CheckoutPage.js +0 -44
- package/dist/components/Checkout/CheckoutPage.js.map +0 -1
- package/dist/components/Checkout/CheckoutSidebar.d.ts +0 -15
- package/dist/components/Checkout/CheckoutSidebar.js +0 -25
- package/dist/components/Checkout/CheckoutSidebar.js.map +0 -1
- package/dist/components/Checkout/index.d.ts +0 -3
- package/dist/components/Checkout/types.d.ts +0 -21
- package/dist/components/CommerceSidebar/CommerceSidebar.d.ts +0 -20
- package/dist/components/CommerceSidebar/CommerceSidebar.js +0 -14
- package/dist/components/CommerceSidebar/CommerceSidebar.js.map +0 -1
- package/dist/components/CommerceSidebar/index.d.ts +0 -1
- package/dist/components/MarketplaceLayout/MarketplaceLayout.d.ts +0 -17
- package/dist/components/MarketplaceLayout/MarketplaceLayout.js +0 -22
- package/dist/components/MarketplaceLayout/MarketplaceLayout.js.map +0 -1
- package/dist/components/MarketplaceLayout/index.d.ts +0 -1
- package/dist/components/ProfileManagement/ProfileManagementPage.d.ts +0 -16
- package/dist/components/ProfileManagement/ProfileManagementPage.js +0 -65
- package/dist/components/ProfileManagement/ProfileManagementPage.js.map +0 -1
- package/dist/components/SingleBlogView/SingleBlogView.d.ts +0 -26
- package/dist/components/SingleBlogView/SingleBlogView.js +0 -17
- package/dist/components/SingleBlogView/SingleBlogView.js.map +0 -1
- package/dist/components/SingleBlogView/index.d.ts +0 -1
- package/dist/components/SingleProductView/SingleProductView.d.ts +0 -31
- package/dist/components/SingleProductView/SingleProductView.js +0 -34
- package/dist/components/SingleProductView/SingleProductView.js.map +0 -1
- package/dist/components/SingleProductView/index.d.ts +0 -1
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
// Sample blog posts for demonstration
|
|
2
|
+
const sampleBlogPosts = [
|
|
3
|
+
{
|
|
4
|
+
id: '1',
|
|
5
|
+
title: 'Building Modern React Applications with TypeScript',
|
|
6
|
+
slug: 'building-modern-react-typescript',
|
|
7
|
+
content: `# Building Modern React Applications with TypeScript
|
|
8
|
+
|
|
9
|
+
## Introduction
|
|
10
|
+
|
|
11
|
+
TypeScript has become an essential tool for React developers who want to build scalable, maintainable applications. In this comprehensive guide, we'll explore the best practices for combining React with TypeScript.
|
|
12
|
+
|
|
13
|
+
## Why TypeScript with React?
|
|
14
|
+
|
|
15
|
+
TypeScript brings several advantages to React development:
|
|
16
|
+
|
|
17
|
+
- **Type Safety**: Catch errors at compile time rather than runtime
|
|
18
|
+
- **Better Developer Experience**: Enhanced IntelliSense and autocomplete
|
|
19
|
+
- **Refactoring Confidence**: Safe code changes with compiler verification
|
|
20
|
+
- **Documentation**: Types serve as living documentation
|
|
21
|
+
|
|
22
|
+
## Setting Up Your Project
|
|
23
|
+
|
|
24
|
+
\`\`\`bash
|
|
25
|
+
npx create-react-app my-app --template typescript
|
|
26
|
+
cd my-app
|
|
27
|
+
npm start
|
|
28
|
+
\`\`\`
|
|
29
|
+
|
|
30
|
+
## Component Patterns
|
|
31
|
+
|
|
32
|
+
### Functional Components with Props
|
|
33
|
+
|
|
34
|
+
\`\`\`tsx
|
|
35
|
+
interface ButtonProps {
|
|
36
|
+
variant: 'primary' | 'secondary';
|
|
37
|
+
children: React.ReactNode;
|
|
38
|
+
onClick?: () => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const Button: React.FC<ButtonProps> = ({ variant, children, onClick }) => {
|
|
42
|
+
return (
|
|
43
|
+
<button
|
|
44
|
+
className={\`btn btn-\${variant}\`}
|
|
45
|
+
onClick={onClick}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</button>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
\`\`\`
|
|
52
|
+
|
|
53
|
+
## Advanced Patterns
|
|
54
|
+
|
|
55
|
+
### Custom Hooks
|
|
56
|
+
|
|
57
|
+
Custom hooks are a powerful way to share stateful logic between components:
|
|
58
|
+
|
|
59
|
+
\`\`\`tsx
|
|
60
|
+
function useCounter(initialValue: number = 0) {
|
|
61
|
+
const [count, setCount] = useState(initialValue);
|
|
62
|
+
|
|
63
|
+
const increment = useCallback(() => setCount(c => c + 1), []);
|
|
64
|
+
const decrement = useCallback(() => setCount(c => c - 1), []);
|
|
65
|
+
const reset = useCallback(() => setCount(initialValue), [initialValue]);
|
|
66
|
+
|
|
67
|
+
return { count, increment, decrement, reset };
|
|
68
|
+
}
|
|
69
|
+
\`\`\`
|
|
70
|
+
|
|
71
|
+
## Best Practices
|
|
72
|
+
|
|
73
|
+
1. **Use strict TypeScript configuration**
|
|
74
|
+
2. **Define clear prop interfaces**
|
|
75
|
+
3. **Leverage union types for variants**
|
|
76
|
+
4. **Use generic types for reusable components**
|
|
77
|
+
5. **Implement proper error boundaries**
|
|
78
|
+
|
|
79
|
+
## Conclusion
|
|
80
|
+
|
|
81
|
+
TypeScript and React make a powerful combination for building modern web applications. By following these patterns and best practices, you can create applications that are both robust and maintainable.`,
|
|
82
|
+
excerpt: 'Learn how to build scalable React applications using TypeScript with modern patterns and best practices.',
|
|
83
|
+
author: {
|
|
84
|
+
id: 'author1',
|
|
85
|
+
name: 'Sarah Johnson',
|
|
86
|
+
avatar: 'https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg?auto=compress&cs=tinysrgb&w=64',
|
|
87
|
+
bio: 'Senior Frontend Developer with 8+ years of experience in React and TypeScript.',
|
|
88
|
+
},
|
|
89
|
+
publishedAt: '2024-01-15T10:00:00Z',
|
|
90
|
+
updatedAt: '2024-01-16T14:30:00Z',
|
|
91
|
+
tags: ['React', 'TypeScript', 'Frontend', 'JavaScript'],
|
|
92
|
+
category: 'Development',
|
|
93
|
+
readingTime: 8,
|
|
94
|
+
featured: true,
|
|
95
|
+
status: 'published',
|
|
96
|
+
seoMeta: {
|
|
97
|
+
title: 'Building Modern React Applications with TypeScript - Complete Guide',
|
|
98
|
+
description: 'Learn how to build scalable React applications using TypeScript with modern patterns and best practices.',
|
|
99
|
+
keywords: ['React', 'TypeScript', 'Frontend Development', 'JavaScript'],
|
|
100
|
+
ogImage: 'https://images.pexels.com/photos/11035380/pexels-photo-11035380.jpeg?auto=compress&cs=tinysrgb&w=1200',
|
|
101
|
+
},
|
|
102
|
+
stats: {
|
|
103
|
+
views: 1250,
|
|
104
|
+
likes: 89,
|
|
105
|
+
comments: 23,
|
|
106
|
+
shares: 45,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: '2',
|
|
111
|
+
title: 'CSS Grid vs Flexbox: When to Use Each',
|
|
112
|
+
slug: 'css-grid-vs-flexbox',
|
|
113
|
+
content: `# CSS Grid vs Flexbox: When to Use Each
|
|
114
|
+
|
|
115
|
+
## Understanding the Fundamentals
|
|
116
|
+
|
|
117
|
+
Both CSS Grid and Flexbox are powerful layout systems, but they serve different purposes and excel in different scenarios.
|
|
118
|
+
|
|
119
|
+
## CSS Grid: Two-Dimensional Layouts
|
|
120
|
+
|
|
121
|
+
CSS Grid is designed for two-dimensional layouts where you need to control both rows and columns simultaneously.
|
|
122
|
+
|
|
123
|
+
### Best Use Cases:
|
|
124
|
+
- Page layouts with header, sidebar, main content, and footer
|
|
125
|
+
- Card grids with consistent sizing
|
|
126
|
+
- Complex dashboard layouts
|
|
127
|
+
- Magazine-style layouts
|
|
128
|
+
|
|
129
|
+
### Example:
|
|
130
|
+
\`\`\`css
|
|
131
|
+
.grid-container {
|
|
132
|
+
display: grid;
|
|
133
|
+
grid-template-columns: 250px 1fr;
|
|
134
|
+
grid-template-rows: auto 1fr auto;
|
|
135
|
+
grid-template-areas:
|
|
136
|
+
"sidebar header"
|
|
137
|
+
"sidebar main"
|
|
138
|
+
"footer footer";
|
|
139
|
+
min-height: 100vh;
|
|
140
|
+
}
|
|
141
|
+
\`\`\`
|
|
142
|
+
|
|
143
|
+
## Flexbox: One-Dimensional Layouts
|
|
144
|
+
|
|
145
|
+
Flexbox excels at one-dimensional layouts, either in a row or column direction.
|
|
146
|
+
|
|
147
|
+
### Best Use Cases:
|
|
148
|
+
- Navigation bars
|
|
149
|
+
- Button groups
|
|
150
|
+
- Centering content
|
|
151
|
+
- Distributing space between items
|
|
152
|
+
|
|
153
|
+
### Example:
|
|
154
|
+
\`\`\`css
|
|
155
|
+
.flex-container {
|
|
156
|
+
display: flex;
|
|
157
|
+
justify-content: space-between;
|
|
158
|
+
align-items: center;
|
|
159
|
+
padding: 1rem;
|
|
160
|
+
}
|
|
161
|
+
\`\`\`
|
|
162
|
+
|
|
163
|
+
## Decision Framework
|
|
164
|
+
|
|
165
|
+
Choose **CSS Grid** when:
|
|
166
|
+
- You need to control both dimensions
|
|
167
|
+
- Creating overall page layouts
|
|
168
|
+
- Working with complex, overlapping designs
|
|
169
|
+
|
|
170
|
+
Choose **Flexbox** when:
|
|
171
|
+
- Working with one-dimensional layouts
|
|
172
|
+
- Aligning items within a container
|
|
173
|
+
- Creating responsive navigation
|
|
174
|
+
|
|
175
|
+
## Conclusion
|
|
176
|
+
|
|
177
|
+
Both CSS Grid and Flexbox are essential tools in modern web development. Understanding when to use each will help you create more efficient and maintainable layouts.`,
|
|
178
|
+
excerpt: 'A comprehensive guide to understanding when to use CSS Grid versus Flexbox for your layout needs.',
|
|
179
|
+
author: {
|
|
180
|
+
id: 'author2',
|
|
181
|
+
name: 'Mike Chen',
|
|
182
|
+
avatar: 'https://images.pexels.com/photos/1222271/pexels-photo-1222271.jpeg?auto=compress&cs=tinysrgb&w=64',
|
|
183
|
+
bio: 'CSS specialist and design systems architect with expertise in modern layout techniques.',
|
|
184
|
+
},
|
|
185
|
+
publishedAt: '2024-01-10T09:00:00Z',
|
|
186
|
+
tags: ['CSS', 'Layout', 'Grid', 'Flexbox', 'Web Design'],
|
|
187
|
+
category: 'Design',
|
|
188
|
+
readingTime: 6,
|
|
189
|
+
featured: false,
|
|
190
|
+
status: 'published',
|
|
191
|
+
seoMeta: {
|
|
192
|
+
title: 'CSS Grid vs Flexbox: Complete Comparison Guide',
|
|
193
|
+
description: 'Learn when to use CSS Grid versus Flexbox with practical examples and decision frameworks.',
|
|
194
|
+
keywords: ['CSS Grid', 'Flexbox', 'CSS Layout', 'Web Design'],
|
|
195
|
+
},
|
|
196
|
+
stats: {
|
|
197
|
+
views: 890,
|
|
198
|
+
likes: 67,
|
|
199
|
+
comments: 15,
|
|
200
|
+
shares: 32,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
id: '3',
|
|
205
|
+
title: 'Accessibility in Modern Web Development',
|
|
206
|
+
slug: 'accessibility-modern-web-development',
|
|
207
|
+
content: `# Accessibility in Modern Web Development
|
|
208
|
+
|
|
209
|
+
## Why Accessibility Matters
|
|
210
|
+
|
|
211
|
+
Web accessibility ensures that websites and applications are usable by everyone, including people with disabilities. It's not just the right thing to do—it's also a legal requirement in many jurisdictions.
|
|
212
|
+
|
|
213
|
+
## WCAG Guidelines
|
|
214
|
+
|
|
215
|
+
The Web Content Accessibility Guidelines (WCAG) provide a framework for making web content accessible:
|
|
216
|
+
|
|
217
|
+
### Four Principles:
|
|
218
|
+
1. **Perceivable**: Information must be presentable in ways users can perceive
|
|
219
|
+
2. **Operable**: Interface components must be operable
|
|
220
|
+
3. **Understandable**: Information and UI operation must be understandable
|
|
221
|
+
4. **Robust**: Content must be robust enough for various assistive technologies
|
|
222
|
+
|
|
223
|
+
## Practical Implementation
|
|
224
|
+
|
|
225
|
+
### Semantic HTML
|
|
226
|
+
Use proper HTML elements for their intended purpose:
|
|
227
|
+
|
|
228
|
+
\`\`\`html
|
|
229
|
+
<header>
|
|
230
|
+
<nav>
|
|
231
|
+
<ul>
|
|
232
|
+
<li><a href="/home">Home</a></li>
|
|
233
|
+
<li><a href="/about">About</a></li>
|
|
234
|
+
</ul>
|
|
235
|
+
</nav>
|
|
236
|
+
</header>
|
|
237
|
+
|
|
238
|
+
<main>
|
|
239
|
+
<article>
|
|
240
|
+
<h1>Article Title</h1>
|
|
241
|
+
<p>Article content...</p>
|
|
242
|
+
</article>
|
|
243
|
+
</main>
|
|
244
|
+
\`\`\`
|
|
245
|
+
|
|
246
|
+
### ARIA Labels
|
|
247
|
+
Enhance semantic meaning with ARIA attributes:
|
|
248
|
+
|
|
249
|
+
\`\`\`html
|
|
250
|
+
<button aria-label="Close dialog" aria-expanded="false">
|
|
251
|
+
<span aria-hidden="true">×</span>
|
|
252
|
+
</button>
|
|
253
|
+
\`\`\`
|
|
254
|
+
|
|
255
|
+
### Keyboard Navigation
|
|
256
|
+
Ensure all interactive elements are keyboard accessible:
|
|
257
|
+
|
|
258
|
+
\`\`\`css
|
|
259
|
+
.button:focus {
|
|
260
|
+
outline: 2px solid #007acc;
|
|
261
|
+
outline-offset: 2px;
|
|
262
|
+
}
|
|
263
|
+
\`\`\`
|
|
264
|
+
|
|
265
|
+
## Testing Accessibility
|
|
266
|
+
|
|
267
|
+
### Tools:
|
|
268
|
+
- **axe-core**: Automated accessibility testing
|
|
269
|
+
- **WAVE**: Web accessibility evaluation tool
|
|
270
|
+
- **Lighthouse**: Built-in Chrome accessibility audit
|
|
271
|
+
- **Screen readers**: NVDA, JAWS, VoiceOver
|
|
272
|
+
|
|
273
|
+
## Conclusion
|
|
274
|
+
|
|
275
|
+
Building accessible websites benefits everyone and creates a more inclusive web. Start with semantic HTML, add ARIA where needed, and test with real users and assistive technologies.`,
|
|
276
|
+
excerpt: 'Learn how to build accessible web applications that work for everyone, including users with disabilities.',
|
|
277
|
+
author: {
|
|
278
|
+
id: 'author3',
|
|
279
|
+
name: 'Emily Rodriguez',
|
|
280
|
+
avatar: 'https://images.pexels.com/photos/1239291/pexels-photo-1239291.jpeg?auto=compress&cs=tinysrgb&w=64',
|
|
281
|
+
bio: 'Accessibility advocate and UX engineer focused on inclusive design practices.',
|
|
282
|
+
},
|
|
283
|
+
publishedAt: '2024-01-05T11:30:00Z',
|
|
284
|
+
tags: ['Accessibility', 'WCAG', 'UX', 'Inclusive Design'],
|
|
285
|
+
category: 'Accessibility',
|
|
286
|
+
readingTime: 7,
|
|
287
|
+
featured: true,
|
|
288
|
+
status: 'published',
|
|
289
|
+
seoMeta: {
|
|
290
|
+
title: 'Web Accessibility Guide - WCAG Compliance and Best Practices',
|
|
291
|
+
description: 'Complete guide to web accessibility, WCAG compliance, and building inclusive web applications.',
|
|
292
|
+
keywords: ['Web Accessibility', 'WCAG', 'Inclusive Design', 'Screen Readers'],
|
|
293
|
+
},
|
|
294
|
+
stats: {
|
|
295
|
+
views: 2100,
|
|
296
|
+
likes: 156,
|
|
297
|
+
comments: 34,
|
|
298
|
+
shares: 78,
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
];
|
|
302
|
+
const sampleBlogComments = [
|
|
303
|
+
{
|
|
304
|
+
id: 'c1',
|
|
305
|
+
postId: '1',
|
|
306
|
+
author: {
|
|
307
|
+
id: 'u1',
|
|
308
|
+
name: 'John Doe',
|
|
309
|
+
avatar: 'https://images.pexels.com/photos/774909/pexels-photo-774909.jpeg?auto=compress&cs=tinysrgb&w=64',
|
|
310
|
+
},
|
|
311
|
+
content: 'Great article! I\'ve been using TypeScript with React for a while now and these patterns are exactly what I recommend to my team.',
|
|
312
|
+
createdAt: '2024-01-16T08:30:00Z',
|
|
313
|
+
likes: 12,
|
|
314
|
+
dislikes: 0,
|
|
315
|
+
isModerated: false,
|
|
316
|
+
isReported: false,
|
|
317
|
+
replies: [
|
|
318
|
+
{
|
|
319
|
+
id: 'c1-r1',
|
|
320
|
+
postId: '1',
|
|
321
|
+
parentId: 'c1',
|
|
322
|
+
author: {
|
|
323
|
+
id: 'author1',
|
|
324
|
+
name: 'Sarah Johnson',
|
|
325
|
+
avatar: 'https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg?auto=compress&cs=tinysrgb&w=64',
|
|
326
|
+
},
|
|
327
|
+
content: 'Thanks John! I\'m glad you found the patterns useful. Have you tried the new React 18 features with TypeScript?',
|
|
328
|
+
createdAt: '2024-01-16T10:15:00Z',
|
|
329
|
+
likes: 5,
|
|
330
|
+
dislikes: 0,
|
|
331
|
+
isModerated: false,
|
|
332
|
+
isReported: false,
|
|
333
|
+
},
|
|
334
|
+
],
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
id: 'c2',
|
|
338
|
+
postId: '1',
|
|
339
|
+
author: {
|
|
340
|
+
id: 'u2',
|
|
341
|
+
name: 'Alice Smith',
|
|
342
|
+
avatar: 'https://images.pexels.com/photos/1239291/pexels-photo-1239291.jpeg?auto=compress&cs=tinysrgb&w=64',
|
|
343
|
+
},
|
|
344
|
+
content: 'The custom hooks section was particularly helpful. I\'ve been struggling with sharing state logic between components.',
|
|
345
|
+
createdAt: '2024-01-16T12:45:00Z',
|
|
346
|
+
likes: 8,
|
|
347
|
+
dislikes: 0,
|
|
348
|
+
isModerated: false,
|
|
349
|
+
isReported: false,
|
|
350
|
+
},
|
|
351
|
+
];
|
|
352
|
+
const sampleBlogCategories = [
|
|
353
|
+
{
|
|
354
|
+
id: 'dev',
|
|
355
|
+
name: 'Development',
|
|
356
|
+
slug: 'development',
|
|
357
|
+
description: 'Programming tutorials, frameworks, and development best practices',
|
|
358
|
+
postCount: 45,
|
|
359
|
+
color: '#3b82f6',
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
id: 'design',
|
|
363
|
+
name: 'Design',
|
|
364
|
+
slug: 'design',
|
|
365
|
+
description: 'UI/UX design, CSS techniques, and design systems',
|
|
366
|
+
postCount: 32,
|
|
367
|
+
color: '#8b5cf6',
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
id: 'accessibility',
|
|
371
|
+
name: 'Accessibility',
|
|
372
|
+
slug: 'accessibility',
|
|
373
|
+
description: 'Web accessibility, inclusive design, and WCAG compliance',
|
|
374
|
+
postCount: 18,
|
|
375
|
+
color: '#10b981',
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
id: 'performance',
|
|
379
|
+
name: 'Performance',
|
|
380
|
+
slug: 'performance',
|
|
381
|
+
description: 'Web performance optimization and best practices',
|
|
382
|
+
postCount: 24,
|
|
383
|
+
color: '#f59e0b',
|
|
384
|
+
},
|
|
385
|
+
];
|
|
386
|
+
|
|
387
|
+
export { sampleBlogCategories, sampleBlogComments, sampleBlogPosts };
|
|
388
|
+
//# sourceMappingURL=sampleData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampleData.js","sources":["../../../../src/components/Blog/data/sampleData.ts"],"sourcesContent":["import type { BlogPost, BlogComment, BlogCategory } from '../types';\n\n// Sample blog posts for demonstration\nexport const sampleBlogPosts: BlogPost[] = [\n {\n id: '1',\n title: 'Building Modern React Applications with TypeScript',\n slug: 'building-modern-react-typescript',\n content: `# Building Modern React Applications with TypeScript\n\n## Introduction\n\nTypeScript has become an essential tool for React developers who want to build scalable, maintainable applications. In this comprehensive guide, we'll explore the best practices for combining React with TypeScript.\n\n## Why TypeScript with React?\n\nTypeScript brings several advantages to React development:\n\n- **Type Safety**: Catch errors at compile time rather than runtime\n- **Better Developer Experience**: Enhanced IntelliSense and autocomplete\n- **Refactoring Confidence**: Safe code changes with compiler verification\n- **Documentation**: Types serve as living documentation\n\n## Setting Up Your Project\n\n\\`\\`\\`bash\nnpx create-react-app my-app --template typescript\ncd my-app\nnpm start\n\\`\\`\\`\n\n## Component Patterns\n\n### Functional Components with Props\n\n\\`\\`\\`tsx\ninterface ButtonProps {\n variant: 'primary' | 'secondary';\n children: React.ReactNode;\n onClick?: () => void;\n}\n\nconst Button: React.FC<ButtonProps> = ({ variant, children, onClick }) => {\n return (\n <button \n className={\\`btn btn-\\${variant}\\`}\n onClick={onClick}\n >\n {children}\n </button>\n );\n};\n\\`\\`\\`\n\n## Advanced Patterns\n\n### Custom Hooks\n\nCustom hooks are a powerful way to share stateful logic between components:\n\n\\`\\`\\`tsx\nfunction useCounter(initialValue: number = 0) {\n const [count, setCount] = useState(initialValue);\n \n const increment = useCallback(() => setCount(c => c + 1), []);\n const decrement = useCallback(() => setCount(c => c - 1), []);\n const reset = useCallback(() => setCount(initialValue), [initialValue]);\n \n return { count, increment, decrement, reset };\n}\n\\`\\`\\`\n\n## Best Practices\n\n1. **Use strict TypeScript configuration**\n2. **Define clear prop interfaces**\n3. **Leverage union types for variants**\n4. **Use generic types for reusable components**\n5. **Implement proper error boundaries**\n\n## Conclusion\n\nTypeScript and React make a powerful combination for building modern web applications. By following these patterns and best practices, you can create applications that are both robust and maintainable.`,\n excerpt: 'Learn how to build scalable React applications using TypeScript with modern patterns and best practices.',\n author: {\n id: 'author1',\n name: 'Sarah Johnson',\n avatar: 'https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg?auto=compress&cs=tinysrgb&w=64',\n bio: 'Senior Frontend Developer with 8+ years of experience in React and TypeScript.',\n },\n publishedAt: '2024-01-15T10:00:00Z',\n updatedAt: '2024-01-16T14:30:00Z',\n tags: ['React', 'TypeScript', 'Frontend', 'JavaScript'],\n category: 'Development',\n readingTime: 8,\n featured: true,\n status: 'published',\n seoMeta: {\n title: 'Building Modern React Applications with TypeScript - Complete Guide',\n description: 'Learn how to build scalable React applications using TypeScript with modern patterns and best practices.',\n keywords: ['React', 'TypeScript', 'Frontend Development', 'JavaScript'],\n ogImage: 'https://images.pexels.com/photos/11035380/pexels-photo-11035380.jpeg?auto=compress&cs=tinysrgb&w=1200',\n },\n stats: {\n views: 1250,\n likes: 89,\n comments: 23,\n shares: 45,\n },\n },\n {\n id: '2',\n title: 'CSS Grid vs Flexbox: When to Use Each',\n slug: 'css-grid-vs-flexbox',\n content: `# CSS Grid vs Flexbox: When to Use Each\n\n## Understanding the Fundamentals\n\nBoth CSS Grid and Flexbox are powerful layout systems, but they serve different purposes and excel in different scenarios.\n\n## CSS Grid: Two-Dimensional Layouts\n\nCSS Grid is designed for two-dimensional layouts where you need to control both rows and columns simultaneously.\n\n### Best Use Cases:\n- Page layouts with header, sidebar, main content, and footer\n- Card grids with consistent sizing\n- Complex dashboard layouts\n- Magazine-style layouts\n\n### Example:\n\\`\\`\\`css\n.grid-container {\n display: grid;\n grid-template-columns: 250px 1fr;\n grid-template-rows: auto 1fr auto;\n grid-template-areas: \n \"sidebar header\"\n \"sidebar main\"\n \"footer footer\";\n min-height: 100vh;\n}\n\\`\\`\\`\n\n## Flexbox: One-Dimensional Layouts\n\nFlexbox excels at one-dimensional layouts, either in a row or column direction.\n\n### Best Use Cases:\n- Navigation bars\n- Button groups\n- Centering content\n- Distributing space between items\n\n### Example:\n\\`\\`\\`css\n.flex-container {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 1rem;\n}\n\\`\\`\\`\n\n## Decision Framework\n\nChoose **CSS Grid** when:\n- You need to control both dimensions\n- Creating overall page layouts\n- Working with complex, overlapping designs\n\nChoose **Flexbox** when:\n- Working with one-dimensional layouts\n- Aligning items within a container\n- Creating responsive navigation\n\n## Conclusion\n\nBoth CSS Grid and Flexbox are essential tools in modern web development. Understanding when to use each will help you create more efficient and maintainable layouts.`,\n excerpt: 'A comprehensive guide to understanding when to use CSS Grid versus Flexbox for your layout needs.',\n author: {\n id: 'author2',\n name: 'Mike Chen',\n avatar: 'https://images.pexels.com/photos/1222271/pexels-photo-1222271.jpeg?auto=compress&cs=tinysrgb&w=64',\n bio: 'CSS specialist and design systems architect with expertise in modern layout techniques.',\n },\n publishedAt: '2024-01-10T09:00:00Z',\n tags: ['CSS', 'Layout', 'Grid', 'Flexbox', 'Web Design'],\n category: 'Design',\n readingTime: 6,\n featured: false,\n status: 'published',\n seoMeta: {\n title: 'CSS Grid vs Flexbox: Complete Comparison Guide',\n description: 'Learn when to use CSS Grid versus Flexbox with practical examples and decision frameworks.',\n keywords: ['CSS Grid', 'Flexbox', 'CSS Layout', 'Web Design'],\n },\n stats: {\n views: 890,\n likes: 67,\n comments: 15,\n shares: 32,\n },\n },\n {\n id: '3',\n title: 'Accessibility in Modern Web Development',\n slug: 'accessibility-modern-web-development',\n content: `# Accessibility in Modern Web Development\n\n## Why Accessibility Matters\n\nWeb accessibility ensures that websites and applications are usable by everyone, including people with disabilities. It's not just the right thing to do—it's also a legal requirement in many jurisdictions.\n\n## WCAG Guidelines\n\nThe Web Content Accessibility Guidelines (WCAG) provide a framework for making web content accessible:\n\n### Four Principles:\n1. **Perceivable**: Information must be presentable in ways users can perceive\n2. **Operable**: Interface components must be operable\n3. **Understandable**: Information and UI operation must be understandable\n4. **Robust**: Content must be robust enough for various assistive technologies\n\n## Practical Implementation\n\n### Semantic HTML\nUse proper HTML elements for their intended purpose:\n\n\\`\\`\\`html\n<header>\n <nav>\n <ul>\n <li><a href=\"/home\">Home</a></li>\n <li><a href=\"/about\">About</a></li>\n </ul>\n </nav>\n</header>\n\n<main>\n <article>\n <h1>Article Title</h1>\n <p>Article content...</p>\n </article>\n</main>\n\\`\\`\\`\n\n### ARIA Labels\nEnhance semantic meaning with ARIA attributes:\n\n\\`\\`\\`html\n<button aria-label=\"Close dialog\" aria-expanded=\"false\">\n <span aria-hidden=\"true\">×</span>\n</button>\n\\`\\`\\`\n\n### Keyboard Navigation\nEnsure all interactive elements are keyboard accessible:\n\n\\`\\`\\`css\n.button:focus {\n outline: 2px solid #007acc;\n outline-offset: 2px;\n}\n\\`\\`\\`\n\n## Testing Accessibility\n\n### Tools:\n- **axe-core**: Automated accessibility testing\n- **WAVE**: Web accessibility evaluation tool\n- **Lighthouse**: Built-in Chrome accessibility audit\n- **Screen readers**: NVDA, JAWS, VoiceOver\n\n## Conclusion\n\nBuilding accessible websites benefits everyone and creates a more inclusive web. Start with semantic HTML, add ARIA where needed, and test with real users and assistive technologies.`,\n excerpt: 'Learn how to build accessible web applications that work for everyone, including users with disabilities.',\n author: {\n id: 'author3',\n name: 'Emily Rodriguez',\n avatar: 'https://images.pexels.com/photos/1239291/pexels-photo-1239291.jpeg?auto=compress&cs=tinysrgb&w=64',\n bio: 'Accessibility advocate and UX engineer focused on inclusive design practices.',\n },\n publishedAt: '2024-01-05T11:30:00Z',\n tags: ['Accessibility', 'WCAG', 'UX', 'Inclusive Design'],\n category: 'Accessibility',\n readingTime: 7,\n featured: true,\n status: 'published',\n seoMeta: {\n title: 'Web Accessibility Guide - WCAG Compliance and Best Practices',\n description: 'Complete guide to web accessibility, WCAG compliance, and building inclusive web applications.',\n keywords: ['Web Accessibility', 'WCAG', 'Inclusive Design', 'Screen Readers'],\n },\n stats: {\n views: 2100,\n likes: 156,\n comments: 34,\n shares: 78,\n },\n },\n];\n\nexport const sampleBlogComments: BlogComment[] = [\n {\n id: 'c1',\n postId: '1',\n author: {\n id: 'u1',\n name: 'John Doe',\n avatar: 'https://images.pexels.com/photos/774909/pexels-photo-774909.jpeg?auto=compress&cs=tinysrgb&w=64',\n },\n content: 'Great article! I\\'ve been using TypeScript with React for a while now and these patterns are exactly what I recommend to my team.',\n createdAt: '2024-01-16T08:30:00Z',\n likes: 12,\n dislikes: 0,\n isModerated: false,\n isReported: false,\n replies: [\n {\n id: 'c1-r1',\n postId: '1',\n parentId: 'c1',\n author: {\n id: 'author1',\n name: 'Sarah Johnson',\n avatar: 'https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg?auto=compress&cs=tinysrgb&w=64',\n },\n content: 'Thanks John! I\\'m glad you found the patterns useful. Have you tried the new React 18 features with TypeScript?',\n createdAt: '2024-01-16T10:15:00Z',\n likes: 5,\n dislikes: 0,\n isModerated: false,\n isReported: false,\n },\n ],\n },\n {\n id: 'c2',\n postId: '1',\n author: {\n id: 'u2',\n name: 'Alice Smith',\n avatar: 'https://images.pexels.com/photos/1239291/pexels-photo-1239291.jpeg?auto=compress&cs=tinysrgb&w=64',\n },\n content: 'The custom hooks section was particularly helpful. I\\'ve been struggling with sharing state logic between components.',\n createdAt: '2024-01-16T12:45:00Z',\n likes: 8,\n dislikes: 0,\n isModerated: false,\n isReported: false,\n },\n];\n\nexport const sampleBlogCategories: BlogCategory[] = [\n {\n id: 'dev',\n name: 'Development',\n slug: 'development',\n description: 'Programming tutorials, frameworks, and development best practices',\n postCount: 45,\n color: '#3b82f6',\n },\n {\n id: 'design',\n name: 'Design',\n slug: 'design',\n description: 'UI/UX design, CSS techniques, and design systems',\n postCount: 32,\n color: '#8b5cf6',\n },\n {\n id: 'accessibility',\n name: 'Accessibility',\n slug: 'accessibility',\n description: 'Web accessibility, inclusive design, and WCAG compliance',\n postCount: 18,\n color: '#10b981',\n },\n {\n id: 'performance',\n name: 'Performance',\n slug: 'performance',\n description: 'Web performance optimization and best practices',\n postCount: 24,\n color: '#f59e0b',\n },\n];"],"names":[],"mappings":"AAEA;AACO,MAAM,eAAe,GAAe;AACzC,IAAA;AACE,QAAA,EAAE,EAAE,GAAG;AACP,QAAA,KAAK,EAAE,oDAAoD;AAC3D,QAAA,IAAI,EAAE,kCAAkC;AACxC,QAAA,OAAO,EAAE,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0E6L,yMAAA,CAAA;AACtM,QAAA,OAAO,EAAE,0GAA0G;AACnH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|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BlogPost, BlogFilters, BlogPagination } from '../types';
|
|
2
|
+
export interface UseBlogProps {
|
|
3
|
+
initialFilters?: Partial<BlogFilters>;
|
|
4
|
+
pageSize?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface UseBlogReturn {
|
|
7
|
+
posts: BlogPost[];
|
|
8
|
+
loading: boolean;
|
|
9
|
+
error: string | null;
|
|
10
|
+
filters: BlogFilters;
|
|
11
|
+
pagination: BlogPagination;
|
|
12
|
+
updateFilters: (newFilters: Partial<BlogFilters>) => void;
|
|
13
|
+
clearFilters: () => void;
|
|
14
|
+
loadMore: () => void;
|
|
15
|
+
refreshPosts: () => void;
|
|
16
|
+
searchPosts: (query: string) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Custom hook for blog data management and filtering
|
|
20
|
+
* Handles search, filtering, pagination, and data fetching
|
|
21
|
+
*/
|
|
22
|
+
export declare const useBlog: ({ initialFilters, pageSize, }?: UseBlogProps) => UseBlogReturn;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { useState, useMemo, useEffect, useCallback } from 'react';
|
|
2
|
+
import { useDebounce } from '../../../hooks/useDebounce.js';
|
|
3
|
+
import { sampleBlogPosts } from '../data/sampleData.js';
|
|
4
|
+
|
|
5
|
+
const defaultFilters = {
|
|
6
|
+
search: '',
|
|
7
|
+
tags: [],
|
|
8
|
+
categories: [],
|
|
9
|
+
authors: [],
|
|
10
|
+
dateRange: {},
|
|
11
|
+
sortBy: 'newest',
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Custom hook for blog data management and filtering
|
|
15
|
+
* Handles search, filtering, pagination, and data fetching
|
|
16
|
+
*/
|
|
17
|
+
const useBlog = ({ initialFilters = {}, pageSize = 10, } = {}) => {
|
|
18
|
+
const [posts, setPosts] = useState([]);
|
|
19
|
+
const [loading, setLoading] = useState(true);
|
|
20
|
+
const [error, setError] = useState(null);
|
|
21
|
+
const [filters, setFilters] = useState({
|
|
22
|
+
...defaultFilters,
|
|
23
|
+
...initialFilters,
|
|
24
|
+
});
|
|
25
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
26
|
+
const debouncedSearchQuery = useDebounce(filters.search, 300);
|
|
27
|
+
// Filter and sort posts
|
|
28
|
+
const filteredPosts = useMemo(() => {
|
|
29
|
+
let filtered = [...sampleBlogPosts];
|
|
30
|
+
// Search filter
|
|
31
|
+
if (debouncedSearchQuery) {
|
|
32
|
+
const query = debouncedSearchQuery.toLowerCase();
|
|
33
|
+
filtered = filtered.filter(post => post.title.toLowerCase().includes(query) ||
|
|
34
|
+
post.excerpt.toLowerCase().includes(query) ||
|
|
35
|
+
post.content.toLowerCase().includes(query) ||
|
|
36
|
+
post.tags.some(tag => tag.toLowerCase().includes(query)) ||
|
|
37
|
+
post.author.name.toLowerCase().includes(query));
|
|
38
|
+
}
|
|
39
|
+
// Category filter
|
|
40
|
+
if (filters.categories.length > 0) {
|
|
41
|
+
filtered = filtered.filter(post => filters.categories.includes(post.category));
|
|
42
|
+
}
|
|
43
|
+
// Tags filter
|
|
44
|
+
if (filters.tags.length > 0) {
|
|
45
|
+
filtered = filtered.filter(post => filters.tags.some(tag => post.tags.includes(tag)));
|
|
46
|
+
}
|
|
47
|
+
// Author filter
|
|
48
|
+
if (filters.authors.length > 0) {
|
|
49
|
+
filtered = filtered.filter(post => filters.authors.includes(post.author.id));
|
|
50
|
+
}
|
|
51
|
+
// Date range filter
|
|
52
|
+
if (filters.dateRange.start || filters.dateRange.end) {
|
|
53
|
+
filtered = filtered.filter(post => {
|
|
54
|
+
const postDate = new Date(post.publishedAt);
|
|
55
|
+
const startDate = filters.dateRange.start ? new Date(filters.dateRange.start) : null;
|
|
56
|
+
const endDate = filters.dateRange.end ? new Date(filters.dateRange.end) : null;
|
|
57
|
+
if (startDate && postDate < startDate)
|
|
58
|
+
return false;
|
|
59
|
+
if (endDate && postDate > endDate)
|
|
60
|
+
return false;
|
|
61
|
+
return true;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// Sort posts
|
|
65
|
+
switch (filters.sortBy) {
|
|
66
|
+
case 'oldest':
|
|
67
|
+
filtered.sort((a, b) => new Date(a.publishedAt).getTime() - new Date(b.publishedAt).getTime());
|
|
68
|
+
break;
|
|
69
|
+
case 'popular':
|
|
70
|
+
filtered.sort((a, b) => b.stats.views - a.stats.views);
|
|
71
|
+
break;
|
|
72
|
+
case 'trending':
|
|
73
|
+
filtered.sort((a, b) => (b.stats.likes + b.stats.shares) - (a.stats.likes + a.stats.shares));
|
|
74
|
+
break;
|
|
75
|
+
default: // newest
|
|
76
|
+
filtered.sort((a, b) => new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime());
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
return filtered;
|
|
80
|
+
}, [debouncedSearchQuery, filters, sampleBlogPosts]);
|
|
81
|
+
// Pagination
|
|
82
|
+
const paginatedPosts = useMemo(() => {
|
|
83
|
+
const startIndex = (currentPage - 1) * pageSize;
|
|
84
|
+
return filteredPosts.slice(0, startIndex + pageSize);
|
|
85
|
+
}, [filteredPosts, currentPage, pageSize]);
|
|
86
|
+
const pagination = useMemo(() => ({
|
|
87
|
+
page: currentPage,
|
|
88
|
+
limit: pageSize,
|
|
89
|
+
total: filteredPosts.length,
|
|
90
|
+
hasNext: currentPage * pageSize < filteredPosts.length,
|
|
91
|
+
hasPrev: currentPage > 1,
|
|
92
|
+
}), [currentPage, pageSize, filteredPosts.length]);
|
|
93
|
+
// Simulate API call
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const fetchPosts = async () => {
|
|
96
|
+
setLoading(true);
|
|
97
|
+
setError(null);
|
|
98
|
+
try {
|
|
99
|
+
// Simulate API delay
|
|
100
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
101
|
+
setPosts(paginatedPosts);
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
setError('Failed to load blog posts');
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
setLoading(false);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
fetchPosts();
|
|
111
|
+
}, [paginatedPosts]);
|
|
112
|
+
const updateFilters = useCallback((newFilters) => {
|
|
113
|
+
setFilters(prev => ({ ...prev, ...newFilters }));
|
|
114
|
+
setCurrentPage(1); // Reset to first page when filters change
|
|
115
|
+
}, []);
|
|
116
|
+
const clearFilters = useCallback(() => {
|
|
117
|
+
setFilters(defaultFilters);
|
|
118
|
+
setCurrentPage(1);
|
|
119
|
+
}, []);
|
|
120
|
+
const loadMore = useCallback(() => {
|
|
121
|
+
if (pagination.hasNext) {
|
|
122
|
+
setCurrentPage(prev => prev + 1);
|
|
123
|
+
}
|
|
124
|
+
}, [pagination.hasNext]);
|
|
125
|
+
const refreshPosts = useCallback(() => {
|
|
126
|
+
setCurrentPage(1);
|
|
127
|
+
// Trigger re-fetch
|
|
128
|
+
setPosts([]);
|
|
129
|
+
}, []);
|
|
130
|
+
const searchPosts = useCallback((query) => {
|
|
131
|
+
updateFilters({ search: query });
|
|
132
|
+
}, [updateFilters]);
|
|
133
|
+
return {
|
|
134
|
+
posts,
|
|
135
|
+
loading,
|
|
136
|
+
error,
|
|
137
|
+
filters,
|
|
138
|
+
pagination,
|
|
139
|
+
updateFilters,
|
|
140
|
+
clearFilters,
|
|
141
|
+
loadMore,
|
|
142
|
+
refreshPosts,
|
|
143
|
+
searchPosts,
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export { useBlog };
|
|
148
|
+
//# sourceMappingURL=useBlog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBlog.js","sources":["../../../../src/components/Blog/hooks/useBlog.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useMemo } from 'react';\nimport { useDebounce } from '../../../hooks/useDebounce';\nimport type { BlogPost, BlogFilters, BlogPagination } from '../types';\nimport { sampleBlogPosts } from '../data/sampleData';\n\nexport interface UseBlogProps {\n initialFilters?: Partial<BlogFilters>;\n pageSize?: number;\n}\n\nexport interface UseBlogReturn {\n posts: BlogPost[];\n loading: boolean;\n error: string | null;\n filters: BlogFilters;\n pagination: BlogPagination;\n updateFilters: (newFilters: Partial<BlogFilters>) => void;\n clearFilters: () => void;\n loadMore: () => void;\n refreshPosts: () => void;\n searchPosts: (query: string) => void;\n}\n\nconst defaultFilters: BlogFilters = {\n search: '',\n tags: [],\n categories: [],\n authors: [],\n dateRange: {},\n sortBy: 'newest',\n};\n\n/**\n * Custom hook for blog data management and filtering\n * Handles search, filtering, pagination, and data fetching\n */\nexport const useBlog = ({\n initialFilters = {},\n pageSize = 10,\n}: UseBlogProps = {}): UseBlogReturn => {\n const [posts, setPosts] = useState<BlogPost[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [filters, setFilters] = useState<BlogFilters>({\n ...defaultFilters,\n ...initialFilters,\n });\n const [currentPage, setCurrentPage] = useState(1);\n\n const debouncedSearchQuery = useDebounce(filters.search, 300);\n\n // Filter and sort posts\n const filteredPosts = useMemo(() => {\n let filtered = [...sampleBlogPosts];\n\n // Search filter\n if (debouncedSearchQuery) {\n const query = debouncedSearchQuery.toLowerCase();\n filtered = filtered.filter(post =>\n post.title.toLowerCase().includes(query) ||\n post.excerpt.toLowerCase().includes(query) ||\n post.content.toLowerCase().includes(query) ||\n post.tags.some(tag => tag.toLowerCase().includes(query)) ||\n post.author.name.toLowerCase().includes(query)\n );\n }\n\n // Category filter\n if (filters.categories.length > 0) {\n filtered = filtered.filter(post =>\n filters.categories.includes(post.category)\n );\n }\n\n // Tags filter\n if (filters.tags.length > 0) {\n filtered = filtered.filter(post =>\n filters.tags.some(tag => post.tags.includes(tag))\n );\n }\n\n // Author filter\n if (filters.authors.length > 0) {\n filtered = filtered.filter(post =>\n filters.authors.includes(post.author.id)\n );\n }\n\n // Date range filter\n if (filters.dateRange.start || filters.dateRange.end) {\n filtered = filtered.filter(post => {\n const postDate = new Date(post.publishedAt);\n const startDate = filters.dateRange.start ? new Date(filters.dateRange.start) : null;\n const endDate = filters.dateRange.end ? new Date(filters.dateRange.end) : null;\n\n if (startDate && postDate < startDate) return false;\n if (endDate && postDate > endDate) return false;\n return true;\n });\n }\n\n // Sort posts\n switch (filters.sortBy) {\n case 'oldest':\n filtered.sort((a, b) => new Date(a.publishedAt).getTime() - new Date(b.publishedAt).getTime());\n break;\n case 'popular':\n filtered.sort((a, b) => b.stats.views - a.stats.views);\n break;\n case 'trending':\n filtered.sort((a, b) => (b.stats.likes + b.stats.shares) - (a.stats.likes + a.stats.shares));\n break;\n default: // newest\n filtered.sort((a, b) => new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime());\n break;\n }\n\n return filtered;\n }, [debouncedSearchQuery, filters, sampleBlogPosts]);\n\n // Pagination\n const paginatedPosts = useMemo(() => {\n const startIndex = (currentPage - 1) * pageSize;\n return filteredPosts.slice(0, startIndex + pageSize);\n }, [filteredPosts, currentPage, pageSize]);\n\n const pagination: BlogPagination = useMemo(() => ({\n page: currentPage,\n limit: pageSize,\n total: filteredPosts.length,\n hasNext: currentPage * pageSize < filteredPosts.length,\n hasPrev: currentPage > 1,\n }), [currentPage, pageSize, filteredPosts.length]);\n\n // Simulate API call\n useEffect(() => {\n const fetchPosts = async () => {\n setLoading(true);\n setError(null);\n \n try {\n // Simulate API delay\n await new Promise(resolve => setTimeout(resolve, 500));\n setPosts(paginatedPosts);\n } catch (err) {\n setError('Failed to load blog posts');\n } finally {\n setLoading(false);\n }\n };\n\n fetchPosts();\n }, [paginatedPosts]);\n\n const updateFilters = useCallback((newFilters: Partial<BlogFilters>) => {\n setFilters(prev => ({ ...prev, ...newFilters }));\n setCurrentPage(1); // Reset to first page when filters change\n }, []);\n\n const clearFilters = useCallback(() => {\n setFilters(defaultFilters);\n setCurrentPage(1);\n }, []);\n\n const loadMore = useCallback(() => {\n if (pagination.hasNext) {\n setCurrentPage(prev => prev + 1);\n }\n }, [pagination.hasNext]);\n\n const refreshPosts = useCallback(() => {\n setCurrentPage(1);\n // Trigger re-fetch\n setPosts([]);\n }, []);\n\n const searchPosts = useCallback((query: string) => {\n updateFilters({ search: query });\n }, [updateFilters]);\n\n return {\n posts,\n loading,\n error,\n filters,\n pagination,\n updateFilters,\n clearFilters,\n loadMore,\n refreshPosts,\n searchPosts,\n };\n};"],"names":[],"mappings":";;;;AAuBA,MAAM,cAAc,GAAgB;AAClC,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,IAAI,EAAE,EAAE;AACR,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,OAAO,EAAE,EAAE;AACX,IAAA,SAAS,EAAE,EAAE;AACb,IAAA,MAAM,EAAE,QAAQ;CACjB;AAED;;;AAGG;AACI,MAAM,OAAO,GAAG,CAAC,EACtB,cAAc,GAAG,EAAE,EACnB,QAAQ,GAAG,EAAE,GAAA,GACG,EAAE,KAAmB;IACrC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAa,EAAE,CAAC;IAClD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC;AACvD,IAAA,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAc;AAClD,QAAA,GAAG,cAAc;AACjB,QAAA,GAAG,cAAc;AAClB,KAAA,CAAC;IACF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAEjD,MAAM,oBAAoB,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;;AAG7D,IAAA,MAAM,aAAa,GAAG,OAAO,CAAC,MAAK;AACjC,QAAA,IAAI,QAAQ,GAAG,CAAC,GAAG,eAAe,CAAC;;QAGnC,IAAI,oBAAoB,EA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Y;QACZ,QAAQ;QACR,YAAY;QACZ,WAAW;KACZ;AACH;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TableOfContentsItem } from '../types';
|
|
2
|
+
export interface UseBlogNavigationReturn {
|
|
3
|
+
tableOfContents: TableOfContentsItem[];
|
|
4
|
+
activeSection: string;
|
|
5
|
+
scrollToSection: (anchor: string) => void;
|
|
6
|
+
generateTableOfContents: (content: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Custom hook for blog navigation and table of contents
|
|
10
|
+
* Handles smooth scrolling and active section tracking
|
|
11
|
+
*/
|
|
12
|
+
export declare const useBlogNavigation: () => UseBlogNavigationReturn;
|