import Foundation


struct NavigationBar: HtmlProducer {

    struct Link {

        let text: String

        let url: String
    }

    private let links: [Link]

    private let languageButton: Link

    private let iconUrl: String

    init(links: [Link], languageButton: Link, iconUrl: String) {
        self.links = links
        self.languageButton = languageButton
        self.iconUrl = iconUrl
    }

    func populate(_ result: inout String) {
        result += "<nav class='navbar'>"
        result += "<div class='fade'></div>"
        result += "<div class='centered'>"
        result += "<a class='icon-link' href='\(iconUrl)'><div class='icon'></div></a>"
        result += "<div class='buttons'><input type='checkbox' id='menu-toggle'>"
        result += "<label for='menu-toggle' class='burger'><div></div><div></div><div></div></label>"
        result += "<ul>"
        for item in links {
            result += "<li><a href='\(item.url)'>\(item.text)</a></li>"
        }
        result += "</ul>"
        result += "<a class='lang-button' href='\(languageButton.url)'>\(languageButton.text)</a>"
        result += "</div></div></nav>" // Close buttons, centered, navbar
    }
}
