@ndla/ui 36.0.0 → 36.0.2
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/es/BlogPost/BlogPost.js +4 -4
- package/es/CampaignBlock/CampaignBlock.js +77 -0
- package/es/CampaignBlock/index.js +9 -0
- package/es/ContactBlock/ContactBlock.js +63 -39
- package/es/Embed/BrightcoveEmbed.js +3 -3
- package/es/LicenseByline/EmbedByline.js +90 -0
- package/es/LicenseByline/LicenseDescription.js +37 -0
- package/es/LicenseByline/LicenseLink.js +36 -0
- package/es/LicenseByline/index.js +1 -0
- package/es/Messages/MessageBox.js +9 -9
- package/es/locale/messages-en.js +8 -1
- package/es/locale/messages-nb.js +8 -1
- package/es/locale/messages-nn.js +8 -1
- package/es/locale/messages-se.js +8 -1
- package/es/locale/messages-sma.js +8 -1
- package/lib/BlogPost/BlogPost.js +4 -4
- package/lib/CampaignBlock/CampaignBlock.d.ts +31 -0
- package/lib/CampaignBlock/CampaignBlock.js +82 -0
- package/lib/CampaignBlock/index.d.ts +8 -0
- package/lib/CampaignBlock/index.js +13 -0
- package/lib/ContactBlock/ContactBlock.js +63 -39
- package/lib/Embed/BrightcoveEmbed.js +3 -3
- package/lib/LicenseByline/EmbedByline.d.ts +43 -0
- package/lib/LicenseByline/EmbedByline.js +95 -0
- package/lib/LicenseByline/LicenseDescription.d.ts +12 -0
- package/lib/LicenseByline/LicenseDescription.js +43 -0
- package/lib/LicenseByline/LicenseLink.d.ts +14 -0
- package/lib/LicenseByline/LicenseLink.js +44 -0
- package/lib/LicenseByline/index.d.ts +1 -0
- package/lib/LicenseByline/index.js +13 -0
- package/lib/Messages/MessageBox.js +9 -9
- package/lib/locale/messages-en.d.ts +7 -0
- package/lib/locale/messages-en.js +8 -1
- package/lib/locale/messages-nb.d.ts +7 -0
- package/lib/locale/messages-nb.js +8 -1
- package/lib/locale/messages-nn.d.ts +7 -0
- package/lib/locale/messages-nn.js +8 -1
- package/lib/locale/messages-se.d.ts +7 -0
- package/lib/locale/messages-se.js +8 -1
- package/lib/locale/messages-sma.d.ts +7 -0
- package/lib/locale/messages-sma.js +8 -1
- package/package.json +2 -2
- package/src/BlogPost/BlogPost.tsx +0 -4
- package/src/CampaignBlock/CampaignBlock.stories.tsx +63 -0
- package/src/CampaignBlock/CampaignBlock.tsx +99 -0
- package/src/CampaignBlock/index.ts +9 -0
- package/src/ContactBlock/ContactBlock.tsx +27 -19
- package/src/ContactBlock/Contactblock.stories.tsx +0 -1
- package/src/Embed/BrightcoveEmbed.tsx +1 -1
- package/src/LicenseByline/EmbedByline.stories.tsx +82 -0
- package/src/LicenseByline/EmbedByline.tsx +117 -0
- package/src/LicenseByline/LicenseDescription.tsx +37 -0
- package/src/LicenseByline/LicenseLink.tsx +42 -0
- package/src/LicenseByline/index.tsx +1 -0
- package/src/Messages/MessageBox.tsx +1 -1
- package/src/locale/messages-en.ts +7 -0
- package/src/locale/messages-nb.ts +7 -0
- package/src/locale/messages-nn.ts +7 -0
- package/src/locale/messages-se.ts +7 -0
- package/src/locale/messages-sma.ts +7 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ReactNode } from 'react';
|
|
10
|
+
import { useTranslation } from 'react-i18next';
|
|
11
|
+
import styled from '@emotion/styled';
|
|
12
|
+
import { breakpoints, colors, misc, mq, spacing } from '@ndla/core';
|
|
13
|
+
import { getLicenseByAbbreviation, getLicenseCredits } from '@ndla/licenses';
|
|
14
|
+
import { ICopyright as ImageCopyright } from '@ndla/types-backend/image-api';
|
|
15
|
+
import { ICopyright as AudioCopyright } from '@ndla/types-backend/audio-api';
|
|
16
|
+
import { ICopyright as ConceptCopyright } from '@ndla/types-backend/concept-api';
|
|
17
|
+
import { BrightcoveCopyright } from '@ndla/types-embed';
|
|
18
|
+
import LicenseLink from './LicenseLink';
|
|
19
|
+
import LicenseDescription from './LicenseDescription';
|
|
20
|
+
|
|
21
|
+
interface BaseProps {
|
|
22
|
+
topRounded?: boolean;
|
|
23
|
+
description?: string;
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
visibleAlt?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface ImageProps extends BaseProps {
|
|
29
|
+
type: 'image';
|
|
30
|
+
copyright: ImageCopyright;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface BrightcoveProps extends BaseProps {
|
|
34
|
+
type: 'video';
|
|
35
|
+
copyright: BrightcoveCopyright;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface AudioProps extends BaseProps {
|
|
39
|
+
type: 'audio';
|
|
40
|
+
copyright: AudioCopyright;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface PodcastProps extends BaseProps {
|
|
44
|
+
type: 'podcast';
|
|
45
|
+
copyright: AudioCopyright;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface ConceptProps extends BaseProps {
|
|
49
|
+
type: 'concept';
|
|
50
|
+
copyright: ConceptCopyright;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type Props = ImageProps | BrightcoveProps | AudioProps | PodcastProps | ConceptProps;
|
|
54
|
+
|
|
55
|
+
export type LicenseType = ReturnType<typeof getLicenseByAbbreviation>;
|
|
56
|
+
|
|
57
|
+
const BylineWrapper = styled.div`
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
gap: ${spacing.small};
|
|
61
|
+
background-color: ${colors.brand.lightest};
|
|
62
|
+
padding: ${spacing.small} ${spacing.normal};
|
|
63
|
+
border: 1px solid ${colors.brand.tertiary};
|
|
64
|
+
border-bottom-right-radius: ${misc.borderRadius};
|
|
65
|
+
border-bottom-left-radius: ${misc.borderRadius};
|
|
66
|
+
|
|
67
|
+
&[data-top-rounded='true'] {
|
|
68
|
+
border-radius: ${misc.borderRadius};
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
const RightsWrapper = styled.div`
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
gap: ${spacing.nsmall};
|
|
76
|
+
|
|
77
|
+
${mq.range({ until: breakpoints.tablet })} {
|
|
78
|
+
align-items: flex-start;
|
|
79
|
+
gap: ${spacing.xsmall};
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
const StyledSpan = styled.span`
|
|
85
|
+
font-style: italic;
|
|
86
|
+
color: grey;
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
const LicenseInformationWrapper = styled.div`
|
|
90
|
+
flex: 1;
|
|
91
|
+
`;
|
|
92
|
+
|
|
93
|
+
const EmbedByline = ({ type, topRounded, description, copyright, children, visibleAlt }: Props) => {
|
|
94
|
+
const { t, i18n } = useTranslation();
|
|
95
|
+
const license = getLicenseByAbbreviation(copyright.license?.license ?? '', i18n.language);
|
|
96
|
+
const authors = getLicenseCredits(copyright);
|
|
97
|
+
const captionAuthors = Object.values(authors).find((i) => i.length > 0) ?? [];
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<BylineWrapper data-top-rounded={topRounded}>
|
|
101
|
+
{!!description && <LicenseDescription description={description} />}
|
|
102
|
+
{visibleAlt ? <StyledSpan>{`Alt: ${visibleAlt}`}</StyledSpan> : null}
|
|
103
|
+
<RightsWrapper>
|
|
104
|
+
<LicenseLink license={license} asLink={!!license.url.length} />
|
|
105
|
+
<LicenseInformationWrapper>
|
|
106
|
+
<span>
|
|
107
|
+
<b>{t(`embed.type.${type}`)}: </b>
|
|
108
|
+
{captionAuthors.map((author) => author.name).join(', ')}
|
|
109
|
+
</span>
|
|
110
|
+
</LicenseInformationWrapper>
|
|
111
|
+
{children}
|
|
112
|
+
</RightsWrapper>
|
|
113
|
+
</BylineWrapper>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default EmbedByline;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import styled from '@emotion/styled';
|
|
10
|
+
import { colors, spacing } from '@ndla/core';
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
description: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const StyledParagraph = styled.p`
|
|
17
|
+
margin: 0;
|
|
18
|
+
padding-bottom: ${spacing.xsmall};
|
|
19
|
+
border-bottom: 1px solid ${colors.brand.tertiary};
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
const StyledFigCaption = styled.figcaption`
|
|
23
|
+
background: unset;
|
|
24
|
+
padding: unset;
|
|
25
|
+
font-size: unset;
|
|
26
|
+
color: unset;
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const LicenseDescription = ({ description }: Props) => {
|
|
30
|
+
return (
|
|
31
|
+
<StyledFigCaption>
|
|
32
|
+
<StyledParagraph>{description}</StyledParagraph>
|
|
33
|
+
</StyledFigCaption>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default LicenseDescription;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import styled from '@emotion/styled';
|
|
10
|
+
import SafeLink from '@ndla/safelink';
|
|
11
|
+
import { colors, fonts } from '@ndla/core';
|
|
12
|
+
import { LicenseType } from './EmbedByline';
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
license: LicenseType;
|
|
16
|
+
asLink?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const StyledSafeLink = styled(SafeLink)`
|
|
20
|
+
color: ${colors.brand.primary};
|
|
21
|
+
font-weight: ${fonts.weight.bold};
|
|
22
|
+
text-decoration: underline;
|
|
23
|
+
box-shadow: none;
|
|
24
|
+
&:hover,
|
|
25
|
+
&:focus-within {
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const StyledSpan = styled.span`
|
|
31
|
+
font-weight: ${fonts.weight.bold};
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
const LicenseLink = ({ license, asLink = true }: Props) => {
|
|
35
|
+
if (asLink) {
|
|
36
|
+
return <StyledSafeLink to={license.url}>{license.abbreviation}</StyledSafeLink>;
|
|
37
|
+
} else {
|
|
38
|
+
return <StyledSpan>{license.abbreviation}</StyledSpan>;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default LicenseLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as EmbedByline } from './EmbedByline';
|
|
@@ -1305,6 +1305,13 @@ const messages = {
|
|
|
1305
1305
|
conceptListError: 'Failed to show concept list',
|
|
1306
1306
|
linkError: 'Failed to show link.',
|
|
1307
1307
|
unsupported: `Embed {{type}} not supported.`,
|
|
1308
|
+
type: {
|
|
1309
|
+
image: 'Image',
|
|
1310
|
+
video: 'Video',
|
|
1311
|
+
audio: 'Audio',
|
|
1312
|
+
podcast: 'Podcast',
|
|
1313
|
+
concept: 'Concept',
|
|
1314
|
+
},
|
|
1308
1315
|
},
|
|
1309
1316
|
};
|
|
1310
1317
|
|
|
@@ -1301,6 +1301,13 @@ const messages = {
|
|
|
1301
1301
|
conceptListError: 'Klarte ikke å vise forklaringsliste',
|
|
1302
1302
|
linkError: 'Klarte ikke å vise lenke.',
|
|
1303
1303
|
unsupported: `Embed {{type}} er ikke støttet.`,
|
|
1304
|
+
type: {
|
|
1305
|
+
image: 'Bilde',
|
|
1306
|
+
video: 'Video',
|
|
1307
|
+
audio: 'Lyd',
|
|
1308
|
+
podcast: 'Podkast',
|
|
1309
|
+
concept: 'Forklaring',
|
|
1310
|
+
},
|
|
1304
1311
|
},
|
|
1305
1312
|
};
|
|
1306
1313
|
|
|
@@ -1301,6 +1301,13 @@ const messages = {
|
|
|
1301
1301
|
conceptListError: 'Klarte ikkje å vise forklaringsliste',
|
|
1302
1302
|
linkError: 'Klarte ikkje å vise lenke.',
|
|
1303
1303
|
unsupported: `Embed {{type}} er ikkje støtta.`,
|
|
1304
|
+
type: {
|
|
1305
|
+
image: 'Bilde',
|
|
1306
|
+
video: 'Video',
|
|
1307
|
+
audio: 'Lyd',
|
|
1308
|
+
podcast: 'Podkast',
|
|
1309
|
+
concept: 'Forklaring',
|
|
1310
|
+
},
|
|
1304
1311
|
},
|
|
1305
1312
|
};
|
|
1306
1313
|
|
|
@@ -1302,6 +1302,13 @@ const messages = {
|
|
|
1302
1302
|
conceptListError: 'Ii sáhttán čájehit čilgehuslisttu',
|
|
1303
1303
|
linkError: 'Ii sáhttán čájehit liŋkka.',
|
|
1304
1304
|
unsupported: `Embed {{type}} ii dorjojuvvo.`,
|
|
1305
|
+
type: {
|
|
1306
|
+
image: 'Bilde',
|
|
1307
|
+
video: 'Video',
|
|
1308
|
+
audio: 'Lyd',
|
|
1309
|
+
podcast: 'Podkast',
|
|
1310
|
+
concept: 'Forklaring',
|
|
1311
|
+
},
|
|
1305
1312
|
},
|
|
1306
1313
|
};
|
|
1307
1314
|
|
|
@@ -1306,6 +1306,13 @@ const messages = {
|
|
|
1306
1306
|
conceptListError: 'Klarte ikkje å vise forklaringsliste',
|
|
1307
1307
|
linkError: 'Klarte ikkje å vise lenke.',
|
|
1308
1308
|
unsupported: `Embed {{type}} er ikkje støtta.`,
|
|
1309
|
+
type: {
|
|
1310
|
+
image: 'Bilde',
|
|
1311
|
+
video: 'Video',
|
|
1312
|
+
audio: 'Lyd',
|
|
1313
|
+
podcast: 'Podkast',
|
|
1314
|
+
concept: 'Forklaring',
|
|
1315
|
+
},
|
|
1309
1316
|
},
|
|
1310
1317
|
};
|
|
1311
1318
|
|