@@ -229,6 +229,86 @@ export function updateElementsVisibilityForOptions(
229229 } ) ;
230230 }
231231 } ) ;
232+
233+ // Handle integrations wrapper: hide opening/closing brackets if no integrations are visible
234+ const openWrappers = document . querySelectorAll < HTMLElement > (
235+ '[data-integrations-wrapper="open"]'
236+ ) ;
237+
238+ openWrappers . forEach ( openLine => {
239+ const codeBlock = openLine . closest ( 'code.code-highlight' ) ;
240+ if ( ! codeBlock ) return ;
241+
242+ const allLines = Array . from ( codeBlock . children ) as HTMLElement [ ] ;
243+ const openIndex = allLines . indexOf ( openLine ) ;
244+
245+ // Find the matching close line in the same code block
246+ let closeIndex = - 1 ;
247+ for ( let i = openIndex + 1 ; i < allLines . length ; i ++ ) {
248+ if ( allLines [ i ] . dataset . integrationsWrapper === 'close' ) {
249+ closeIndex = i ;
250+ break ;
251+ }
252+ }
253+
254+ if ( closeIndex === - 1 ) return ;
255+
256+ // Check if any lines between open and close are visible (non-marker lines)
257+ let hasVisibleIntegrations = false ;
258+ for ( let i = openIndex + 1 ; i < closeIndex ; i ++ ) {
259+ const line = allLines [ i ] ;
260+ const isHidden = line . classList . contains ( 'hidden' ) ;
261+ const isMarker = line . dataset . onboardingOptionHidden ;
262+
263+ // Count any visible non-marker line
264+ if ( ! isMarker && ! isHidden ) {
265+ hasVisibleIntegrations = true ;
266+ break ;
267+ }
268+ }
269+
270+ // Toggle visibility of both open and close lines
271+ openLine . classList . toggle ( 'hidden' , ! hasVisibleIntegrations ) ;
272+ allLines [ closeIndex ] . classList . toggle ( 'hidden' , ! hasVisibleIntegrations ) ;
273+
274+ // Hide empty lines adjacent to the wrapper when no integrations are visible
275+ if ( ! hasVisibleIntegrations ) {
276+ // Check line before open wrapper
277+ if ( openIndex > 0 ) {
278+ const prevLine = allLines [ openIndex - 1 ] ;
279+ if ( ! prevLine . textContent ?. trim ( ) ) {
280+ prevLine . classList . add ( 'hidden' ) ;
281+ prevLine . dataset . emptyLineHidden = 'true' ;
282+ }
283+ }
284+
285+ // Check line after close wrapper
286+ if ( closeIndex < allLines . length - 1 ) {
287+ const nextLine = allLines [ closeIndex + 1 ] ;
288+ if ( ! nextLine . textContent ?. trim ( ) ) {
289+ nextLine . classList . add ( 'hidden' ) ;
290+ nextLine . dataset . emptyLineHidden = 'true' ;
291+ }
292+ }
293+ } else {
294+ // Show empty lines when integrations are visible
295+ if ( openIndex > 0 ) {
296+ const prevLine = allLines [ openIndex - 1 ] ;
297+ if ( prevLine . dataset . emptyLineHidden === 'true' ) {
298+ prevLine . classList . remove ( 'hidden' ) ;
299+ delete prevLine . dataset . emptyLineHidden ;
300+ }
301+ }
302+
303+ if ( closeIndex < allLines . length - 1 ) {
304+ const nextLine = allLines [ closeIndex + 1 ] ;
305+ if ( nextLine . dataset . emptyLineHidden === 'true' ) {
306+ nextLine . classList . remove ( 'hidden' ) ;
307+ delete nextLine . dataset . emptyLineHidden ;
308+ }
309+ }
310+ }
311+ } ) ;
232312}
233313
234314export function OnboardingOptionButtons ( {
0 commit comments