@ndla/ui 56.0.3-alpha.0 → 56.0.4-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 +34 -5
- package/dist/styles.css +144 -18
- package/es/Article/Article.js +1 -5
- package/es/Article/ArticleContent.js +27 -0
- package/es/Article/index.js +2 -1
- package/es/Embed/ImageEmbed.js +2 -1
- package/es/ErrorMessage/ErrorMessage.js +2 -0
- package/es/FileList/File.js +78 -23
- package/es/FileList/FileList.js +32 -37
- package/es/FileList/PdfFile.js +17 -16
- package/es/FileList/index.js +3 -5
- package/es/Grid/Grid.js +69 -48
- package/es/Grid/GridParallaxItem.js +32 -0
- package/es/Grid/index.js +2 -1
- package/es/KeyFigure/KeyFigure.js +28 -33
- package/es/LinkBlock/LinkBlockSection.js +1 -0
- package/es/RelatedArticleList/RelatedArticleList.js +1 -1
- package/es/index.js +1 -4
- package/es/styles.css +144 -18
- package/lib/Article/Article.d.ts +0 -1
- package/lib/Article/Article.js +3 -7
- package/lib/Article/ArticleContent.d.ts +11 -0
- package/lib/Article/ArticleContent.js +33 -0
- package/lib/Article/index.d.ts +2 -1
- package/lib/Article/index.js +2 -1
- package/lib/Embed/ImageEmbed.js +2 -1
- package/lib/ErrorMessage/ErrorMessage.js +2 -0
- package/lib/FileList/File.d.ts +5 -3
- package/lib/FileList/File.js +78 -23
- package/lib/FileList/FileList.d.ts +6 -6
- package/lib/FileList/FileList.js +35 -38
- package/lib/FileList/PdfFile.d.ts +2 -2
- package/lib/FileList/PdfFile.js +17 -15
- package/lib/FileList/index.d.ts +3 -5
- package/lib/FileList/index.js +19 -18
- package/lib/Grid/Grid.d.ts +4 -7
- package/lib/Grid/Grid.js +71 -49
- package/lib/Grid/GridParallaxItem.d.ts +9 -0
- package/lib/Grid/GridParallaxItem.js +39 -0
- package/lib/Grid/index.d.ts +2 -1
- package/lib/Grid/index.js +4 -5
- package/lib/KeyFigure/KeyFigure.js +30 -33
- package/lib/LinkBlock/LinkBlockSection.js +1 -0
- package/lib/RelatedArticleList/RelatedArticleList.js +1 -1
- package/lib/index.d.ts +1 -4
- package/lib/index.js +9 -24
- package/lib/styles.css +144 -18
- package/package.json +7 -7
- package/src/Article/Article.tsx +1 -6
- package/src/Article/ArticleContent.tsx +21 -0
- package/src/Article/index.ts +2 -1
- package/src/ContentTypeBadge/ContentTypeBadge.stories.tsx +8 -7
- package/src/Embed/ImageEmbed.tsx +3 -2
- package/src/ErrorMessage/ErrorMessage.tsx +2 -0
- package/src/FileList/File.tsx +63 -28
- package/src/FileList/FileList.stories.tsx +121 -12
- package/src/FileList/FileList.tsx +31 -37
- package/src/FileList/PdfFile.tsx +9 -9
- package/src/FileList/index.ts +3 -7
- package/src/Grid/Grid.stories.tsx +30 -31
- package/src/Grid/Grid.tsx +57 -85
- package/src/Grid/GridParallaxItem.tsx +26 -0
- package/src/Grid/index.ts +3 -1
- package/src/KeyFigure/KeyFigure.stories.tsx +18 -11
- package/src/KeyFigure/KeyFigure.tsx +33 -47
- package/src/LinkBlock/LinkBlockSection.tsx +1 -1
- package/src/RelatedArticleList/RelatedArticleList.tsx +1 -1
- package/src/index.ts +1 -7
- package/es/FileList/Format.js +0 -93
- package/es/Footer/FooterBlock.js +0 -17
- package/es/Footer/index.js +0 -9
- package/es/Messages/MessageBox.js +0 -79
- package/es/Messages/index.js +0 -10
- package/es/utils/resourceTypeColor.js +0 -46
- package/lib/FileList/Format.d.ts +0 -16
- package/lib/FileList/Format.js +0 -98
- package/lib/Footer/FooterBlock.d.ts +0 -13
- package/lib/Footer/FooterBlock.js +0 -24
- package/lib/Footer/index.d.ts +0 -8
- package/lib/Footer/index.js +0 -12
- package/lib/Messages/MessageBox.d.ts +0 -23
- package/lib/Messages/MessageBox.js +0 -87
- package/lib/Messages/index.d.ts +0 -9
- package/lib/Messages/index.js +0 -13
- package/lib/utils/resourceTypeColor.d.ts +0 -9
- package/lib/utils/resourceTypeColor.js +0 -54
- package/src/FileList/Format.tsx +0 -83
- package/src/Footer/Footer.stories.tsx +0 -35
- package/src/Footer/FooterBlock.tsx +0 -30
- package/src/Footer/index.ts +0 -9
- package/src/Messages/MessageBox.stories.tsx +0 -95
- package/src/Messages/MessageBox.tsx +0 -126
- package/src/Messages/index.ts +0 -11
- package/src/utils/resourceTypeColor.tsx +0 -46
|
@@ -6,49 +6,43 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
10
10
|
import { useTranslation } from "react-i18next";
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import { Heading } from "@ndla/typography";
|
|
14
|
-
interface Props extends ComponentProps<"section"> {
|
|
15
|
-
children: ReactNode;
|
|
16
|
-
headingButtons?: ReactNode;
|
|
17
|
-
}
|
|
11
|
+
import { Heading } from "@ndla/primitives";
|
|
12
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
margin: ${spacing.large} 0;
|
|
21
|
-
padding: 0 0 ${spacing.normal} ${spacing.normal};
|
|
22
|
-
border-left: 2px solid ${colors.brand.greyLightest};
|
|
23
|
-
font-family: ${fonts.sans};
|
|
24
|
-
`;
|
|
14
|
+
interface Props extends ComponentPropsWithoutRef<"div"> {}
|
|
25
15
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
`;
|
|
16
|
+
export const FileListWrapper = styled("div", {
|
|
17
|
+
base: {
|
|
18
|
+
display: "flex",
|
|
19
|
+
flexDirection: "column",
|
|
20
|
+
gap: "xsmall",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
34
23
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
export const FileListItem = styled("li", {
|
|
25
|
+
base: {
|
|
26
|
+
background: "surface.infoSubtle",
|
|
27
|
+
borderBlockEnd: "1px solid",
|
|
28
|
+
borderColor: "stroke.default",
|
|
29
|
+
display: "flex",
|
|
30
|
+
justifyContent: "space-between",
|
|
38
31
|
|
|
39
|
-
|
|
32
|
+
_hover: {
|
|
33
|
+
backgroundColor: "surface.infoSubtle.hover",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const FileListEmbed = ({ children, ...rest }: Props) => {
|
|
40
39
|
const { t } = useTranslation();
|
|
41
40
|
return (
|
|
42
|
-
<
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
</FileListHeaderWrapper>
|
|
49
|
-
<FilesList>{children}</FilesList>
|
|
50
|
-
</FileListSection>
|
|
41
|
+
<FileListWrapper {...rest} data-embed-type="file-list">
|
|
42
|
+
<Heading fontWeight="bold" textStyle="heading.small" asChild consumeCss>
|
|
43
|
+
<h3>{t("files")}</h3>
|
|
44
|
+
</Heading>
|
|
45
|
+
<ul>{children}</ul>
|
|
46
|
+
</FileListWrapper>
|
|
51
47
|
);
|
|
52
48
|
};
|
|
53
|
-
|
|
54
|
-
export default FileList;
|
package/src/FileList/PdfFile.tsx
CHANGED
|
@@ -28,15 +28,15 @@ const StyledFigure = styled(Figure, {
|
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
const PdfFile = ({ title, url }: Props) => {
|
|
31
|
+
export const PdfFile = ({ title, url }: Props) => {
|
|
32
32
|
return (
|
|
33
|
-
<
|
|
34
|
-
<
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
<li>
|
|
34
|
+
<StyledFigure>
|
|
35
|
+
<Heading asChild consumeCss textStyle="title.medium">
|
|
36
|
+
<h4>{title}</h4>
|
|
37
|
+
</Heading>
|
|
38
|
+
<StyledIframe title={title} height="1050" src={url} />
|
|
39
|
+
</StyledFigure>
|
|
40
|
+
</li>
|
|
39
41
|
);
|
|
40
42
|
};
|
|
41
|
-
|
|
42
|
-
export default PdfFile;
|
package/src/FileList/index.ts
CHANGED
|
@@ -6,10 +6,6 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
export { default as PdfFile } from "./PdfFile";
|
|
13
|
-
export { default as Format } from "./Format";
|
|
14
|
-
|
|
15
|
-
export default FileList;
|
|
9
|
+
export { FileListEmbed, FileListItem } from "./FileList";
|
|
10
|
+
export { File, FileListElement } from "./File";
|
|
11
|
+
export { PdfFile } from "./PdfFile";
|
|
@@ -6,52 +6,51 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import styled from "@emotion/styled";
|
|
10
|
-
import { DocsContainer, DocsContainerProps } from "@storybook/addon-docs";
|
|
11
9
|
import { Meta, StoryFn } from "@storybook/react";
|
|
12
|
-
import {
|
|
13
|
-
import Grid from "./Grid";
|
|
10
|
+
import { ArticleContent, ArticleWrapper, OneColumn } from "@ndla/ui";
|
|
11
|
+
import { Grid } from "./Grid";
|
|
14
12
|
import { BlogPostStory } from "../BlogPost/BlogPost.stories";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
const GridWrapper = styled.div`
|
|
18
|
-
.docs-story {
|
|
19
|
-
background-color: ${colors.background.lightBlue};
|
|
20
|
-
}
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
const GridDocsContainer = ({ ...props }: DocsContainerProps) => (
|
|
24
|
-
<GridWrapper>
|
|
25
|
-
<DocsContainer {...props} />
|
|
26
|
-
</GridWrapper>
|
|
27
|
-
);
|
|
13
|
+
import { Plain } from "../KeyFigure/KeyFigure.stories";
|
|
28
14
|
|
|
29
15
|
export default {
|
|
30
16
|
title: "Components/Grid",
|
|
31
17
|
component: Grid,
|
|
32
18
|
tags: ["autodocs"],
|
|
33
19
|
parameters: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
container: GridDocsContainer,
|
|
37
|
-
},
|
|
20
|
+
inlineStories: true,
|
|
21
|
+
layout: "fullscreen",
|
|
38
22
|
},
|
|
39
23
|
args: {
|
|
40
|
-
columns: "
|
|
24
|
+
columns: "3",
|
|
41
25
|
border: "none",
|
|
42
|
-
background: "
|
|
26
|
+
background: "gray",
|
|
43
27
|
},
|
|
28
|
+
decorators: [
|
|
29
|
+
(Story) => (
|
|
30
|
+
<OneColumn wide>
|
|
31
|
+
<ArticleWrapper>
|
|
32
|
+
<ArticleContent>
|
|
33
|
+
<Story />
|
|
34
|
+
</ArticleContent>
|
|
35
|
+
</ArticleWrapper>
|
|
36
|
+
</OneColumn>
|
|
37
|
+
),
|
|
38
|
+
],
|
|
44
39
|
} as Meta<typeof Grid>;
|
|
45
40
|
|
|
41
|
+
const keyFigureArgs = [
|
|
42
|
+
{ title: "22 000+", subtitle: "Tilgjengelige ressurser" },
|
|
43
|
+
{ title: "149", subtitle: "Eksamensfag" },
|
|
44
|
+
{ title: "500", subtitle: "Tverrfaglige ressurser" },
|
|
45
|
+
{ title: "0", subtitle: "Dårlige ideer" },
|
|
46
|
+
];
|
|
47
|
+
|
|
46
48
|
export const GridKeyPerformanceStory: StoryFn<typeof Grid> = ({ ...args }) => {
|
|
47
49
|
const columns = args.columns === "2x2" ? 4 : parseInt(args.columns);
|
|
48
|
-
const items = new Array(columns).fill(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
image={KeyFigureStory.args?.image!}
|
|
53
|
-
/>,
|
|
54
|
-
);
|
|
50
|
+
const items = new Array(columns).fill(0).map((_, idx) => {
|
|
51
|
+
const args = keyFigureArgs[idx % keyFigureArgs.length];
|
|
52
|
+
return <Plain key={idx} {...args} />;
|
|
53
|
+
});
|
|
55
54
|
return <Grid {...args}>{items}</Grid>;
|
|
56
55
|
};
|
|
57
56
|
|
|
@@ -61,7 +60,7 @@ export const GridBlogPostStory: StoryFn<typeof Grid> = ({ ...args }) => {
|
|
|
61
60
|
<BlogPostStory
|
|
62
61
|
metaImage={BlogPostStory.args?.metaImage!}
|
|
63
62
|
title={BlogPostStory.args?.title!}
|
|
64
|
-
size={
|
|
63
|
+
size={"normal"}
|
|
65
64
|
headingLevel={BlogPostStory.args?.headingLevel}
|
|
66
65
|
url={BlogPostStory.args?.url!}
|
|
67
66
|
author={BlogPostStory.args?.author}
|
package/src/Grid/Grid.tsx
CHANGED
|
@@ -6,103 +6,75 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import styled from "@
|
|
11
|
-
|
|
9
|
+
import { ReactNode } from "react";
|
|
10
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
11
|
+
|
|
12
|
+
const GridContainer = styled("div", {
|
|
13
|
+
base: {
|
|
14
|
+
display: "grid",
|
|
15
|
+
justifyContent: "center",
|
|
16
|
+
borderRadius: "xsmall",
|
|
17
|
+
padding: "xsmall",
|
|
18
|
+
gridRowGap: "large",
|
|
19
|
+
gridColumnGap: "medium",
|
|
20
|
+
width: "100%",
|
|
21
|
+
backgroundColor: "background.subtle",
|
|
22
|
+
maxWidth: "surface.4xlarge",
|
|
23
|
+
minWidth: "surface.xxsmall",
|
|
24
|
+
gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
|
|
25
|
+
tabletDown: {
|
|
26
|
+
gridTemplateColumns: "repeat(1, minmax(0, 1fr))",
|
|
27
|
+
},
|
|
28
|
+
tabletToDesktop: {
|
|
29
|
+
gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
|
|
30
|
+
"& > div:nth-child(3):last-child": {
|
|
31
|
+
display: "flex",
|
|
32
|
+
flexFlow: "column",
|
|
33
|
+
justifyContent: "center",
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
gridColumn: "span 2",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
variants: {
|
|
40
|
+
columns: {
|
|
41
|
+
"2": {},
|
|
42
|
+
"2x2": {},
|
|
43
|
+
"3": { desktop: { gridTemplateColumns: "repeat(3, minmax(0, 1fr))" } },
|
|
44
|
+
"4": { desktop: { gridTemplateColumns: "repeat(4, minmax(0, 1fr))" } },
|
|
45
|
+
},
|
|
46
|
+
background: {
|
|
47
|
+
white: { backgroundColor: "surface.default" },
|
|
48
|
+
transparent: { backgroundColor: "transparent" },
|
|
49
|
+
gray: { backgroundColor: "background.subtle" },
|
|
50
|
+
},
|
|
51
|
+
border: {
|
|
52
|
+
lightBlue: {
|
|
53
|
+
border: "1px solid",
|
|
54
|
+
borderColor: "surface.brand.2",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
12
59
|
|
|
13
60
|
export interface GridProps {
|
|
14
|
-
columns: "2" | "4" | "2x2";
|
|
61
|
+
columns: "2" | "3" | "4" | "2x2";
|
|
15
62
|
border?: "none" | "lightBlue";
|
|
16
|
-
background?: "transparent" | "white";
|
|
17
|
-
size?: boolean;
|
|
63
|
+
background?: "transparent" | "white" | "gray";
|
|
18
64
|
children?: ReactNode[];
|
|
19
65
|
}
|
|
20
66
|
|
|
21
|
-
const
|
|
22
|
-
display: grid;
|
|
23
|
-
justify-content: center;
|
|
24
|
-
border-radius: ${misc.borderRadius};
|
|
25
|
-
grid-template-columns: 1fr;
|
|
26
|
-
grid-gap: ${spacing.normal};
|
|
27
|
-
padding: ${spacing.normal};
|
|
28
|
-
margin-bottom: ${spacing.normal};
|
|
29
|
-
clear: both;
|
|
30
|
-
|
|
31
|
-
${mq.range({ until: breakpoints.tabletWide })} {
|
|
32
|
-
&[data-columns="2x2"],
|
|
33
|
-
&[data-columns="3"],
|
|
34
|
-
&[data-columns="4"] {
|
|
35
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
${mq.range({ until: breakpoints.desktop })} {
|
|
40
|
-
> div:nth-child(3):last-child {
|
|
41
|
-
display: flex;
|
|
42
|
-
flex-flow: column;
|
|
43
|
-
justify-content: center;
|
|
44
|
-
align-items: center;
|
|
45
|
-
grid-column: span 2;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
${mq.range({ from: breakpoints.tabletWide })} {
|
|
50
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
51
|
-
|
|
52
|
-
&[data-columns="3"] {
|
|
53
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
&[data-columns="4"] {
|
|
57
|
-
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
&[data-frontpage="true"] {
|
|
62
|
-
grid-gap: ${spacing.large};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
&[data-border="lightBlue"] {
|
|
66
|
-
border: 1px solid ${colors.brand.lighter};
|
|
67
|
-
}
|
|
68
|
-
&[data-background="white"] {
|
|
69
|
-
background-color: ${colors.white};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
p {
|
|
73
|
-
word-break: break-word;
|
|
74
|
-
margin-top: 0px;
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
|
|
78
|
-
const Grid = ({ columns, border, children, background, size, ...rest }: GridProps) => {
|
|
67
|
+
export const Grid = ({ columns, border, children, background = "gray" }: GridProps) => {
|
|
79
68
|
const amountOfColumns = children?.length === 3 ? "3" : columns;
|
|
80
69
|
|
|
81
70
|
return (
|
|
82
71
|
<GridContainer
|
|
83
|
-
data-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
{...rest}
|
|
72
|
+
data-embed-type="grid"
|
|
73
|
+
border={border === "none" ? undefined : border}
|
|
74
|
+
columns={amountOfColumns}
|
|
75
|
+
background={background}
|
|
88
76
|
>
|
|
89
77
|
{children}
|
|
90
78
|
</GridContainer>
|
|
91
79
|
);
|
|
92
80
|
};
|
|
93
|
-
|
|
94
|
-
const StyledGridParallaxItem = styled.div`
|
|
95
|
-
position: relative;
|
|
96
|
-
> div {
|
|
97
|
-
top: var(--masthead-height, 0px);
|
|
98
|
-
position: sticky;
|
|
99
|
-
}
|
|
100
|
-
`;
|
|
101
|
-
|
|
102
|
-
export const GridParallaxItem = ({ children, ...rest }: HTMLAttributes<HTMLDivElement>) => (
|
|
103
|
-
<StyledGridParallaxItem {...rest}>
|
|
104
|
-
<div>{children}</div>
|
|
105
|
-
</StyledGridParallaxItem>
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
export default Grid;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-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 { HTMLAttributes } from "react";
|
|
10
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
11
|
+
|
|
12
|
+
const StyledGridParallaxItem = styled("div", {
|
|
13
|
+
base: {
|
|
14
|
+
position: "relative",
|
|
15
|
+
"& > div": {
|
|
16
|
+
top: "var(--masthead-height, 0px)",
|
|
17
|
+
position: "sticky",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const GridParallaxItem = ({ children, ...rest }: HTMLAttributes<HTMLDivElement>) => (
|
|
23
|
+
<StyledGridParallaxItem {...rest} data-embed-type="grid-parallax">
|
|
24
|
+
<div>{children}</div>
|
|
25
|
+
</StyledGridParallaxItem>
|
|
26
|
+
);
|
package/src/Grid/index.ts
CHANGED
|
@@ -6,15 +6,12 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { Meta, StoryFn } from "@storybook/react";
|
|
9
|
+
import { Meta, StoryFn, StoryObj } from "@storybook/react";
|
|
10
10
|
import KeyFigure from "./KeyFigure";
|
|
11
|
+
|
|
11
12
|
const args = {
|
|
12
|
-
title: "
|
|
13
|
-
subtitle:
|
|
14
|
-
image: {
|
|
15
|
-
alt: "Nøkkeltall tverrfaglig",
|
|
16
|
-
src: "https://api.test.ndla.no/image-api/raw/wMowCjRg.svg",
|
|
17
|
-
},
|
|
13
|
+
title: "22 000+",
|
|
14
|
+
subtitle: "Tilgjengelige ressurser",
|
|
18
15
|
};
|
|
19
16
|
|
|
20
17
|
export default {
|
|
@@ -24,12 +21,22 @@ export default {
|
|
|
24
21
|
parameters: {
|
|
25
22
|
layout: "centered",
|
|
26
23
|
},
|
|
27
|
-
args
|
|
24
|
+
args,
|
|
28
25
|
} as Meta<typeof KeyFigure>;
|
|
29
26
|
|
|
30
|
-
export const
|
|
27
|
+
export const Plain: StoryFn<typeof KeyFigure> = ({ ...args }) => {
|
|
31
28
|
return <KeyFigure {...args} />;
|
|
32
29
|
};
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
export const WithImageAndHTML: StoryObj<typeof KeyFigure> = {
|
|
32
|
+
args: {
|
|
33
|
+
title: "<i>500</i>",
|
|
34
|
+
subtitle: `<span lang="nn">TVERRFAGLEGE</span> RESSURSER`,
|
|
35
|
+
image: {
|
|
36
|
+
alt: "Nøkkeltall tverrfaglig",
|
|
37
|
+
src: "https://api.test.ndla.no/image-api/raw/wMowCjRg.svg",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
Plain.args = args;
|
|
@@ -7,51 +7,37 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import parse from "html-react-parser";
|
|
10
|
-
import styled from "@
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
const SubTitleWrapper = styled.div`
|
|
44
|
-
overflow-wrap: "break-word";
|
|
45
|
-
text-align: center;
|
|
46
|
-
${fonts.sizes("18px", "29px")};
|
|
47
|
-
color: ${colors.text.primary};
|
|
48
|
-
font-weight: ${fonts.weight.normal};
|
|
49
|
-
font-family: ${fonts.sans};
|
|
50
|
-
|
|
51
|
-
${mq.range({ until: breakpoints.tabletWide })} {
|
|
52
|
-
padding-top: ${spacing.xxsmall};
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
10
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
11
|
+
|
|
12
|
+
const ContentWrapper = styled("div", {
|
|
13
|
+
base: {
|
|
14
|
+
display: "flex",
|
|
15
|
+
flexDirection: "column",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const StyledImage = styled("img", {
|
|
22
|
+
base: {
|
|
23
|
+
height: "surface.3xsmall",
|
|
24
|
+
width: "surface.3xsmall",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const TitleWrapper = styled("div", {
|
|
29
|
+
base: {
|
|
30
|
+
textStyle: "heading.large",
|
|
31
|
+
textAlign: "center",
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const SubTitleWrapper = styled("div", {
|
|
36
|
+
base: {
|
|
37
|
+
textStyle: "title.medium",
|
|
38
|
+
textAlign: "center",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
55
41
|
|
|
56
42
|
interface Props {
|
|
57
43
|
image?: {
|
|
@@ -64,8 +50,8 @@ interface Props {
|
|
|
64
50
|
|
|
65
51
|
const KeyFigure = ({ image, title, subtitle }: Props) => {
|
|
66
52
|
return (
|
|
67
|
-
<ContentWrapper>
|
|
68
|
-
<StyledImage src={`${image?.src}?width=150`} width={150} height={150} alt={image?.alt} />
|
|
53
|
+
<ContentWrapper data-embed-type="key-figure">
|
|
54
|
+
{image && <StyledImage src={`${image?.src}?width=150`} width={150} height={150} alt={image?.alt} />}
|
|
69
55
|
<TitleWrapper>{parse(title)}</TitleWrapper>
|
|
70
56
|
<SubTitleWrapper>{parse(subtitle)}</SubTitleWrapper>
|
|
71
57
|
</ContentWrapper>
|
|
@@ -24,7 +24,7 @@ const StyledList = styled("ul", {
|
|
|
24
24
|
|
|
25
25
|
const LinkBlockSection = ({ children, ...rest }: Props) => {
|
|
26
26
|
return (
|
|
27
|
-
<nav {...rest}>
|
|
27
|
+
<nav {...rest} data-embed-type="link-block-list">
|
|
28
28
|
<StyledList>
|
|
29
29
|
{Children.map(children, (child) => (
|
|
30
30
|
<li>{child}</li>
|
package/src/index.ts
CHANGED
|
@@ -52,19 +52,13 @@ export { default as RelatedArticleList, RelatedArticle } from "./RelatedArticleL
|
|
|
52
52
|
|
|
53
53
|
export { ErrorResourceAccessDenied, default as ErrorMessage } from "./ErrorMessage";
|
|
54
54
|
|
|
55
|
-
export {
|
|
55
|
+
export { FileListEmbed, File, PdfFile, FileListItem, FileListElement } from "./FileList";
|
|
56
56
|
|
|
57
57
|
export { default as FactBox } from "./FactBox";
|
|
58
58
|
|
|
59
59
|
export type { ContentTypeHeroProps } from "./ContentTypeHero";
|
|
60
60
|
export { ContentTypeHero } from "./ContentTypeHero";
|
|
61
61
|
|
|
62
|
-
export { FooterBlock } from "./Footer";
|
|
63
|
-
|
|
64
|
-
export { default as resourceTypeColor } from "./utils/resourceTypeColor";
|
|
65
|
-
|
|
66
|
-
export { MessageBox } from "./Messages";
|
|
67
|
-
|
|
68
62
|
export { ResourceBox } from "./ResourceBox";
|
|
69
63
|
|
|
70
64
|
export { default as AudioPlayer } from "./AudioPlayer";
|