Skip to content

Commit 306a226

Browse files
committed
Move fullscreen button to ContentView and update related components
1 parent d779266 commit 306a226

File tree

3 files changed

+33
-26
lines changed

3 files changed

+33
-26
lines changed

legacy-archive/client/components/main-section/content-view/ContentView.module.css

+5
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@
1616
.header {
1717
margin-bottom: 0.25rem;
1818
}
19+
20+
.viewSelectorWrapper {
21+
display: flex;
22+
gap: 1rem;
23+
}

legacy-archive/client/components/main-section/content-view/ContentView.tsx

+28-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React, { useEffect, useState } from 'react';
2+
import { ExternalLinkIcon } from '@navikt/aksel-icons';
3+
import { useAppState } from 'client/context/app-state/useAppState';
24
import { CmsContent } from '../../../../shared/cms-documents/content';
35
import { XmlView } from './xml-view/XmlView';
46
import { HtmlView } from './html-view/HtmlView';
57
import { FilesView } from './files-view/FilesView';
68
import { ViewSelector, ViewState } from '../view-selector/ViewSelector';
79
import { VersionSelector } from './version-selector/VersionSelector';
8-
import { Heading } from '@navikt/ds-react';
10+
import { Button, Heading } from '@navikt/ds-react';
911
import { CategoriesPath } from '../../common/categories-path/CategoriesPath';
1012
import { PdfExporter } from './pdf-exporter/PdfExporter';
1113

@@ -23,6 +25,9 @@ export const ContentView = ({ content }: Props) => {
2325
setViewState(getDefaultViewState(content));
2426
}, [content]);
2527

28+
const { appContext } = useAppState();
29+
const fullscreenPath = `${appContext.basePath}/html/${versionKey}`;
30+
2631
return (
2732
<>
2833
<CategoriesPath path={content.path} className={style.path} />
@@ -31,11 +36,28 @@ export const ContentView = ({ content }: Props) => {
3136
<Heading size={'medium'} level={'2'} className={style.header}>
3237
{content.displayName}
3338
</Heading>
34-
<ViewSelector
35-
content={content}
36-
viewState={viewState}
37-
setViewState={setViewState}
38-
/>
39+
<div className={style.viewSelectorWrapper}>
40+
<ViewSelector
41+
content={content}
42+
viewState={viewState}
43+
setViewState={setViewState}
44+
/>
45+
<Button
46+
size={'small'}
47+
variant={'primary'}
48+
as={'a'}
49+
href={fullscreenPath}
50+
className={style.fullscreenButton}
51+
icon={<ExternalLinkIcon />}
52+
iconPosition={'right'}
53+
onClick={(e) => {
54+
e.preventDefault();
55+
window.open(fullscreenPath, '_blank');
56+
}}
57+
>
58+
{'Åpne i nytt vindu'}
59+
</Button>
60+
</div>
3961
</div>
4062
<VersionSelector content={content} />
4163
</div>

legacy-archive/client/components/main-section/content-view/html-view/HtmlView.tsx

-20
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import React, { useRef } from 'react';
22
import { classNames } from '../../../../../../common/src/client/utils/classNames';
3-
import { Button } from '@navikt/ds-react';
4-
import { useAppState } from '../../../../context/app-state/useAppState';
5-
import { ExpandIcon } from '@navikt/aksel-icons';
63

74
import style from './HtmlView.module.css';
85

@@ -15,25 +12,8 @@ type Props = {
1512
export const HtmlView = ({ html, versionKey, hidden }: Props) => {
1613
const ref = useRef<HTMLIFrameElement>(null);
1714

18-
const { appContext } = useAppState();
19-
const fullscreenPath = `${appContext.basePath}/html/${versionKey}`;
20-
2115
return (
2216
<div className={classNames(style.wrapper, hidden && style.hidden)}>
23-
<Button
24-
size={'small'}
25-
variant={'primary'}
26-
as={'a'}
27-
href={fullscreenPath}
28-
className={style.fullscreenButton}
29-
icon={<ExpandIcon />}
30-
onClick={(e) => {
31-
e.preventDefault();
32-
window.open(fullscreenPath, '_blank');
33-
}}
34-
>
35-
{'Åpne i nytt vindu'}
36-
</Button>
3717
<iframe
3818
srcDoc={html}
3919
className={classNames(style.htmlFrame)}

0 commit comments

Comments
 (0)