@ndla/ui 35.0.19 → 35.0.20
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 +54 -0
- package/es/BlogPost/index.js +9 -0
- package/es/TreeStructure/ComboboxButton.js +3 -3
- package/es/TreeStructure/TreeStructure.js +7 -7
- package/es/index.js +2 -1
- package/lib/BlogPost/BlogPost.d.ts +24 -0
- package/lib/BlogPost/BlogPost.js +61 -0
- package/lib/BlogPost/index.d.ts +8 -0
- package/lib/BlogPost/index.js +13 -0
- package/lib/TreeStructure/ComboboxButton.js +3 -3
- package/lib/TreeStructure/TreeStructure.d.ts +1 -1
- package/lib/TreeStructure/TreeStructure.js +7 -7
- package/lib/index.d.ts +1 -0
- package/lib/index.js +7 -0
- package/package.json +12 -12
- package/src/BlogPost/BlogPost.stories.tsx +37 -0
- package/src/BlogPost/BlogPost.tsx +102 -0
- package/src/BlogPost/index.ts +9 -0
- package/src/TreeStructure/ComboboxButton.tsx +1 -1
- package/src/TreeStructure/TreeStructure.tsx +1 -1
- package/src/index.ts +1 -0
package/lib/index.d.ts
CHANGED
|
@@ -95,3 +95,4 @@ export { TreeStructure } from './TreeStructure';
|
|
|
95
95
|
export type { TreeStructureProps } from './TreeStructure';
|
|
96
96
|
export { SearchField, SearchResultList, SearchResultItem, ActiveFilters, ToggleSearchButton } from './Search';
|
|
97
97
|
export { default as LetterFilter } from './LetterFilter';
|
|
98
|
+
export { BlogPostV2 } from './BlogPost';
|
package/lib/index.js
CHANGED
|
@@ -148,6 +148,12 @@ Object.defineProperty(exports, "BlogPost", {
|
|
|
148
148
|
return _BlogPosts.BlogPost;
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
|
+
Object.defineProperty(exports, "BlogPostV2", {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
get: function get() {
|
|
154
|
+
return _BlogPost.BlogPostV2;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
151
157
|
Object.defineProperty(exports, "BlogPostWrapper", {
|
|
152
158
|
enumerable: true,
|
|
153
159
|
get: function get() {
|
|
@@ -1329,6 +1335,7 @@ var _InfoBlock = require("./InfoBlock");
|
|
|
1329
1335
|
var _TreeStructure = require("./TreeStructure");
|
|
1330
1336
|
var _Search = require("./Search");
|
|
1331
1337
|
var _LetterFilter = _interopRequireDefault(require("./LetterFilter"));
|
|
1338
|
+
var _BlogPost = require("./BlogPost");
|
|
1332
1339
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1333
1340
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1334
1341
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "35.0.
|
|
3
|
+
"version": "35.0.20",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@ndla/article-scripts": "^3.0.17",
|
|
35
|
-
"@ndla/button": "^10.0.
|
|
36
|
-
"@ndla/carousel": "^3.0.
|
|
35
|
+
"@ndla/button": "^10.0.9",
|
|
36
|
+
"@ndla/carousel": "^3.0.10",
|
|
37
37
|
"@ndla/core": "^3.1.3",
|
|
38
|
-
"@ndla/forms": "^4.2.
|
|
38
|
+
"@ndla/forms": "^4.2.18",
|
|
39
39
|
"@ndla/hooks": "^2.0.4",
|
|
40
|
-
"@ndla/icons": "^2.2.
|
|
40
|
+
"@ndla/icons": "^2.2.10",
|
|
41
41
|
"@ndla/licenses": "^7.0.4",
|
|
42
|
-
"@ndla/modal": "^2.2.
|
|
43
|
-
"@ndla/notion": "^4.2.
|
|
44
|
-
"@ndla/safelink": "^4.0.
|
|
42
|
+
"@ndla/modal": "^2.2.14",
|
|
43
|
+
"@ndla/notion": "^4.2.15",
|
|
44
|
+
"@ndla/safelink": "^4.0.19",
|
|
45
45
|
"@ndla/switch": "^1.0.8",
|
|
46
|
-
"@ndla/tabs": "^2.1.
|
|
47
|
-
"@ndla/tooltip": "^4.0.
|
|
46
|
+
"@ndla/tabs": "^2.1.16",
|
|
47
|
+
"@ndla/tooltip": "^4.0.17",
|
|
48
48
|
"@ndla/types-learningpath-api": "^0.0.20",
|
|
49
49
|
"@ndla/util": "^3.1.12",
|
|
50
50
|
"@radix-ui/react-accordion": "1.1.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
|
|
78
|
-
"@ndla/types-embed": "^1.0.
|
|
78
|
+
"@ndla/types-embed": "^1.0.7",
|
|
79
79
|
"@ndla/types-image-api": "0.0.10",
|
|
80
80
|
"@types/reach__dialog": "^0.1.0",
|
|
81
81
|
"css-loader": "^6.7.3",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "496319a9a156a2ec659bb9cf119d35654281417b"
|
|
91
91
|
}
|
|
@@ -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 React from 'react';
|
|
10
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
11
|
+
import BlogPost from './BlogPost';
|
|
12
|
+
import { defaultParameters } from '../../../../stories/defaults';
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: 'Enkle komponenter/Blog Post',
|
|
16
|
+
component: BlogPost,
|
|
17
|
+
parameters: {
|
|
18
|
+
...defaultParameters,
|
|
19
|
+
},
|
|
20
|
+
args: {
|
|
21
|
+
title: { title: 'Min bloggpost', language: 'nb-no' },
|
|
22
|
+
author: 'Ola Nordmann',
|
|
23
|
+
url: '#',
|
|
24
|
+
headingLevel: 'h3',
|
|
25
|
+
size: 'large',
|
|
26
|
+
metaImage: {
|
|
27
|
+
alt: 'Yonghetempelet i Beijing. Foto.',
|
|
28
|
+
url: 'https://api.test.ndla.no/image-api/raw/20080101-032119-ag.jpg',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
} as ComponentMeta<typeof BlogPost>;
|
|
32
|
+
|
|
33
|
+
export const BlogPostStory: ComponentStory<typeof BlogPost> = ({ ...args }) => {
|
|
34
|
+
return <BlogPost {...args} />;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
BlogPostStory.storyName = 'BlogPost';
|
|
@@ -0,0 +1,102 @@
|
|
|
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 { css } from '@emotion/react';
|
|
11
|
+
import SafeLink from '@ndla/safelink';
|
|
12
|
+
import { colors, fonts, misc, spacing } from '@ndla/core';
|
|
13
|
+
import { Quote } from '@ndla/icons/editor';
|
|
14
|
+
import { HeadingLevel } from '../types';
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
title: {
|
|
18
|
+
title: string;
|
|
19
|
+
language: string;
|
|
20
|
+
};
|
|
21
|
+
author?: string;
|
|
22
|
+
url: string;
|
|
23
|
+
headingLevel?: HeadingLevel;
|
|
24
|
+
size?: 'normal' | 'large';
|
|
25
|
+
metaImage: {
|
|
26
|
+
url: string;
|
|
27
|
+
alt: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const Container = styled(SafeLink)`
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
color: ${colors.text.primary};
|
|
35
|
+
max-width: 350px;
|
|
36
|
+
min-width: 350px;
|
|
37
|
+
max-height: 415px;
|
|
38
|
+
min-height: 415px;
|
|
39
|
+
gap: ${spacing.nsmall};
|
|
40
|
+
box-shadow: none;
|
|
41
|
+
border: 1px solid ${colors.brand.lightest};
|
|
42
|
+
border-radius: ${misc.borderRadius};
|
|
43
|
+
padding: ${spacing.normal} ${spacing.medium};
|
|
44
|
+
&[data-size='large'] {
|
|
45
|
+
min-width: 532px;
|
|
46
|
+
max-width: 532px;
|
|
47
|
+
min-height: 550px;
|
|
48
|
+
max-height: 550px;
|
|
49
|
+
}
|
|
50
|
+
&:hover,
|
|
51
|
+
&:focus-within {
|
|
52
|
+
.blog-title {
|
|
53
|
+
box-shadow: inset 0 -1px;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const headingCss = css`
|
|
59
|
+
display: inline-block;
|
|
60
|
+
width: fit-content;
|
|
61
|
+
margin: 0;
|
|
62
|
+
font-weight: ${fonts.weight.semibold};
|
|
63
|
+
${fonts.sizes('26px', '36px')};
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
const AuthorContainer = styled.div`
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: ${spacing.xsmall};
|
|
70
|
+
svg {
|
|
71
|
+
color: rgba(78, 81, 242, 1);
|
|
72
|
+
}
|
|
73
|
+
text-transform: uppercase;
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
const StyledImg = styled.img`
|
|
77
|
+
border-radius: ${misc.borderRadius};
|
|
78
|
+
flex: 1;
|
|
79
|
+
object-fit: cover;
|
|
80
|
+
width: 100%;
|
|
81
|
+
height: 100%;
|
|
82
|
+
border: 0;
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
const BlogPost = ({ title, author, url, metaImage, headingLevel: Heading = 'h3', size = 'normal' }: Props) => {
|
|
86
|
+
return (
|
|
87
|
+
<Container data-size={size} to={url}>
|
|
88
|
+
<Heading className="blog-title" css={headingCss} lang={title.language}>
|
|
89
|
+
{title.title}
|
|
90
|
+
</Heading>
|
|
91
|
+
<StyledImg src={metaImage.url} alt={metaImage.alt} />
|
|
92
|
+
{!!author && (
|
|
93
|
+
<AuthorContainer>
|
|
94
|
+
<Quote />
|
|
95
|
+
{author}
|
|
96
|
+
</AuthorContainer>
|
|
97
|
+
)}
|
|
98
|
+
</Container>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default BlogPost;
|
|
@@ -11,7 +11,7 @@ import styled from '@emotion/styled';
|
|
|
11
11
|
import { colors, fonts, misc, utils } from '@ndla/core';
|
|
12
12
|
import { css } from '@emotion/react';
|
|
13
13
|
import uniq from 'lodash/uniq';
|
|
14
|
-
import { IFolder } from '@ndla/types-learningpath-api';
|
|
14
|
+
import { IFolder } from '@ndla/types-backend/learningpath-api';
|
|
15
15
|
import FolderItems from './FolderItems';
|
|
16
16
|
import { flattenFolders, treestructureId } from './helperFunctions';
|
|
17
17
|
import { CommonTreeStructureProps, NewFolderInputFunc, TreeStructureType } from './types';
|
package/src/index.ts
CHANGED
|
@@ -269,3 +269,4 @@ export type { TreeStructureProps } from './TreeStructure';
|
|
|
269
269
|
|
|
270
270
|
export { SearchField, SearchResultList, SearchResultItem, ActiveFilters, ToggleSearchButton } from './Search';
|
|
271
271
|
export { default as LetterFilter } from './LetterFilter';
|
|
272
|
+
export { BlogPostV2 } from './BlogPost';
|