@ndla/ui 33.0.5 → 33.0.7
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/Footer/FooterPrivacy.js +19 -8
- package/es/Image/Image.js +5 -5
- package/es/Image/ImageLink.js +5 -5
- package/es/ResourcesWrapper/ResourcesTopicTitle.js +63 -31
- package/es/ResourcesWrapper/ResourcesWrapper.js +12 -16
- package/es/ResourcesWrapper/index.js +0 -1
- package/es/SearchTypeResult/SearchItemList.js +11 -11
- package/es/Subject/Subject.js +15 -21
- package/es/Subject/index.js +1 -6
- package/es/all.css +1 -1
- package/es/index.js +2 -3
- package/es/locale/messages-en.js +1 -1
- package/es/locale/messages-nb.js +2 -2
- package/es/locale/messages-nn.js +1 -1
- package/es/locale/messages-se.js +1 -1
- package/es/locale/messages-sma.js +1 -1
- package/lib/Footer/FooterPrivacy.js +17 -8
- package/lib/Image/Image.js +5 -5
- package/lib/Image/ImageLink.js +5 -5
- package/lib/ResourcesWrapper/ResourcesTopicTitle.js +62 -30
- package/lib/ResourcesWrapper/ResourcesWrapper.d.ts +4 -6
- package/lib/ResourcesWrapper/ResourcesWrapper.js +13 -17
- package/lib/ResourcesWrapper/index.d.ts +0 -1
- package/lib/ResourcesWrapper/index.js +0 -7
- package/lib/SearchTypeResult/SearchItemList.js +11 -11
- package/lib/Subject/Subject.d.ts +0 -3
- package/lib/Subject/Subject.js +16 -23
- package/lib/Subject/index.d.ts +1 -6
- package/lib/Subject/index.js +0 -41
- package/lib/all.css +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +0 -57
- package/lib/locale/messages-en.js +1 -1
- package/lib/locale/messages-nb.js +2 -2
- package/lib/locale/messages-nn.js +1 -1
- package/lib/locale/messages-se.js +1 -1
- package/lib/locale/messages-sma.js +1 -1
- package/package.json +6 -6
- package/src/Footer/FooterPrivacy.tsx +14 -5
- package/src/Image/Image.tsx +0 -2
- package/src/Image/ImageLink.tsx +0 -2
- package/src/Image/__tests__/__snapshots__/Image-test.jsx.snap +0 -6
- package/src/LetterFilter/LetterFilter.stories.tsx +1 -1
- package/src/MyNdla/Resource/Folder.stories.mdx +1 -1
- package/src/Resource/BlockResource.stories.mdx +1 -1
- package/src/Resource/Resource.stories.mdx +1 -1
- package/src/ResourcesWrapper/ResourcesTopicTitle.tsx +118 -15
- package/src/ResourcesWrapper/ResourcesWrapper.tsx +14 -13
- package/src/ResourcesWrapper/index.ts +0 -1
- package/src/SearchTypeResult/SearchItemList.tsx +1 -0
- package/src/Subject/Subject.tsx +0 -4
- package/src/Subject/index.ts +0 -6
- package/src/index.ts +1 -9
- package/src/locale/messages-en.ts +1 -1
- package/src/locale/messages-nb.ts +2 -2
- package/src/locale/messages-nn.ts +1 -1
- package/src/locale/messages-se.ts +1 -1
- package/src/locale/messages-sma.ts +1 -1
- package/src/main.scss +0 -2
- package/es/ResourcesWrapper/ResourcesTitle.js +0 -28
- package/es/Subject/SubjectAbout.js +0 -81
- package/es/Subject/SubjectArchive.js +0 -203
- package/es/Subject/SubjectLinks.js +0 -53
- package/es/Subject/SubjectShortcuts.js +0 -136
- package/es/TopicIntroductionList/TopicIntroduction.js +0 -90
- package/es/TopicIntroductionList/TopicIntroductionList.js +0 -68
- package/es/TopicIntroductionList/TopicIntroductionShortcuts.js +0 -86
- package/es/TopicIntroductionList/TopicShortcutItem.js +0 -43
- package/es/TopicIntroductionList/index.js +0 -10
- package/lib/ResourcesWrapper/ResourcesTitle.d.ts +0 -13
- package/lib/ResourcesWrapper/ResourcesTitle.js +0 -27
- package/lib/Subject/SubjectAbout.d.ts +0 -12
- package/lib/Subject/SubjectAbout.js +0 -88
- package/lib/Subject/SubjectArchive.d.ts +0 -32
- package/lib/Subject/SubjectArchive.js +0 -211
- package/lib/Subject/SubjectLinks.d.ts +0 -12
- package/lib/Subject/SubjectLinks.js +0 -60
- package/lib/Subject/SubjectShortcuts.d.ts +0 -34
- package/lib/Subject/SubjectShortcuts.js +0 -137
- package/lib/TopicIntroductionList/TopicIntroduction.d.ts +0 -21
- package/lib/TopicIntroductionList/TopicIntroduction.js +0 -97
- package/lib/TopicIntroductionList/TopicIntroductionList.d.ts +0 -35
- package/lib/TopicIntroductionList/TopicIntroductionList.js +0 -67
- package/lib/TopicIntroductionList/TopicIntroductionShortcuts.d.ts +0 -8
- package/lib/TopicIntroductionList/TopicIntroductionShortcuts.js +0 -96
- package/lib/TopicIntroductionList/TopicShortcutItem.d.ts +0 -6
- package/lib/TopicIntroductionList/TopicShortcutItem.js +0 -50
- package/lib/TopicIntroductionList/index.d.ts +0 -9
- package/lib/TopicIntroductionList/index.js +0 -17
- package/src/ResourcesWrapper/ResourcesTitle.tsx +0 -23
- package/src/ResourcesWrapper/component.resources.scss +0 -216
- package/src/Subject/SubjectAbout.tsx +0 -116
- package/src/Subject/SubjectArchive.tsx +0 -221
- package/src/Subject/SubjectLinks.tsx +0 -47
- package/src/Subject/SubjectShortcuts.tsx +0 -158
- package/src/TopicIntroductionList/TopicIntroduction.tsx +0 -100
- package/src/TopicIntroductionList/TopicIntroductionList.tsx +0 -93
- package/src/TopicIntroductionList/TopicIntroductionShortcuts.tsx +0 -71
- package/src/TopicIntroductionList/TopicShortcutItem.tsx +0 -29
- package/src/TopicIntroductionList/component.topic-introduction.scss +0 -111
- package/src/TopicIntroductionList/component.topic-shortcuts.scss +0 -90
- package/src/TopicIntroductionList/index.ts +0 -11
|
@@ -1,158 +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
|
-
*/
|
|
8
|
-
|
|
9
|
-
import React, { Component } from 'react';
|
|
10
|
-
import styled from '@emotion/styled';
|
|
11
|
-
import { colors, fonts, spacing } from '@ndla/core';
|
|
12
|
-
import { Forward } from '@ndla/icons/common';
|
|
13
|
-
import SafeLink from '@ndla/safelink';
|
|
14
|
-
import { SubjectSectionTitle } from './Subject';
|
|
15
|
-
import Fade from '../Animation/Fade';
|
|
16
|
-
import { HeadingLevel } from '../types';
|
|
17
|
-
|
|
18
|
-
const SubjectShortcutsSection = styled.section`
|
|
19
|
-
margin-bottom: ${spacing.large};
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
const StyledList = styled.ul`
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-wrap: wrap;
|
|
25
|
-
list-style: none;
|
|
26
|
-
margin: 0;
|
|
27
|
-
padding: 0;
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
const StyledListItem = styled.li`
|
|
31
|
-
display: block;
|
|
32
|
-
margin-right: 9px;
|
|
33
|
-
margin-bottom: 9px;
|
|
34
|
-
a {
|
|
35
|
-
display: block;
|
|
36
|
-
background: ${colors.brand.light};
|
|
37
|
-
box-shadow: none;
|
|
38
|
-
border-radius: 5px;
|
|
39
|
-
${fonts.sizes('18px', '23px')};
|
|
40
|
-
font-weight: ${fonts.weight.semibold};
|
|
41
|
-
color: ${colors.brand.dark};
|
|
42
|
-
padding: 9px 20px;
|
|
43
|
-
&:hover,
|
|
44
|
-
&:active,
|
|
45
|
-
&:focus {
|
|
46
|
-
background-color: ${colors.brand.primary};
|
|
47
|
-
color: ${colors.white};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
`;
|
|
51
|
-
|
|
52
|
-
const StyledButton = styled.button`
|
|
53
|
-
display: flex;
|
|
54
|
-
background: none;
|
|
55
|
-
border: 0;
|
|
56
|
-
align-items: center;
|
|
57
|
-
padding: 0;
|
|
58
|
-
color: ${colors.brand};
|
|
59
|
-
margin-top: ${spacing.normal};
|
|
60
|
-
cursor: pointer;
|
|
61
|
-
.c-icon {
|
|
62
|
-
width: 18px;
|
|
63
|
-
height: 18px;
|
|
64
|
-
margin-right: ${spacing.xsmall};
|
|
65
|
-
}
|
|
66
|
-
span {
|
|
67
|
-
${fonts.sizes('14px', '18px')};
|
|
68
|
-
}
|
|
69
|
-
`;
|
|
70
|
-
|
|
71
|
-
interface Props {
|
|
72
|
-
links: {
|
|
73
|
-
url: string;
|
|
74
|
-
text: string;
|
|
75
|
-
}[];
|
|
76
|
-
headingLevel: HeadingLevel;
|
|
77
|
-
messages: {
|
|
78
|
-
heading: string;
|
|
79
|
-
showMore: string;
|
|
80
|
-
showLess: string;
|
|
81
|
-
};
|
|
82
|
-
defaultVisableCount: number;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
interface State {
|
|
86
|
-
visibleCount: number;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const defaultVisableCount = 6;
|
|
90
|
-
|
|
91
|
-
class SubjectShortcuts extends Component<Props, State> {
|
|
92
|
-
constructor(props: Props) {
|
|
93
|
-
super(props);
|
|
94
|
-
this.state = {
|
|
95
|
-
visibleCount: props.defaultVisableCount,
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
this.handleOnExpand = this.handleOnExpand.bind(this);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
handleOnExpand(expanded: boolean) {
|
|
102
|
-
const newVisibleCount = expanded ? this.props.links.length : this.props.defaultVisableCount;
|
|
103
|
-
|
|
104
|
-
this.setState({
|
|
105
|
-
visibleCount: newVisibleCount,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
render() {
|
|
110
|
-
const { links, messages, defaultVisableCount, headingLevel } = this.props;
|
|
111
|
-
const id = 'subject-shortcut';
|
|
112
|
-
|
|
113
|
-
const showExpand = defaultVisableCount < links.length;
|
|
114
|
-
let button = null;
|
|
115
|
-
let filteredLinks = this.props.links;
|
|
116
|
-
|
|
117
|
-
if (showExpand) {
|
|
118
|
-
const isExpanded = this.state.visibleCount > defaultVisableCount;
|
|
119
|
-
const buttonText = isExpanded ? messages.showLess : messages.showMore;
|
|
120
|
-
|
|
121
|
-
button = (
|
|
122
|
-
<StyledButton
|
|
123
|
-
type="button"
|
|
124
|
-
aria-expanded={isExpanded}
|
|
125
|
-
aria-controls={id}
|
|
126
|
-
onClick={() => this.handleOnExpand(!isExpanded)}>
|
|
127
|
-
<Forward />
|
|
128
|
-
<span>{buttonText}</span>
|
|
129
|
-
</StyledButton>
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
filteredLinks = this.props.links.filter((link, index) => index < this.state.visibleCount);
|
|
133
|
-
}
|
|
134
|
-
return (
|
|
135
|
-
<SubjectShortcutsSection>
|
|
136
|
-
<SubjectSectionTitle headingLevel={headingLevel}>{messages.heading}</SubjectSectionTitle>
|
|
137
|
-
<nav id={id}>
|
|
138
|
-
<StyledList>
|
|
139
|
-
{filteredLinks.map((link) => (
|
|
140
|
-
<Fade key={link.url} show={true}>
|
|
141
|
-
<StyledListItem>
|
|
142
|
-
<SafeLink to={link.url}>{link.text}</SafeLink>
|
|
143
|
-
</StyledListItem>
|
|
144
|
-
</Fade>
|
|
145
|
-
))}
|
|
146
|
-
</StyledList>
|
|
147
|
-
</nav>
|
|
148
|
-
{button}
|
|
149
|
-
</SubjectShortcutsSection>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
static defaultProps = {
|
|
154
|
-
defaultVisableCount,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export default SubjectShortcuts;
|
|
@@ -1,100 +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
|
-
import React from 'react';
|
|
10
|
-
import BEMHelper from 'react-bem-helper';
|
|
11
|
-
import { useTranslation } from 'react-i18next';
|
|
12
|
-
import { Additional, Core } from '@ndla/icons/common';
|
|
13
|
-
import Tooltip from '@ndla/tooltip';
|
|
14
|
-
import SafeLink from '@ndla/safelink';
|
|
15
|
-
import TopicIntroductionShortcuts from './TopicIntroductionShortcuts';
|
|
16
|
-
import { Shortcut, Topic } from './TopicIntroductionList';
|
|
17
|
-
|
|
18
|
-
const topicClasses = new BEMHelper({
|
|
19
|
-
prefix: 'c-',
|
|
20
|
-
name: 'topic-introduction',
|
|
21
|
-
outputIsString: true,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
interface Props {
|
|
25
|
-
additional?: boolean;
|
|
26
|
-
showAdditionalCores?: boolean;
|
|
27
|
-
topic: Topic;
|
|
28
|
-
toTopic: (id: string) => string;
|
|
29
|
-
subjectPage?: boolean;
|
|
30
|
-
shortcuts?: Shortcut[];
|
|
31
|
-
twoColumns?: boolean;
|
|
32
|
-
shortcutAlwaysExpanded?: boolean;
|
|
33
|
-
id: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const TopicIntroduction = ({
|
|
37
|
-
toTopic,
|
|
38
|
-
topic,
|
|
39
|
-
subjectPage,
|
|
40
|
-
shortcuts,
|
|
41
|
-
shortcutAlwaysExpanded,
|
|
42
|
-
additional = false,
|
|
43
|
-
showAdditionalCores = false,
|
|
44
|
-
id,
|
|
45
|
-
}: Props) => {
|
|
46
|
-
const { t } = useTranslation();
|
|
47
|
-
const contentTypeDescription = t(additional ? 'resource.tooltipAdditionalTopic' : 'resource.tooltipCoreTopic');
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<li
|
|
51
|
-
className={topicClasses('item', {
|
|
52
|
-
subjectPage: !!subjectPage,
|
|
53
|
-
additional,
|
|
54
|
-
showAdditionalCores,
|
|
55
|
-
})}>
|
|
56
|
-
<article className={topicClasses('body')}>
|
|
57
|
-
<div className={topicClasses('heading-wrapper')}>
|
|
58
|
-
<h1 className={topicClasses('header')}>
|
|
59
|
-
<SafeLink to={toTopic(topic.id)} aria-describedby={id}>
|
|
60
|
-
{topic.name}
|
|
61
|
-
</SafeLink>
|
|
62
|
-
</h1>
|
|
63
|
-
<span id={id} hidden>
|
|
64
|
-
{contentTypeDescription}
|
|
65
|
-
</span>
|
|
66
|
-
{additional && (
|
|
67
|
-
<Tooltip tooltip={t('resource.tooltipAdditionalTopic')}>
|
|
68
|
-
<Additional className="c-icon--20 u-margin-left-tiny" />
|
|
69
|
-
</Tooltip>
|
|
70
|
-
)}
|
|
71
|
-
{!additional && showAdditionalCores && (
|
|
72
|
-
<Tooltip tooltip={t('resource.tooltipCoreTopic')}>
|
|
73
|
-
<Core className="c-icon--20 u-margin-left-tiny" />
|
|
74
|
-
</Tooltip>
|
|
75
|
-
)}
|
|
76
|
-
</div>
|
|
77
|
-
<div className={topicClasses('content-wrapper')}>
|
|
78
|
-
<div>
|
|
79
|
-
{/* Since topic introduction is already escaped from the api
|
|
80
|
-
we run into a double escaping issues as React escapes all strings.
|
|
81
|
-
Use dangerouslySetInnerHTML to circumvent the issue */}
|
|
82
|
-
<p dangerouslySetInnerHTML={{ __html: topic.introduction }} />
|
|
83
|
-
{shortcuts && (
|
|
84
|
-
<TopicIntroductionShortcuts
|
|
85
|
-
alwaysExpanded={shortcutAlwaysExpanded}
|
|
86
|
-
id={`${topic.id}_shortcuts`}
|
|
87
|
-
shortcuts={shortcuts}
|
|
88
|
-
/>
|
|
89
|
-
)}
|
|
90
|
-
</div>
|
|
91
|
-
{topic.metaImage && (
|
|
92
|
-
<div>
|
|
93
|
-
<img src={topic.metaImage.url} alt={topic.metaImage.alt} />
|
|
94
|
-
</div>
|
|
95
|
-
)}
|
|
96
|
-
</div>
|
|
97
|
-
</article>
|
|
98
|
-
</li>
|
|
99
|
-
);
|
|
100
|
-
};
|
|
@@ -1,93 +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
|
-
import React from 'react';
|
|
10
|
-
import BEMHelper from 'react-bem-helper';
|
|
11
|
-
import { useTranslation } from 'react-i18next';
|
|
12
|
-
import NoContentBox from '../NoContentBox';
|
|
13
|
-
import { TopicIntroduction } from './TopicIntroduction';
|
|
14
|
-
|
|
15
|
-
const topicClasses = new BEMHelper({
|
|
16
|
-
prefix: 'c-',
|
|
17
|
-
name: 'topic-introduction',
|
|
18
|
-
outputIsString: true,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export interface Shortcut {
|
|
22
|
-
id: string | number;
|
|
23
|
-
tooltip: string;
|
|
24
|
-
contentType: string;
|
|
25
|
-
url: string;
|
|
26
|
-
count: number;
|
|
27
|
-
}
|
|
28
|
-
export interface Topic {
|
|
29
|
-
name: string;
|
|
30
|
-
id: string;
|
|
31
|
-
additional?: boolean;
|
|
32
|
-
shortcuts?: Shortcut[];
|
|
33
|
-
introduction: string;
|
|
34
|
-
metaImage?: {
|
|
35
|
-
url?: string;
|
|
36
|
-
alt?: string;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface Props {
|
|
41
|
-
toTopic: (id: string) => string;
|
|
42
|
-
topics: Topic[];
|
|
43
|
-
twoColumns?: boolean;
|
|
44
|
-
shortcutAlwaysExpanded?: boolean;
|
|
45
|
-
showAdditionalCores?: boolean;
|
|
46
|
-
toggleAdditionalCores?: () => void;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const TopicIntroductionList = ({
|
|
50
|
-
topics,
|
|
51
|
-
twoColumns = false,
|
|
52
|
-
shortcutAlwaysExpanded = false,
|
|
53
|
-
showAdditionalCores = false,
|
|
54
|
-
toggleAdditionalCores,
|
|
55
|
-
...rest
|
|
56
|
-
}: Props) => {
|
|
57
|
-
const { t } = useTranslation();
|
|
58
|
-
const renderAdditionalTopicsTrigger =
|
|
59
|
-
!showAdditionalCores &&
|
|
60
|
-
topics.filter((topic) => topic.additional).length > 0 &&
|
|
61
|
-
topics.filter((topic) => !topic.additional).length === 0;
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<ul className={topicClasses('list', { twoColumns })}>
|
|
65
|
-
{topics.map((topic, index) => {
|
|
66
|
-
const { shortcuts, additional } = topic;
|
|
67
|
-
return (
|
|
68
|
-
<TopicIntroduction
|
|
69
|
-
key={topic.id}
|
|
70
|
-
{...rest}
|
|
71
|
-
topic={topic}
|
|
72
|
-
shortcuts={shortcuts}
|
|
73
|
-
additional={additional}
|
|
74
|
-
showAdditionalCores={showAdditionalCores}
|
|
75
|
-
shortcutAlwaysExpanded={shortcutAlwaysExpanded}
|
|
76
|
-
id={`${topic.id}_${index}`}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
})}
|
|
80
|
-
{renderAdditionalTopicsTrigger && (
|
|
81
|
-
<li>
|
|
82
|
-
<NoContentBox
|
|
83
|
-
onClick={toggleAdditionalCores}
|
|
84
|
-
text={t('resource.noCoreResourcesAvailableUnspecific')}
|
|
85
|
-
buttonText={t('resource.activateAdditionalResources')}
|
|
86
|
-
/>
|
|
87
|
-
</li>
|
|
88
|
-
)}
|
|
89
|
-
</ul>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default TopicIntroductionList;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import BEMHelper from 'react-bem-helper';
|
|
4
|
-
import { Forward } from '@ndla/icons/common';
|
|
5
|
-
|
|
6
|
-
import ShortcutItem from './TopicShortcutItem';
|
|
7
|
-
|
|
8
|
-
import { Shortcut } from './TopicIntroductionList';
|
|
9
|
-
|
|
10
|
-
const classes = new BEMHelper({
|
|
11
|
-
name: 'topic-shortcuts',
|
|
12
|
-
prefix: 'c-',
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
interface Props {
|
|
16
|
-
id: string;
|
|
17
|
-
alwaysExpanded?: boolean;
|
|
18
|
-
shortcuts: Shortcut[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const TopicIntroductionShortcuts = ({ id, alwaysExpanded = false, shortcuts }: Props) => {
|
|
22
|
-
const { t } = useTranslation();
|
|
23
|
-
const [open, setOpen] = useState(alwaysExpanded);
|
|
24
|
-
const [returned, setReturned] = useState(false);
|
|
25
|
-
const [showButtonText, setShowButtonText] = useState(true);
|
|
26
|
-
|
|
27
|
-
const handleOnToggle = (newOpen: boolean) => {
|
|
28
|
-
setOpen(newOpen);
|
|
29
|
-
setShowButtonText(!newOpen);
|
|
30
|
-
setReturned(!newOpen);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
let onMouseEnter = undefined;
|
|
34
|
-
let onMouseLeave = undefined;
|
|
35
|
-
|
|
36
|
-
let buttonView = null;
|
|
37
|
-
|
|
38
|
-
if (!alwaysExpanded) {
|
|
39
|
-
onMouseEnter = () => handleOnToggle(true);
|
|
40
|
-
onMouseLeave = () => handleOnToggle(false);
|
|
41
|
-
|
|
42
|
-
buttonView = (
|
|
43
|
-
<button
|
|
44
|
-
type="button"
|
|
45
|
-
aria-expanded={open}
|
|
46
|
-
aria-label={t('resource.label')}
|
|
47
|
-
aria-controls={id}
|
|
48
|
-
{...classes('button', returned ? 're-enter' : '')}
|
|
49
|
-
onClick={() => handleOnToggle(!open)}>
|
|
50
|
-
<Forward />
|
|
51
|
-
{showButtonText && <span {...classes('label')}>{t('resource.label')}</span>}
|
|
52
|
-
</button>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
return (
|
|
56
|
-
<div onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} {...classes()}>
|
|
57
|
-
{buttonView}
|
|
58
|
-
{open && (
|
|
59
|
-
<ul className={classes('list', open ? 'visible' : '').className}>
|
|
60
|
-
{shortcuts.map((shortcut) => (
|
|
61
|
-
<li {...classes('item')} key={shortcut.id}>
|
|
62
|
-
<ShortcutItem shortcut={shortcut} />
|
|
63
|
-
</li>
|
|
64
|
-
))}
|
|
65
|
-
</ul>
|
|
66
|
-
)}
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export default TopicIntroductionShortcuts;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import BEMHelper from 'react-bem-helper';
|
|
3
|
-
import Tooltip from '@ndla/tooltip';
|
|
4
|
-
import SafeLink from '@ndla/safelink';
|
|
5
|
-
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import ContentTypeBadge from '../ContentTypeBadge';
|
|
7
|
-
import { Shortcut } from './TopicIntroductionList';
|
|
8
|
-
|
|
9
|
-
const classes = new BEMHelper({
|
|
10
|
-
name: 'topic-shortcuts',
|
|
11
|
-
prefix: 'c-',
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
interface Props {
|
|
15
|
-
shortcut: Shortcut;
|
|
16
|
-
}
|
|
17
|
-
const ShortcutItem = ({ shortcut: { id, tooltip, contentType, url, count } }: Props) => {
|
|
18
|
-
const { t } = useTranslation();
|
|
19
|
-
return (
|
|
20
|
-
<Tooltip id={`shortcut-tooltip-${id}`} tooltip={t('resource.shortcutsTooltip', { count })}>
|
|
21
|
-
<SafeLink {...classes('item-link')} aria-label={tooltip} to={url}>
|
|
22
|
-
<ContentTypeBadge type={contentType} size="x-small" background />
|
|
23
|
-
<span {...classes('count')}>{count}</span>
|
|
24
|
-
</SafeLink>
|
|
25
|
-
</Tooltip>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default ShortcutItem;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
** TOPIC INTRODUCTION
|
|
3
|
-
** Topic list with introductions
|
|
4
|
-
**/
|
|
5
|
-
|
|
6
|
-
@import './component.topic-shortcuts';
|
|
7
|
-
|
|
8
|
-
.c-topic-introduction {
|
|
9
|
-
&__text {
|
|
10
|
-
padding: $spacing 0;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
&__heading-wrapper {
|
|
14
|
-
display: flex;
|
|
15
|
-
width: 100%;
|
|
16
|
-
justify-content: space-between;
|
|
17
|
-
align-items: center;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&__list {
|
|
21
|
-
list-style: none;
|
|
22
|
-
margin: $spacing--small 0 $spacing--medium 0;
|
|
23
|
-
padding: 0;
|
|
24
|
-
|
|
25
|
-
&--twoColumns {
|
|
26
|
-
@include mq(850px) {
|
|
27
|
-
display: flex;
|
|
28
|
-
flex-wrap: wrap;
|
|
29
|
-
border-bottom: none;
|
|
30
|
-
margin-bottom: 0;
|
|
31
|
-
justify-content: space-between;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
& > li {
|
|
35
|
-
flex-basis: calc(50% - 52px);
|
|
36
|
-
margin-right: 52px;
|
|
37
|
-
box-sizing: border-box;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&__body {
|
|
43
|
-
width: 100%;
|
|
44
|
-
}
|
|
45
|
-
&__content-wrapper {
|
|
46
|
-
display: flex;
|
|
47
|
-
justify-content: space-between;
|
|
48
|
-
align-items: flex-start;
|
|
49
|
-
img {
|
|
50
|
-
max-width: 120px;
|
|
51
|
-
margin-left: $spacing--medium;
|
|
52
|
-
@include mq(tablet) {
|
|
53
|
-
max-width: 160px;
|
|
54
|
-
margin-left: $spacing--medium;
|
|
55
|
-
}
|
|
56
|
-
@include mq(desktop) {
|
|
57
|
-
max-width: 200px;
|
|
58
|
-
margin-left: $spacing--large;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
&__item {
|
|
63
|
-
margin: 0;
|
|
64
|
-
padding-bottom: $spacing;
|
|
65
|
-
@include mq(tablet) {
|
|
66
|
-
padding: 0 $spacing $spacing--medium 0;
|
|
67
|
-
}
|
|
68
|
-
border-bottom: 1px solid $brand-grey--lighter;
|
|
69
|
-
list-style: none;
|
|
70
|
-
background-color: transparent;
|
|
71
|
-
@include inuit-font-size(16px, 26px);
|
|
72
|
-
|
|
73
|
-
p {
|
|
74
|
-
max-width: $max-text-width;
|
|
75
|
-
margin: 0;
|
|
76
|
-
font-family: $font;
|
|
77
|
-
}
|
|
78
|
-
a {
|
|
79
|
-
color: $brand-color;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@include mq(tablet) {
|
|
83
|
-
padding-right: 0;
|
|
84
|
-
}
|
|
85
|
-
margin-top: $spacing;
|
|
86
|
-
margin-bottom: $spacing--small;
|
|
87
|
-
|
|
88
|
-
&--additional {
|
|
89
|
-
display: none;
|
|
90
|
-
}
|
|
91
|
-
&--showAdditionalCores {
|
|
92
|
-
display: block;
|
|
93
|
-
padding: $spacing;
|
|
94
|
-
border: 1px solid $brand-color--tertiary;
|
|
95
|
-
&.c-topic-introduction__item--additional {
|
|
96
|
-
animation-name: fadeIn;
|
|
97
|
-
animation-duration: 0.2s;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
&--additional {
|
|
101
|
-
border: 1px dashed $brand-color--tertiary;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
&__header {
|
|
105
|
-
@include inuit-font-size(18px, 26px);
|
|
106
|
-
text-decoration: none;
|
|
107
|
-
color: $brand-color;
|
|
108
|
-
margin-bottom: $spacing--small;
|
|
109
|
-
margin-top: 0;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
.c-topic-shortcuts {
|
|
2
|
-
@include inuit-font-size(14px);
|
|
3
|
-
min-height: 40px;
|
|
4
|
-
padding: $spacing--small 0 0 0;
|
|
5
|
-
display: none;
|
|
6
|
-
align-items: center;
|
|
7
|
-
|
|
8
|
-
@include mq(tablet) {
|
|
9
|
-
display: inline-flex;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
&:hover {
|
|
13
|
-
cursor: default;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&__button {
|
|
17
|
-
@extend .o-text-link;
|
|
18
|
-
&--re-enter {
|
|
19
|
-
span {
|
|
20
|
-
animation: fadeInLeft 200ms;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
background: transparent;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&__list {
|
|
27
|
-
list-style: none;
|
|
28
|
-
align-items: center;
|
|
29
|
-
padding: 0;
|
|
30
|
-
margin: 0;
|
|
31
|
-
line-height: 1rem;
|
|
32
|
-
display: none;
|
|
33
|
-
&--visible {
|
|
34
|
-
display: flex;
|
|
35
|
-
@include fadeInLeftItems(li, 10);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&__item {
|
|
40
|
-
display: inline-flex;
|
|
41
|
-
align-items: center;
|
|
42
|
-
margin: 0;
|
|
43
|
-
line-height: 1rem;
|
|
44
|
-
border-right: 1px solid $brand-grey--light;
|
|
45
|
-
padding: 0 $spacing--small 0 $spacing--small;
|
|
46
|
-
position: relative;
|
|
47
|
-
|
|
48
|
-
&:first-child {
|
|
49
|
-
padding-left: 0;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
&:last-child {
|
|
53
|
-
border-right: 0;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&__count {
|
|
58
|
-
color: $brand-color--secondary;
|
|
59
|
-
margin-left: $spacing--small / 2;
|
|
60
|
-
@include font-size(16px, 16px);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&__item-link {
|
|
64
|
-
box-shadow: none;
|
|
65
|
-
display: flex;
|
|
66
|
-
align-items: center;
|
|
67
|
-
|
|
68
|
-
&:hover,
|
|
69
|
-
&:focus,
|
|
70
|
-
&:active {
|
|
71
|
-
.c-content-type-badge {
|
|
72
|
-
border-width: 1px;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&__tooltip {
|
|
78
|
-
display: block;
|
|
79
|
-
position: absolute;
|
|
80
|
-
top: -2.5em;
|
|
81
|
-
left: -1em;
|
|
82
|
-
width: 200px;
|
|
83
|
-
line-height: 1rem;
|
|
84
|
-
text-align: center;
|
|
85
|
-
font-weight: 600;
|
|
86
|
-
color: $white;
|
|
87
|
-
background-color: $brand-color;
|
|
88
|
-
padding: $spacing--small / 2;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2018-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 TopicIntroductionList from './TopicIntroductionList';
|
|
10
|
-
|
|
11
|
-
export default TopicIntroductionList;
|