@ndla/ui 56.0.185-alpha.0 → 56.0.186-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 +5 -22
- package/dist/styles.css +8 -127
- package/es/Article/ArticleByline.mjs +2 -1
- package/es/Article/ArticleByline.mjs.map +1 -1
- package/es/Breadcrumb/BreadcrumbItem.mjs +1 -2
- package/es/Breadcrumb/BreadcrumbItem.mjs.map +1 -1
- package/es/Embed/AudioEmbed.mjs +1 -2
- package/es/Embed/AudioEmbed.mjs.map +1 -1
- package/es/Embed/ExternalEmbed.mjs +13 -16
- package/es/Embed/ExternalEmbed.mjs.map +1 -1
- package/es/Embed/IframeEmbed.mjs +4 -5
- package/es/Embed/IframeEmbed.mjs.map +1 -1
- package/es/FactBox/FactBox.mjs +14 -38
- package/es/FactBox/FactBox.mjs.map +1 -1
- package/es/Grid/Grid.mjs +1 -2
- package/es/Grid/Grid.mjs.map +1 -1
- package/es/LinkBlock/LinkBlock.mjs +9 -2
- package/es/LinkBlock/LinkBlock.mjs.map +1 -1
- package/es/Pitch/Pitch.mjs +1 -2
- package/es/Pitch/Pitch.mjs.map +1 -1
- package/lib/Article/ArticleByline.js +2 -1
- package/lib/Article/ArticleByline.js.map +1 -1
- package/lib/Breadcrumb/BreadcrumbItem.js +1 -2
- package/lib/Breadcrumb/BreadcrumbItem.js.map +1 -1
- package/lib/Embed/AudioEmbed.js +1 -2
- package/lib/Embed/AudioEmbed.js.map +1 -1
- package/lib/Embed/ExternalEmbed.js +13 -16
- package/lib/Embed/ExternalEmbed.js.map +1 -1
- package/lib/Embed/IframeEmbed.js +4 -5
- package/lib/Embed/IframeEmbed.js.map +1 -1
- package/lib/FactBox/FactBox.js +13 -37
- package/lib/FactBox/FactBox.js.map +1 -1
- package/lib/Grid/Grid.js +1 -2
- package/lib/Grid/Grid.js.map +1 -1
- package/lib/LinkBlock/LinkBlock.js +9 -2
- package/lib/LinkBlock/LinkBlock.js.map +1 -1
- package/lib/Pitch/Pitch.js +1 -2
- package/lib/Pitch/Pitch.js.map +1 -1
- package/package.json +10 -10
- package/src/Article/ArticleByline.tsx +5 -1
- package/src/FactBox/FactBox.tsx +13 -43
- package/src/LinkBlock/LinkBlock.tsx +5 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schemaVersion": "1.
|
|
2
|
+
"schemaVersion": "1.10.0",
|
|
3
3
|
"styles": {
|
|
4
4
|
"atomic": [
|
|
5
5
|
"position]___[value:absolute]___[cond:_before",
|
|
@@ -251,32 +251,15 @@
|
|
|
251
251
|
"transitionTimingFunction]___[value:ease-in-out",
|
|
252
252
|
"justifyItems]___[value:center",
|
|
253
253
|
"gridTemplateRows]___[value:1fr]___[cond:_open",
|
|
254
|
-
"
|
|
255
|
-
"
|
|
254
|
+
"gridTemplateRows]___[value:1fr]___[cond:_print",
|
|
255
|
+
"overflow]___[value:visible]___[cond:_print",
|
|
256
|
+
"maxHeight]___[value:500vh]___[cond:_print",
|
|
256
257
|
"minHeight]___[value:surface.3xsmall]___[cond:& > div",
|
|
257
258
|
"overflow]___[value:hidden]___[cond:& > div",
|
|
259
|
+
"overflow]___[value:visible]___[cond:& > div<___>_print",
|
|
258
260
|
"marginBlockStart]___[value:0]___[cond:& :first-child",
|
|
259
|
-
"content]___[value:\"\"]___[cond:_after",
|
|
260
|
-
"textAlign]___[value:center]___[cond:_after",
|
|
261
|
-
"position]___[value:absolute]___[cond:_after",
|
|
262
|
-
"inset]___[value:0]___[cond:_after",
|
|
263
|
-
"transitionProperty]___[value:opacity]___[cond:_after",
|
|
264
|
-
"transitionDuration]___[value:slow]___[cond:_after",
|
|
265
|
-
"transitionTimingFunction]___[value:ease-in-out]___[cond:_after",
|
|
266
|
-
"gradientFrom]___[value:surface.default/20]___[cond:_after",
|
|
267
|
-
"gradientTo]___[value:surface.default/95]___[cond:_after",
|
|
268
|
-
"backgroundGradient]___[value:to-b]___[cond:_after",
|
|
269
|
-
"opacity]___[value:1]___[cond:_after",
|
|
270
|
-
"zIndex]___[value:base]___[cond:_after",
|
|
271
|
-
"pointerEvents]___[value:none]___[cond:_after",
|
|
272
|
-
"overflow]___[value:visible]___[cond:_print",
|
|
273
|
-
"display]___[value:none]___[cond:_print<___>_after",
|
|
274
261
|
"paddingBlockEnd]___[value:xsmall]___[cond:_open",
|
|
275
|
-
"opacity]___[value:0]___[cond:_open<___>_after",
|
|
276
262
|
"bottom]___[value:-medium",
|
|
277
|
-
"transitionTimingFunction]___[value:ease-in-out]___[cond:& svg",
|
|
278
|
-
"transitionDuration]___[value:fast]___[cond:& svg",
|
|
279
|
-
"transform]___[value:rotate(180deg)]___[cond:_open<___>& svg",
|
|
280
263
|
"textUnderlineOffset]___[value:2px",
|
|
281
264
|
"paddingBlock]___[value:small",
|
|
282
265
|
"paddingInlineEnd]___[value:medium",
|
package/dist/styles.css
CHANGED
|
@@ -101,9 +101,6 @@
|
|
|
101
101
|
font-size: calc(var(--font-sizes-3xlarge) * 1.11);
|
|
102
102
|
line-height: calc(var(--line-heights-3xlarge) * 1.11);
|
|
103
103
|
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
@media screen and (max-width: 29.7475rem) {
|
|
107
104
|
.textStyle_title\.medium {
|
|
108
105
|
font-size: var(--font-sizes-medium);
|
|
109
106
|
line-height: var(--line-heights-small);
|
|
@@ -125,9 +122,6 @@
|
|
|
125
122
|
font-size: calc(var(--font-sizes-xsmall) * 1.11);
|
|
126
123
|
line-height: calc(var(--line-heights-xsmall) * 1.11);
|
|
127
124
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@media print {
|
|
131
125
|
.textStyle_label\.large {
|
|
132
126
|
font-size: var(--font-sizes-small);
|
|
133
127
|
line-height: var(--line-heights-small);
|
|
@@ -137,9 +131,6 @@
|
|
|
137
131
|
font-size: calc(var(--font-sizes-small) * 1.11);
|
|
138
132
|
line-height: calc(var(--line-heights-small) * 1.11);
|
|
139
133
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
@media print {
|
|
143
134
|
.textStyle_heading\.large {
|
|
144
135
|
font-size: var(--font-sizes-3xlarge);
|
|
145
136
|
line-height: var(--line-heights-3xlarge);
|
|
@@ -149,9 +140,6 @@
|
|
|
149
140
|
font-size: calc(var(--font-sizes-3xlarge) * 1.11);
|
|
150
141
|
line-height: calc(var(--line-heights-3xlarge) * 1.11);
|
|
151
142
|
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
@media print {
|
|
155
143
|
.textStyle_title\.medium {
|
|
156
144
|
font-size: var(--font-sizes-medium);
|
|
157
145
|
line-height: var(--line-heights-medium);
|
|
@@ -161,9 +149,6 @@
|
|
|
161
149
|
font-size: calc(var(--font-sizes-medium) * 1.11);
|
|
162
150
|
line-height: calc(var(--line-heights-medium) * 1.11);
|
|
163
151
|
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
@media print {
|
|
167
152
|
.textStyle_label\.medium {
|
|
168
153
|
font-size: var(--font-sizes-xsmall);
|
|
169
154
|
line-height: var(--line-heights-xsmall);
|
|
@@ -173,9 +158,6 @@
|
|
|
173
158
|
font-size: calc(var(--font-sizes-xsmall) * 1.11);
|
|
174
159
|
line-height: calc(var(--line-heights-xsmall) * 1.11);
|
|
175
160
|
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
@media print {
|
|
179
161
|
.\[\&_a\]\:textStyle_label\.xsmall a {
|
|
180
162
|
font-size: var(--font-sizes-xxsmall);
|
|
181
163
|
line-height: var(--line-heights-xxsmall);
|
|
@@ -832,7 +814,7 @@
|
|
|
832
814
|
height: unset;
|
|
833
815
|
}
|
|
834
816
|
|
|
835
|
-
.
|
|
817
|
+
.before\:inset_0::before {
|
|
836
818
|
inset: 0;
|
|
837
819
|
}
|
|
838
820
|
|
|
@@ -1000,75 +982,10 @@
|
|
|
1000
982
|
margin-block-start: 0;
|
|
1001
983
|
}
|
|
1002
984
|
|
|
1003
|
-
.after\:content_\"\"::after {
|
|
1004
|
-
content: "";
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
.after\:ta_center::after {
|
|
1008
|
-
text-align: center;
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
.after\:pos_absolute::after {
|
|
1012
|
-
position: absolute;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
.after\:trs-prop_opacity::after {
|
|
1016
|
-
--transition-prop: opacity;
|
|
1017
|
-
transition-property: opacity;
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
.after\:trs-dur_slow::after {
|
|
1021
|
-
--transition-duration: var(--durations-slow);
|
|
1022
|
-
transition-duration: var(--durations-slow);
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
.after\:trs-tmf_ease-in-out::after {
|
|
1026
|
-
--transition-easing: ease-in-out;
|
|
1027
|
-
transition-timing-function: ease-in-out;
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
.after\:grad-from_surface\.default\/20::after {
|
|
1031
|
-
--mix---gradient-from: color-mix(in srgb, var(--colors-surface-default) 20%, transparent);
|
|
1032
|
-
--gradient-from: var(--mix---gradient-from, var(--colors-surface-default));
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
.after\:grad-to_surface\.default\/95::after {
|
|
1036
|
-
--mix---gradient-to: color-mix(in srgb, var(--colors-surface-default) 95%, transparent);
|
|
1037
|
-
--gradient-to: var(--mix---gradient-to, var(--colors-surface-default));
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
.after\:bg-grad_to-b::after {
|
|
1041
|
-
--gradient-stops: var(--gradient-via-stops, var(--gradient-position), var(--gradient-from) var(--gradient-from-position), var(--gradient-to) var(--gradient-to-position));
|
|
1042
|
-
--gradient-position: to bottom;
|
|
1043
|
-
background-image: linear-gradient(var(--gradient-stops));
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
.after\:op_1::after {
|
|
1047
|
-
opacity: 1;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
.after\:z_base::after {
|
|
1051
|
-
z-index: var(--z-index-base);
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
.after\:pointer-events_none::after {
|
|
1055
|
-
pointer-events: none;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
985
|
.open\:pbe_xsmall:is([open], [data-open], [data-state="open"], :popover-open) {
|
|
1059
986
|
padding-block-end: var(--spacing-xsmall);
|
|
1060
987
|
}
|
|
1061
988
|
|
|
1062
|
-
.\[\&_svg\]\:trs-tmf_ease-in-out svg {
|
|
1063
|
-
--transition-easing: ease-in-out;
|
|
1064
|
-
transition-timing-function: ease-in-out;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
.\[\&_svg\]\:trs-dur_fast svg {
|
|
1068
|
-
--transition-duration: var(--durations-fast);
|
|
1069
|
-
transition-duration: var(--durations-fast);
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
989
|
.before\:z_0::before {
|
|
1073
990
|
z-index: 0;
|
|
1074
991
|
}
|
|
@@ -1144,11 +1061,7 @@
|
|
|
1144
1061
|
height: 100%;
|
|
1145
1062
|
}
|
|
1146
1063
|
|
|
1147
|
-
.focusWithin\:text-decoration_none:focus-within {
|
|
1148
|
-
text-decoration: none;
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
.focusVisible\:text-decoration_none:is(:focus-visible, [data-focus-visible]) {
|
|
1064
|
+
.focusWithin\:text-decoration_none:focus-within,.focusVisible\:text-decoration_none:is(:focus-visible, [data-focus-visible]) {
|
|
1152
1065
|
text-decoration: none;
|
|
1153
1066
|
}
|
|
1154
1067
|
|
|
@@ -1198,14 +1111,6 @@
|
|
|
1198
1111
|
transform: rotate(-45deg);
|
|
1199
1112
|
}
|
|
1200
1113
|
|
|
1201
|
-
.open\:after\:op_0:is([open], [data-open], [data-state="open"], :popover-open)::after {
|
|
1202
|
-
opacity: 0;
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
.open\:\[\&_svg\]\:trf_rotate\(180deg\):is([open], [data-open], [data-state="open"], :popover-open) svg {
|
|
1206
|
-
transform: rotate(180deg);
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
1114
|
.first\:\[\&_p\]\:fw_bold:first-child p {
|
|
1210
1115
|
font-weight: var(--font-weights-bold);
|
|
1211
1116
|
}
|
|
@@ -1340,9 +1245,6 @@
|
|
|
1340
1245
|
.\[\&\[data-has-image\=\'true\'\]\]\:tablet\:px_medium[data-has-image='true'] {
|
|
1341
1246
|
padding-inline: var(--spacing-medium);
|
|
1342
1247
|
}
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
@media screen and (min-width: 37.5625rem) {
|
|
1346
1248
|
.hover\:tablet\:before\:vis_visible:is(:hover, [data-hover])::before {
|
|
1347
1249
|
visibility: visible;
|
|
1348
1250
|
}
|
|
@@ -1538,27 +1440,15 @@
|
|
|
1538
1440
|
.mobileWideDown\:max-h_large {
|
|
1539
1441
|
max-height: var(--sizes-large);
|
|
1540
1442
|
}
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
@media screen and (max-width: 29.7475rem) {
|
|
1544
1443
|
.mobileWideDown\:open\:d_inline:is([open], [data-open], [data-state="open"], :popover-open) {
|
|
1545
1444
|
display: inline;
|
|
1546
1445
|
}
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
@media screen and (max-width: 29.7475rem) {
|
|
1550
1446
|
.mobileWideDown\:open\:white-space_pre-wrap:is([open], [data-open], [data-state="open"], :popover-open) {
|
|
1551
1447
|
white-space: pre-wrap;
|
|
1552
1448
|
}
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
@media screen and (max-width: 29.7475rem) {
|
|
1556
1449
|
.mobileWideDown\:disabled\:d_none:is(:disabled, [disabled], [data-disabled], [aria-disabled=true]) {
|
|
1557
1450
|
display: none;
|
|
1558
1451
|
}
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
@media screen and (max-width: 29.7475rem) {
|
|
1562
1452
|
.mobileWideDown\:open\:max-h_none:is([open], [data-open], [data-state="open"], :popover-open) {
|
|
1563
1453
|
max-height: none;
|
|
1564
1454
|
}
|
|
@@ -1586,23 +1476,14 @@
|
|
|
1586
1476
|
.print\:d_none {
|
|
1587
1477
|
display: none;
|
|
1588
1478
|
}
|
|
1479
|
+
.print\:grid-tr_1fr {
|
|
1480
|
+
grid-template-rows: 1fr;
|
|
1589
1481
|
}
|
|
1590
|
-
|
|
1591
|
-
@media print {
|
|
1592
|
-
.closed\:print\:ov_visible:is([closed], [data-closed], [data-state="closed"]) {
|
|
1593
|
-
overflow: visible;
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
@media print {
|
|
1598
|
-
.print\:after\:d_none::after {
|
|
1599
|
-
display: none;
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
|
|
1603
|
-
@media print {
|
|
1604
|
-
.closed\:print\:max-h_500vh:is([closed], [data-closed], [data-state="closed"]) {
|
|
1482
|
+
.print\:max-h_500vh {
|
|
1605
1483
|
max-height: 500vh;
|
|
1484
|
+
}
|
|
1485
|
+
.\[\&_\>_div\]\:print\:ov_visible > div {
|
|
1486
|
+
overflow: visible;
|
|
1606
1487
|
}
|
|
1607
1488
|
}
|
|
1608
1489
|
}
|
|
@@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next";
|
|
|
6
6
|
import { ArrowDownShortLine } from "@ndla/icons";
|
|
7
7
|
import { SafeLink } from "@ndla/safelink";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { toIntlLanguage } from "@ndla/util";
|
|
9
10
|
import { useAccordionContext } from "@ark-ui/react";
|
|
10
11
|
//#region src/Article/ArticleByline.tsx
|
|
11
12
|
/**
|
|
@@ -50,7 +51,7 @@ const accordionItemValue = "rulesForUse";
|
|
|
50
51
|
const ArticleByline = ({ lang, authors = [], suppliers = [], footnotes, licenseBox, published, displayByline = true, bylineType = "article", bylineSuffix, learningpathCopiedFrom }) => {
|
|
51
52
|
const { t, i18n } = useTranslation();
|
|
52
53
|
const showPrimaryContributors = suppliers.length > 0 || authors.length > 0;
|
|
53
|
-
const listFormatter = new Intl.ListFormat(lang ?? i18n.language, {
|
|
54
|
+
const listFormatter = new Intl.ListFormat(toIntlLanguage(lang ?? i18n.language), {
|
|
54
55
|
style: "long",
|
|
55
56
|
type: "conjunction"
|
|
56
57
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArticleByline.mjs","names":[],"sources":["../../src/Article/ArticleByline.tsx"],"sourcesContent":["/**\n * Copyright (c) 2020-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { useAccordionContext } from \"@ark-ui/react\";\nimport { ArrowDownShortLine } from \"@ndla/icons\";\nimport {\n AccordionItem,\n AccordionItemContent,\n AccordionItemIndicator,\n type AccordionItemProps,\n AccordionItemTrigger,\n AccordionRoot,\n Heading,\n} from \"@ndla/primitives\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { type ReactNode, forwardRef, useCallback, useEffect, useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport type { FootNote } from \"../types\";\nimport { ArticleFootNotes } from \"./ArticleFootNotes\";\n\nconst Wrapper = styled(\"div\", {\n base: {\n // TODO: Figure out if we want to remove this margin. It's only here to add some gap between the article content and the byline.\n marginBlockStart: \"medium\",\n paddingBlockStart: \"xsmall\",\n borderTop: \"1px solid\",\n borderColor: \"stroke.subtle\",\n },\n});\n\nconst TextWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"3xsmall\",\n width: \"100%\",\n justifyContent: \"space-between\",\n paddingBlock: \"xsmall\",\n textStyle: \"body.medium\",\n '& [data-contributors=\"false\"]': {\n marginInlineStart: \"auto\",\n },\n },\n variants: {\n learningpath: {\n true: {},\n false: {\n tabletWide: {\n flexDirection: \"row\",\n },\n },\n },\n },\n});\n\ntype AuthorProps = {\n name: string;\n};\n\ntype SupplierProps = {\n name: string;\n};\n\ntype Props = {\n lang?: string;\n authors?: AuthorProps[];\n suppliers?: SupplierProps[];\n published?: string;\n licenseBox?: ReactNode;\n footnotes?: FootNote[];\n displayByline?: boolean;\n bylineType?: \"article\" | \"learningPath\" | \"external\";\n bylineSuffix?: ReactNode;\n learningpathCopiedFrom?: string;\n};\n\nfunction formatList(list: SupplierProps[], listFormatter: Intl.ListFormat) {\n return listFormatter.format(list.map((l) => l.name));\n}\n\nconst StyledAccordionRoot = styled(AccordionRoot, {\n base: {\n paddingBlockStart: \"xxlarge\",\n _print: {\n display: \"none\",\n },\n },\n});\n\nconst refRegexp = /note\\d/;\nconst footnotesAccordionId = \"footnotes\";\nconst accordionItemValue = \"rulesForUse\";\n\nexport const ArticleByline = ({\n lang,\n authors = [],\n suppliers = [],\n footnotes,\n licenseBox,\n published,\n displayByline = true,\n bylineType = \"article\",\n bylineSuffix,\n learningpathCopiedFrom,\n}: Props) => {\n const { t, i18n } = useTranslation();\n\n const showPrimaryContributors = suppliers.length > 0 || authors.length > 0;\n const listFormatter = new Intl.ListFormat(lang ?? i18n.language, {
|
|
1
|
+
{"version":3,"file":"ArticleByline.mjs","names":[],"sources":["../../src/Article/ArticleByline.tsx"],"sourcesContent":["/**\n * Copyright (c) 2020-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { useAccordionContext } from \"@ark-ui/react\";\nimport { ArrowDownShortLine } from \"@ndla/icons\";\nimport {\n AccordionItem,\n AccordionItemContent,\n AccordionItemIndicator,\n type AccordionItemProps,\n AccordionItemTrigger,\n AccordionRoot,\n Heading,\n} from \"@ndla/primitives\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { toIntlLanguage } from \"@ndla/util\";\nimport { type ReactNode, forwardRef, useCallback, useEffect, useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport type { FootNote } from \"../types\";\nimport { ArticleFootNotes } from \"./ArticleFootNotes\";\n\nconst Wrapper = styled(\"div\", {\n base: {\n // TODO: Figure out if we want to remove this margin. It's only here to add some gap between the article content and the byline.\n marginBlockStart: \"medium\",\n paddingBlockStart: \"xsmall\",\n borderTop: \"1px solid\",\n borderColor: \"stroke.subtle\",\n },\n});\n\nconst TextWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"3xsmall\",\n width: \"100%\",\n justifyContent: \"space-between\",\n paddingBlock: \"xsmall\",\n textStyle: \"body.medium\",\n '& [data-contributors=\"false\"]': {\n marginInlineStart: \"auto\",\n },\n },\n variants: {\n learningpath: {\n true: {},\n false: {\n tabletWide: {\n flexDirection: \"row\",\n },\n },\n },\n },\n});\n\ntype AuthorProps = {\n name: string;\n};\n\ntype SupplierProps = {\n name: string;\n};\n\ntype Props = {\n lang?: string;\n authors?: AuthorProps[];\n suppliers?: SupplierProps[];\n published?: string;\n licenseBox?: ReactNode;\n footnotes?: FootNote[];\n displayByline?: boolean;\n bylineType?: \"article\" | \"learningPath\" | \"external\";\n bylineSuffix?: ReactNode;\n learningpathCopiedFrom?: string;\n};\n\nfunction formatList(list: SupplierProps[], listFormatter: Intl.ListFormat) {\n return listFormatter.format(list.map((l) => l.name));\n}\n\nconst StyledAccordionRoot = styled(AccordionRoot, {\n base: {\n paddingBlockStart: \"xxlarge\",\n _print: {\n display: \"none\",\n },\n },\n});\n\nconst refRegexp = /note\\d/;\nconst footnotesAccordionId = \"footnotes\";\nconst accordionItemValue = \"rulesForUse\";\n\nexport const ArticleByline = ({\n lang,\n authors = [],\n suppliers = [],\n footnotes,\n licenseBox,\n published,\n displayByline = true,\n bylineType = \"article\",\n bylineSuffix,\n learningpathCopiedFrom,\n}: Props) => {\n const { t, i18n } = useTranslation();\n\n const showPrimaryContributors = suppliers.length > 0 || authors.length > 0;\n const listFormatter = new Intl.ListFormat(toIntlLanguage(lang ?? i18n.language), {\n style: \"long\",\n type: \"conjunction\",\n });\n\n return (\n <Wrapper>\n {!!displayByline && (\n <TextWrapper learningpath={bylineType === \"learningPath\"}>\n {!!showPrimaryContributors && (\n <span>\n {authors.length > 0 &&\n `${t(\"article.authorsLabel\", { context: bylineType })} ${formatList(authors, listFormatter)}. `}\n {suppliers.length > 0 &&\n `${t(\"article.supplierLabel\", { count: suppliers.length })} ${formatList(suppliers, listFormatter)}.`}\n </span>\n )}\n {learningpathCopiedFrom ? (\n <SafeLink to={learningpathCopiedFrom}>{t(`learningPath.copiedFrom`)}</SafeLink>\n ) : null}\n {published ? (\n <div data-contributors={showPrimaryContributors}>\n {t(`${bylineType}.lastUpdated`)} {published}\n </div>\n ) : null}\n {bylineSuffix}\n </TextWrapper>\n )}\n {(!!licenseBox || !!footnotes?.length) && (\n <StyledAccordionRoot multiple>\n {!!licenseBox && (\n <ArticleBylineAccordionItem value={accordionItemValue} accordionTitle={t(\"article.useContent\")}>\n {licenseBox}\n </ArticleBylineAccordionItem>\n )}\n {!!footnotes?.length && <ArticleBylineFootnotes footnotes={footnotes} />}\n </StyledAccordionRoot>\n )}\n </Wrapper>\n );\n};\n\ninterface ArticleBylineAccordionprops extends AccordionItemProps {\n accordionTitle: ReactNode;\n}\n\ninterface ArticleBylineFootnotesProps {\n footnotes: FootNote[];\n}\n\nexport const ArticleBylineFootnotes = ({ footnotes }: ArticleBylineFootnotesProps) => {\n const { t } = useTranslation();\n const { value, setValue } = useAccordionContext();\n const ref = useRef<HTMLDivElement>(null);\n\n const onHashChange = useCallback(\n (e: HashChangeEvent) => {\n const hash = e.newURL.split(\"#\")[1];\n if (hash?.match(refRegexp) && !value.includes(footnotesAccordionId)) {\n ref.current?.scrollIntoView({ behavior: \"smooth\" });\n setValue([...value, footnotesAccordionId]);\n setTimeout(() => {\n const el = document.getElementById(`${hash}`);\n el?.click();\n el?.focus();\n }, 300);\n }\n },\n [value, setValue],\n );\n\n useEffect(() => {\n window.addEventListener(\"hashchange\", onHashChange);\n return () => window.removeEventListener(\"hashchange\", onHashChange);\n }, [onHashChange]);\n\n return (\n <ArticleBylineAccordionItem ref={ref} value={footnotesAccordionId} accordionTitle={t(\"article.footnotes\")}>\n <ArticleFootNotes footNotes={footnotes} />\n </ArticleBylineAccordionItem>\n );\n};\n\nexport const ArticleBylineAccordionItem = forwardRef<HTMLDivElement, ArticleBylineAccordionprops>(\n ({ value, accordionTitle, children, ...props }, ref) => {\n return (\n <AccordionItem value={value} ref={ref} {...props}>\n <Heading asChild consumeCss textStyle=\"label.medium\" fontWeight=\"bold\">\n <h2>\n <AccordionItemTrigger>\n {accordionTitle}\n <AccordionItemIndicator asChild>\n <ArrowDownShortLine />\n </AccordionItemIndicator>\n </AccordionItemTrigger>\n </h2>\n </Heading>\n <AccordionItemContent>{children}</AccordionItemContent>\n </AccordionItem>\n );\n },\n);\n"],"mappings":"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"}
|
|
@@ -18,9 +18,8 @@ const StyledListItem = styled("li", { base: {
|
|
|
18
18
|
"& a": { _visited: { color: "inherit" } }
|
|
19
19
|
} });
|
|
20
20
|
const BreadcrumbItem = ({ renderItem, renderSeparator, item, totalCount }) => {
|
|
21
|
-
const isLast = item.index === totalCount - 1;
|
|
22
21
|
return /* @__PURE__ */ jsxs(StyledListItem, {
|
|
23
|
-
"aria-current":
|
|
22
|
+
"aria-current": item.index === totalCount - 1 ? "page" : void 0,
|
|
24
23
|
children: [renderItem(item, totalCount), renderSeparator(item, totalCount)]
|
|
25
24
|
});
|
|
26
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BreadcrumbItem.mjs","names":[],"sources":["../../src/Breadcrumb/BreadcrumbItem.tsx"],"sourcesContent":["/**\n * Copyright (c) 2016-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { type ReactNode } from \"react\";\n\nexport interface SimpleBreadcrumbItem {\n to: string | Partial<Location>;\n name: ReactNode;\n}\n\nexport interface IndexedBreadcrumbItem extends SimpleBreadcrumbItem {\n index: number;\n}\n\nexport interface BreadcrumbRenderProps {\n item: IndexedBreadcrumbItem;\n totalCount: number;\n}\n\nconst StyledListItem = styled(\"li\", {\n base: {\n display: \"flex\",\n color: \"inherit\",\n gap: \"3xsmall\",\n alignItems: \"flex-end\",\n tabletDown: {\n display: \"block\",\n },\n \"& a\": {\n _visited: {\n color: \"inherit\",\n },\n },\n },\n});\n\ninterface Props {\n item: IndexedBreadcrumbItem;\n autoCollapse?: boolean;\n totalCount: number;\n renderItem: (item: IndexedBreadcrumbItem, totalCount: number) => ReactNode;\n renderSeparator: (item: IndexedBreadcrumbItem, totalCount: number) => ReactNode;\n}\n\nexport const BreadcrumbItem = ({ renderItem, renderSeparator, item, totalCount }: Props) => {\n const isLast = item.index === totalCount - 1;\n return (\n <StyledListItem aria-current={isLast ? \"page\" : undefined}>\n {renderItem(item, totalCount)}\n {renderSeparator(item, totalCount)}\n </StyledListItem>\n );\n};\n"],"mappings":";;;;;;;;;;;AAyBA,MAAM,iBAAiB,OAAO,MAAM,EAClC,MAAM;CACJ,SAAS;CACT,OAAO;CACP,KAAK;CACL,YAAY;CACZ,YAAY,EACV,SAAS,SACV;CACD,OAAO,EACL,UAAU,EACR,OAAO,WACR,EACF;CACF,EACF,CAAC;AAUF,MAAa,kBAAkB,EAAE,YAAY,iBAAiB,MAAM,iBAAwB;
|
|
1
|
+
{"version":3,"file":"BreadcrumbItem.mjs","names":[],"sources":["../../src/Breadcrumb/BreadcrumbItem.tsx"],"sourcesContent":["/**\n * Copyright (c) 2016-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { type ReactNode } from \"react\";\n\nexport interface SimpleBreadcrumbItem {\n to: string | Partial<Location>;\n name: ReactNode;\n}\n\nexport interface IndexedBreadcrumbItem extends SimpleBreadcrumbItem {\n index: number;\n}\n\nexport interface BreadcrumbRenderProps {\n item: IndexedBreadcrumbItem;\n totalCount: number;\n}\n\nconst StyledListItem = styled(\"li\", {\n base: {\n display: \"flex\",\n color: \"inherit\",\n gap: \"3xsmall\",\n alignItems: \"flex-end\",\n tabletDown: {\n display: \"block\",\n },\n \"& a\": {\n _visited: {\n color: \"inherit\",\n },\n },\n },\n});\n\ninterface Props {\n item: IndexedBreadcrumbItem;\n autoCollapse?: boolean;\n totalCount: number;\n renderItem: (item: IndexedBreadcrumbItem, totalCount: number) => ReactNode;\n renderSeparator: (item: IndexedBreadcrumbItem, totalCount: number) => ReactNode;\n}\n\nexport const BreadcrumbItem = ({ renderItem, renderSeparator, item, totalCount }: Props) => {\n const isLast = item.index === totalCount - 1;\n return (\n <StyledListItem aria-current={isLast ? \"page\" : undefined}>\n {renderItem(item, totalCount)}\n {renderSeparator(item, totalCount)}\n </StyledListItem>\n );\n};\n"],"mappings":";;;;;;;;;;;AAyBA,MAAM,iBAAiB,OAAO,MAAM,EAClC,MAAM;CACJ,SAAS;CACT,OAAO;CACP,KAAK;CACL,YAAY;CACZ,YAAY,EACV,SAAS,SACV;CACD,OAAO,EACL,UAAU,EACR,OAAO,WACR,EACF;CACF,EACF,CAAC;AAUF,MAAa,kBAAkB,EAAE,YAAY,iBAAiB,MAAM,iBAAwB;AAE1F,QACE,qBAAC,gBAAD;EAAgB,gBAFH,KAAK,UAAU,aAAa,IAEF,SAAS,KAAA;YAAhD,CACG,WAAW,MAAM,WAAW,EAC5B,gBAAgB,MAAM,WAAW,CACnB"}
|
package/es/Embed/AudioEmbed.mjs
CHANGED
|
@@ -32,11 +32,10 @@ const AudioEmbed = ({ embed, lang }) => {
|
|
|
32
32
|
url: coverPhoto.url,
|
|
33
33
|
alt: coverPhoto.altText
|
|
34
34
|
};
|
|
35
|
-
const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);
|
|
36
35
|
return /* @__PURE__ */ jsxs(StyledFigure, {
|
|
37
36
|
lang,
|
|
38
37
|
"data-embed-type": type,
|
|
39
|
-
...
|
|
38
|
+
...licenseAttributes(data.copyright.license.license, lang, embedData.url),
|
|
40
39
|
children: [/* @__PURE__ */ jsx(AudioPlayer, {
|
|
41
40
|
description: data.podcastMeta?.introduction ?? "",
|
|
42
41
|
img,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioEmbed.mjs","names":[],"sources":["../../src/Embed/AudioEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { AudioMetaData } from \"@ndla/types-embed\";\nimport { AudioPlayer } from \"../AudioPlayer/AudioPlayer\";\nimport { EmbedByline } from \"../LicenseByline/EmbedByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\nimport type { Author } from \"./ImageEmbed\";\n\nconst StyledFigure = styled(Figure, {\n base: {\n clear: \"both\",\n },\n});\n\ninterface Props {\n embed: AudioMetaData;\n lang?: string;\n}\n\nexport const getFirstNonEmptyLicenseCredits = (authors: {\n creators: Author[];\n rightsholders: Author[];\n processors: Author[];\n}) => Object.values(authors).find((i) => i.length > 0) ?? [];\n\nexport const AudioEmbed = ({ embed, lang }: Props) => {\n const type = embed.embedData.type === \"standard\" ? \"audio\" : \"podcast\";\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type={type} />;\n }\n\n const { data, embedData } = embed;\n\n if (embedData.type === \"minimal\") {\n return <AudioPlayer speech src={data.audioFile.url} title={data.title.title} />;\n }\n\n const subtitle = data.series ? { title: data.series.title.title, url: `/podkast/${data.series.id}` } : undefined;\n\n const coverPhoto = data.podcastMeta?.coverPhoto;\n\n const img = coverPhoto && { url: coverPhoto.url, alt: coverPhoto.altText };\n\n const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);\n\n return (\n <StyledFigure lang={lang} data-embed-type={type} {...licenseProps}>\n <AudioPlayer\n description={data.podcastMeta?.introduction ?? \"\"}\n img={img}\n src={data.audioFile.url}\n textVersion={\n data.manuscript?.manuscript.length ? (\n <div dangerouslySetInnerHTML={{ __html: data.manuscript.manuscript }} />\n ) : undefined\n }\n title={data.title.title}\n subtitle={subtitle}\n />\n <EmbedByline\n error={false}\n type={data.audioType === \"standard\" ? \"audio\" : \"podcast\"}\n copyright={embed.data.copyright}\n />\n </StyledFigure>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,eAAe,OAAO,QAAQ,EAClC,MAAM,EACJ,OAAO,QACR,EACF,CAAC;AAaF,MAAa,cAAc,EAAE,OAAO,WAAkB;CACpD,MAAM,OAAO,MAAM,UAAU,SAAS,aAAa,UAAU;AAC7D,KAAI,MAAM,WAAW,QACnB,QAAO,oBAAC,uBAAD,EAA6B,MAAQ,CAAA;CAG9C,MAAM,EAAE,MAAM,cAAc;AAE5B,KAAI,UAAU,SAAS,UACrB,QAAO,oBAAC,aAAD;EAAa,QAAA;EAAO,KAAK,KAAK,UAAU;EAAK,OAAO,KAAK,MAAM;EAAS,CAAA;CAGjF,MAAM,WAAW,KAAK,SAAS;EAAE,OAAO,KAAK,OAAO,MAAM;EAAO,KAAK,YAAY,KAAK,OAAO;EAAM,GAAG,KAAA;CAEvG,MAAM,aAAa,KAAK,aAAa;CAErC,MAAM,MAAM,cAAc;EAAE,KAAK,WAAW;EAAK,KAAK,WAAW;EAAS;
|
|
1
|
+
{"version":3,"file":"AudioEmbed.mjs","names":[],"sources":["../../src/Embed/AudioEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { AudioMetaData } from \"@ndla/types-embed\";\nimport { AudioPlayer } from \"../AudioPlayer/AudioPlayer\";\nimport { EmbedByline } from \"../LicenseByline/EmbedByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\nimport type { Author } from \"./ImageEmbed\";\n\nconst StyledFigure = styled(Figure, {\n base: {\n clear: \"both\",\n },\n});\n\ninterface Props {\n embed: AudioMetaData;\n lang?: string;\n}\n\nexport const getFirstNonEmptyLicenseCredits = (authors: {\n creators: Author[];\n rightsholders: Author[];\n processors: Author[];\n}) => Object.values(authors).find((i) => i.length > 0) ?? [];\n\nexport const AudioEmbed = ({ embed, lang }: Props) => {\n const type = embed.embedData.type === \"standard\" ? \"audio\" : \"podcast\";\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type={type} />;\n }\n\n const { data, embedData } = embed;\n\n if (embedData.type === \"minimal\") {\n return <AudioPlayer speech src={data.audioFile.url} title={data.title.title} />;\n }\n\n const subtitle = data.series ? { title: data.series.title.title, url: `/podkast/${data.series.id}` } : undefined;\n\n const coverPhoto = data.podcastMeta?.coverPhoto;\n\n const img = coverPhoto && { url: coverPhoto.url, alt: coverPhoto.altText };\n\n const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);\n\n return (\n <StyledFigure lang={lang} data-embed-type={type} {...licenseProps}>\n <AudioPlayer\n description={data.podcastMeta?.introduction ?? \"\"}\n img={img}\n src={data.audioFile.url}\n textVersion={\n data.manuscript?.manuscript.length ? (\n <div dangerouslySetInnerHTML={{ __html: data.manuscript.manuscript }} />\n ) : undefined\n }\n title={data.title.title}\n subtitle={subtitle}\n />\n <EmbedByline\n error={false}\n type={data.audioType === \"standard\" ? \"audio\" : \"podcast\"}\n copyright={embed.data.copyright}\n />\n </StyledFigure>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,eAAe,OAAO,QAAQ,EAClC,MAAM,EACJ,OAAO,QACR,EACF,CAAC;AAaF,MAAa,cAAc,EAAE,OAAO,WAAkB;CACpD,MAAM,OAAO,MAAM,UAAU,SAAS,aAAa,UAAU;AAC7D,KAAI,MAAM,WAAW,QACnB,QAAO,oBAAC,uBAAD,EAA6B,MAAQ,CAAA;CAG9C,MAAM,EAAE,MAAM,cAAc;AAE5B,KAAI,UAAU,SAAS,UACrB,QAAO,oBAAC,aAAD;EAAa,QAAA;EAAO,KAAK,KAAK,UAAU;EAAK,OAAO,KAAK,MAAM;EAAS,CAAA;CAGjF,MAAM,WAAW,KAAK,SAAS;EAAE,OAAO,KAAK,OAAO,MAAM;EAAO,KAAK,YAAY,KAAK,OAAO;EAAM,GAAG,KAAA;CAEvG,MAAM,aAAa,KAAK,aAAa;CAErC,MAAM,MAAM,cAAc;EAAE,KAAK,WAAW;EAAK,KAAK,WAAW;EAAS;AAI1E,QACE,qBAAC,cAAD;EAAoB;EAAM,mBAAiB;EAAM,GAH9B,kBAAkB,KAAK,UAAU,QAAQ,SAAS,MAAM,UAAU,IAAI;YAGzF,CACE,oBAAC,aAAD;GACE,aAAa,KAAK,aAAa,gBAAgB;GAC1C;GACL,KAAK,KAAK,UAAU;GACpB,aACE,KAAK,YAAY,WAAW,SAC1B,oBAAC,OAAD,EAAK,yBAAyB,EAAE,QAAQ,KAAK,WAAW,YAAY,EAAI,CAAA,GACtE,KAAA;GAEN,OAAO,KAAK,MAAM;GACR;GACV,CAAA,EACF,oBAAC,aAAD;GACE,OAAO;GACP,MAAM,KAAK,cAAc,aAAa,UAAU;GAChD,WAAW,MAAM,KAAK;GACtB,CAAA,CACW"}
|
|
@@ -31,22 +31,19 @@ const ExternalEmbed = ({ embed }) => {
|
|
|
31
31
|
}, []);
|
|
32
32
|
if (embed.status === "error") return /* @__PURE__ */ jsx(EmbedErrorPlaceholder, { type: "external" });
|
|
33
33
|
const { embedData, data } = embed;
|
|
34
|
-
if (embedData.type === "fullscreen") {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
48
|
-
});
|
|
49
|
-
}
|
|
34
|
+
if (embedData.type === "fullscreen") return /* @__PURE__ */ jsx(Figure, {
|
|
35
|
+
"data-embed-type": "external",
|
|
36
|
+
children: /* @__PURE__ */ jsx(ResourceBox, {
|
|
37
|
+
image: {
|
|
38
|
+
src: data.iframeImage?.image.imageUrl,
|
|
39
|
+
alt: embedData.alt !== void 0 ? embedData.alt : data.iframeImage?.alttext?.alttext ?? ""
|
|
40
|
+
},
|
|
41
|
+
title: embedData.title ?? "",
|
|
42
|
+
url: embedData.url,
|
|
43
|
+
caption: embedData.caption ?? "",
|
|
44
|
+
buttonText: t("license.other.itemImage.ariaLabel")
|
|
45
|
+
})
|
|
46
|
+
});
|
|
50
47
|
return /* @__PURE__ */ jsx(StyledFigure, {
|
|
51
48
|
"data-embed-type": "external",
|
|
52
49
|
ref: figRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalEmbed.mjs","names":[],"sources":["../../src/Embed/ExternalEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { OembedMetaData } from \"@ndla/types-embed\";\nimport { useEffect, useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { ResourceBox } from \"../ResourceBox/ResourceBox\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\n\ninterface Props {\n embed: OembedMetaData;\n}\n\nconst StyledFigure = styled(Figure, {\n base: {\n \"& iframe\": {\n height: \"auto\",\n width: \"100%\",\n },\n },\n});\n\nexport const ExternalEmbed = ({ embed }: Props) => {\n const { t } = useTranslation();\n const figRef = useRef<HTMLElement>(null);\n\n useEffect(() => {\n const iframe = figRef.current?.querySelector(\"iframe\");\n if (iframe) {\n const [width, height] = [Number.parseInt(iframe.width), Number.parseInt(iframe.height)];\n iframe.style.aspectRatio = `${width ? width : 16}/${height ? height : 9}`;\n iframe.width = \"\";\n iframe.height = \"\";\n }\n }, []);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type=\"external\" />;\n }\n\n const { embedData, data } = embed;\n\n if (embedData.type === \"fullscreen\") {\n const image = {\n src: data.iframeImage?.image.imageUrl,\n alt: embedData.alt !== undefined ? embedData.alt : (data.iframeImage?.alttext?.alttext ?? \"\"),\n };\n return (\n <Figure data-embed-type=\"external\">\n <ResourceBox\n image={image}\n title={embedData.title ?? \"\"}\n url={embedData.url}\n caption={embedData.caption ?? \"\"}\n buttonText={t(\"license.other.itemImage.ariaLabel\")}\n />\n </Figure>\n );\n }\n\n return (\n <StyledFigure\n data-embed-type=\"external\"\n ref={figRef}\n dangerouslySetInnerHTML={{ __html: data?.oembed?.html ?? \"\" }}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,MAAM,eAAe,OAAO,QAAQ,EAClC,MAAM,EACJ,YAAY;CACV,QAAQ;CACR,OAAO;CACR,EACF,EACF,CAAC;AAEF,MAAa,iBAAiB,EAAE,YAAmB;CACjD,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,SAAS,OAAoB,KAAK;AAExC,iBAAgB;EACd,MAAM,SAAS,OAAO,SAAS,cAAc,SAAS;AACtD,MAAI,QAAQ;GACV,MAAM,CAAC,OAAO,UAAU,CAAC,OAAO,SAAS,OAAO,MAAM,EAAE,OAAO,SAAS,OAAO,OAAO,CAAC;AACvF,UAAO,MAAM,cAAc,GAAG,QAAQ,QAAQ,GAAG,GAAG,SAAS,SAAS;AACtE,UAAO,QAAQ;AACf,UAAO,SAAS;;IAEjB,EAAE,CAAC;AAEN,KAAI,MAAM,WAAW,QACnB,QAAO,oBAAC,uBAAD,EAAuB,MAAK,YAAa,CAAA;CAGlD,MAAM,EAAE,WAAW,SAAS;AAE5B,KAAI,UAAU,SAAS,
|
|
1
|
+
{"version":3,"file":"ExternalEmbed.mjs","names":[],"sources":["../../src/Embed/ExternalEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { OembedMetaData } from \"@ndla/types-embed\";\nimport { useEffect, useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { ResourceBox } from \"../ResourceBox/ResourceBox\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\n\ninterface Props {\n embed: OembedMetaData;\n}\n\nconst StyledFigure = styled(Figure, {\n base: {\n \"& iframe\": {\n height: \"auto\",\n width: \"100%\",\n },\n },\n});\n\nexport const ExternalEmbed = ({ embed }: Props) => {\n const { t } = useTranslation();\n const figRef = useRef<HTMLElement>(null);\n\n useEffect(() => {\n const iframe = figRef.current?.querySelector(\"iframe\");\n if (iframe) {\n const [width, height] = [Number.parseInt(iframe.width), Number.parseInt(iframe.height)];\n iframe.style.aspectRatio = `${width ? width : 16}/${height ? height : 9}`;\n iframe.width = \"\";\n iframe.height = \"\";\n }\n }, []);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type=\"external\" />;\n }\n\n const { embedData, data } = embed;\n\n if (embedData.type === \"fullscreen\") {\n const image = {\n src: data.iframeImage?.image.imageUrl,\n alt: embedData.alt !== undefined ? embedData.alt : (data.iframeImage?.alttext?.alttext ?? \"\"),\n };\n return (\n <Figure data-embed-type=\"external\">\n <ResourceBox\n image={image}\n title={embedData.title ?? \"\"}\n url={embedData.url}\n caption={embedData.caption ?? \"\"}\n buttonText={t(\"license.other.itemImage.ariaLabel\")}\n />\n </Figure>\n );\n }\n\n return (\n <StyledFigure\n data-embed-type=\"external\"\n ref={figRef}\n dangerouslySetInnerHTML={{ __html: data?.oembed?.html ?? \"\" }}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,MAAM,eAAe,OAAO,QAAQ,EAClC,MAAM,EACJ,YAAY;CACV,QAAQ;CACR,OAAO;CACR,EACF,EACF,CAAC;AAEF,MAAa,iBAAiB,EAAE,YAAmB;CACjD,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,SAAS,OAAoB,KAAK;AAExC,iBAAgB;EACd,MAAM,SAAS,OAAO,SAAS,cAAc,SAAS;AACtD,MAAI,QAAQ;GACV,MAAM,CAAC,OAAO,UAAU,CAAC,OAAO,SAAS,OAAO,MAAM,EAAE,OAAO,SAAS,OAAO,OAAO,CAAC;AACvF,UAAO,MAAM,cAAc,GAAG,QAAQ,QAAQ,GAAG,GAAG,SAAS,SAAS;AACtE,UAAO,QAAQ;AACf,UAAO,SAAS;;IAEjB,EAAE,CAAC;AAEN,KAAI,MAAM,WAAW,QACnB,QAAO,oBAAC,uBAAD,EAAuB,MAAK,YAAa,CAAA;CAGlD,MAAM,EAAE,WAAW,SAAS;AAE5B,KAAI,UAAU,SAAS,aAKrB,QACE,oBAAC,QAAD;EAAQ,mBAAgB;YACtB,oBAAC,aAAD;GACE,OAPQ;IACZ,KAAK,KAAK,aAAa,MAAM;IAC7B,KAAK,UAAU,QAAQ,KAAA,IAAY,UAAU,MAAO,KAAK,aAAa,SAAS,WAAW;IAC3F;GAKK,OAAO,UAAU,SAAS;GAC1B,KAAK,UAAU;GACf,SAAS,UAAU,WAAW;GAC9B,YAAY,EAAE,oCAAoC;GAClD,CAAA;EACK,CAAA;AAIb,QACE,oBAAC,cAAD;EACE,mBAAgB;EAChB,KAAK;EACL,yBAAyB,EAAE,QAAQ,MAAM,QAAQ,QAAQ,IAAI;EAC7D,CAAA"}
|
package/es/Embed/IframeEmbed.mjs
CHANGED
|
@@ -35,14 +35,13 @@ const IframeEmbed = ({ embed }) => {
|
|
|
35
35
|
if (embedData.type === "fullscreen") {
|
|
36
36
|
const iframeImage = embed.status === "success" ? data.iframeImage : void 0;
|
|
37
37
|
const alt = embedData.alt !== void 0 ? embedData.alt : iframeImage?.alttext.alttext;
|
|
38
|
-
const image = {
|
|
39
|
-
src: iframeImage?.image.imageUrl,
|
|
40
|
-
alt: alt ?? ""
|
|
41
|
-
};
|
|
42
38
|
return /* @__PURE__ */ jsx(StyledFigure, {
|
|
43
39
|
"data-embed-type": "iframe",
|
|
44
40
|
children: /* @__PURE__ */ jsx(ResourceBox, {
|
|
45
|
-
image
|
|
41
|
+
image: {
|
|
42
|
+
src: iframeImage?.image.imageUrl,
|
|
43
|
+
alt: alt ?? ""
|
|
44
|
+
},
|
|
46
45
|
title: embedData.title ?? "",
|
|
47
46
|
url: embedData.url,
|
|
48
47
|
caption: embedData.caption ?? "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IframeEmbed.mjs","names":[],"sources":["../../src/Embed/IframeEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { IframeMetaData } from \"@ndla/types-embed\";\nimport { useEffect, useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { ResourceBox } from \"../ResourceBox/ResourceBox\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\n\ninterface Props {\n embed: IframeMetaData;\n}\n\nconst StyledIframe = styled(\"iframe\", {\n base: {\n width: \"100%\",\n border: 0,\n },\n});\n\nconst StyledFigure = styled(Figure, {\n base: {\n clear: \"both\",\n },\n});\n\nexport const IframeEmbed = ({ embed }: Props) => {\n const { t } = useTranslation();\n const iframeRef = useRef<HTMLIFrameElement>(null);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (iframe) {\n const [width, height] = [Number.parseInt(iframe.width), Number.parseInt(iframe.height)];\n iframe.style.aspectRatio = `${width ? width : 16}/${height ? height : 9}`;\n iframe.width = \"\";\n iframe.height = \"\";\n }\n }, []);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type=\"external\" />;\n }\n\n const { embedData, data } = embed;\n\n if (embedData.type === \"fullscreen\") {\n const iframeImage = embed.status === \"success\" ? data.iframeImage : undefined;\n const alt = embedData.alt !== undefined ? embedData.alt : iframeImage?.alttext.alttext;\n const image = { src: iframeImage?.image.imageUrl, alt: alt ?? \"\" };\n return (\n <StyledFigure data-embed-type=\"iframe\">\n <ResourceBox\n image={image}\n title={embedData.title ?? \"\"}\n url={embedData.url}\n caption={embedData.caption ?? \"\"}\n buttonText={t(\"license.other.itemImage.ariaLabel\")}\n />\n </StyledFigure>\n );\n }\n\n const { width, height, url } = embedData;\n\n const strippedWidth = typeof width === \"number\" ? width : width?.replace(/\\s*px/, \"\");\n const strippedHeight = typeof height === \"number\" ? height : height?.replace(/\\s*px/, \"\");\n const title = `${t(\"embed.type.external\")}: ${embedData.title?.trim() ? embedData.title : url}`;\n\n return (\n <StyledFigure data-embed-type=\"iframe\">\n <StyledIframe\n ref={iframeRef}\n title={title}\n aria-label={title}\n src={url}\n width={strippedWidth}\n height={strippedHeight}\n allow=\"autoplay; encrypted-media; fullscreen\"\n loading=\"lazy\"\n />\n </StyledFigure>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,MAAM,eAAe,OAAO,UAAU,EACpC,MAAM;CACJ,OAAO;CACP,QAAQ;CACT,EACF,CAAC;AAEF,MAAM,eAAe,OAAO,QAAQ,EAClC,MAAM,EACJ,OAAO,QACR,EACF,CAAC;AAEF,MAAa,eAAe,EAAE,YAAmB;CAC/C,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,YAAY,OAA0B,KAAK;AAEjD,iBAAgB;EACd,MAAM,SAAS,UAAU;AACzB,MAAI,QAAQ;GACV,MAAM,CAAC,OAAO,UAAU,CAAC,OAAO,SAAS,OAAO,MAAM,EAAE,OAAO,SAAS,OAAO,OAAO,CAAC;AACvF,UAAO,MAAM,cAAc,GAAG,QAAQ,QAAQ,GAAG,GAAG,SAAS,SAAS;AACtE,UAAO,QAAQ;AACf,UAAO,SAAS;;IAEjB,EAAE,CAAC;AAEN,KAAI,MAAM,WAAW,QACnB,QAAO,oBAAC,uBAAD,EAAuB,MAAK,YAAa,CAAA;CAGlD,MAAM,EAAE,WAAW,SAAS;AAE5B,KAAI,UAAU,SAAS,cAAc;EACnC,MAAM,cAAc,MAAM,WAAW,YAAY,KAAK,cAAc,KAAA;EACpE,MAAM,MAAM,UAAU,QAAQ,KAAA,IAAY,UAAU,MAAM,aAAa,QAAQ;
|
|
1
|
+
{"version":3,"file":"IframeEmbed.mjs","names":[],"sources":["../../src/Embed/IframeEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { IframeMetaData } from \"@ndla/types-embed\";\nimport { useEffect, useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { ResourceBox } from \"../ResourceBox/ResourceBox\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\n\ninterface Props {\n embed: IframeMetaData;\n}\n\nconst StyledIframe = styled(\"iframe\", {\n base: {\n width: \"100%\",\n border: 0,\n },\n});\n\nconst StyledFigure = styled(Figure, {\n base: {\n clear: \"both\",\n },\n});\n\nexport const IframeEmbed = ({ embed }: Props) => {\n const { t } = useTranslation();\n const iframeRef = useRef<HTMLIFrameElement>(null);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (iframe) {\n const [width, height] = [Number.parseInt(iframe.width), Number.parseInt(iframe.height)];\n iframe.style.aspectRatio = `${width ? width : 16}/${height ? height : 9}`;\n iframe.width = \"\";\n iframe.height = \"\";\n }\n }, []);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type=\"external\" />;\n }\n\n const { embedData, data } = embed;\n\n if (embedData.type === \"fullscreen\") {\n const iframeImage = embed.status === \"success\" ? data.iframeImage : undefined;\n const alt = embedData.alt !== undefined ? embedData.alt : iframeImage?.alttext.alttext;\n const image = { src: iframeImage?.image.imageUrl, alt: alt ?? \"\" };\n return (\n <StyledFigure data-embed-type=\"iframe\">\n <ResourceBox\n image={image}\n title={embedData.title ?? \"\"}\n url={embedData.url}\n caption={embedData.caption ?? \"\"}\n buttonText={t(\"license.other.itemImage.ariaLabel\")}\n />\n </StyledFigure>\n );\n }\n\n const { width, height, url } = embedData;\n\n const strippedWidth = typeof width === \"number\" ? width : width?.replace(/\\s*px/, \"\");\n const strippedHeight = typeof height === \"number\" ? height : height?.replace(/\\s*px/, \"\");\n const title = `${t(\"embed.type.external\")}: ${embedData.title?.trim() ? embedData.title : url}`;\n\n return (\n <StyledFigure data-embed-type=\"iframe\">\n <StyledIframe\n ref={iframeRef}\n title={title}\n aria-label={title}\n src={url}\n width={strippedWidth}\n height={strippedHeight}\n allow=\"autoplay; encrypted-media; fullscreen\"\n loading=\"lazy\"\n />\n </StyledFigure>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,MAAM,eAAe,OAAO,UAAU,EACpC,MAAM;CACJ,OAAO;CACP,QAAQ;CACT,EACF,CAAC;AAEF,MAAM,eAAe,OAAO,QAAQ,EAClC,MAAM,EACJ,OAAO,QACR,EACF,CAAC;AAEF,MAAa,eAAe,EAAE,YAAmB;CAC/C,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,YAAY,OAA0B,KAAK;AAEjD,iBAAgB;EACd,MAAM,SAAS,UAAU;AACzB,MAAI,QAAQ;GACV,MAAM,CAAC,OAAO,UAAU,CAAC,OAAO,SAAS,OAAO,MAAM,EAAE,OAAO,SAAS,OAAO,OAAO,CAAC;AACvF,UAAO,MAAM,cAAc,GAAG,QAAQ,QAAQ,GAAG,GAAG,SAAS,SAAS;AACtE,UAAO,QAAQ;AACf,UAAO,SAAS;;IAEjB,EAAE,CAAC;AAEN,KAAI,MAAM,WAAW,QACnB,QAAO,oBAAC,uBAAD,EAAuB,MAAK,YAAa,CAAA;CAGlD,MAAM,EAAE,WAAW,SAAS;AAE5B,KAAI,UAAU,SAAS,cAAc;EACnC,MAAM,cAAc,MAAM,WAAW,YAAY,KAAK,cAAc,KAAA;EACpE,MAAM,MAAM,UAAU,QAAQ,KAAA,IAAY,UAAU,MAAM,aAAa,QAAQ;AAE/E,SACE,oBAAC,cAAD;GAAc,mBAAgB;aAC5B,oBAAC,aAAD;IACE,OAJQ;KAAE,KAAK,aAAa,MAAM;KAAU,KAAK,OAAO;KAAI;IAK5D,OAAO,UAAU,SAAS;IAC1B,KAAK,UAAU;IACf,SAAS,UAAU,WAAW;IAC9B,YAAY,EAAE,oCAAoC;IAClD,CAAA;GACW,CAAA;;CAInB,MAAM,EAAE,OAAO,QAAQ,QAAQ;CAE/B,MAAM,gBAAgB,OAAO,UAAU,WAAW,QAAQ,OAAO,QAAQ,SAAS,GAAG;CACrF,MAAM,iBAAiB,OAAO,WAAW,WAAW,SAAS,QAAQ,QAAQ,SAAS,GAAG;CACzF,MAAM,QAAQ,GAAG,EAAE,sBAAsB,CAAC,IAAI,UAAU,OAAO,MAAM,GAAG,UAAU,QAAQ;AAE1F,QACE,oBAAC,cAAD;EAAc,mBAAgB;YAC5B,oBAAC,cAAD;GACE,KAAK;GACE;GACP,cAAY;GACZ,KAAK;GACL,OAAO;GACP,QAAQ;GACR,OAAM;GACN,SAAQ;GACR,CAAA;EACW,CAAA"}
|
package/es/FactBox/FactBox.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Button } from "@ndla/primitives";
|
|
2
2
|
import { styled } from "@ndla/styled-system/jsx";
|
|
3
3
|
import React, { forwardRef, useCallback, useEffect, useId, useMemo, useState } from "react";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
|
-
import { ArrowDownShortLine } from "@ndla/icons";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
6
|
//#region src/FactBox/FactBox.tsx
|
|
8
7
|
/**
|
|
@@ -27,52 +26,29 @@ const StyledAside = styled("aside", {
|
|
|
27
26
|
borderRadius: "xsmall",
|
|
28
27
|
clear: "both",
|
|
29
28
|
_open: { gridTemplateRows: "1fr" },
|
|
30
|
-
|
|
29
|
+
_print: {
|
|
30
|
+
gridTemplateRows: "1fr",
|
|
31
31
|
overflow: "visible",
|
|
32
32
|
maxHeight: "500vh"
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
34
|
"& > div": { minHeight: "surface.3xsmall" }
|
|
35
35
|
},
|
|
36
|
-
variants: { overflowHidden: { true: { "& > div": {
|
|
36
|
+
variants: { overflowHidden: { true: { "& > div": {
|
|
37
|
+
overflow: "hidden",
|
|
38
|
+
_print: { overflow: "visible" }
|
|
39
|
+
} } } }
|
|
37
40
|
});
|
|
38
41
|
const StyledContent = styled("div", { base: {
|
|
39
42
|
position: "relative",
|
|
40
43
|
width: "100%",
|
|
41
44
|
"& :first-child": { marginBlockStart: "0" },
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
textAlign: "center",
|
|
45
|
-
position: "absolute",
|
|
46
|
-
inset: "0",
|
|
47
|
-
transitionProperty: "opacity",
|
|
48
|
-
transitionDuration: "slow",
|
|
49
|
-
transitionTimingFunction: "ease-in-out",
|
|
50
|
-
gradientFrom: "surface.default/20",
|
|
51
|
-
gradientTo: "surface.default/95",
|
|
52
|
-
backgroundGradient: "to-b",
|
|
53
|
-
opacity: "1",
|
|
54
|
-
zIndex: "base",
|
|
55
|
-
pointerEvents: "none"
|
|
56
|
-
},
|
|
57
|
-
_print: {
|
|
58
|
-
overflow: "visible",
|
|
59
|
-
_after: { display: "none" }
|
|
60
|
-
},
|
|
61
|
-
_open: {
|
|
62
|
-
paddingBlockEnd: "xsmall",
|
|
63
|
-
_after: { opacity: "0" }
|
|
64
|
-
}
|
|
45
|
+
_print: { overflow: "visible" },
|
|
46
|
+
_open: { paddingBlockEnd: "xsmall" }
|
|
65
47
|
} });
|
|
66
|
-
const
|
|
48
|
+
const StyledButton = styled(Button, { base: {
|
|
67
49
|
position: "absolute",
|
|
68
50
|
bottom: "-medium",
|
|
69
51
|
zIndex: "base",
|
|
70
|
-
"& svg": {
|
|
71
|
-
transitionProperty: "transform",
|
|
72
|
-
transitionTimingFunction: "ease-in-out",
|
|
73
|
-
transitionDuration: "fast"
|
|
74
|
-
},
|
|
75
|
-
_open: { "& svg": { transform: "rotate(180deg)" } },
|
|
76
52
|
_print: { display: "none" }
|
|
77
53
|
} });
|
|
78
54
|
const FactBox = forwardRef(({ children, open, onOpenChange, defaultOpen = false, ...rest }, ref) => {
|
|
@@ -103,14 +79,14 @@ const FactBox = forwardRef(({ children, open, onOpenChange, defaultOpen = false,
|
|
|
103
79
|
onTransitionEnd: (e) => {
|
|
104
80
|
if (e.target === e.currentTarget && state === "open") setOverflowHidden(false);
|
|
105
81
|
},
|
|
106
|
-
children: [/* @__PURE__ */ jsx(
|
|
82
|
+
children: [/* @__PURE__ */ jsx(StyledButton, {
|
|
107
83
|
"data-state": state,
|
|
108
84
|
onClick,
|
|
109
85
|
contentEditable: false,
|
|
110
86
|
"aria-expanded": state === "open",
|
|
87
|
+
variant: "secondary",
|
|
111
88
|
"aria-controls": contentId,
|
|
112
|
-
|
|
113
|
-
children: /* @__PURE__ */ jsx(ArrowDownShortLine, {})
|
|
89
|
+
children: t(`factbox.${state === "open" ? "showLess" : "showMore"}`)
|
|
114
90
|
}), /* @__PURE__ */ jsx(StyledContent, {
|
|
115
91
|
id: contentId,
|
|
116
92
|
"data-state": state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FactBox.mjs","names":[],"sources":["../../src/FactBox/FactBox.tsx"],"sourcesContent":["/**\n * Copyright (c) 2016-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"FactBox.mjs","names":[],"sources":["../../src/FactBox/FactBox.tsx"],"sourcesContent":["/**\n * Copyright (c) 2016-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { Button } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport React, {\n type ComponentProps,\n type ReactNode,\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { useTranslation } from \"react-i18next\";\n\ninterface Props extends ComponentProps<\"aside\"> {\n children?: ReactNode;\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\nconst StyledAside = styled(\"aside\", {\n base: {\n position: \"relative\",\n padding: \"medium\",\n display: \"grid\",\n gridTemplateRows: \"0fr\",\n transitionProperty: \"grid-template-rows\",\n transitionDuration: \"slow\",\n transitionTimingFunction: \"ease-in-out\",\n justifyItems: \"center\",\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n borderRadius: \"xsmall\",\n clear: \"both\",\n _open: {\n gridTemplateRows: \"1fr\",\n },\n _print: {\n gridTemplateRows: \"1fr\",\n overflow: \"visible\",\n maxHeight: \"500vh\",\n },\n \"& > div\": {\n minHeight: \"surface.3xsmall\",\n },\n },\n variants: {\n overflowHidden: {\n true: {\n \"& > div\": {\n overflow: \"hidden\",\n _print: {\n overflow: \"visible\",\n },\n },\n },\n },\n },\n});\n\nconst StyledContent = styled(\"div\", {\n base: {\n position: \"relative\",\n width: \"100%\",\n // Reset the top margin of the very first child.\n \"& :first-child\": {\n marginBlockStart: \"0\",\n },\n _print: {\n overflow: \"visible\",\n },\n _open: {\n paddingBlockEnd: \"xsmall\",\n },\n },\n});\n\nconst StyledButton = styled(Button, {\n base: {\n position: \"absolute\",\n bottom: \"-medium\",\n zIndex: \"base\",\n _print: {\n display: \"none\",\n },\n },\n});\n\n// TODO: Consider moving the open trigger depending on whether the content is open or closed.\n\nexport const FactBox = forwardRef<HTMLElement, Props>(\n ({ children, open, onOpenChange, defaultOpen = false, ...rest }, ref) => {\n const { t } = useTranslation();\n const [state, setState] = useState<\"open\" | \"closed\">(defaultOpen ? \"open\" : \"closed\");\n const [overflowHidden, setOverflowHidden] = useState(!defaultOpen);\n const contentId = useId();\n // Inert has existed since early 2023. It allows us to disable tabindex inside the content if it is closed, allowing us to be accessible for users with newish browsers. React 18 removes this because it doesn't recognize the attribute. This is a workaround for that.\n // When running in React 18, we need to use an empty string instead of true.\n // TODO: Remove this hack once we upgrade to React 19 as a peer dep.\n const inertAttribute = useMemo(() => {\n return state === \"closed\" ? { inert: typeof React.use === \"function\" ? true : \"\" } : {};\n }, [state]) as { inert?: boolean };\n\n useEffect(() => {\n if (open !== undefined) {\n setState(open ? \"open\" : \"closed\");\n }\n }, [open]);\n\n const onClick = useCallback(() => {\n const newState = state === \"open\" ? \"closed\" : \"open\";\n setState(newState);\n onOpenChange?.(newState === \"open\");\n }, [state, onOpenChange]);\n\n return (\n <StyledAside\n data-state={state}\n data-embed-type=\"factbox\"\n {...rest}\n ref={ref}\n overflowHidden={overflowHidden}\n onTransitionStart={(e) => {\n if (e.target === e.currentTarget && state === \"closed\") {\n setOverflowHidden(true);\n }\n }}\n onTransitionEnd={(e) => {\n if (e.target === e.currentTarget && state === \"open\") {\n setOverflowHidden(false);\n }\n }}\n >\n <StyledButton\n data-state={state}\n onClick={onClick}\n contentEditable={false}\n aria-expanded={state === \"open\"}\n variant=\"secondary\"\n aria-controls={contentId}\n >\n {t(`factbox.${state === \"open\" ? \"showLess\" : \"showMore\"}`)}\n </StyledButton>\n <StyledContent id={contentId} data-state={state} aria-hidden={state === \"closed\"} {...inertAttribute}>\n {children}\n </StyledContent>\n </StyledAside>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;AA6BA,MAAM,cAAc,OAAO,SAAS;CAClC,MAAM;EACJ,UAAU;EACV,SAAS;EACT,SAAS;EACT,kBAAkB;EAClB,oBAAoB;EACpB,oBAAoB;EACpB,0BAA0B;EAC1B,cAAc;EACd,QAAQ;EACR,aAAa;EACb,cAAc;EACd,OAAO;EACP,OAAO,EACL,kBAAkB,OACnB;EACD,QAAQ;GACN,kBAAkB;GAClB,UAAU;GACV,WAAW;GACZ;EACD,WAAW,EACT,WAAW,mBACZ;EACF;CACD,UAAU,EACR,gBAAgB,EACd,MAAM,EACJ,WAAW;EACT,UAAU;EACV,QAAQ,EACN,UAAU,WACX;EACF,EACF,EACF,EACF;CACF,CAAC;AAEF,MAAM,gBAAgB,OAAO,OAAO,EAClC,MAAM;CACJ,UAAU;CACV,OAAO;CAEP,kBAAkB,EAChB,kBAAkB,KACnB;CACD,QAAQ,EACN,UAAU,WACX;CACD,OAAO,EACL,iBAAiB,UAClB;CACF,EACF,CAAC;AAEF,MAAM,eAAe,OAAO,QAAQ,EAClC,MAAM;CACJ,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,QAAQ,EACN,SAAS,QACV;CACF,EACF,CAAC;AAIF,MAAa,UAAU,YACpB,EAAE,UAAU,MAAM,cAAc,cAAc,OAAO,GAAG,QAAQ,QAAQ;CACvE,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,CAAC,OAAO,YAAY,SAA4B,cAAc,SAAS,SAAS;CACtF,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,CAAC,YAAY;CAClE,MAAM,YAAY,OAAO;CAIzB,MAAM,iBAAiB,cAAc;AACnC,SAAO,UAAU,WAAW,EAAE,OAAO,OAAO,MAAM,QAAQ,aAAa,OAAO,IAAI,GAAG,EAAE;IACtF,CAAC,MAAM,CAAC;AAEX,iBAAgB;AACd,MAAI,SAAS,KAAA,EACX,UAAS,OAAO,SAAS,SAAS;IAEnC,CAAC,KAAK,CAAC;CAEV,MAAM,UAAU,kBAAkB;EAChC,MAAM,WAAW,UAAU,SAAS,WAAW;AAC/C,WAAS,SAAS;AAClB,iBAAe,aAAa,OAAO;IAClC,CAAC,OAAO,aAAa,CAAC;AAEzB,QACE,qBAAC,aAAD;EACE,cAAY;EACZ,mBAAgB;EAChB,GAAI;EACC;EACW;EAChB,oBAAoB,MAAM;AACxB,OAAI,EAAE,WAAW,EAAE,iBAAiB,UAAU,SAC5C,mBAAkB,KAAK;;EAG3B,kBAAkB,MAAM;AACtB,OAAI,EAAE,WAAW,EAAE,iBAAiB,UAAU,OAC5C,mBAAkB,MAAM;;YAb9B,CAiBE,oBAAC,cAAD;GACE,cAAY;GACH;GACT,iBAAiB;GACjB,iBAAe,UAAU;GACzB,SAAQ;GACR,iBAAe;aAEd,EAAE,WAAW,UAAU,SAAS,aAAa,aAAa;GAC9C,CAAA,EACf,oBAAC,eAAD;GAAe,IAAI;GAAW,cAAY;GAAO,eAAa,UAAU;GAAU,GAAI;GACnF;GACa,CAAA,CACJ;;EAGnB"}
|