@windstream/react-shared-components 0.1.63 → 0.1.67

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.
@@ -1,119 +1,119 @@
1
- import { BlogCategoryOption, BlogGridBaseProps } from "./types";
2
-
3
- import { Pagination } from "@shared/components/pagination";
4
- import { Select } from "@shared/components/select";
5
- import { Text } from "@shared/components/text";
6
- import { BlogCard } from "@shared/contentful/blocks/cards/blog-card";
7
-
8
- export function BlogGridBase({
9
- title = "recent articles",
10
- paginatedArticles,
11
- totalArticles,
12
- currentPage,
13
- totalPages,
14
- selectedCategory,
15
- categoryOptions,
16
- onCategoryChange,
17
- onPageChange,
18
- imageComponent,
19
- }: BlogGridBaseProps) {
20
- function handleCategoryChange(value: unknown) {
21
- if (!value || Array.isArray(value)) return;
22
- const cat = value as BlogCategoryOption;
23
- onCategoryChange?.(cat);
24
- }
25
-
26
- function handlePageChange(page: number) {
27
- onPageChange?.(page);
28
- }
29
-
30
- return (
31
- <section
32
- aria-label="Blog articles"
33
- data-section-type={"blogs-grid"}
34
- data-section-index={"0"}
35
- >
36
- {/* Controls bar */}
37
- <div className="mx-auto flex max-w-[1200px] flex-wrap items-center justify-between gap-3 px-6 pb-6">
38
- <Text className="w-full text-center text-heading5 font-black lowercase text-text-secondary md:w-auto md:text-left">
39
- {title}
40
- </Text>
41
-
42
- {categoryOptions.length > 0 && (
43
- <div className="flex w-full flex-col-reverse gap-3 md:w-auto md:flex-row md:items-center md:gap-6">
44
- {/* Showing count */}
45
- <Text className="whitespace-nowrap text-center text-label3 font-bold text-text-info md:text-right md:text-label2">
46
- <Text as="span" className="hidden md:block">
47
- showing
48
- </Text>
49
- <strong className="block text-nowrap font-bold text-text-info">
50
- <Text as="span" className="md:hidden">
51
- showing{" "}
52
- </Text>
53
- {paginatedArticles.length} of {totalArticles} articles
54
- </strong>
55
- </Text>
56
-
57
- {/* Filter dropdown */}
58
- <Select
59
- options={categoryOptions}
60
- value={selectedCategory}
61
- onChange={handleCategoryChange}
62
- className="w-full md:w-[280px]"
63
- />
64
- </div>
65
- )}
66
- </div>
67
-
68
- {/* Articles grid */}
69
- {paginatedArticles.length > 0 ? (
70
- <div className="mx-auto grid max-w-[1200px] grid-cols-1 gap-6 px-5 pb-16 sm:grid-cols-2 lg:grid-cols-3">
71
- {paginatedArticles.map((article, index) => {
72
- const href = article.slug.startsWith("/")
73
- ? article.slug
74
- : `/${article.slug}`;
75
- const coverImage = article?.cover?.url
76
- ? {
77
- src: article?.cover?.url,
78
- alt:
79
- article?.cover?.title ||
80
- article?.title ||
81
- "Blog article image",
82
- width: article?.cover?.width || 600,
83
- height: article?.cover?.height || 338,
84
- }
85
- : undefined;
86
-
87
- return (
88
- <BlogCard
89
- key={article.slug}
90
- href={href}
91
- title={article.title}
92
- description={article.shortDescription}
93
- date={article.blogCreationDate}
94
- category={article.category}
95
- image={coverImage}
96
- imageComponent={imageComponent}
97
- index={index}
98
- />
99
- );
100
- })}
101
- </div>
102
- ) : (
103
- <Text className="px-6 py-12 text-center text-text-info">
104
- No articles found.
105
- </Text>
106
- )}
107
-
108
- {/* Pagination */}
109
- {totalPages > 1 && (
110
- <Pagination
111
- currentPage={currentPage}
112
- totalPages={totalPages}
113
- onPageChange={handlePageChange}
114
- ariaLabel="Blog article pagination"
115
- />
116
- )}
117
- </section>
118
- );
119
- }
1
+ import { BlogCategoryOption, BlogGridBaseProps } from "./types";
2
+
3
+ import { Pagination } from "@shared/components/pagination";
4
+ import { Select } from "@shared/components/select";
5
+ import { Text } from "@shared/components/text";
6
+ import { BlogCard } from "@shared/contentful/blocks/cards/blog-card";
7
+
8
+ export function BlogGridBase({
9
+ title = "recent articles",
10
+ paginatedArticles,
11
+ totalArticles,
12
+ currentPage,
13
+ totalPages,
14
+ selectedCategory,
15
+ categoryOptions,
16
+ onCategoryChange,
17
+ onPageChange,
18
+ imageComponent,
19
+ }: BlogGridBaseProps) {
20
+ function handleCategoryChange(value: unknown) {
21
+ if (!value || Array.isArray(value)) return;
22
+ const cat = value as BlogCategoryOption;
23
+ onCategoryChange?.(cat);
24
+ }
25
+
26
+ function handlePageChange(page: number) {
27
+ onPageChange?.(page);
28
+ }
29
+
30
+ return (
31
+ <section
32
+ aria-label="Blog articles"
33
+ data-section-type={"blogs-grid"}
34
+ data-section-index={"0"}
35
+ >
36
+ {/* Controls bar */}
37
+ <div className="mx-auto flex max-w-[1200px] flex-wrap items-center justify-between gap-3 px-6 pb-6">
38
+ <Text className="w-full text-center text-heading5 font-black lowercase text-text-secondary md:w-auto md:text-left">
39
+ {title}
40
+ </Text>
41
+
42
+ {categoryOptions.length > 0 && (
43
+ <div className="flex w-full flex-col-reverse gap-3 md:w-auto md:flex-row md:items-center md:gap-6">
44
+ {/* Showing count */}
45
+ <Text className="whitespace-nowrap text-center text-label3 font-bold text-text-info md:text-right md:text-label2">
46
+ <Text as="span" className="hidden md:block">
47
+ showing
48
+ </Text>
49
+ <strong className="block text-nowrap font-bold text-text-info">
50
+ <Text as="span" className="md:hidden">
51
+ showing{" "}
52
+ </Text>
53
+ {paginatedArticles.length} of {totalArticles} articles
54
+ </strong>
55
+ </Text>
56
+
57
+ {/* Filter dropdown */}
58
+ <Select
59
+ options={categoryOptions}
60
+ value={selectedCategory}
61
+ onChange={handleCategoryChange}
62
+ className="w-full md:w-[280px]"
63
+ />
64
+ </div>
65
+ )}
66
+ </div>
67
+
68
+ {/* Articles grid */}
69
+ {paginatedArticles.length > 0 ? (
70
+ <div className="mx-auto grid max-w-[1200px] grid-cols-1 gap-6 px-5 pb-16 sm:grid-cols-2 lg:grid-cols-3">
71
+ {paginatedArticles.map((article, index) => {
72
+ const href = article.slug.startsWith("/")
73
+ ? article.slug
74
+ : `/${article.slug}`;
75
+ const coverImage = article?.cover?.url
76
+ ? {
77
+ src: article?.cover?.url,
78
+ alt:
79
+ article?.cover?.title ||
80
+ article?.title ||
81
+ "Blog article image",
82
+ width: article?.cover?.width || 600,
83
+ height: article?.cover?.height || 338,
84
+ }
85
+ : undefined;
86
+
87
+ return (
88
+ <BlogCard
89
+ key={article.slug}
90
+ href={href}
91
+ title={article.title}
92
+ description={article.shortDescription}
93
+ date={article.blogCreationDate}
94
+ category={article.category}
95
+ image={coverImage}
96
+ imageComponent={imageComponent}
97
+ index={index}
98
+ />
99
+ );
100
+ })}
101
+ </div>
102
+ ) : (
103
+ <Text className="px-6 py-12 text-center text-text-info">
104
+ No articles found.
105
+ </Text>
106
+ )}
107
+
108
+ {/* Pagination */}
109
+ {totalPages > 1 && (
110
+ <Pagination
111
+ currentPage={currentPage}
112
+ totalPages={totalPages}
113
+ onPageChange={handlePageChange}
114
+ ariaLabel="Blog article pagination"
115
+ />
116
+ )}
117
+ </section>
118
+ );
119
+ }
@@ -1,35 +1,35 @@
1
- import React from "react";
2
- import { BlogCardImageProps } from "@shared/contentful/blocks/cards/blog-card/types";
3
-
4
- export interface BlogCardProps {
5
- slug: string;
6
- title?: string;
7
- shortDescription?: string;
8
- blogCreationDate?: string;
9
- category?: string;
10
- cover?: {
11
- url: string;
12
- width?: number;
13
- height?: number;
14
- title?: string;
15
- };
16
- }
17
-
18
- export interface BlogGridBaseProps {
19
- title?: string;
20
- paginatedArticles: BlogCardProps[];
21
- totalArticles: number;
22
- currentPage: number;
23
- totalPages: number;
24
- selectedCategory: BlogCategoryOption;
25
- categoryOptions: BlogCategoryOption[];
26
- onCategoryChange?: (category: BlogCategoryOption) => void;
27
- onPageChange?: (page: number) => void;
28
- /** Pass next/image's Image component here to enable image optimization */
29
- imageComponent?: React.ComponentType<BlogCardImageProps>;
30
- }
31
-
32
- export interface BlogCategoryOption {
33
- value: string;
34
- label: string;
35
- }
1
+ import React from "react";
2
+ import { BlogCardImageProps } from "@shared/contentful/blocks/cards/blog-card/types";
3
+
4
+ export interface BlogCardProps {
5
+ slug: string;
6
+ title?: string;
7
+ shortDescription?: string;
8
+ blogCreationDate?: string;
9
+ category?: string;
10
+ cover?: {
11
+ url: string;
12
+ width?: number;
13
+ height?: number;
14
+ title?: string;
15
+ };
16
+ }
17
+
18
+ export interface BlogGridBaseProps {
19
+ title?: string;
20
+ paginatedArticles: BlogCardProps[];
21
+ totalArticles: number;
22
+ currentPage: number;
23
+ totalPages: number;
24
+ selectedCategory: BlogCategoryOption;
25
+ categoryOptions: BlogCategoryOption[];
26
+ onCategoryChange?: (category: BlogCategoryOption) => void;
27
+ onPageChange?: (page: number) => void;
28
+ /** Pass next/image's Image component here to enable image optimization */
29
+ imageComponent?: React.ComponentType<BlogCardImageProps>;
30
+ }
31
+
32
+ export interface BlogCategoryOption {
33
+ value: string;
34
+ label: string;
35
+ }
@@ -25,7 +25,7 @@ export const BreadcrumbNavigation: React.FC<
25
25
  return (
26
26
  <nav
27
27
  aria-label="Breadcrumb"
28
- className={`${maxWidth ? "mx-5 max-w-120 xl:mx-auto" : "mx-auto"} relative`}
28
+ className={`${maxWidth ? `${!floatOnMobile && "mx-5"} max-w-120 xl:mx-auto` : "mx-auto"} relative`}
29
29
  >
30
30
  <ol
31
31
  className={`right-0 z-10 mx-0 flex w-full flex-nowrap items-center gap-2 px-7 pb-0 pt-8 md:px-14 ${floatOnMobile ? "absolute" : "relative xl:absolute"} xl:mx-auto xl:flex-wrap xl:px-3`}
@@ -1,129 +1,129 @@
1
- import React from "react";
2
- import { BlogCardProps } from "./types";
3
- import * as _NextLink from "next/link";
4
-
5
- // import { Button } from "@shared/components/button";
6
- import { MaterialIcon } from "@shared/components/material-icon";
7
- import { Text } from "@shared/components/text";
8
-
9
- // CJS/ESM interop: next/link uses standard __esModule exports so this is safe.
10
- // next/image is intentionally avoided — its image-external.js uses the
11
- // `0 && (module.exports = {...})` tree-shaking hint which confuses webpack's
12
- // CJS→ESM interop and causes "got: object" errors in consuming apps.
13
- const Link = ((_NextLink as any).default ??
14
- _NextLink) as typeof import("next/link").default;
15
-
16
- export const BlogCard: React.FC<BlogCardProps> = ({
17
- href,
18
- title,
19
- description,
20
- date,
21
- category,
22
- image,
23
- imageComponent: ImageComponent,
24
- readMoreText = "Read more",
25
- asGrid = true,
26
- lgWidth,
27
- mdWidth,
28
- index,
29
- }: BlogCardProps) => {
30
- const basehwClass = "lg:w-[calc(33.3333%-1rem)] md:w-[calc(50%-1rem)]";
31
- const parentClassName = asGrid
32
- ? "flex h-full flex-col overflow-hidden rounded-card-lg bg-white shadow-drop transition-all duration-200 hover:-translate-y-0.5 hover:shadow-cardDrop"
33
- : `callout-card ${basehwClass} ${lgWidth} ${mdWidth} w-full overflow-hidden rounded-card-lg bg-white shadow-drop transition-all duration-200 hover:-translate-y-0.5 hover:shadow-cardDrop`;
34
-
35
- return (
36
- <article
37
- className={parentClassName}
38
- data-section-type={"blog-card"}
39
- data-section-index={index}
40
- >
41
- {/* Image */}
42
- <Link href={href} tabIndex={-1} aria-hidden="true" className="block">
43
- <div className="h-[232px] w-full flex-shrink-0 overflow-hidden bg-gray-100">
44
- {image ? (
45
- ImageComponent ? (
46
- <ImageComponent
47
- src={image.src}
48
- alt={image.alt}
49
- width={image.width}
50
- height={image.height}
51
- className="h-full w-full object-cover transition-transform duration-300 hover:scale-[1.03]"
52
- sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 33vw"
53
- />
54
- ) : (
55
- <img
56
- src={image.src}
57
- alt={image.alt}
58
- width={image.width}
59
- height={image.height}
60
- loading="lazy"
61
- decoding="async"
62
- className="h-full w-full object-cover transition-transform duration-300 hover:scale-[1.03]"
63
- />
64
- )
65
- ) : (
66
- <div
67
- className="h-full w-full bg-gradient-to-br from-gray-200 to-gray-100"
68
- aria-hidden="true"
69
- />
70
- )}
71
- </div>
72
- </Link>
73
-
74
- {/* Body */}
75
- <div className="flex flex-1 flex-col gap-5 p-6 md:p-8">
76
- {/* Meta: category + date */}
77
- <div className="flex items-center gap-2 text-[13px]">
78
- <span className="body2 text-text-brand">{category}</span>
79
- {date && (
80
- <>
81
- <span className="footnote text-text" aria-hidden="true">
82
-
83
- </span>
84
- <time className="body2 text-text">{date}</time>
85
- </>
86
- )}
87
- </div>
88
-
89
- {/* Title */}
90
- {title && (
91
- <Link
92
- href={href}
93
- className="heading6 m-0 line-clamp-3 font-black transition-colors duration-150 hover:text-text-brand"
94
- >
95
- {title}
96
- </Link>
97
- )}
98
-
99
- {/* Excerpt */}
100
- {description && (
101
- <Text className="body1 m-0 line-clamp-3 flex-1 text-text">
102
- {description}
103
- </Text>
104
- )}
105
-
106
- {/* Read more */}
107
- <Link
108
- href={href}
109
- className="group mt-auto inline-flex items-center justify-start gap-2 pt-3 text-sm text-text-brand no-underline"
110
- aria-label={`${readMoreText} about ${title || "this article"}`}
111
- >
112
- <Text
113
- aria-label={`${readMoreText} about ${title || "this article"}`}
114
- className="label1 text-nowrap"
115
- >
116
- {readMoreText}
117
- </Text>
118
- <MaterialIcon
119
- name="expand_circle_right"
120
- fill={1}
121
- size={24}
122
- weight="200"
123
- />
124
- </Link>
125
- </div>
126
- </article>
127
- );
128
- };
129
- export default BlogCard;
1
+ import React from "react";
2
+ import { BlogCardProps } from "./types";
3
+ import * as _NextLink from "next/link";
4
+
5
+ // import { Button } from "@shared/components/button";
6
+ import { MaterialIcon } from "@shared/components/material-icon";
7
+ import { Text } from "@shared/components/text";
8
+
9
+ // CJS/ESM interop: next/link uses standard __esModule exports so this is safe.
10
+ // next/image is intentionally avoided — its image-external.js uses the
11
+ // `0 && (module.exports = {...})` tree-shaking hint which confuses webpack's
12
+ // CJS→ESM interop and causes "got: object" errors in consuming apps.
13
+ const Link = ((_NextLink as any).default ??
14
+ _NextLink) as typeof import("next/link").default;
15
+
16
+ export const BlogCard: React.FC<BlogCardProps> = ({
17
+ href,
18
+ title,
19
+ description,
20
+ date,
21
+ category,
22
+ image,
23
+ imageComponent: ImageComponent,
24
+ readMoreText = "Read more",
25
+ asGrid = true,
26
+ lgWidth,
27
+ mdWidth,
28
+ index,
29
+ }: BlogCardProps) => {
30
+ const basehwClass = "lg:w-[calc(33.3333%-1rem)] md:w-[calc(50%-1rem)]";
31
+ const parentClassName = asGrid
32
+ ? "flex h-full flex-col overflow-hidden rounded-card-lg bg-white shadow-drop transition-all duration-200 hover:-translate-y-0.5 hover:shadow-cardDrop"
33
+ : `callout-card ${basehwClass} ${lgWidth} ${mdWidth} w-full overflow-hidden rounded-card-lg bg-white shadow-drop transition-all duration-200 hover:-translate-y-0.5 hover:shadow-cardDrop`;
34
+
35
+ return (
36
+ <article
37
+ className={parentClassName}
38
+ data-section-type={"blog-card"}
39
+ data-section-index={index}
40
+ >
41
+ {/* Image */}
42
+ <Link href={href} tabIndex={-1} aria-hidden="true" className="block">
43
+ <div className="h-[232px] w-full flex-shrink-0 overflow-hidden bg-gray-100">
44
+ {image ? (
45
+ ImageComponent ? (
46
+ <ImageComponent
47
+ src={image.src}
48
+ alt={image.alt}
49
+ width={image.width}
50
+ height={image.height}
51
+ className="h-full w-full object-cover transition-transform duration-300 hover:scale-[1.03]"
52
+ sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 33vw"
53
+ />
54
+ ) : (
55
+ <img
56
+ src={image.src}
57
+ alt={image.alt}
58
+ width={image.width}
59
+ height={image.height}
60
+ loading="lazy"
61
+ decoding="async"
62
+ className="h-full w-full object-cover transition-transform duration-300 hover:scale-[1.03]"
63
+ />
64
+ )
65
+ ) : (
66
+ <div
67
+ className="h-full w-full bg-gradient-to-br from-gray-200 to-gray-100"
68
+ aria-hidden="true"
69
+ />
70
+ )}
71
+ </div>
72
+ </Link>
73
+
74
+ {/* Body */}
75
+ <div className="flex flex-1 flex-col gap-5 p-6 md:p-8">
76
+ {/* Meta: category + date */}
77
+ <div className="flex items-center gap-2 text-[13px]">
78
+ <span className="body2 text-text-brand">{category}</span>
79
+ {date && (
80
+ <>
81
+ <span className="footnote text-text" aria-hidden="true">
82
+
83
+ </span>
84
+ <time className="body2 text-text">{date}</time>
85
+ </>
86
+ )}
87
+ </div>
88
+
89
+ {/* Title */}
90
+ {title && (
91
+ <Link
92
+ href={href}
93
+ className="heading6 m-0 line-clamp-3 font-black transition-colors duration-150 hover:text-text-brand"
94
+ >
95
+ {title}
96
+ </Link>
97
+ )}
98
+
99
+ {/* Excerpt */}
100
+ {description && (
101
+ <Text className="body1 m-0 line-clamp-3 flex-1 text-text">
102
+ {description}
103
+ </Text>
104
+ )}
105
+
106
+ {/* Read more */}
107
+ <Link
108
+ href={href}
109
+ className="group mt-auto inline-flex items-center justify-start gap-2 pt-3 text-sm text-text-brand no-underline"
110
+ aria-label={`${readMoreText} about ${title || "this article"}`}
111
+ >
112
+ <Text
113
+ aria-label={`${readMoreText} about ${title || "this article"}`}
114
+ className="label1 text-nowrap"
115
+ >
116
+ {readMoreText}
117
+ </Text>
118
+ <MaterialIcon
119
+ name="expand_circle_right"
120
+ fill={1}
121
+ size={24}
122
+ weight="200"
123
+ />
124
+ </Link>
125
+ </div>
126
+ </article>
127
+ );
128
+ };
129
+ export default BlogCard;