Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splitt alle sidetyper ut i egne navnerom
- Loading branch information
Showing
5 changed files
with
153 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(ns matvaretabellen.pages.food-group-page | ||
(:require [datomic-type-extensions.api :as d] | ||
[matvaretabellen.urls :as urls] | ||
[mt-designsystem.components.breadcrumbs :refer [Breadcrumbs]] | ||
[mt-designsystem.components.site-header :refer [SiteHeader]])) | ||
|
||
(defn create-food-group-breadcrumbs [locale food-group url?] | ||
(let [food-group-name (get-in food-group [:food-group/name locale])] | ||
(concat (when-let [parent (:food-group/parent food-group)] | ||
(create-food-group-breadcrumbs locale parent true)) | ||
[(cond-> {:text food-group-name} | ||
url? (assoc :url (urls/get-food-group-url locale food-group-name)))]))) | ||
|
||
(defn render [context _db page] | ||
(let [food-group (d/entity (:foods/db context) | ||
[:food-group/id (:food-group/id page)]) | ||
locale (:page/locale page)] | ||
[:html | ||
[:body | ||
(SiteHeader {:home-url "/"}) | ||
[:div | ||
[:div.mvt-hero-banner | ||
[:div.container | ||
(Breadcrumbs {:links (concat [{:text "Mattilsynet.no" :url "https://www.mattilsynet.no/"} | ||
{:text [:i18n :breadcrumbs/search-label] :url "/"} | ||
{:text [:i18n :breadcrumbs/all-food-groups] :url [:i18n :breadcrumbs/food-groups-url]}] | ||
(create-food-group-breadcrumbs locale food-group false))})]] | ||
[:div.mvt-hero-banner | ||
[:div.container | ||
[:h1.h1 (get-in food-group [:food-group/name locale])] | ||
[:div.mvt-cards.mtl | ||
(for [child (:food-group/_parent food-group)] | ||
(let [the-name (get-in child [:food-group/name locale])] | ||
[:a.mvt-card {:href (urls/get-food-group-url locale the-name)} | ||
the-name]))]]]]]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(ns matvaretabellen.pages.food-groups-page | ||
(:require [datomic-type-extensions.api :as d] | ||
[matvaretabellen.urls :as urls] | ||
[mt-designsystem.components.breadcrumbs :refer [Breadcrumbs]] | ||
[mt-designsystem.components.site-header :refer [SiteHeader]])) | ||
|
||
(defn render [context _db page] | ||
(let [db (:foods/db context) | ||
food-groups (map #(d/entity db %) | ||
(d/q '[:find [?e ...] | ||
:where | ||
[?e :food-group/id] | ||
(not [?e :food-group/parent])] | ||
db)) | ||
locale (:page/locale page)] | ||
[:html | ||
[:body | ||
(SiteHeader {:home-url "/"}) | ||
[:div | ||
[:div.mvt-hero-banner | ||
[:div.container | ||
(Breadcrumbs {:links [{:text "Mattilsynet.no" :url "https://www.mattilsynet.no/"} | ||
{:text [:i18n :breadcrumbs/search-label] :url "/"} | ||
{:text [:i18n :breadcrumbs/all-food-groups] :url [:i18n :breadcrumbs/food-groups-url]}]})]] | ||
[:div.mvt-hero-banner | ||
[:div.container | ||
[:h1.h1 [:i18n :food-groups/all-food-groups]] | ||
[:div.mvt-cards.mtl | ||
(for [child food-groups] | ||
(let [the-name (get-in child [:food-group/name locale])] | ||
[:a.mvt-card {:href (urls/get-food-group-url locale the-name)} | ||
the-name]))]]]]]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
(ns matvaretabellen.pages.food-page | ||
(:require [datomic-type-extensions.api :as d] | ||
[matvaretabellen.components.toc :refer [Toc]] | ||
[matvaretabellen.urls :as urls] | ||
[mt-designsystem.components.breadcrumbs :refer [Breadcrumbs]] | ||
[mt-designsystem.components.site-header :refer [SiteHeader]])) | ||
|
||
(defn create-food-group-breadcrumbs [locale food-group url?] | ||
(let [food-group-name (get-in food-group [:food-group/name locale])] | ||
(concat (when-let [parent (:food-group/parent food-group)] | ||
(create-food-group-breadcrumbs locale parent true)) | ||
[(cond-> {:text food-group-name} | ||
url? (assoc :url (urls/get-food-group-url locale food-group-name)))]))) | ||
|
||
(defn render [context _db page] | ||
(let [food (d/entity (:foods/db context) [:food/id (:food/id page)]) | ||
locale (:page/locale page) | ||
food-name (get-in food [:food/name locale])] | ||
[:html | ||
[:body | ||
(SiteHeader {:home-url "/"}) | ||
[:div | ||
[:div.mvt-hero-banner | ||
[:div.container | ||
(Breadcrumbs | ||
{:links (concat | ||
[{:text "Mattilsynet.no" :url "https://www.mattilsynet.no/"} | ||
{:text [:i18n :breadcrumbs/search-label] :url "/"} | ||
{:text [:i18n :breadcrumbs/all-food-groups] :url [:i18n :breadcrumbs/food-groups-url]}] | ||
(create-food-group-breadcrumbs locale (:food/food-group food) true) | ||
[{:text food-name}])})]] | ||
[:div.mvt-hero-banner | ||
[:div.container | ||
[:div {:style {:display "flex"}} | ||
[:div {:style {:flex "1"}} | ||
[:h1.h1 food-name] | ||
[:div.intro.mtl | ||
[:div [:i18n :food/food-id {:id (:food/id food)}]] | ||
[:div [:i18n :food/category {:category (get-in food [:food/food-group :food-group/name locale])}] ] | ||
[:div [:i18n :food/latin-name {:food/latin-name (:food/latin-name food)}]]]] | ||
(Toc {:title [:i18n :food/toc-title] | ||
:contents [{:title [:i18n :food/nutrition-title] | ||
:href "#naeringsinnhold" | ||
:contents [{:title [:i18n :food/energy-title] | ||
:href "#energi"} | ||
{:title [:i18n :food/fat-title] | ||
:href "#fett"} | ||
{:title [:i18n :food/carbohydrates-title] | ||
:href "#karbohydrater"} | ||
{:title [:i18n :food/vitamins-title] | ||
:href "#vitaminer"} | ||
{:title [:i18n :food/minerals-title] | ||
:href "#mineraler"}]} | ||
{:title [:i18n :food/adi-title] | ||
:href "#adi"} | ||
{:title [:i18n :food/description-title] | ||
:href "#beskrivelse"}]})]]]]]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(ns matvaretabellen.pages.frontpage | ||
(:require [mt-designsystem.components.breadcrumbs :refer [Breadcrumbs]] | ||
[mt-designsystem.components.search-input :refer [SearchInput]] | ||
[mt-designsystem.components.site-header :refer [SiteHeader]])) | ||
|
||
(defn render [_context _db _page] | ||
[:html | ||
[:body | ||
(SiteHeader {:home-url "/"}) | ||
[:div | ||
[:div.container.mtl | ||
(Breadcrumbs | ||
{:links [{:text "Mattilsynet.no" :url "https://www.mattilsynet.no/"} | ||
{:text [:i18n :frontpage/search-label]}]})] | ||
[:div.container.mtl | ||
[:div.search-input-wrap | ||
(SearchInput {:label [:i18n :frontpage/search-label] | ||
:button {:text [:i18n :frontpage/search-button]} | ||
:input {:name "foods-search"} | ||
:autocomplete-id "foods-results"})]]]]]) |