All files / scripts/generate-news-indexes/template rtl.ts

100% Statements 4/4
100% Branches 4/4
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49                        4x   2x                                                 33x                  
/**
 * @module generate-news-indexes/template/rtl
 * @description Minimal RTL-specific styles. Kept as a public export for
 * backward compatibility; canonical RTL handling is now performed by
 * `buildChrome` via `dir="rtl"` on `<html>`.
 *
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
/** Generate the standalone RTL `<style>` block (legacy export). */
export function generateRTLStyles(isRTL: boolean | undefined): string {
  if (!isRTL) return '';
 
  return `
  <style>
    /* RTL-specific overrides for Arabic and Hebrew */
    .news-page .language-notice {
      border-left: none;
      border-right: 4px solid var(--primary-yellow, #ffbe0b);
    }
 
    .news-page .language-badge {
      margin-left: 0;
      margin-right: 0.5rem;
    }
 
    .news-page .back-link:hover {
      transform: translateX(5px); /* Reverse direction for RTL */
    }
  </style>`;
}
 
/**
 * RTL-specific overrides injected into `buildChrome`'s `extraStyle`. Trimmer
 * than {@link generateRTLStyles} because the canonical chrome already sets
 * `dir="rtl"` on `<html>` so we only need the news-page-specific tweaks.
 */
export function newsPageExtraRtlStyle(isRTL: boolean): string {
  return isRTL ? `
    /* RTL-specific overrides for Arabic and Hebrew */
    .news-page .language-notice {
      border-left: none;
      border-right: 4px solid var(--primary-yellow, #ffbe0b);
    }
    .news-page .language-badge { margin-left: 0; margin-right: 0.5rem; }
` : '';
}