Commit 3956a2c4 authored by Jakob Moser's avatar Jakob Moser
Browse files

Extract tab into piece

parent 46c53406
Loading
Loading
Loading
Loading
+3 −12
Changes for frontend/TabBar.mjs: 3 added lines, 12 removed lines.
Original line number Diff line number Diff line
import { Tab } from "./components/pieces/Tab.mjs"

// TabBar.mjs
const TabBar = {
    view: function (vnode) {
@@ -10,18 +12,7 @@ const TabBar = {

        return m(
            "nav",
            tabs.map(tab => {
                return m(
                    m.route.Link,
                    {
                        class: currentView === tab.id ? "active" : "",
                        href: `/${tab.id}`,
                        role: "button", // Für Barrierefreiheit
                        tabindex: 0, // Für Tastaturnavigation
                    },
                    tab.label,
                )
            }),
            tabs.map(it => m(Tab, it)),
        )
    },
}
+16 −0
Changes for frontend/components/pieces/Tab.mjs: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
export const Tab = {
    view(vnode) {
        const route = `/${vnode.attrs.id}`

        return m(
            m.route.Link,
            {
                class: m.route.get() === route ? "active" : "",
                href: route,
                role: "button", // Für Barrierefreiheit
                tabindex: 0, // Für Tastaturnavigation
            },
            vnode.attrs.label,
        )
    }
}