export function generateStaticFlexLayoutStyles()

in projects/libs/flex-layout/server/server-provider.ts [32:61]


export function generateStaticFlexLayoutStyles(serverSheet: StylesheetMap,
                                               mediaController: ServerMatchMedia,
                                               breakpoints: BreakPoint[],
                                               mediaMarshaller: MediaMarshaller) {
  // Store the custom classes in the following map, that way only
  // one class gets allocated per HTMLElement, and each class can
  // be referenced in the static media queries
  const classMap = new Map<HTMLElement, string>();

  // Get the initial stylings for all the directives,
  // and initialize the fallback block of stylings.
  const defaultStyles = new Map(serverSheet.stylesheet);
  // Reset the class counter, otherwise class numbers will
  // increase with each server render.
  nextId = 0;
  let styleText = generateCss(defaultStyles, 'all', classMap);
  mediaMarshaller.useFallbacks = false;

  [...breakpoints].sort(sortAscendingPriority).forEach((bp) => {
    serverSheet.clearStyles();
    mediaController.activateBreakpoint(bp);
    const stylesheet = new Map(serverSheet.stylesheet);
    if (stylesheet.size > 0) {
      styleText += generateCss(stylesheet, bp.mediaQuery, classMap);
    }
    mediaController.deactivateBreakpoint(bp);
  });

  return styleText;
}