@ndla/ui 55.0.15-alpha.0 → 55.0.17-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 +125 -29
- package/dist/styles.css +453 -103
- package/es/Article/Article.js +101 -162
- package/es/Article/ArticleByline.js +89 -56
- package/es/Article/ArticleFootNotes.js +35 -23
- package/es/Article/ArticleParagraph.js +2 -2
- package/es/Article/index.js +3 -5
- package/es/AudioPlayer/AudioPlayer.js +20 -20
- package/es/AudioPlayer/Controls.js +45 -45
- package/es/AudioPlayer/SpeechControl.js +8 -8
- package/es/BlogPost/BlogPost.js +6 -6
- package/es/Breadcrumb/Breadcrumb.js +19 -29
- package/es/Breadcrumb/BreadcrumbItem.js +20 -49
- package/es/Breadcrumb/HomeBreadcrumb.js +36 -82
- package/es/CampaignBlock/CampaignBlock.js +12 -12
- package/es/CodeBlock/CodeBlock.js +2 -2
- package/es/Concept/Concept.js +11 -11
- package/es/ContactBlock/ContactBlock.js +170 -185
- package/es/ContactBlock/index.js +3 -3
- package/es/ContentLoader/index.js +12 -12
- package/es/ContentPlaceholder/ContentPlaceholder.js +3 -3
- package/es/ContentTypeBadge/ContentTypeBadge.js +81 -80
- package/es/ContentTypeBadge/ContentTypeBadgeNew.js +3 -2
- package/es/ContentTypeHero/ContentTypeHero.js +50 -0
- package/es/{Logo → ContentTypeHero}/index.js +2 -3
- package/es/CopyParagraphButton/CopyParagraphButton.js +13 -12
- package/es/Embed/AudioEmbed.js +7 -7
- package/es/Embed/BrightcoveEmbed.js +8 -8
- package/es/Embed/CodeEmbed.js +6 -6
- package/es/Embed/ConceptEmbed.js +13 -13
- package/es/Embed/ConceptListEmbed.js +9 -9
- package/es/Embed/ContentLinkEmbed.js +6 -6
- package/es/Embed/CopyrightEmbed.js +3 -3
- package/es/Embed/EmbedErrorPlaceholder.js +5 -5
- package/es/Embed/ExternalEmbed.js +5 -5
- package/es/Embed/FootnoteEmbed.js +5 -5
- package/es/Embed/GlossEmbed.js +11 -11
- package/es/Embed/H5pEmbed.js +5 -5
- package/es/Embed/IframeEmbed.js +6 -6
- package/es/Embed/ImageEmbed.js +10 -10
- package/es/Embed/InlineTriggerButton.js +2 -2
- package/es/Embed/RelatedContentEmbed.js +5 -5
- package/es/Embed/UnknownEmbed.js +3 -3
- package/es/Embed/UuDisclaimerEmbed.js +6 -6
- package/es/ErrorMessage/ErrorMessage.js +14 -14
- package/es/ErrorMessage/ErrorResourceAccessDenied.js +6 -6
- package/es/FactBox/FactBox.js +5 -5
- package/es/FileList/File.js +3 -3
- package/es/FileList/FileList.js +6 -6
- package/es/FileList/Format.js +6 -6
- package/es/FileList/PdfFile.js +5 -5
- package/es/FrontpageArticle/FrontpageArticle.js +7 -8
- package/es/Gloss/Gloss.js +23 -23
- package/es/Gloss/GlossExample.js +9 -9
- package/es/Grid/Grid.js +4 -4
- package/es/KeyFigure/KeyFigure.js +5 -5
- package/es/Layout/LayoutItem.js +25 -37
- package/es/Layout/OneColumn.js +33 -31
- package/es/Layout/PageContainer.js +21 -30
- package/es/LicenseByline/EmbedByline.js +21 -21
- package/es/LicenseByline/LicenseLink.js +3 -3
- package/es/LinkBlock/LinkBlock.js +8 -8
- package/es/LinkBlock/LinkBlockSection.js +4 -4
- package/es/Messages/MessageBox.js +11 -11
- package/es/Messages/index.js +1 -2
- package/es/ProgrammeCard/ProgrammeCard.js +5 -5
- package/es/RelatedArticleList/RelatedArticleList.js +15 -15
- package/es/ResourceBox/ResourceBox.js +9 -9
- package/es/SnackBar/DefaultSnackbar.js +5 -5
- package/es/SnackBar/SnackbarProvider.js +7 -7
- package/es/TagSelector/TagSelector.js +17 -17
- package/es/TreeStructure/AddFolderButton.js +4 -4
- package/es/TreeStructure/ComboboxButton.js +7 -7
- package/es/TreeStructure/FolderItem.js +13 -13
- package/es/TreeStructure/FolderItems.js +6 -6
- package/es/TreeStructure/TreeStructure.js +9 -9
- package/es/ZendeskButton/ZendeskButton.js +2 -2
- package/es/i18n/index.js +1 -1
- package/es/index.js +5 -12
- package/es/locale/messages-en.js +1 -1
- package/es/locale/messages-nb.js +1 -1
- 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/es/model/ContentType.js +3 -1
- package/es/styles.css +453 -103
- package/lib/Article/Article.d.ts +9 -30
- package/lib/Article/Article.js +104 -164
- package/lib/Article/ArticleByline.d.ts +1 -3
- package/lib/Article/ArticleByline.js +89 -56
- package/lib/Article/ArticleFootNotes.js +35 -24
- package/lib/Article/ArticleParagraph.js +2 -2
- package/lib/Article/index.d.ts +2 -5
- package/lib/Article/index.js +18 -24
- package/lib/AudioPlayer/AudioPlayer.js +20 -20
- package/lib/AudioPlayer/Controls.js +45 -45
- package/lib/AudioPlayer/SpeechControl.js +8 -8
- package/lib/BlogPost/BlogPost.js +6 -6
- package/lib/Breadcrumb/Breadcrumb.js +21 -29
- package/lib/Breadcrumb/BreadcrumbItem.js +22 -50
- package/lib/Breadcrumb/HomeBreadcrumb.d.ts +1 -2
- package/lib/Breadcrumb/HomeBreadcrumb.js +38 -82
- package/lib/CampaignBlock/CampaignBlock.js +12 -12
- package/lib/CodeBlock/CodeBlock.js +2 -2
- package/lib/Concept/Concept.js +11 -11
- package/lib/ContactBlock/ContactBlock.d.ts +6 -7
- package/lib/ContactBlock/ContactBlock.js +173 -184
- package/lib/ContactBlock/index.d.ts +3 -3
- package/lib/ContactBlock/index.js +13 -11
- package/lib/ContentLoader/index.js +12 -12
- package/lib/ContentPlaceholder/ContentPlaceholder.js +3 -3
- package/lib/ContentTypeBadge/ContentTypeBadge.d.ts +11 -12
- package/lib/ContentTypeBadge/ContentTypeBadge.js +83 -80
- package/lib/ContentTypeBadge/ContentTypeBadgeNew.d.ts +1 -2
- package/lib/ContentTypeBadge/ContentTypeBadgeNew.js +3 -2
- package/lib/ContentTypeHero/ContentTypeHero.d.ts +15 -0
- package/lib/ContentTypeHero/ContentTypeHero.js +57 -0
- package/lib/ContentTypeHero/index.d.ts +9 -0
- package/lib/ContentTypeHero/index.js +12 -0
- package/lib/CopyParagraphButton/CopyParagraphButton.js +13 -12
- package/lib/Embed/AudioEmbed.js +7 -7
- package/lib/Embed/BrightcoveEmbed.js +8 -8
- package/lib/Embed/CodeEmbed.js +6 -6
- package/lib/Embed/ConceptEmbed.js +13 -13
- package/lib/Embed/ConceptListEmbed.js +9 -9
- package/lib/Embed/ContentLinkEmbed.js +6 -6
- package/lib/Embed/CopyrightEmbed.js +3 -3
- package/lib/Embed/EmbedErrorPlaceholder.js +5 -5
- package/lib/Embed/ExternalEmbed.js +5 -5
- package/lib/Embed/FootnoteEmbed.js +5 -5
- package/lib/Embed/GlossEmbed.js +11 -11
- package/lib/Embed/H5pEmbed.js +5 -5
- package/lib/Embed/IframeEmbed.js +6 -6
- package/lib/Embed/ImageEmbed.js +10 -10
- package/lib/Embed/InlineTriggerButton.js +2 -2
- package/lib/Embed/RelatedContentEmbed.js +5 -5
- package/lib/Embed/UnknownEmbed.js +3 -3
- package/lib/Embed/UuDisclaimerEmbed.js +6 -6
- package/lib/ErrorMessage/ErrorMessage.js +14 -14
- package/lib/ErrorMessage/ErrorResourceAccessDenied.js +6 -6
- package/lib/FactBox/FactBox.js +5 -5
- package/lib/FileList/File.js +3 -3
- package/lib/FileList/FileList.js +6 -6
- package/lib/FileList/Format.js +6 -6
- package/lib/FileList/PdfFile.js +5 -5
- package/lib/FrontpageArticle/FrontpageArticle.js +7 -8
- package/lib/Gloss/Gloss.js +23 -23
- package/lib/Gloss/GlossExample.js +9 -9
- package/lib/Grid/Grid.js +4 -4
- package/lib/KeyFigure/KeyFigure.js +5 -5
- package/lib/Layout/LayoutItem.d.ts +3 -7
- package/lib/Layout/LayoutItem.js +27 -38
- package/lib/Layout/OneColumn.d.ts +3 -6
- package/lib/Layout/OneColumn.js +36 -33
- package/lib/Layout/PageContainer.d.ts +3 -6
- package/lib/Layout/PageContainer.js +24 -32
- package/lib/LicenseByline/EmbedByline.js +21 -21
- package/lib/LicenseByline/LicenseLink.js +3 -3
- package/lib/LinkBlock/LinkBlock.js +8 -8
- package/lib/LinkBlock/LinkBlockSection.js +4 -4
- package/lib/Messages/MessageBox.js +11 -11
- package/lib/Messages/index.d.ts +1 -2
- package/lib/Messages/index.js +0 -7
- package/lib/ProgrammeCard/ProgrammeCard.js +5 -5
- package/lib/RelatedArticleList/RelatedArticleList.js +15 -15
- package/lib/ResourceBox/ResourceBox.js +9 -9
- package/lib/SnackBar/DefaultSnackbar.js +5 -5
- package/lib/SnackBar/SnackbarProvider.js +7 -7
- package/lib/TagSelector/TagSelector.js +17 -17
- package/lib/TreeStructure/AddFolderButton.js +4 -4
- package/lib/TreeStructure/ComboboxButton.js +7 -7
- package/lib/TreeStructure/FolderItem.js +13 -13
- package/lib/TreeStructure/FolderItems.js +6 -6
- package/lib/TreeStructure/TreeStructure.js +9 -9
- package/lib/ZendeskButton/ZendeskButton.js +2 -2
- package/lib/i18n/index.d.ts +1 -1
- package/lib/i18n/index.js +6 -0
- package/lib/index.d.ts +8 -15
- package/lib/index.js +30 -139
- package/lib/locale/messages-en.js +1 -1
- package/lib/locale/messages-nb.js +1 -1
- 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/lib/model/ContentType.d.ts +1 -0
- package/lib/model/ContentType.js +4 -2
- package/lib/styles.css +453 -103
- package/package.json +10 -11
- package/src/Article/Article.tsx +101 -229
- package/src/Article/ArticleByline.tsx +82 -69
- package/src/Article/ArticleFootNotes.tsx +32 -36
- package/src/Article/index.ts +3 -7
- package/src/Breadcrumb/Breadcrumb.tsx +20 -18
- package/src/Breadcrumb/BreadcrumbItem.tsx +36 -59
- package/src/Breadcrumb/HomeBreadcrumb.stories.tsx +0 -12
- package/src/Breadcrumb/HomeBreadcrumb.tsx +33 -46
- package/src/ContactBlock/{Contactblock.stories.tsx → ContactBlock.stories.tsx} +3 -4
- package/src/ContactBlock/ContactBlock.tsx +165 -199
- package/src/ContactBlock/index.ts +3 -3
- package/src/ContentTypeBadge/ContentTypeBadge.tsx +77 -77
- package/src/ContentTypeBadge/ContentTypeBadgeNew.tsx +3 -1
- package/src/ContentTypeHero/ContentTypeHero.stories.tsx +76 -0
- package/src/ContentTypeHero/ContentTypeHero.tsx +55 -0
- package/src/ContentTypeHero/index.ts +10 -0
- package/src/CopyParagraphButton/CopyParagraphButton.tsx +10 -3
- package/src/Embed/AudioEmbed.stories.tsx +6 -8
- package/src/Embed/BrightcoveEmbed.stories.tsx +6 -8
- package/src/Embed/ConceptEmbed.stories.tsx +6 -8
- package/src/Embed/ExternalEmbed.stories.tsx +5 -5
- package/src/Embed/H5pEmbed.stories.tsx +6 -8
- package/src/Embed/IframeEmbed.stories.tsx +6 -8
- package/src/Embed/ImageEmbed.stories.tsx +6 -8
- package/src/Embed/RelatedContentEmbed.stories.tsx +6 -8
- package/src/Embed/UuDisclaimerEmbed.stories.tsx +6 -8
- package/src/FrontpageArticle/FrontpageArticle.tsx +1 -1
- package/src/Layout/LayoutItem.tsx +25 -41
- package/src/Layout/OneColumn.tsx +33 -33
- package/src/Layout/PageContainer.tsx +22 -24
- package/src/Messages/index.ts +1 -2
- package/src/i18n/index.ts +1 -0
- package/src/index.ts +11 -35
- package/src/locale/messages-en.ts +1 -1
- package/src/locale/messages-nb.ts +1 -1
- 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/model/ContentType.ts +2 -0
- package/es/Article/ArticleHeaderWrapper.js +0 -33
- package/es/CreatedBy/CreatedBy.js +0 -73
- package/es/CreatedBy/index.js +0 -10
- package/es/Hero/Hero.js +0 -68
- package/es/Hero/HeroContent.js +0 -16
- package/es/Hero/index.js +0 -10
- package/es/LanguageSelector/LanguageSelector.js +0 -87
- package/es/LanguageSelector/index.js +0 -10
- package/es/Logo/Logo.js +0 -52
- package/es/Logo/SvgLogo.js +0 -54
- package/es/Messages/MessageBanner.js +0 -72
- package/es/Search/ActiveFilterContent.js +0 -40
- package/es/Search/ActiveFilters.js +0 -112
- package/es/Search/ContentTypeResult.js +0 -151
- package/es/Search/ContentTypeResultStyles.js +0 -51
- package/es/Search/IsPathToHighlight.js +0 -12
- package/es/Search/LoadingWrapper.js +0 -31
- package/es/Search/SearchField.js +0 -110
- package/es/Search/SearchFieldForm.js +0 -33
- package/es/Search/SearchResult.js +0 -185
- package/es/Search/SearchResultSleeve.js +0 -229
- package/es/Search/index.js +0 -12
- package/lib/Article/ArticleHeaderWrapper.d.ts +0 -14
- package/lib/Article/ArticleHeaderWrapper.js +0 -40
- package/lib/CreatedBy/CreatedBy.d.ts +0 -15
- package/lib/CreatedBy/CreatedBy.js +0 -78
- package/lib/CreatedBy/index.d.ts +0 -9
- package/lib/CreatedBy/index.js +0 -16
- package/lib/Hero/Hero.d.ts +0 -25
- package/lib/Hero/Hero.js +0 -83
- package/lib/Hero/HeroContent.d.ts +0 -12
- package/lib/Hero/HeroContent.js +0 -23
- package/lib/Hero/index.d.ts +0 -10
- package/lib/Hero/index.js +0 -61
- package/lib/LanguageSelector/LanguageSelector.d.ts +0 -15
- package/lib/LanguageSelector/LanguageSelector.js +0 -92
- package/lib/LanguageSelector/index.d.ts +0 -9
- package/lib/LanguageSelector/index.js +0 -13
- package/lib/Logo/Logo.d.ts +0 -20
- package/lib/Logo/Logo.js +0 -58
- package/lib/Logo/SvgLogo.d.ts +0 -14
- package/lib/Logo/SvgLogo.js +0 -62
- package/lib/Logo/index.d.ts +0 -9
- package/lib/Logo/index.js +0 -16
- package/lib/Messages/MessageBanner.d.ts +0 -16
- package/lib/Messages/MessageBanner.js +0 -77
- package/lib/Search/ActiveFilterContent.d.ts +0 -23
- package/lib/Search/ActiveFilterContent.js +0 -47
- package/lib/Search/ActiveFilters.d.ts +0 -19
- package/lib/Search/ActiveFilters.js +0 -119
- package/lib/Search/ContentTypeResult.d.ts +0 -29
- package/lib/Search/ContentTypeResult.js +0 -159
- package/lib/Search/ContentTypeResultStyles.d.ts +0 -45
- package/lib/Search/ContentTypeResultStyles.js +0 -58
- package/lib/Search/IsPathToHighlight.d.ts +0 -8
- package/lib/Search/IsPathToHighlight.js +0 -19
- package/lib/Search/LoadingWrapper.d.ts +0 -12
- package/lib/Search/LoadingWrapper.js +0 -38
- package/lib/Search/SearchField.d.ts +0 -25
- package/lib/Search/SearchField.js +0 -117
- package/lib/Search/SearchFieldForm.d.ts +0 -15
- package/lib/Search/SearchFieldForm.js +0 -41
- package/lib/Search/SearchResult.d.ts +0 -43
- package/lib/Search/SearchResult.js +0 -194
- package/lib/Search/SearchResultSleeve.d.ts +0 -25
- package/lib/Search/SearchResultSleeve.js +0 -237
- package/lib/Search/index.d.ts +0 -11
- package/lib/Search/index.js +0 -33
- package/src/Article/ArticleHeaderWrapper.tsx +0 -38
- package/src/CreatedBy/CreatedBy.stories.tsx +0 -36
- package/src/CreatedBy/CreatedBy.tsx +0 -63
- package/src/CreatedBy/index.ts +0 -11
- package/src/Hero/Hero.stories.tsx +0 -35
- package/src/Hero/Hero.tsx +0 -129
- package/src/Hero/HeroContent.tsx +0 -43
- package/src/Hero/index.ts +0 -21
- package/src/LanguageSelector/LanguageSelector.stories.tsx +0 -44
- package/src/LanguageSelector/LanguageSelector.tsx +0 -101
- package/src/LanguageSelector/index.ts +0 -11
- package/src/Logo/Logo.stories.tsx +0 -47
- package/src/Logo/Logo.tsx +0 -47
- package/src/Logo/SvgLogo.tsx +0 -48
- package/src/Logo/index.ts +0 -11
- package/src/Messages/MessageBanner.stories.tsx +0 -31
- package/src/Messages/MessageBanner.tsx +0 -67
- package/src/Search/ActiveFilterContent.tsx +0 -64
- package/src/Search/ActiveFilters.tsx +0 -145
- package/src/Search/ContentTypeResult.tsx +0 -190
- package/src/Search/ContentTypeResultStyles.tsx +0 -172
- package/src/Search/IsPathToHighlight.ts +0 -12
- package/src/Search/LoadingWrapper.tsx +0 -44
- package/src/Search/SearchField.tsx +0 -175
- package/src/Search/SearchFieldForm.tsx +0 -64
- package/src/Search/SearchResult.tsx +0 -368
- package/src/Search/SearchResultSleeve.tsx +0 -367
- package/src/Search/__tests__/Highlight-test.ts +0 -66
- package/src/Search/index.ts +0 -14
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2019-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
|
-
/** @jsxImportSource @emotion/react */
|
|
10
|
-
import { useEffect, useRef, useState } from "react";
|
|
11
|
-
import { useTranslation } from "react-i18next";
|
|
12
|
-
import styled from "@emotion/styled";
|
|
13
|
-
import { breakpoints, colors, fonts, misc, mq, spacing } from "@ndla/core";
|
|
14
|
-
import { ChevronDown, ChevronUp, Esc, KeyboardReturn, Search as SearchIcon, Wrench } from "@ndla/icons/common";
|
|
15
|
-
import { SafeLink } from "@ndla/safelink";
|
|
16
|
-
import ContentTypeResult from "./ContentTypeResult";
|
|
17
|
-
import { highlightStyle } from "./ContentTypeResultStyles";
|
|
18
|
-
import { ContentTypeResultType, Resource } from "../types";
|
|
19
|
-
|
|
20
|
-
const GO_TO_SEARCHPAGE = "GO_TO_SEARCHPAGE";
|
|
21
|
-
const GO_TO_SUGGESTION = "GO_TO_SUGGESTION";
|
|
22
|
-
|
|
23
|
-
const StyledNoHits = styled.div`
|
|
24
|
-
${fonts.sizes(16, 1.1)};
|
|
25
|
-
color: ${colors.text.primary};
|
|
26
|
-
`;
|
|
27
|
-
|
|
28
|
-
const StyledAside = styled.aside`
|
|
29
|
-
${fonts.sizes("16px", "22px")};
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: flex-start;
|
|
32
|
-
margin: 0;
|
|
33
|
-
color: ${colors.text.primary};
|
|
34
|
-
padding: ${spacing.normal} ${spacing.large} ${spacing.normal} ${spacing.normal};
|
|
35
|
-
background: ${colors.support.yellowLight};
|
|
36
|
-
border-radius: ${misc.borderRadius};
|
|
37
|
-
span {
|
|
38
|
-
display: block;
|
|
39
|
-
max-width: 700px;
|
|
40
|
-
padding-left: ${spacing.small};
|
|
41
|
-
flex: 1;
|
|
42
|
-
}
|
|
43
|
-
svg {
|
|
44
|
-
transform: translateY(6px);
|
|
45
|
-
}
|
|
46
|
-
${mq.range({ until: breakpoints.tablet })} {
|
|
47
|
-
display: none;
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
50
|
-
|
|
51
|
-
const SearchLinkContainer = styled.div`
|
|
52
|
-
margin: ${spacing.normal} -${spacing.small};
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
const StyledSearchLink = styled(SafeLink)`
|
|
56
|
-
width: 100%;
|
|
57
|
-
box-shadow: none;
|
|
58
|
-
border: 0;
|
|
59
|
-
background: transparent;
|
|
60
|
-
display: inline-flex;
|
|
61
|
-
flex-grow: 1;
|
|
62
|
-
align-items: center;
|
|
63
|
-
padding: ${spacing.xsmall} ${spacing.small};
|
|
64
|
-
line-height: 1.7rem;
|
|
65
|
-
color: ${colors.brand.primary};
|
|
66
|
-
strong {
|
|
67
|
-
font-weight: ${fonts.weight.semibold};
|
|
68
|
-
margin-left: ${spacing.xsmall};
|
|
69
|
-
}
|
|
70
|
-
&:focus {
|
|
71
|
-
${highlightStyle}
|
|
72
|
-
}
|
|
73
|
-
&:hover {
|
|
74
|
-
strong {
|
|
75
|
-
text-decoration: underline;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
small {
|
|
79
|
-
color: ${colors.text.light};
|
|
80
|
-
padding-left: ${spacing.xsmall};
|
|
81
|
-
}
|
|
82
|
-
&[data-highlighted="true"] {
|
|
83
|
-
${highlightStyle};
|
|
84
|
-
}
|
|
85
|
-
`;
|
|
86
|
-
|
|
87
|
-
type WrapperProps = {
|
|
88
|
-
frontpage?: boolean;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const StyledSearchResultsWrapper = styled.section<WrapperProps>`
|
|
92
|
-
background: #fff;
|
|
93
|
-
width: 100%;
|
|
94
|
-
position: ${(props) => (props.frontpage ? "absolute" : "static")};
|
|
95
|
-
left: 0;
|
|
96
|
-
right: 0;
|
|
97
|
-
top: 62px;
|
|
98
|
-
border-radius: ${misc.borderRadius};
|
|
99
|
-
${mq.range({ until: breakpoints.tablet })} {
|
|
100
|
-
position: fixed;
|
|
101
|
-
left: 0;
|
|
102
|
-
right: 0;
|
|
103
|
-
bottom: 0;
|
|
104
|
-
top: 74px;
|
|
105
|
-
}
|
|
106
|
-
`;
|
|
107
|
-
|
|
108
|
-
type StyledScrollableContentProps = {
|
|
109
|
-
extendHeight: number;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const StyledScrollableContent = styled.div<StyledScrollableContentProps>`
|
|
113
|
-
max-height: calc(100vh - ${(props) => 260 - props.extendHeight}px);
|
|
114
|
-
overflow-y: auto;
|
|
115
|
-
-webkit-overflow-scrolling: touch;
|
|
116
|
-
overflow-x: hidden;
|
|
117
|
-
// prettier-ignore
|
|
118
|
-
padding: ${(props) =>
|
|
119
|
-
props.extendHeight ? spacing.normal : spacing.large} ${spacing.large} ${spacing.large} ${spacing.large};
|
|
120
|
-
${mq.range({ from: breakpoints.tablet, until: breakpoints.tabletWide })} {
|
|
121
|
-
max-height: calc(100vh - ${(props) => 200 - props.extendHeight});
|
|
122
|
-
}
|
|
123
|
-
${mq.range({ until: breakpoints.tablet })} {
|
|
124
|
-
padding: 0 ${spacing.normal} ${spacing.large};
|
|
125
|
-
max-height: calc(100vh - 74px);
|
|
126
|
-
}
|
|
127
|
-
`;
|
|
128
|
-
|
|
129
|
-
const StyledFooter = styled.div`
|
|
130
|
-
${mq.range({ until: breakpoints.tabletWide })} {
|
|
131
|
-
display: none;
|
|
132
|
-
}
|
|
133
|
-
flex-direction: row-reverse;
|
|
134
|
-
align-items: center;
|
|
135
|
-
background: ${colors.brand.greyLightest};
|
|
136
|
-
border-top: 1px solid ${colors.brand.greyLight};
|
|
137
|
-
border-bottom-left-radius: ${misc.borderRadius};
|
|
138
|
-
border-bottom-right-radius: ${misc.borderRadius};
|
|
139
|
-
padding: ${spacing.xsmall} 0 ${spacing.xsmall} ${spacing.large};
|
|
140
|
-
`;
|
|
141
|
-
|
|
142
|
-
const StyledInstructions = styled.div`
|
|
143
|
-
flex: 1;
|
|
144
|
-
align-items: center;
|
|
145
|
-
padding-right: ${spacing.large};
|
|
146
|
-
svg {
|
|
147
|
-
width: 24px;
|
|
148
|
-
height: 24px;
|
|
149
|
-
border: 1px solid ${colors.brand.grey};
|
|
150
|
-
background: ${colors.brand.greyLight};
|
|
151
|
-
border-radius: 2px;
|
|
152
|
-
margin-left: 2px;
|
|
153
|
-
}
|
|
154
|
-
span {
|
|
155
|
-
display: inline-flex;
|
|
156
|
-
${fonts.sizes(14, 1.1)};
|
|
157
|
-
margin: ${spacing.xsmall} ${spacing.small} ${spacing.xsmall} ${spacing.xsmall};
|
|
158
|
-
}
|
|
159
|
-
`;
|
|
160
|
-
|
|
161
|
-
const getNextElementInDirection = (
|
|
162
|
-
current: HTMLElement | string,
|
|
163
|
-
arr: Array<HTMLElement | string>,
|
|
164
|
-
direction: 1 | -1 | null,
|
|
165
|
-
): HTMLElement | string | null => {
|
|
166
|
-
const currentIdx = arr.indexOf(current);
|
|
167
|
-
|
|
168
|
-
if (direction === 1) {
|
|
169
|
-
const idx = currentIdx + 1 > arr.length - 1 ? 0 : currentIdx + 1;
|
|
170
|
-
return arr[idx];
|
|
171
|
-
}
|
|
172
|
-
if (direction === -1) {
|
|
173
|
-
const idx = currentIdx - 1 < 0 ? arr.length - 1 : currentIdx - 1;
|
|
174
|
-
return arr[idx];
|
|
175
|
-
}
|
|
176
|
-
return arr[currentIdx];
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const getDefaultCount = () => {
|
|
180
|
-
return window.innerWidth > 980 ? 7 : 3;
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const findPathForKeyboardNavigation = (
|
|
184
|
-
contentRef: HTMLDivElement | null,
|
|
185
|
-
current: HTMLElement | string | null,
|
|
186
|
-
direction: 1 | -1 | null,
|
|
187
|
-
): HTMLElement | string | null => {
|
|
188
|
-
const selectables = contentRef ? Array.from(contentRef.querySelectorAll("li")) : [];
|
|
189
|
-
const resultsContainingPaths: Array<string | HTMLElement> = (
|
|
190
|
-
[GO_TO_SEARCHPAGE, GO_TO_SUGGESTION] as Array<HTMLElement | string>
|
|
191
|
-
).concat(...selectables);
|
|
192
|
-
|
|
193
|
-
// Nothing selected, goto either first or last depending on direction
|
|
194
|
-
if (current === null) {
|
|
195
|
-
switch (direction) {
|
|
196
|
-
case 1:
|
|
197
|
-
return resultsContainingPaths[0];
|
|
198
|
-
case -1:
|
|
199
|
-
return resultsContainingPaths[resultsContainingPaths.length - 1];
|
|
200
|
-
default:
|
|
201
|
-
return current;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return getNextElementInDirection(current, resultsContainingPaths, direction);
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
type Props = {
|
|
208
|
-
result: Array<ContentTypeResultType>;
|
|
209
|
-
allResultUrl: string;
|
|
210
|
-
resourceToLinkProps: (resource: Resource) => {
|
|
211
|
-
to: string;
|
|
212
|
-
};
|
|
213
|
-
onNavigate?: VoidFunction;
|
|
214
|
-
infoText?: string;
|
|
215
|
-
ignoreContentTypeBadge?: boolean;
|
|
216
|
-
searchString: string;
|
|
217
|
-
loading: boolean;
|
|
218
|
-
frontpage?: boolean;
|
|
219
|
-
suggestion?: string;
|
|
220
|
-
suggestionUrl?: string;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const SearchResultSleeve = ({
|
|
224
|
-
result,
|
|
225
|
-
allResultUrl,
|
|
226
|
-
resourceToLinkProps,
|
|
227
|
-
onNavigate,
|
|
228
|
-
infoText,
|
|
229
|
-
ignoreContentTypeBadge,
|
|
230
|
-
searchString,
|
|
231
|
-
loading,
|
|
232
|
-
frontpage,
|
|
233
|
-
suggestion,
|
|
234
|
-
suggestionUrl,
|
|
235
|
-
}: Props) => {
|
|
236
|
-
const { t } = useTranslation();
|
|
237
|
-
const contentRef = useRef<HTMLDivElement>(null);
|
|
238
|
-
const searchAllRef = useRef<HTMLDivElement>(null);
|
|
239
|
-
const searchSuggestionRef = useRef<HTMLDivElement>(null);
|
|
240
|
-
const [keyboardPathNavigation, setKeyNavigation] = useState<HTMLElement | string | null>("");
|
|
241
|
-
|
|
242
|
-
useEffect(() => {
|
|
243
|
-
const onKeyDownEvent = (e: KeyboardEvent) => {
|
|
244
|
-
if (e.code === "ArrowDown") {
|
|
245
|
-
e.stopPropagation();
|
|
246
|
-
e.preventDefault();
|
|
247
|
-
|
|
248
|
-
setKeyNavigation((prevKeyPath) => {
|
|
249
|
-
return findPathForKeyboardNavigation(contentRef.current, prevKeyPath, 1);
|
|
250
|
-
});
|
|
251
|
-
} else if (e.code === "ArrowUp") {
|
|
252
|
-
e.stopPropagation();
|
|
253
|
-
e.preventDefault();
|
|
254
|
-
|
|
255
|
-
setKeyNavigation((prevKeyPath) => {
|
|
256
|
-
return findPathForKeyboardNavigation(contentRef.current, prevKeyPath, -1);
|
|
257
|
-
});
|
|
258
|
-
} else if (e.code === "Enter") {
|
|
259
|
-
if (keyboardPathNavigation === GO_TO_SUGGESTION) {
|
|
260
|
-
searchSuggestionRef?.current?.closest("a")?.click();
|
|
261
|
-
} else if (keyboardPathNavigation instanceof HTMLElement) {
|
|
262
|
-
e.stopPropagation();
|
|
263
|
-
e.preventDefault();
|
|
264
|
-
const toClick =
|
|
265
|
-
keyboardPathNavigation?.querySelector &&
|
|
266
|
-
(keyboardPathNavigation.querySelector("a") || keyboardPathNavigation.querySelector("button"));
|
|
267
|
-
|
|
268
|
-
toClick?.click();
|
|
269
|
-
}
|
|
270
|
-
} else if (e.code === "Tab") {
|
|
271
|
-
setKeyNavigation("");
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
window.addEventListener("keydown", onKeyDownEvent);
|
|
276
|
-
setKeyNavigation((prevKeyNav) => {
|
|
277
|
-
return findPathForKeyboardNavigation(contentRef.current, prevKeyNav, null);
|
|
278
|
-
});
|
|
279
|
-
return () => {
|
|
280
|
-
window.removeEventListener("keydown", onKeyDownEvent);
|
|
281
|
-
};
|
|
282
|
-
}, [result, contentRef, searchAllRef, keyboardPathNavigation]);
|
|
283
|
-
|
|
284
|
-
useEffect(() => {
|
|
285
|
-
const highlightedElement =
|
|
286
|
-
keyboardPathNavigation === GO_TO_SEARCHPAGE
|
|
287
|
-
? searchAllRef.current
|
|
288
|
-
: contentRef.current?.querySelector('[data-highlighted="true"]');
|
|
289
|
-
|
|
290
|
-
if (highlightedElement) {
|
|
291
|
-
highlightedElement.scrollIntoView({
|
|
292
|
-
behavior: "smooth",
|
|
293
|
-
block: "nearest",
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
}, [keyboardPathNavigation]);
|
|
297
|
-
|
|
298
|
-
return (
|
|
299
|
-
<StyledSearchResultsWrapper frontpage={frontpage} ref={contentRef}>
|
|
300
|
-
<StyledScrollableContent extendHeight={frontpage ? 0 : 52}>
|
|
301
|
-
{infoText && (
|
|
302
|
-
<StyledAside>
|
|
303
|
-
<Wrench size="medium" />
|
|
304
|
-
<span>{infoText}</span>
|
|
305
|
-
</StyledAside>
|
|
306
|
-
)}
|
|
307
|
-
<div>
|
|
308
|
-
<SearchLinkContainer>
|
|
309
|
-
<StyledSearchLink
|
|
310
|
-
data-highlighted={keyboardPathNavigation === GO_TO_SEARCHPAGE}
|
|
311
|
-
to={allResultUrl}
|
|
312
|
-
tabIndex={-1}
|
|
313
|
-
>
|
|
314
|
-
<SearchIcon size="medium" />
|
|
315
|
-
<strong ref={searchAllRef}>{searchString}</strong>
|
|
316
|
-
<small>{t("welcomePage.searchAllInfo")}</small>
|
|
317
|
-
</StyledSearchLink>
|
|
318
|
-
{suggestion && suggestionUrl && (
|
|
319
|
-
<StyledSearchLink
|
|
320
|
-
data-highlighted={keyboardPathNavigation === GO_TO_SUGGESTION}
|
|
321
|
-
to={suggestionUrl}
|
|
322
|
-
tabIndex={-1}
|
|
323
|
-
>
|
|
324
|
-
<SearchIcon size="medium" />
|
|
325
|
-
<small>{t("searchPage.resultType.searchPhraseSuggestion")}</small>
|
|
326
|
-
<strong ref={searchSuggestionRef}>{suggestion}</strong>
|
|
327
|
-
</StyledSearchLink>
|
|
328
|
-
)}
|
|
329
|
-
</SearchLinkContainer>
|
|
330
|
-
{result.map((contentTypeResult: ContentTypeResultType) => (
|
|
331
|
-
<ContentTypeResult
|
|
332
|
-
ignoreContentTypeBadge={!!ignoreContentTypeBadge}
|
|
333
|
-
onNavigate={onNavigate}
|
|
334
|
-
contentTypeResult={contentTypeResult}
|
|
335
|
-
resourceToLinkProps={resourceToLinkProps}
|
|
336
|
-
defaultCount={getDefaultCount()}
|
|
337
|
-
key={contentTypeResult.title}
|
|
338
|
-
keyboardPathNavigation={keyboardPathNavigation}
|
|
339
|
-
showAdditionalResources
|
|
340
|
-
messages={{
|
|
341
|
-
allResultLabel: t("searchPage.searchField.contentTypeResultShowMoreLabel"),
|
|
342
|
-
showLessResultLabel: t("searchPage.searchField.contentTypeResultShowLessLabel"),
|
|
343
|
-
noHit: t("searchPage.searchField.contentTypeResultNoHit"),
|
|
344
|
-
}}
|
|
345
|
-
/>
|
|
346
|
-
))}
|
|
347
|
-
{result.length === 0 && !loading && (
|
|
348
|
-
<StyledNoHits>{t("searchPage.searchField.contentTypeResultNoHit")}</StyledNoHits>
|
|
349
|
-
)}
|
|
350
|
-
</div>
|
|
351
|
-
</StyledScrollableContent>
|
|
352
|
-
<StyledFooter>
|
|
353
|
-
<StyledInstructions>
|
|
354
|
-
<ChevronUp />
|
|
355
|
-
<ChevronDown />
|
|
356
|
-
<span>{t("siteNav.navigate")}</span>
|
|
357
|
-
<KeyboardReturn />
|
|
358
|
-
<span>{t("siteNav.select")}</span>
|
|
359
|
-
<Esc />
|
|
360
|
-
<span>{t("siteNav.close")}</span>
|
|
361
|
-
</StyledInstructions>
|
|
362
|
-
</StyledFooter>
|
|
363
|
-
</StyledSearchResultsWrapper>
|
|
364
|
-
);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
export default SearchResultSleeve;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2020-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
|
-
/* eslint-env jest */
|
|
10
|
-
|
|
11
|
-
import { isPathToHighlight } from "../IsPathToHighlight";
|
|
12
|
-
|
|
13
|
-
test("Test that determining whether to highlight path works with locale and not", () => {
|
|
14
|
-
const tests = [
|
|
15
|
-
{
|
|
16
|
-
path: "/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
17
|
-
href: "/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
18
|
-
expected: true,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
path: "/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
22
|
-
href: "/nn/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
23
|
-
expected: true,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
path: "/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
27
|
-
href: "/nb/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
28
|
-
expected: true,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
path: "/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
32
|
-
href: "/kultspråk/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
33
|
-
expected: true,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
path: "/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
37
|
-
href: "/nb/subject:123/topic:1:123/topic:2:5343",
|
|
38
|
-
expected: false,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
path: "/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
42
|
-
href: "/nb/subject:123/topic:1:123",
|
|
43
|
-
expected: false,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
path: "/subject:123/topic:1:123/topic:2:5343/resource:1:1231231231",
|
|
47
|
-
href: "/nb/subject:123",
|
|
48
|
-
expected: false,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
path: "/subject:123/topic:1:123/topic:2:5343",
|
|
52
|
-
href: "/nb/subject:123/topic:1:123",
|
|
53
|
-
expected: false,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
path: "/subject:123/topic:1:123/topic:2:5343",
|
|
57
|
-
href: "/nb/subject:123",
|
|
58
|
-
expected: false,
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
tests.forEach((t) => {
|
|
63
|
-
const result = isPathToHighlight(t.path, t.href);
|
|
64
|
-
expect(result).toBe(t.expected);
|
|
65
|
-
});
|
|
66
|
-
});
|
package/src/Search/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017-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 ActiveFilters from "./ActiveFilters";
|
|
10
|
-
import SearchField from "./SearchField";
|
|
11
|
-
|
|
12
|
-
import { SearchResultList, SearchResultItem } from "./SearchResult";
|
|
13
|
-
|
|
14
|
-
export { SearchField, SearchResultItem, SearchResultList, ActiveFilters };
|