@c-rex/components 0.1.0 → 0.1.1
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/package.json +1 -1
- package/src/blog-card.tsx +4 -3
- package/src/navbar/navbar.tsx +1 -1
- package/src/result-list.tsx +14 -8
- package/src/result-view/table.tsx +16 -26
package/package.json
CHANGED
package/src/blog-card.tsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Link from "next/link";
|
|
2
2
|
import { cn } from "@c-rex/utils";
|
|
3
3
|
import { BlurImage } from "./blur-image";
|
|
4
|
-
|
|
5
|
-
//import Author from "./author";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
6
5
|
|
|
7
6
|
interface BlogCardProp {
|
|
8
7
|
data: {
|
|
@@ -24,6 +23,8 @@ export const BlogCard = ({
|
|
|
24
23
|
priority,
|
|
25
24
|
horizontal = false,
|
|
26
25
|
}: BlogCardProp) => {
|
|
26
|
+
const t = useTranslations("results")
|
|
27
|
+
|
|
27
28
|
return (
|
|
28
29
|
<article
|
|
29
30
|
className={cn(
|
|
@@ -80,7 +81,7 @@ export const BlogCard = ({
|
|
|
80
81
|
</div>
|
|
81
82
|
</div>
|
|
82
83
|
<Link href={data.slug} className="absolute inset-0" target="_blank">
|
|
83
|
-
<span className="sr-only">
|
|
84
|
+
<span className="sr-only">{t("viewArticle")}</span>
|
|
84
85
|
</Link>
|
|
85
86
|
</article>
|
|
86
87
|
);
|
package/src/navbar/navbar.tsx
CHANGED
|
@@ -48,7 +48,6 @@ export const NavBar: FC<NavBarProps> = async () => {
|
|
|
48
48
|
country: getCountryCodeByLang(lang)
|
|
49
49
|
}));
|
|
50
50
|
|
|
51
|
-
|
|
52
51
|
return (
|
|
53
52
|
<header className="sticky top-0 z-40 flex w-full bg-background/60 backdrop-blur-xl transition-all bg-transparent border-b justify-center py-4">
|
|
54
53
|
<div className="container flex justify-between">
|
|
@@ -61,6 +60,7 @@ export const NavBar: FC<NavBarProps> = async () => {
|
|
|
61
60
|
height={50}
|
|
62
61
|
/>
|
|
63
62
|
</Link>
|
|
63
|
+
{configs.projectName}
|
|
64
64
|
</div>
|
|
65
65
|
|
|
66
66
|
<div className="flex items-center space-x-3">
|
package/src/result-list.tsx
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
import { informationUnitsItems } from "@c-rex/interfaces";
|
|
1
|
+
import React, { FC } from "react";
|
|
2
|
+
import { ConfigInterface, informationUnitsItems } from "@c-rex/interfaces";
|
|
3
3
|
import { Empty } from "./empty";
|
|
4
|
-
//import { CUSTOMER_CONFIG } from '@/config/customerConfig';
|
|
5
|
-
//import { RESULT_VIEW_OPTIONS } from '@/constants/components';
|
|
6
4
|
import BlogView from './result-view/blog';
|
|
7
|
-
|
|
8
|
-
const ViewComponent = BlogView;
|
|
5
|
+
import TableView from './result-view/table';
|
|
9
6
|
|
|
10
7
|
interface ResultListProps {
|
|
11
8
|
items: informationUnitsItems[];
|
|
9
|
+
configs: ConfigInterface
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
export const ResultList: FC<ResultListProps> = ({ items }) => {
|
|
15
|
-
|
|
12
|
+
export const ResultList: FC<ResultListProps> = ({ items, configs }) => {
|
|
13
|
+
const ViewComponent = configs.resultViewStyle == "table" ? TableView : BlogView;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
{
|
|
18
|
+
items.length == 0 ? <Empty /> : <ViewComponent items={items} />
|
|
19
|
+
}
|
|
20
|
+
</>
|
|
21
|
+
);
|
|
16
22
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { FC, ReactNode } from "react";
|
|
2
|
-
|
|
1
|
+
import React, { FC, ReactNode } from "react";
|
|
3
2
|
import {
|
|
4
3
|
Table,
|
|
5
4
|
TableBody,
|
|
@@ -8,36 +7,21 @@ import {
|
|
|
8
7
|
TableRow,
|
|
9
8
|
} from "@c-rex/ui/table";
|
|
10
9
|
import { informationUnitsItems, Labels } from "@c-rex/interfaces";
|
|
11
|
-
|
|
10
|
+
import Link from "next/link";
|
|
11
|
+
import { useTranslations } from "next-intl";
|
|
12
12
|
|
|
13
13
|
interface TableViewProps {
|
|
14
14
|
items: informationUnitsItems[];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const TableView: FC<TableViewProps> = ({ items }) => {
|
|
18
|
+
const t = useTranslations("results")
|
|
19
|
+
|
|
18
20
|
const getTitle = (labels: Labels[]): string => {
|
|
19
21
|
return labels.map((item) => item.value).join();
|
|
20
22
|
};
|
|
21
|
-
const getIcons = (languages: string[]):
|
|
22
|
-
return languages.map((lang
|
|
23
|
-
const aux = lang.split("-")[1];
|
|
24
|
-
|
|
25
|
-
/*
|
|
26
|
-
const FlagIcon = getFlagIcon(aux);
|
|
27
|
-
|
|
28
|
-
return FlagIcon && (
|
|
29
|
-
<div key={index} style={{ width: 36 }} className="border me-3">
|
|
30
|
-
<FlagIcon />
|
|
31
|
-
</div>
|
|
32
|
-
)
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div key={index} style={{ width: 36 }} className="border me-3">
|
|
37
|
-
{aux}
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
});
|
|
23
|
+
const getIcons = (languages: string[]): string => {
|
|
24
|
+
return languages.map((lang) => lang.split("-")[1]).join(",");
|
|
41
25
|
};
|
|
42
26
|
|
|
43
27
|
return (
|
|
@@ -45,14 +29,20 @@ const TableView: FC<TableViewProps> = ({ items }) => {
|
|
|
45
29
|
<Table>
|
|
46
30
|
<TableHeader>
|
|
47
31
|
<TableRow>
|
|
48
|
-
<TableCell>
|
|
49
|
-
<TableCell>
|
|
32
|
+
<TableCell>{t("title")}</TableCell>
|
|
33
|
+
<TableCell>{t("language")}</TableCell>
|
|
50
34
|
</TableRow>
|
|
51
35
|
</TableHeader>
|
|
52
36
|
<TableBody>
|
|
53
37
|
{items.map((item: informationUnitsItems, index: number) => (
|
|
54
38
|
<TableRow key={index}>
|
|
55
|
-
<
|
|
39
|
+
<Link
|
|
40
|
+
key={index}
|
|
41
|
+
href={`info/${item.shortId}`}
|
|
42
|
+
target="_blank"
|
|
43
|
+
>
|
|
44
|
+
<TableCell>{getTitle(item.labels)}</TableCell>
|
|
45
|
+
</Link>
|
|
56
46
|
<TableCell>{getIcons(item.languages)}</TableCell>
|
|
57
47
|
</TableRow>
|
|
58
48
|
))}
|