@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.
Files changed (92) hide show
  1. package/es/Article/Article.js +3 -3
  2. package/es/Article/ArticleByline.js +12 -10
  3. package/es/AudioPlayer/AudioPlayer.js +19 -19
  4. package/es/AudioPlayer/index.js +0 -2
  5. package/es/CampaignBlock/CampaignBlock.js +7 -7
  6. package/es/Embed/conceptComponents.js +15 -8
  7. package/es/Figure/Figure.js +11 -89
  8. package/es/Figure/index.js +1 -3
  9. package/es/FrontpageArticle/FrontpageArticle.js +4 -9
  10. package/es/Notion/index.js +1 -3
  11. package/es/all.css +1 -1
  12. package/es/index.js +3 -4
  13. package/lib/Article/Article.js +3 -3
  14. package/lib/Article/ArticleByline.d.ts +4 -3
  15. package/lib/Article/ArticleByline.js +12 -10
  16. package/lib/AudioPlayer/AudioPlayer.js +19 -19
  17. package/lib/AudioPlayer/index.d.ts +0 -2
  18. package/lib/AudioPlayer/index.js +0 -7
  19. package/lib/CampaignBlock/CampaignBlock.js +7 -7
  20. package/lib/Embed/conceptComponents.js +17 -10
  21. package/lib/Figure/Figure.d.ts +0 -38
  22. package/lib/Figure/Figure.js +20 -96
  23. package/lib/Figure/index.d.ts +1 -3
  24. package/lib/Figure/index.js +2 -17
  25. package/lib/FrontpageArticle/FrontpageArticle.js +4 -9
  26. package/lib/Notion/index.d.ts +0 -4
  27. package/lib/Notion/index.js +0 -14
  28. package/lib/all.css +1 -1
  29. package/lib/index.d.ts +3 -5
  30. package/lib/index.js +1 -32
  31. package/package.json +19 -23
  32. package/src/Article/Article.tsx +1 -1
  33. package/src/Article/ArticleByline.tsx +25 -21
  34. package/src/AudioPlayer/AudiPlayer.stories.tsx +88 -0
  35. package/src/AudioPlayer/AudioPlayer.tsx +3 -1
  36. package/src/AudioPlayer/index.ts +0 -2
  37. package/src/CampaignBlock/CampaignBlock.tsx +1 -1
  38. package/src/Embed/IframeEmbed.stories.tsx +15 -0
  39. package/src/Embed/ImageEmbed.stories.tsx +169 -2
  40. package/src/Embed/RelatedContentEmbed.stories.tsx +438 -0
  41. package/src/Embed/conceptComponents.tsx +13 -1
  42. package/src/Figure/Figure.tsx +1 -120
  43. package/src/Figure/index.ts +1 -3
  44. package/src/FrontpageArticle/FrontpageArticle.tsx +1 -12
  45. package/src/Notion/index.ts +0 -4
  46. package/src/index.ts +3 -13
  47. package/src/main.scss +0 -1
  48. package/es/Animation/Fade.js +0 -62
  49. package/es/Animation/index.js +0 -1
  50. package/es/AudioPlayer/initAudioPlayers.js +0 -60
  51. package/es/Dialog/Dialog.js +0 -70
  52. package/es/Dialog/index.js +0 -11
  53. package/es/Figure/FigureLicense.js +0 -72
  54. package/es/Figure/FigureLicenseDialog.js +0 -54
  55. package/es/Notion/ConceptNotion.js +0 -135
  56. package/es/Notion/FigureNotion.js +0 -93
  57. package/es/Notion/NotionVisualElement.js +0 -68
  58. package/es/utils/createUniversalPortal.js +0 -25
  59. package/lib/Animation/Fade.d.ts +0 -17
  60. package/lib/Animation/Fade.js +0 -70
  61. package/lib/Animation/index.d.ts +0 -1
  62. package/lib/Animation/index.js +0 -13
  63. package/lib/AudioPlayer/initAudioPlayers.d.ts +0 -11
  64. package/lib/AudioPlayer/initAudioPlayers.js +0 -69
  65. package/lib/Dialog/Dialog.d.ts +0 -23
  66. package/lib/Dialog/Dialog.js +0 -75
  67. package/lib/Dialog/index.d.ts +0 -10
  68. package/lib/Dialog/index.js +0 -22
  69. package/lib/Figure/FigureLicense.d.ts +0 -33
  70. package/lib/Figure/FigureLicense.js +0 -76
  71. package/lib/Figure/FigureLicenseDialog.d.ts +0 -29
  72. package/lib/Figure/FigureLicenseDialog.js +0 -57
  73. package/lib/Notion/ConceptNotion.d.ts +0 -24
  74. package/lib/Notion/ConceptNotion.js +0 -141
  75. package/lib/Notion/FigureNotion.d.ts +0 -27
  76. package/lib/Notion/FigureNotion.js +0 -97
  77. package/lib/Notion/NotionVisualElement.d.ts +0 -22
  78. package/lib/Notion/NotionVisualElement.js +0 -75
  79. package/lib/utils/createUniversalPortal.d.ts +0 -9
  80. package/lib/utils/createUniversalPortal.js +0 -32
  81. package/src/Animation/Fade.tsx +0 -46
  82. package/src/Animation/index.ts +0 -1
  83. package/src/AudioPlayer/initAudioPlayers.tsx +0 -57
  84. package/src/Dialog/Dialog.tsx +0 -80
  85. package/src/Dialog/component.dialog.scss +0 -144
  86. package/src/Dialog/index.ts +0 -13
  87. package/src/Figure/FigureLicense.tsx +0 -75
  88. package/src/Figure/FigureLicenseDialog.tsx +0 -51
  89. package/src/Notion/ConceptNotion.tsx +0 -170
  90. package/src/Notion/FigureNotion.tsx +0 -104
  91. package/src/Notion/NotionVisualElement.tsx +0 -80
  92. 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
- }