import React from "react"; import { BrowserSupportNote } from "./browser-support-note"; function shouldDisplayBlock(blockDisplayed, versionAdded) { if (blockDisplayed) { return !!versionAdded; } return true; } function flagInfoForBrowser(browser) { switch (browser) { case "chrome": case "chrome_android": return "To change preferences in Chrome, visit chrome://flags."; case "firefox": case "firefox_android": return "To change preferences in Firefox, visit about:config."; default: return ""; } } export const BrowserSupportNotes: any = ({ indexNote, blockElementTag, noteElementTag, noBlocks, }) => { let blockDisplayed = false; let browserSupportNotes: any = []; let currentNoteContent, currentNote; if (Array.isArray(indexNote.support) && indexNote.notes.length === 0) { browserSupportNotes.push( ); blockDisplayed = true; } else if (indexNote.notes.length > 0) { browserSupportNotes.push( indexNote.notes.map((note, index) => { currentNoteContent = ( <> Notes ); currentNote = ( ); blockDisplayed = true; return currentNote; }) ); blockDisplayed = true; } if (indexNote.flags.length > 0) { browserSupportNotes.push( indexNote.flags.map((flag, index) => { currentNoteContent = ( <> Disabled {" "} From version {flag.version_added || indexNote.version_added}: this feature is behind the {flag.name} {flag.type} {!!flag.value_to_set && ` (needs to be set to ${flag.value_to_set})`} . {flagInfoForBrowser(indexNote.browser)} ); return ( ); }) ); } if (indexNote.alternatives.length > 0) { browserSupportNotes.push( indexNote.alternatives.map((alternative, index) => { currentNoteContent = ( <> Alternate Name {" "} Uses the non-standard name:{" "} {alternative.alternative_name} ); return ( ); }) ); } if (indexNote.prefixes.length > 0) { browserSupportNotes.push( indexNote.prefixes.map((prefix, index) => { currentNoteContent = ( <> Prefixed Implemented with the vendor prefix: {prefix.prefix} ); return ( ); }) ); } return browserSupportNotes; };