|
1 | 1 | import { PageWithHeader } from '@backstage/core-components'; |
2 | | -import { TechDocsReaderPageContent } from '@backstage/plugin-techdocs'; |
3 | | -import { TechDocsReaderPageProvider } from '@backstage/plugin-techdocs-react'; |
4 | | -import React from 'react'; |
| 2 | +import React, { useLayoutEffect, useRef, useState } from 'react'; |
5 | 3 |
|
6 | | -export const DeveloperGuidePage = () => ( |
7 | | - <PageWithHeader title="Developer Guide" themeId="documentation"> |
8 | | - <TechDocsReaderPageProvider |
9 | | - entityRef={{ |
10 | | - kind: 'component', |
11 | | - namespace: 'default', |
12 | | - name: 'developer-guide', |
13 | | - }} |
14 | | - > |
15 | | - <TechDocsReaderPageContent /> |
16 | | - </TechDocsReaderPageProvider> |
17 | | - </PageWithHeader> |
18 | | -); |
| 4 | +export const DeveloperGuidePage = () => { |
| 5 | + const anchorRef = useRef<HTMLDivElement | null>(null); |
| 6 | + const [top, setTop] = useState(0); |
| 7 | + const [left, setLeft] = useState(0); |
| 8 | + |
| 9 | + useLayoutEffect(() => { |
| 10 | + function updateOffsets() { |
| 11 | + if (anchorRef.current) { |
| 12 | + const rect = anchorRef.current.getBoundingClientRect(); |
| 13 | + setTop(rect.top); |
| 14 | + setLeft(rect.left); |
| 15 | + } |
| 16 | + } |
| 17 | + |
| 18 | + updateOffsets(); |
| 19 | + window.addEventListener('resize', updateOffsets); |
| 20 | + return () => window.removeEventListener('resize', updateOffsets); |
| 21 | + }, []); |
| 22 | + |
| 23 | + return ( |
| 24 | + <PageWithHeader title="Developer Guide" themeId="documentation"> |
| 25 | + {/* Marker element inside content area */} |
| 26 | + <div ref={anchorRef} /> |
| 27 | + <div |
| 28 | + style={{ |
| 29 | + position: 'fixed', |
| 30 | + top, |
| 31 | + left, |
| 32 | + right: 0, |
| 33 | + bottom: 0, |
| 34 | + }} |
| 35 | + > |
| 36 | + <iframe |
| 37 | + src="https://dev-guide.diamond.ac.uk" |
| 38 | + title="Embedded Docs" |
| 39 | + style={{ width: '100%', height: '100%', border: 'none' }} |
| 40 | + /> |
| 41 | + </div> |
| 42 | + </PageWithHeader> |
| 43 | + ); |
| 44 | +}; |
0 commit comments