File tree 3 files changed +44
-10
lines changed
src/components/main-section/content-view
3 files changed +44
-10
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ type Props = {
15
15
} ;
16
16
17
17
export const ContentView = ( { content } : Props ) => {
18
- const { html, xmlAsString } = content ;
18
+ const { html, xmlAsString, versionKey } = content ;
19
19
const [ viewState , setViewState ] = useState < ViewState > ( getDefaultViewState ( content ) ) ;
20
20
21
21
useEffect ( ( ) => {
@@ -39,7 +39,7 @@ export const ContentView = ({ content }: Props) => {
39
39
< VersionSelector content = { content } />
40
40
</ div >
41
41
< XmlView xml = { xmlAsString } hidden = { viewState !== 'xml' } />
42
- { html && < HtmlView html = { html } hidden = { viewState !== 'html' } /> }
42
+ { html && < HtmlView html = { html } versionKey = { versionKey } hidden = { viewState !== 'html' } /> }
43
43
{ content . binaries && (
44
44
< FilesView binaries = { content . binaries } hidden = { viewState !== 'files' } />
45
45
) }
Original file line number Diff line number Diff line change 1
- .html {
1
+ .wrapper {
2
+ position : relative;
3
+ height : 100% ;
4
+ width : 100% ;
5
+ }
6
+
7
+ .htmlFrame {
2
8
width : 100% ;
3
9
height : 100% ;
4
10
border : none;
5
11
}
6
12
13
+ .fullscreenButton {
14
+ position : absolute;
15
+ top : 0.25rem ;
16
+ left : 0.25rem ;
17
+ background-color : var (--a-white );
18
+ }
19
+
7
20
.hidden {
8
21
display : none;
9
22
}
Original file line number Diff line number Diff line change 1
1
import React , { useRef } from 'react' ;
2
2
import { classNames } from '../../../../utils/classNames' ;
3
+ import { Button } from '@navikt/ds-react' ;
4
+ import { useAppState } from '../../../../state/useAppState' ;
3
5
4
6
import style from './HtmlView.module.css' ;
5
7
6
8
type Props = {
7
9
html : string ;
10
+ versionKey : string ;
8
11
hidden : boolean ;
9
12
} ;
10
13
11
- export const HtmlView = ( { html, hidden } : Props ) => {
14
+ export const HtmlView = ( { html, versionKey, hidden } : Props ) => {
15
+ const { appContext } = useAppState ( ) ;
12
16
const ref = useRef < HTMLIFrameElement > ( null ) ;
13
17
18
+ const fullscreenPath = `${ appContext . basePath } /html/${ versionKey } ` ;
19
+
14
20
return (
15
- < iframe
16
- srcDoc = { html }
17
- className = { classNames ( style . html , hidden && style . hidden ) }
18
- ref = { ref }
19
- onLoad = { ( e ) => disableLinksAndEventListeners ( e . currentTarget ) }
20
- />
21
+ < div className = { classNames ( style . wrapper , hidden && style . hidden ) } >
22
+ < Button
23
+ size = { 'small' }
24
+ variant = { 'tertiary' }
25
+ as = { 'a' }
26
+ href = { fullscreenPath }
27
+ className = { style . fullscreenButton }
28
+ onClick = { ( e ) => {
29
+ e . preventDefault ( ) ;
30
+ window . open ( fullscreenPath , '_blank' ) ;
31
+ } }
32
+ >
33
+ { 'Åpne i fullskjerm' }
34
+ </ Button >
35
+ < iframe
36
+ src = { html }
37
+ className = { classNames ( style . htmlFrame ) }
38
+ ref = { ref }
39
+ onLoad = { ( e ) => disableLinksAndEventListeners ( e . currentTarget ) }
40
+ />
41
+ </ div >
21
42
) ;
22
43
} ;
23
44
You can’t perform that action at this time.
0 commit comments