@ndla/ui 56.0.86-alpha.0 → 56.0.88-alpha.0
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/panda.buildinfo.json +14 -8
- package/dist/styles.css +50 -26
- package/es/Article/Article.js +17 -4
- package/es/Embed/ExternalEmbed.js +79 -3
- package/es/Embed/UuDisclaimerEmbed.js +46 -41
- package/es/locale/messages-en.js +5 -1
- package/es/locale/messages-nb.js +5 -1
- package/es/locale/messages-nn.js +5 -1
- package/es/locale/messages-se.js +5 -1
- package/es/locale/messages-sma.js +5 -1
- package/lib/Article/Article.d.ts +4 -2
- package/lib/Article/Article.js +17 -4
- package/lib/Embed/ExternalEmbed.js +77 -1
- package/lib/Embed/UuDisclaimerEmbed.d.ts +2 -1
- package/lib/Embed/UuDisclaimerEmbed.js +44 -39
- package/lib/locale/messages-en.d.ts +4 -0
- package/lib/locale/messages-en.js +5 -1
- package/lib/locale/messages-nb.d.ts +4 -0
- package/lib/locale/messages-nb.js +5 -1
- package/lib/locale/messages-nn.d.ts +4 -0
- package/lib/locale/messages-nn.js +5 -1
- package/lib/locale/messages-se.d.ts +4 -0
- package/lib/locale/messages-se.js +5 -1
- package/lib/locale/messages-sma.d.ts +4 -0
- package/lib/locale/messages-sma.js +5 -1
- package/package.json +4 -4
- package/src/Article/Article.tsx +18 -1
- package/src/Embed/ExternalEmbed.stories.tsx +11 -0
- package/src/Embed/ExternalEmbed.tsx +79 -3
- package/src/Embed/UuDisclaimerEmbed.stories.tsx +35 -32
- package/src/Embed/UuDisclaimerEmbed.tsx +46 -43
- package/src/locale/messages-en.ts +2 -0
- package/src/locale/messages-nb.ts +2 -0
- package/src/locale/messages-nn.ts +2 -0
- package/src/locale/messages-se.ts +2 -0
- package/src/locale/messages-sma.ts +2 -0
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
10
10
|
import { ExpandableBox, ExpandableBoxSummary, FramedContent, PageContent } from "@ndla/primitives";
|
|
11
|
-
import type { UuDisclaimerEmbedData } from "@ndla/types-embed";
|
|
11
|
+
import type { UUDisclaimerData, UuDisclaimerEmbedData } from "@ndla/types-embed";
|
|
12
12
|
import H5pEmbed from "./H5pEmbed";
|
|
13
13
|
import IframeEmbed from "./IframeEmbed";
|
|
14
14
|
import UuDisclaimerEmbed from "./UuDisclaimerEmbed";
|
|
@@ -19,13 +19,17 @@ import FactBox from "../FactBox";
|
|
|
19
19
|
const embedData: UuDisclaimerEmbedData = {
|
|
20
20
|
resource: "uu-disclaimer",
|
|
21
21
|
disclaimer: "Dette inholdet er ikke tastaturvennlig.",
|
|
22
|
-
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const data: UUDisclaimerData = {
|
|
25
|
+
transformedContent: "Dette inholdet er ikke tastaturvennlig.",
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
const meta: Meta<typeof UuDisclaimerEmbed> = {
|
|
26
29
|
title: "Embeds/UuDisclaimerEmbed",
|
|
27
30
|
component: UuDisclaimerEmbed,
|
|
28
31
|
tags: ["autodocs"],
|
|
32
|
+
args: { transformedDisclaimer: data.transformedContent },
|
|
29
33
|
decorators: [
|
|
30
34
|
(Story) => (
|
|
31
35
|
<PageContent variant="content" asChild>
|
|
@@ -46,24 +50,8 @@ export const Regular: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
|
46
50
|
embed: {
|
|
47
51
|
resource: "uu-disclaimer",
|
|
48
52
|
status: "success",
|
|
49
|
-
embedData
|
|
50
|
-
data
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const WithLink: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
56
|
-
args: {
|
|
57
|
-
embed: {
|
|
58
|
-
resource: "uu-disclaimer",
|
|
59
|
-
status: "success",
|
|
60
|
-
embedData: embedData,
|
|
61
|
-
data: {
|
|
62
|
-
disclaimerLink: {
|
|
63
|
-
href: "https://ndla.no/article/123",
|
|
64
|
-
text: "Navn på artikkel med innhold",
|
|
65
|
-
},
|
|
66
|
-
},
|
|
53
|
+
embedData,
|
|
54
|
+
data,
|
|
67
55
|
},
|
|
68
56
|
},
|
|
69
57
|
};
|
|
@@ -73,8 +61,8 @@ export const WithIframe: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
|
73
61
|
embed: {
|
|
74
62
|
resource: "uu-disclaimer",
|
|
75
63
|
status: "success",
|
|
76
|
-
embedData
|
|
77
|
-
data
|
|
64
|
+
embedData,
|
|
65
|
+
data,
|
|
78
66
|
},
|
|
79
67
|
children: (
|
|
80
68
|
<IframeEmbed
|
|
@@ -98,8 +86,8 @@ export const WithH5p: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
|
98
86
|
embed: {
|
|
99
87
|
resource: "uu-disclaimer",
|
|
100
88
|
status: "success",
|
|
101
|
-
embedData
|
|
102
|
-
data
|
|
89
|
+
embedData,
|
|
90
|
+
data,
|
|
103
91
|
},
|
|
104
92
|
children: (
|
|
105
93
|
<H5pEmbed
|
|
@@ -134,8 +122,8 @@ export const WithHtml: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
|
134
122
|
embed: {
|
|
135
123
|
resource: "uu-disclaimer",
|
|
136
124
|
status: "success",
|
|
137
|
-
embedData
|
|
138
|
-
data
|
|
125
|
+
embedData,
|
|
126
|
+
data,
|
|
139
127
|
},
|
|
140
128
|
children: (
|
|
141
129
|
<>
|
|
@@ -154,8 +142,8 @@ export const WithFramedContent: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
|
154
142
|
embed: {
|
|
155
143
|
resource: "uu-disclaimer",
|
|
156
144
|
status: "success",
|
|
157
|
-
embedData
|
|
158
|
-
data
|
|
145
|
+
embedData,
|
|
146
|
+
data,
|
|
159
147
|
},
|
|
160
148
|
children: (
|
|
161
149
|
<FramedContent>
|
|
@@ -170,8 +158,8 @@ export const WithFactBox: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
|
170
158
|
embed: {
|
|
171
159
|
resource: "uu-disclaimer",
|
|
172
160
|
status: "success",
|
|
173
|
-
embedData
|
|
174
|
-
data
|
|
161
|
+
embedData,
|
|
162
|
+
data,
|
|
175
163
|
},
|
|
176
164
|
children: (
|
|
177
165
|
<FactBox>
|
|
@@ -186,8 +174,23 @@ export const WithCopyParagraphLink: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
|
186
174
|
embed: {
|
|
187
175
|
resource: "uu-disclaimer",
|
|
188
176
|
status: "success",
|
|
189
|
-
embedData
|
|
190
|
-
data
|
|
177
|
+
embedData,
|
|
178
|
+
data,
|
|
179
|
+
},
|
|
180
|
+
children: (
|
|
181
|
+
<CopyParagraphButton copyText="Dette er en overskrift" lang="no">
|
|
182
|
+
<h2>Dette er en overskrift</h2>
|
|
183
|
+
</CopyParagraphButton>
|
|
184
|
+
),
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export const Error: StoryObj<typeof UuDisclaimerEmbed> = {
|
|
189
|
+
args: {
|
|
190
|
+
embed: {
|
|
191
|
+
resource: "uu-disclaimer",
|
|
192
|
+
status: "error",
|
|
193
|
+
embedData,
|
|
191
194
|
},
|
|
192
195
|
children: (
|
|
193
196
|
<CopyParagraphButton copyText="Dette er en overskrift" lang="no">
|
|
@@ -7,74 +7,77 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { type ReactNode } from "react";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { useTranslation } from "react-i18next";
|
|
11
|
+
import { Portal } from "@ark-ui/react";
|
|
12
|
+
import { AccessibilityFill, ErrorWarningFill } from "@ndla/icons";
|
|
13
|
+
import { IconButton, PopoverContent, PopoverRoot, PopoverTrigger, PopoverTitle } from "@ndla/primitives";
|
|
13
14
|
import { styled } from "@ndla/styled-system/jsx";
|
|
14
15
|
import type { UuDisclaimerMetaData } from "@ndla/types-embed";
|
|
15
16
|
|
|
16
17
|
interface Props {
|
|
17
18
|
embed: UuDisclaimerMetaData;
|
|
19
|
+
transformedDisclaimer: ReactNode;
|
|
18
20
|
children?: ReactNode;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
const
|
|
23
|
+
const DisclaimerWrapper = styled("div", {
|
|
22
24
|
base: {
|
|
23
25
|
display: "flex",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
const Disclaimer = styled("div", {
|
|
29
|
-
base: {
|
|
30
|
-
textStyle: "body.medium",
|
|
26
|
+
flexDirection: "column",
|
|
27
|
+
gap: "3xsmall",
|
|
28
|
+
clear: "both",
|
|
31
29
|
},
|
|
32
30
|
});
|
|
33
|
-
|
|
31
|
+
|
|
32
|
+
const StyledIconButton = styled(IconButton, {
|
|
34
33
|
base: {
|
|
35
|
-
|
|
36
|
-
color: "text.link",
|
|
37
|
-
textDecoration: "underline",
|
|
38
|
-
whiteSpace: "nowrap",
|
|
39
|
-
_hover: {
|
|
40
|
-
textDecoration: "none",
|
|
41
|
-
},
|
|
42
|
-
_focusWithin: {
|
|
43
|
-
textDecoration: "none",
|
|
44
|
-
},
|
|
34
|
+
alignSelf: "flex-end",
|
|
45
35
|
},
|
|
46
36
|
});
|
|
47
37
|
|
|
48
|
-
const
|
|
38
|
+
const StyledErrorWarningFill = styled(ErrorWarningFill, {
|
|
49
39
|
base: {
|
|
50
|
-
|
|
40
|
+
alignSelf: "flex-end",
|
|
41
|
+
fill: "icon.subtle",
|
|
51
42
|
},
|
|
52
43
|
});
|
|
53
44
|
|
|
54
|
-
const UuDisclaimerEmbed = ({ embed, children }: Props) => {
|
|
45
|
+
const UuDisclaimerEmbed = ({ embed, transformedDisclaimer, children }: Props) => {
|
|
46
|
+
const { t } = useTranslation();
|
|
55
47
|
if (embed.status === "error") {
|
|
56
|
-
return
|
|
48
|
+
return (
|
|
49
|
+
<DisclaimerWrapper>
|
|
50
|
+
<StyledErrorWarningFill
|
|
51
|
+
aria-label={t("embed.embedError", { type: t("embed.type.disclaimer") })}
|
|
52
|
+
title={t("embed.embedError", { type: t("embed.type.disclaimer") })}
|
|
53
|
+
/>
|
|
54
|
+
{children}
|
|
55
|
+
</DisclaimerWrapper>
|
|
56
|
+
);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const { embedData, data } = embed;
|
|
60
|
-
|
|
61
|
-
const disclaimerLink = data?.disclaimerLink ? (
|
|
62
|
-
<StyledSafeLink to={data.disclaimerLink.href} target="_blank" rel="noopener noreferrer">
|
|
63
|
-
{data.disclaimerLink.text}
|
|
64
|
-
</StyledSafeLink>
|
|
65
|
-
) : null;
|
|
66
|
-
|
|
67
59
|
return (
|
|
68
|
-
<
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
60
|
+
<DisclaimerWrapper role="region" data-embed-type="uu-disclaimer">
|
|
61
|
+
<PopoverRoot>
|
|
62
|
+
<PopoverTrigger asChild>
|
|
63
|
+
<StyledIconButton
|
|
64
|
+
size="small"
|
|
65
|
+
variant="secondary"
|
|
66
|
+
aria-label={t("uuDisclaimer.title")}
|
|
67
|
+
title={t("uuDisclaimer.title")}
|
|
68
|
+
>
|
|
69
|
+
<AccessibilityFill />
|
|
70
|
+
</StyledIconButton>
|
|
71
|
+
</PopoverTrigger>
|
|
72
|
+
<Portal>
|
|
73
|
+
<PopoverContent>
|
|
74
|
+
<PopoverTitle>{t("uuDisclaimer.title")}</PopoverTitle>
|
|
75
|
+
<div>{transformedDisclaimer}</div>
|
|
76
|
+
</PopoverContent>
|
|
77
|
+
</Portal>
|
|
78
|
+
</PopoverRoot>
|
|
76
79
|
<div data-uu-content="">{children}</div>
|
|
77
|
-
</
|
|
80
|
+
</DisclaimerWrapper>
|
|
78
81
|
);
|
|
79
82
|
};
|
|
80
83
|
|
|
@@ -1439,8 +1439,10 @@ const messages = {
|
|
|
1439
1439
|
gloss: "Gloss",
|
|
1440
1440
|
copyright: "Text",
|
|
1441
1441
|
code: "Code block",
|
|
1442
|
+
disclaimer: "Accessibility warning",
|
|
1442
1443
|
},
|
|
1443
1444
|
},
|
|
1445
|
+
uuDisclaimer: { title: "Accessibility" },
|
|
1444
1446
|
gloss: {
|
|
1445
1447
|
examples: "Examples",
|
|
1446
1448
|
showExamples: "Show examples",
|
|
@@ -1440,8 +1440,10 @@ const messages = {
|
|
|
1440
1440
|
gloss: "Glose",
|
|
1441
1441
|
copyright: "Tekst",
|
|
1442
1442
|
code: "Kodeblokk",
|
|
1443
|
+
disclaimer: "UU-advarsel",
|
|
1443
1444
|
},
|
|
1444
1445
|
},
|
|
1446
|
+
uuDisclaimer: { title: "Tilgjengelighet" },
|
|
1445
1447
|
gloss: {
|
|
1446
1448
|
examples: "Eksempler",
|
|
1447
1449
|
showExamples: "Vis eksempler",
|
|
@@ -1439,8 +1439,10 @@ const messages = {
|
|
|
1439
1439
|
gloss: "Glose",
|
|
1440
1440
|
copyright: "Tekst",
|
|
1441
1441
|
code: "Kodeblokk",
|
|
1442
|
+
disclaimer: "UU-advarsel",
|
|
1442
1443
|
},
|
|
1443
1444
|
},
|
|
1445
|
+
uuDisclaimer: { title: "Tilgjengelighet" },
|
|
1444
1446
|
gloss: {
|
|
1445
1447
|
examples: "Eksempler",
|
|
1446
1448
|
showExamples: "Vis eksempler",
|
|
@@ -1441,8 +1441,10 @@ const messages = {
|
|
|
1441
1441
|
gloss: "Glose",
|
|
1442
1442
|
copyright: "Tekst",
|
|
1443
1443
|
code: "Kodeblokk",
|
|
1444
|
+
disclaimer: "UU-advarsel",
|
|
1444
1445
|
},
|
|
1445
1446
|
},
|
|
1447
|
+
uuDisclaimer: { title: "Tilgjengelighet" },
|
|
1446
1448
|
gloss: {
|
|
1447
1449
|
examples: "Ovdamearkkat",
|
|
1448
1450
|
showExamples: "Vis eksempler",
|
|
@@ -1443,8 +1443,10 @@ const messages = {
|
|
|
1443
1443
|
gloss: "Glosa",
|
|
1444
1444
|
copyright: "Tekst",
|
|
1445
1445
|
code: "Kodeblokk",
|
|
1446
|
+
disclaimer: "UU-advarsel",
|
|
1446
1447
|
},
|
|
1447
1448
|
},
|
|
1449
|
+
uuDisclaimer: { title: "Tilgjengelighet" },
|
|
1448
1450
|
gloss: {
|
|
1449
1451
|
examples: "Eksempler",
|
|
1450
1452
|
showExamples: "Vis eksempler",
|