@ndla/ui 45.0.17 → 46.0.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/es/Article/Article.js +3 -3
- package/es/Article/ArticleByline.js +12 -10
- package/es/AudioPlayer/AudioPlayer.js +19 -19
- package/es/AudioPlayer/index.js +0 -2
- package/es/CampaignBlock/CampaignBlock.js +7 -7
- package/es/Embed/conceptComponents.js +15 -8
- package/es/Figure/Figure.js +11 -89
- package/es/Figure/index.js +1 -3
- package/es/FrontpageArticle/FrontpageArticle.js +4 -9
- package/es/Notion/index.js +1 -3
- package/es/all.css +1 -1
- package/es/index.js +3 -4
- package/lib/Article/Article.js +3 -3
- package/lib/Article/ArticleByline.d.ts +4 -3
- package/lib/Article/ArticleByline.js +12 -10
- package/lib/AudioPlayer/AudioPlayer.js +19 -19
- package/lib/AudioPlayer/index.d.ts +0 -2
- package/lib/AudioPlayer/index.js +0 -7
- package/lib/CampaignBlock/CampaignBlock.js +7 -7
- package/lib/Embed/conceptComponents.js +17 -10
- package/lib/Figure/Figure.d.ts +0 -38
- package/lib/Figure/Figure.js +20 -96
- package/lib/Figure/index.d.ts +1 -3
- package/lib/Figure/index.js +2 -17
- package/lib/FrontpageArticle/FrontpageArticle.js +4 -9
- package/lib/Notion/index.d.ts +0 -4
- package/lib/Notion/index.js +0 -14
- package/lib/all.css +1 -1
- package/lib/index.d.ts +3 -5
- package/lib/index.js +1 -32
- package/package.json +19 -23
- package/src/Article/Article.tsx +1 -1
- package/src/Article/ArticleByline.tsx +25 -21
- package/src/AudioPlayer/AudiPlayer.stories.tsx +88 -0
- package/src/AudioPlayer/AudioPlayer.tsx +3 -1
- package/src/AudioPlayer/index.ts +0 -2
- package/src/CampaignBlock/CampaignBlock.tsx +1 -1
- package/src/Embed/IframeEmbed.stories.tsx +15 -0
- package/src/Embed/ImageEmbed.stories.tsx +169 -2
- package/src/Embed/RelatedContentEmbed.stories.tsx +438 -0
- package/src/Embed/conceptComponents.tsx +13 -1
- package/src/Figure/Figure.tsx +1 -120
- package/src/Figure/index.ts +1 -3
- package/src/FrontpageArticle/FrontpageArticle.tsx +1 -12
- package/src/Notion/index.ts +0 -4
- package/src/index.ts +3 -13
- package/src/main.scss +0 -1
- package/es/Animation/Fade.js +0 -62
- package/es/Animation/index.js +0 -1
- package/es/AudioPlayer/initAudioPlayers.js +0 -60
- package/es/Dialog/Dialog.js +0 -70
- package/es/Dialog/index.js +0 -11
- package/es/Figure/FigureLicense.js +0 -72
- package/es/Figure/FigureLicenseDialog.js +0 -54
- package/es/Notion/ConceptNotion.js +0 -135
- package/es/Notion/FigureNotion.js +0 -93
- package/es/Notion/NotionVisualElement.js +0 -68
- package/es/utils/createUniversalPortal.js +0 -25
- package/lib/Animation/Fade.d.ts +0 -17
- package/lib/Animation/Fade.js +0 -70
- package/lib/Animation/index.d.ts +0 -1
- package/lib/Animation/index.js +0 -13
- package/lib/AudioPlayer/initAudioPlayers.d.ts +0 -11
- package/lib/AudioPlayer/initAudioPlayers.js +0 -69
- package/lib/Dialog/Dialog.d.ts +0 -23
- package/lib/Dialog/Dialog.js +0 -75
- package/lib/Dialog/index.d.ts +0 -10
- package/lib/Dialog/index.js +0 -22
- package/lib/Figure/FigureLicense.d.ts +0 -33
- package/lib/Figure/FigureLicense.js +0 -76
- package/lib/Figure/FigureLicenseDialog.d.ts +0 -29
- package/lib/Figure/FigureLicenseDialog.js +0 -57
- package/lib/Notion/ConceptNotion.d.ts +0 -24
- package/lib/Notion/ConceptNotion.js +0 -141
- package/lib/Notion/FigureNotion.d.ts +0 -27
- package/lib/Notion/FigureNotion.js +0 -97
- package/lib/Notion/NotionVisualElement.d.ts +0 -22
- package/lib/Notion/NotionVisualElement.js +0 -75
- package/lib/utils/createUniversalPortal.d.ts +0 -9
- package/lib/utils/createUniversalPortal.js +0 -32
- package/src/Animation/Fade.tsx +0 -46
- package/src/Animation/index.ts +0 -1
- package/src/AudioPlayer/initAudioPlayers.tsx +0 -57
- package/src/Dialog/Dialog.tsx +0 -80
- package/src/Dialog/component.dialog.scss +0 -144
- package/src/Dialog/index.ts +0 -13
- package/src/Figure/FigureLicense.tsx +0 -75
- package/src/Figure/FigureLicenseDialog.tsx +0 -51
- package/src/Notion/ConceptNotion.tsx +0 -170
- package/src/Notion/FigureNotion.tsx +0 -104
- package/src/Notion/NotionVisualElement.tsx +0 -80
- package/src/utils/createUniversalPortal.tsx +0 -23
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022-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
|
-
import { css } from '@emotion/react';
|
|
8
|
-
import styled from '@emotion/styled';
|
|
9
|
-
import { ReactNode } from 'react';
|
|
10
|
-
import { Copyright } from '../types';
|
|
11
|
-
import FigureNotion from './FigureNotion';
|
|
12
|
-
|
|
13
|
-
const StyledIframe = styled.iframe<{ type: string }>`
|
|
14
|
-
${(props) =>
|
|
15
|
-
props.type === 'video'
|
|
16
|
-
? css`
|
|
17
|
-
min-height: 400px;
|
|
18
|
-
`
|
|
19
|
-
: ''}
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
export type NotionVisualElementType = {
|
|
23
|
-
element?: ReactNode;
|
|
24
|
-
type?: 'video' | 'image' | 'h5p' | 'iframe';
|
|
25
|
-
resource?: string;
|
|
26
|
-
title?: string;
|
|
27
|
-
url?: string;
|
|
28
|
-
copyright?: Partial<Copyright>;
|
|
29
|
-
image?: {
|
|
30
|
-
src: string;
|
|
31
|
-
alt?: string;
|
|
32
|
-
};
|
|
33
|
-
licenseButtons?: ReactNode;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
interface Props {
|
|
37
|
-
visualElement: NotionVisualElementType;
|
|
38
|
-
id: string;
|
|
39
|
-
figureId: string;
|
|
40
|
-
}
|
|
41
|
-
const supportedEmbedTypes = ['brightcove', 'h5p', 'iframe', 'external', 'image'];
|
|
42
|
-
|
|
43
|
-
const getType = (resource: string) => {
|
|
44
|
-
if (resource === 'brightcove') {
|
|
45
|
-
return 'video';
|
|
46
|
-
}
|
|
47
|
-
if (resource === 'image' || resource === 'h5p') {
|
|
48
|
-
return resource;
|
|
49
|
-
}
|
|
50
|
-
return 'other';
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const NotionVisualElement = ({ visualElement, id, figureId }: Props) => {
|
|
54
|
-
if (!visualElement.resource || !supportedEmbedTypes.includes(visualElement.resource)) {
|
|
55
|
-
return <p>Embed type is not supported!</p>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const type = getType(visualElement.resource);
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<FigureNotion
|
|
62
|
-
resizeIframe
|
|
63
|
-
id={id}
|
|
64
|
-
figureId={figureId}
|
|
65
|
-
title={visualElement.title ?? ''}
|
|
66
|
-
copyright={visualElement.copyright}
|
|
67
|
-
licenseString={visualElement.copyright?.license?.license ?? ''}
|
|
68
|
-
licenseButtons={visualElement.licenseButtons}
|
|
69
|
-
type={type}
|
|
70
|
-
>
|
|
71
|
-
{visualElement.image?.src ? (
|
|
72
|
-
<img src={visualElement.image?.src} alt={visualElement.image.alt} />
|
|
73
|
-
) : (
|
|
74
|
-
<StyledIframe allowFullScreen type={type} src={visualElement.url} title={visualElement.title} />
|
|
75
|
-
)}
|
|
76
|
-
</FigureNotion>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export default NotionVisualElement;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2016-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
|
-
// N.B This helper is intended to be used in https://github.com/ndlano/article-converter. It is not a general soultion for using portals in SSR applications.
|
|
10
|
-
|
|
11
|
-
import { ReactNode } from 'react';
|
|
12
|
-
import ReactDOM from 'react-dom';
|
|
13
|
-
|
|
14
|
-
function canUseDOM() {
|
|
15
|
-
return !!(typeof window !== 'undefined' && window.document && !window.document.hidden); // window.document.hidden === jsdom check
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function createUniversalPortal(children: ReactNode, selector: string) {
|
|
19
|
-
if (!canUseDOM()) {
|
|
20
|
-
return <div data-react-universal-portal>{children}</div>;
|
|
21
|
-
}
|
|
22
|
-
return ReactDOM.createPortal(children, document.querySelector(selector) as Element);
|
|
23
|
-
}
|