@reykjavik/hanna-react 0.10.97 → 0.10.98
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/BreadCrumbs.d.ts +6 -1
- package/BreadCrumbs.js +11 -4
- package/CHANGELOG.md +3 -1
- package/esm/BreadCrumbs.d.ts +6 -1
- package/esm/BreadCrumbs.js +10 -3
- package/package.json +1 -1
package/BreadCrumbs.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
|
|
1
2
|
export type BreadCrumb = {
|
|
2
3
|
href?: string;
|
|
3
4
|
label: string;
|
|
4
5
|
};
|
|
5
6
|
export type BreadCrumbTrail = Array<BreadCrumb>;
|
|
6
|
-
export
|
|
7
|
+
export declare const defaultBreadCrumbsTexts: DefaultTexts<{
|
|
7
8
|
title: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type BreadCrumbsProps = {
|
|
11
|
+
title?: string;
|
|
12
|
+
lang?: string;
|
|
8
13
|
trail: BreadCrumbTrail;
|
|
9
14
|
};
|
|
10
15
|
export declare const BreadCrumbs: (props: BreadCrumbsProps) => JSX.Element | null;
|
package/BreadCrumbs.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BreadCrumbs = void 0;
|
|
3
|
+
exports.BreadCrumbs = exports.defaultBreadCrumbsTexts = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const i18n_1 = require("@reykjavik/hanna-utils/i18n");
|
|
6
7
|
const _Link_js_1 = require("./_abstract/_Link.js");
|
|
8
|
+
exports.defaultBreadCrumbsTexts = {
|
|
9
|
+
is: { title: 'Þú ert hér' },
|
|
10
|
+
en: { title: 'You are here' },
|
|
11
|
+
pl: { title: 'Jesteś tutaj' },
|
|
12
|
+
};
|
|
7
13
|
const BreadCrumbs__item = (props) => {
|
|
8
14
|
const { link, current } = props;
|
|
9
15
|
return link.href != null ? (react_1.default.createElement(_Link_js_1.Link, { className: "BreadCrumbs__item", href: link.href, "aria-current": current || undefined }, link.label)) : (react_1.default.createElement("span", { className: "BreadCrumbs__item", "aria-current": current || undefined }, link.label));
|
|
10
16
|
};
|
|
11
17
|
const BreadCrumbs = (props) => {
|
|
12
|
-
const { title,
|
|
18
|
+
const { trail, title, lang } = props;
|
|
19
|
+
const texts = (0, i18n_1.getTexts)({ texts: title ? { title } : undefined, lang }, exports.defaultBreadCrumbsTexts);
|
|
13
20
|
if (trail.length === 0) {
|
|
14
21
|
return null;
|
|
15
22
|
}
|
|
16
23
|
const ancestors = trail.slice(0, -1);
|
|
17
24
|
const current = trail[trail.length - 1];
|
|
18
|
-
return (react_1.default.createElement("nav", { className: "BreadCrumbs", "aria-label": title },
|
|
25
|
+
return (react_1.default.createElement("nav", { className: "BreadCrumbs", "aria-label": texts.title },
|
|
19
26
|
react_1.default.createElement("span", { className: "BreadCrumbs__title" },
|
|
20
|
-
title,
|
|
27
|
+
texts.title,
|
|
21
28
|
":"),
|
|
22
29
|
' ',
|
|
23
30
|
ancestors.map((link, i) => {
|
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
-
## 0.10.
|
|
7
|
+
## 0.10.98
|
|
8
8
|
|
|
9
9
|
_2023-08-22_
|
|
10
10
|
|
|
@@ -14,6 +14,8 @@ _2023-08-22_
|
|
|
14
14
|
`MainMenu__item` children
|
|
15
15
|
- feat: Add default Polish translation for `Layout`
|
|
16
16
|
- feat: Make prop `title` optional for `MainMenu`
|
|
17
|
+
- feat: Make prop `title` optional for `BreadCrumbs`
|
|
18
|
+
- feat: Add prop `lang` to `BreadCrumbs`
|
|
17
19
|
|
|
18
20
|
## 0.10.96
|
|
19
21
|
|
package/esm/BreadCrumbs.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
|
|
1
2
|
export type BreadCrumb = {
|
|
2
3
|
href?: string;
|
|
3
4
|
label: string;
|
|
4
5
|
};
|
|
5
6
|
export type BreadCrumbTrail = Array<BreadCrumb>;
|
|
6
|
-
export
|
|
7
|
+
export declare const defaultBreadCrumbsTexts: DefaultTexts<{
|
|
7
8
|
title: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type BreadCrumbsProps = {
|
|
11
|
+
title?: string;
|
|
12
|
+
lang?: string;
|
|
8
13
|
trail: BreadCrumbTrail;
|
|
9
14
|
};
|
|
10
15
|
export declare const BreadCrumbs: (props: BreadCrumbsProps) => JSX.Element | null;
|
package/esm/BreadCrumbs.js
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { getTexts } from '@reykjavik/hanna-utils/i18n';
|
|
2
3
|
import { Link } from './_abstract/_Link.js';
|
|
4
|
+
export const defaultBreadCrumbsTexts = {
|
|
5
|
+
is: { title: 'Þú ert hér' },
|
|
6
|
+
en: { title: 'You are here' },
|
|
7
|
+
pl: { title: 'Jesteś tutaj' },
|
|
8
|
+
};
|
|
3
9
|
const BreadCrumbs__item = (props) => {
|
|
4
10
|
const { link, current } = props;
|
|
5
11
|
return link.href != null ? (React.createElement(Link, { className: "BreadCrumbs__item", href: link.href, "aria-current": current || undefined }, link.label)) : (React.createElement("span", { className: "BreadCrumbs__item", "aria-current": current || undefined }, link.label));
|
|
6
12
|
};
|
|
7
13
|
export const BreadCrumbs = (props) => {
|
|
8
|
-
const { title,
|
|
14
|
+
const { trail, title, lang } = props;
|
|
15
|
+
const texts = getTexts({ texts: title ? { title } : undefined, lang }, defaultBreadCrumbsTexts);
|
|
9
16
|
if (trail.length === 0) {
|
|
10
17
|
return null;
|
|
11
18
|
}
|
|
12
19
|
const ancestors = trail.slice(0, -1);
|
|
13
20
|
const current = trail[trail.length - 1];
|
|
14
|
-
return (React.createElement("nav", { className: "BreadCrumbs", "aria-label": title },
|
|
21
|
+
return (React.createElement("nav", { className: "BreadCrumbs", "aria-label": texts.title },
|
|
15
22
|
React.createElement("span", { className: "BreadCrumbs__title" },
|
|
16
|
-
title,
|
|
23
|
+
texts.title,
|
|
17
24
|
":"),
|
|
18
25
|
' ',
|
|
19
26
|
ancestors.map((link, i) => {
|