Skip to content

Commit d30a756

Browse files
committed
Merge branch 'feature/listevisning-valg-ny'
2 parents 6968259 + c9e330d commit d30a756

File tree

9 files changed

+394
-217
lines changed

9 files changed

+394
-217
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@fortawesome/pro-solid-svg-icons": "^6.1.1",
1515
"@fortawesome/react-fontawesome": "^0.2.0",
1616
"@kartverket/geonorge-web-components": "^4.0.11",
17+
"@navikt/aksel-icons": "^8.9.0",
1718
"@uiw/react-md-editor": "^3.20.5",
1819
"classnames": "^2.2.6",
1920
"connected-react-router": "^6.5.2",

src/components/partials/SearchResults.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import FacetFilter from "@/components/partials/FacetFilter";
2020
// Stylesheets
2121
import style from "@/components/partials/SearchResults.module.scss";
2222

23-
export const SearchResults = ({ searchData, searchResultsType }) => {
23+
export const SearchResults = ({ searchData, searchResultsType, viewMode }) => {
24+
2425
const dispatch = useDispatch();
2526

2627
const getShowMoreLink = () => {
@@ -43,11 +44,21 @@ export const SearchResults = ({ searchData, searchResultsType }) => {
4344
visibleFields={["DownloadButton", "MapButton", "ApplicationButton"]}
4445
key={i}
4546
stretchButtons
47+
viewMode={viewMode}
4648
/>
4749
</ErrorBoundary>
4850
);
4951
});
50-
return React.createElement("div", { className: style.list, key: "searchResult" }, listItemElements);
52+
return React.createElement(
53+
"div",
54+
{
55+
className: viewMode === "list" ? style.resultsList : style.resultsGrid,
56+
key: "searchResult"
57+
},
58+
listItemElements
59+
);
60+
61+
5162
} else {
5263
return null;
5364
}

src/components/partials/SearchResults.module.scss

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
@use "../../scss/abstracts/all" as *;
2-
32
@import "@digdir/designsystemet-css/index.css";
43

5-
4+
/* =========================
5+
TABS
6+
========================= */
67

78
:local(.tabs) {
89
margin: 0 0 32px;
910
list-style: none;
1011
background-color: #f8f8f7;
1112
flex: 1;
13+
1214
@include breakpoint(tablet) {
1315
padding: 0 20px;
1416
}
@@ -23,6 +25,7 @@
2325
font-weight: 600;
2426
margin-right: 16px;
2527
cursor: pointer;
28+
2629
@include breakpoint(tablet) {
2730
padding: 10px;
2831
}
@@ -52,6 +55,10 @@
5255
}
5356
}
5457

58+
/* =========================
59+
SUB TABS
60+
========================= */
61+
5562
:local(.subTabs) {
5663
margin: 0 0 16px;
5764
padding: 0 20px;
@@ -89,37 +96,35 @@
8996
}
9097
}
9198

92-
:local(.downloadcsv) {
93-
margin: 10px;
94-
text-align: right;
95-
margin-bottom: 20px;
99+
/* =========================
100+
RESULT CONTAINERS
101+
========================= */
102+
103+
:local(.resultsGrid) {
104+
display: grid;
105+
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
106+
gap: 24px;
107+
margin-bottom: 24px;
96108
}
97109

98-
:local(.list) {
99-
display: grid;
100-
grid-template-columns:repeat(auto-fill, minmax(350px, 1fr));
101-
gap: 24px;
102-
margin-bottom: 24px;
103110

104-
}
105111

106-
//styling of card component from Designsystemet
107-
:global(.ds-card){
108-
background-color: var(--ds-color-accent-background-default);
109-
color: var (--ds-color-text-default);
112+
:local(.resultsList) {
110113
display: flex;
111114
flex-direction: column;
112-
border-radius:10px;
113-
border: 1px solid #d3d3d3;
114-
width: 100%;
115-
min-height:200px;
116-
padding: 24px;
117-
margin-bottom:24px;
115+
gap: 16px;
116+
margin-bottom: 24px;
118117
}
119118

120-
:local(.list) :global(.ds-card) {
121-
margin-bottom: 0px;
122-
}
119+
/* =========================
120+
MISC UI
121+
========================= */
122+
123+
:local(.downloadcsv) {
124+
margin: 10px;
125+
text-align: right;
126+
margin-bottom: 20px;
127+
}
123128

124129
:local(.morecontainer) {
125130
width: 100%;
@@ -131,6 +136,7 @@
131136
margin: 0 80px 20px;
132137
font-size: 20px;
133138
height: 52px;
139+
134140
> span {
135141
margin: 0 10px;
136142
display: inline-block;
@@ -147,36 +153,29 @@
147153
}
148154
}
149155

156+
/* =========================
157+
LAYOUT STRUCTURE
158+
========================= */
159+
150160
:local(.activeContent) {
151161
display: block;
162+
margin-top: 70px;
163+
152164
@media print {
153165
margin-top: 0;
154166
}
155-
margin-top: 70px;
156-
flex-wrap: nowrap;
167+
157168
@include breakpoint(tablet) {
158169
flex: 4;
159170
display: flex;
160171
margin-top: 0;
161172
}
162173
}
163174

164-
:local(.resetSearchResults) {
165-
margin-left: 10px;
166-
}
167-
168-
.hide {
169-
display: none;
170-
}
171-
172-
.show {
173-
display: inline;
174-
padding-left: 10px;
175-
}
176-
177175
:local(.searchResultContainer) {
178176
flex: 100%;
179177
margin: 0 20px;
178+
180179
@include breakpoint(tablet) {
181180
flex: 3;
182181
}
@@ -195,3 +194,20 @@
195194
display: block;
196195
margin-bottom: 10px;
197196
}
197+
198+
/* =========================
199+
UTIL
200+
========================= */
201+
202+
:local(.resetSearchResults) {
203+
margin-left: 10px;
204+
}
205+
206+
.hide {
207+
display: none;
208+
}
209+
210+
.show {
211+
display: inline;
212+
padding-left: 10px;
213+
}

src/components/partials/SearchResults/MetadataSearchResult.jsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import style from "@/components/partials/SearchResults/MetadataSearchResult.modu
3535
const MetadataSearchResult = (props) => {
3636
const dispatch = useDispatch();
3737

38+
39+
3840
// State
3941
const [copied, setCopied] = useState(false);
4042

@@ -256,15 +258,17 @@ const MetadataSearchResult = (props) => {
256258

257259
return (
258260
//designsystemet list card element
259-
<div className={style.listItem}>
261+
<div className={`${style.listItem} ${props.viewMode === "list" ? style.listMode : style.gridMode}`}>
260262
<Card color="neutral" variant="outline">
261263
{props.enableThumbnail ? renderThumbnail() : null}
262-
{renderListItemInfo()}
263-
<span className={style.listItemTitle}>
264+
<div className={style.contentWrapper}>
265+
{renderListItemInfo()}
266+
<span className={style.listItemTitle}>
264267
<ErrorBoundary>{renderLink()}</ErrorBoundary>
265-
</span>
266-
<div className={style.flex}>
268+
</span>
269+
<div className={style.flex}>
267270
{renderType()} {renderDistributionFormats()}
271+
</div>
268272
</div>
269273
{renderButtons()}
270274
</Card>
@@ -276,12 +280,14 @@ const MetadataSearchResult = (props) => {
276280

277281
MetadataSearchResult.propTypes = {
278282
searchResult: PropTypes.object.isRequired,
279-
visibleFields: PropTypes.array
283+
visibleFields: PropTypes.array,
284+
viewMode: PropTypes.oneOf(["grid", "list"])
280285
};
281286

282287
MetadataSearchResult.defaultProps = {
283288
visibleFields: [],
284-
enableThumbnail: true
289+
enableThumbnail: true,
290+
viewMode: "grid"
285291
};
286292

287293
export default MetadataSearchResult;

0 commit comments

Comments
 (0)