MCPcopy Create free account
hub / github.com/github/docs / CollapsibleReleaseSection

Function CollapsibleReleaseSection

components/release-notes/GHESReleaseNotes.tsx:120–177  ·  view source on GitHub ↗
({
  release,
  releaseLink,
  focusedPatch,
}: {
  release: GHESReleaseNotesContextT['releases'][0]
  releaseLink: string
  focusedPatch: string
})

Source from the content-addressed store, hash-verified

118}
119
120const CollapsibleReleaseSection = ({
121 release,
122 releaseLink,
123 focusedPatch,
124}: {
125 release: GHESReleaseNotesContextT['releases'][0]
126 releaseLink: string
127 focusedPatch: string
128}) => {
129 const defaultIsOpen = true
130 const [isOpen, setIsOpen] = useState(defaultIsOpen)
131
132 const onToggle = (e: SyntheticEvent) => {
133 const newIsOpen = (e.target as HTMLDetailsElement).open
134 setIsOpen(newIsOpen)
135 }
136 return (
137 <li key={release.version} className="border-bottom">
138 <details
139 className="my-0 details-reset release-notes-version-picker"
140 aria-current="page"
141 open={defaultIsOpen}
142 onToggle={onToggle}
143 >
144 <summary className="px-3 py-4 my-0 d-flex flex-items-center flex-justify-between outline-none">
145 {release.version}
146 <div className="d-flex">
147 <span className="color-fg-muted text-small text-normal mr-1">
148 {release.patches.length} {release.patches.length === 1 ? 'release' : 'releases'}
149 </span>
150 <ChevronDownIcon className={isOpen ? 'rotate-180' : ''} />
151 </div>
152 </summary>
153 <ul className="color-bg-subtle border-top list-style-none py-4 px-0 my-0">
154 {release.patches.map((patch) => {
155 const isActive = patch.version === focusedPatch
156 return (
157 <li
158 key={patch.version}
159 className={cx('px-3 my-0 py-1', isActive && 'color-bg-accent')}
160 >
161 <Link
162 href={`${releaseLink}#${patch.version}`}
163 className="d-flex flex-items-center flex-justify-between"
164 >
165 {patch.version}
166 <span className="color-fg-muted text-mono text-small text-normal">
167 {dayjs(patch.date).format('MMMM DD, YYYY')}
168 </span>
169 </Link>
170 </li>
171 )
172 })}
173 </ul>
174 </details>
175 </li>
176 )
177}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected