Skip to content

Commit 6340bb4

Browse files
authored
Merge pull request #43 from CSCfi/CSCFC4EMSCR-239_Search-styles-improvements
CSCFC4EMSCR-239 Search styles improvements
2 parents 566433d + 49896af commit 6340bb4

File tree

9 files changed

+65
-23
lines changed

9 files changed

+65
-23
lines changed

mscr-ui/public/locales/en/common.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"filter-with-current_other": "",
6868
"go-to": "",
6969
"impersonate-user": "Impersonate user",
70-
"in-all-mscr": "In all MSCR",
7170
"interoperability-logo-title": "",
7271
"items-to-be-unscribed-from_one": "",
7372
"items-to-be-unscribed-from_other": "",
@@ -176,6 +175,7 @@
176175
"search-button": "Search"
177176
},
178177
"facets": {
178+
"filter-by": "Filter results by",
179179
"format": "Format",
180180
"isReferenced": "Source type",
181181
"organization": "Organization",

mscr-ui/public/locales/fi/common.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"filter-with-current_other": "",
6868
"go-to": "",
6969
"impersonate-user": "",
70-
"in-all-mscr": "",
7170
"interoperability-logo-title": "",
7271
"items-to-be-unscribed-from_one": "",
7372
"items-to-be-unscribed-from_other": "",
@@ -174,6 +173,7 @@
174173
"search-button": ""
175174
},
176175
"facets": {
176+
"filter-by": "",
177177
"format": "",
178178
"isReferenced": "",
179179
"organization": "",

mscr-ui/public/locales/sv/common.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"filter-with-current_other": "",
6868
"go-to": "",
6969
"impersonate-user": "",
70-
"in-all-mscr": "",
7170
"interoperability-logo-title": "",
7271
"items-to-be-unscribed-from_one": "",
7372
"items-to-be-unscribed-from_other": "",
@@ -174,6 +173,7 @@
174173
"search-button": ""
175174
},
176175
"facets": {
176+
"filter-by": "",
177177
"format": "",
178178
"isReferenced": "",
179179
"organization": "",

mscr-ui/src/common/components/search-filter-set/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { FacetTitle } from '@app/common/components/search-filter-set/search-filt
22
import { Filter } from '@app/common/interfaces/search.interface';
33
import { Checkbox, CheckboxGroup } from 'suomifi-ui-components';
44
import useUrlState, { UrlState } from '@app/common/utils/hooks/use-url-state';
5+
import { useTranslation } from 'next-i18next';
56

67
interface SearchFilterProps {
78
title: string;

mscr-ui/src/common/components/search-result/index.tsx

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { MscrSearchResult } from '@app/common/interfaces/search.interface';
22
import { Block, RouterLink } from 'suomifi-ui-components';
3-
import { IconMerge, IconFileGeneric } from 'suomifi-icons';
43
import {
5-
ResultIconWrapper,
4+
ChipWrapper, MetadataChip,
65
ResultTextWrapper,
6+
TypeChip
77
} from '@app/common/components/search-result/search-result.styles';
88
import { Schema } from '@app/common/interfaces/schema.interface';
99
import router from 'next/router';
@@ -24,22 +24,23 @@ export default function SearchResult({ hit }: { hit: MscrSearchResult }) {
2424
state: result.state,
2525
versionLabel: result.versionLabel,
2626
description: result.comment,
27+
format: result.format,
2728
};
28-
let icon;
2929
let url;
3030
if (result.type == 'SCHEMA') {
31-
icon = <IconFileGeneric />;
3231
url = `/schema/${displayResult.pid}`;
3332
} else {
34-
icon = <IconMerge />;
3533
url = `/crosswalk/${displayResult.pid}`;
3634
}
35+
let chips : string[] = [result.state];
36+
if (result.format) {
37+
chips = chips.concat(result.format);
38+
}
3739

3840
return (
3941
<Block>
40-
<ResultIconWrapper>{icon}</ResultIconWrapper>
4142
<ResultTextWrapper>
42-
<Link href={url}>
43+
<Link href={url} passHref>
4344
<RouterLink onClick={() => setIsSearchActive(false)}>
4445
<h4>
4546
{getLanguageVersion({
@@ -50,19 +51,26 @@ export default function SearchResult({ hit }: { hit: MscrSearchResult }) {
5051
</h4>
5152
</RouterLink>
5253
</Link>
54+
<ChipWrapper>
55+
{result.type == 'SCHEMA' && (
56+
<TypeChip $isSchema>{result.type}</TypeChip>
57+
)}
58+
{result.type != 'SCHEMA' && (
59+
<TypeChip>{result.type}</TypeChip>
60+
)}
61+
</ChipWrapper>
5362
<p>
5463
{getLanguageVersion({
5564
data: displayResult.description,
5665
lang,
5766
appendLocale: true,
5867
})}
5968
</p>
60-
{/*TODO: What exactly is supposed to be in the chips?
61-
{Object.keys(result.label).map((key) => (
62-
<ChipWrapper key={key}>
63-
<StaticChip>{result.label[key]}</StaticChip>
69+
{chips.map((chip) => (
70+
<ChipWrapper key={chip}>
71+
<MetadataChip>{chip}</MetadataChip>
6472
</ChipWrapper>
65-
))}*/}
73+
))}
6674
</ResultTextWrapper>
6775
</Block>
6876
);
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,47 @@
11
import styled from 'styled-components';
2+
import { StaticChip } from 'suomifi-ui-components';
23

34
export const ResultTextWrapper = styled.div`
4-
padding-left: 30px;
5+
padding: 10px 30px;
56
border-bottom: 1px solid ${(props) => props.theme.suomifi.colors.depthDark2};
6-
`;
7-
8-
export const ResultIconWrapper = styled.div`
9-
position: absolute;
10-
margin-top: 6px;
7+
&& .fi-link--router {
8+
color: ${(props) => props.theme.suomifi.colors.blackBase};
9+
text-decoration: underline;
10+
display: inline-block;
11+
margin-right: 20px;
12+
:hover {
13+
color: ${(props) => props.theme.suomifi.colors.highlightBase};
14+
}
15+
}
1116
`;
1217

1318
export const ChipWrapper = styled.div`
1419
display: inline;
1520
margin: 3px;
21+
span {
22+
font-size: 13px;
23+
}
24+
`;
25+
26+
export const TypeChip = styled(StaticChip)<{ $isSchema?: boolean }>`
27+
&&.fi-chip {
28+
border-style: solid;
29+
border-width: 2px;
30+
background-color: transparent;
31+
color: ${(props) =>
32+
props.$isSchema
33+
? props.theme.suomifi.colors.highlightLight1
34+
: props.theme.suomifi.colors.blackBase};
35+
border-color: ${(props) =>
36+
props.$isSchema
37+
? props.theme.suomifi.colors.highlightLight1
38+
: props.theme.suomifi.colors.blackBase};;
39+
}
40+
`;
41+
42+
export const MetadataChip = styled(StaticChip)`
43+
&&.fi-chip {
44+
background-color: #69D8D7;
45+
color: ${(props) => props.theme.suomifi.colors.blackBase};
46+
}
1647
`;

mscr-ui/src/common/interfaces/search.interface.ts

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface ResultInfo {
3131
revisions: Revision[];
3232
versionLabel: string;
3333
namespace: string;
34+
format?: string;
3435
}
3536

3637
export interface PatchedResult extends ResultInfo {

mscr-ui/src/modules/search-screen/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export default function SearchScreen() {
6969
key,
7070
mscrSearchResults.aggregations[key].buckets
7171
);
72+
if (newFilter.facet == 'organization' || newFilter.facet == 'isReferenced') return;
7273
filters = filters.concat(newFilter);
7374
});
7475
}
@@ -80,7 +81,7 @@ export default function SearchScreen() {
8081
<FacetsWrapper>
8182
{/* Groups of facets for different contexts, made with search-filter-set */}
8283
{filters.length > 0 && (
83-
<SearchFilterSet title={t('in-all-mscr')} filters={filters} />
84+
<SearchFilterSet title={t('search.facets.filter-by')} filters={filters} />
8485
)}
8586
</FacetsWrapper>
8687
</Grid>

mscr-ui/src/modules/search-screen/search-screen.styles.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import styled from 'styled-components';
22
import { Block } from 'suomifi-ui-components';
33

44
export const SearchContainer = styled(Block)`
5-
height: 800px;
5+
height: 100%;
66
position: absolute;
77
background-color: ${(props) => props.theme.suomifi.colors.depthLight3};
88
z-index: 1;

0 commit comments

Comments
 (0)