@@ -3,7 +3,9 @@ import Link from 'next/link';
3
3
import PropTypes from 'prop-types' ;
4
4
import { Box , Button , Nav , Text } from 'grommet' ;
5
5
import styled , { ThemeContext } from 'styled-components' ;
6
+ import { StatusGoodSmall } from 'grommet-icons' ;
6
7
import { nameToSlug } from '../../utils' ;
8
+ import { ViewContext } from '../../pages/_app' ;
7
9
8
10
const SectionButton = styled ( Button ) `
9
11
border-radius: 0 ${ props => props . theme . global . edgeSize . xsmall }
@@ -44,7 +46,7 @@ const useActiveHeadingId = (headings, options) => {
44
46
return activeHeadingId ;
45
47
} ;
46
48
47
- export const InPageNavigation = ( { headings } ) => {
49
+ export const InPageNavigation = ( { headings, title } ) => {
48
50
const theme = useContext ( ThemeContext ) ;
49
51
50
52
let { large, medium } = theme . global . edgeSize ;
@@ -61,6 +63,8 @@ export const InPageNavigation = ({ headings }) => {
61
63
// align "Jump to section" with page title at start
62
64
const marginTop = `${ large + medium } px` ;
63
65
66
+ const { pageUpdateReady, contentHistory } = useContext ( ViewContext ) ;
67
+
64
68
return (
65
69
< Box
66
70
pad = { { horizontal : 'xxsmall' } } // pad for keyboard focus
@@ -108,6 +112,23 @@ export const InPageNavigation = ({ headings }) => {
108
112
if ( level . length > 3 ) subsectionPad = 'large' ;
109
113
else if ( level . length === 3 ) subsectionPad = 'medium' ;
110
114
115
+ let sectionList ;
116
+ let showUpdate = false ;
117
+
118
+ if (
119
+ contentHistory &&
120
+ title in contentHistory &&
121
+ contentHistory [ title ] . update &&
122
+ contentHistory [ title ] . sections [ 0 ] . length > 0
123
+ ) {
124
+ sectionList = contentHistory [ title ] . sections ;
125
+ Object . values ( sectionList ) . forEach ( val => {
126
+ if ( val . toLowerCase ( ) === headingTitle . toLowerCase ( ) ) {
127
+ showUpdate = true ;
128
+ }
129
+ } ) ;
130
+ }
131
+
111
132
return (
112
133
< Link key = { index } href = { `#${ nameToSlug ( headingTitle ) } ` } passHref >
113
134
< SectionButton theme = { theme } hoverIndicator >
@@ -123,10 +144,23 @@ export const InPageNavigation = ({ headings }) => {
123
144
? undefined
124
145
: { left : theme . global . borderSize . small }
125
146
}
147
+ direction = "row"
148
+ align = "top"
149
+ gap = "small"
126
150
>
127
151
< Text color = "text-strong" size = "small" weight = "normal" >
128
152
{ headingTitle }
129
153
</ Text >
154
+ { showUpdate && pageUpdateReady && (
155
+ < Box background = { { dark : true } } justify = "top" >
156
+ < StatusGoodSmall
157
+ a11yTitle = "Section has been updated"
158
+ size = "10px"
159
+ color = "teal"
160
+ height = "small"
161
+ />
162
+ </ Box >
163
+ ) }
130
164
</ Box >
131
165
</ Box >
132
166
</ SectionButton >
@@ -140,4 +174,5 @@ export const InPageNavigation = ({ headings }) => {
140
174
141
175
InPageNavigation . propTypes = {
142
176
headings : PropTypes . arrayOf ( PropTypes . array ) ,
177
+ title : PropTypes . string ,
143
178
} ;
0 commit comments