Skip to content

Commit

Permalink
finish basic component abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Mar 5, 2023
1 parent ee346b1 commit 63a1a76
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 96 deletions.
39 changes: 39 additions & 0 deletions src/FsLab.Fornax/Components.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace FsLab.Fornax

type Components() =

static member Icon(iconClass: string) = IconComponent.icon iconClass

static member DefaultHeadTags(siteTitle: string) = DefaultHeadTagsComponent.defaultHeadTags siteTitle

static member Navbar(
?LogoLink: string,
?MenuEntries: HtmlElement list,
?SocialLinks: HtmlElement list
) =
let logoLink = defaultArg LogoLink (TemplateConfig.PrefixUrl "/images/favicon.png")
let menuEntries = defaultArg MenuEntries []
let socialLinks = defaultArg SocialLinks []

NavbarComponent.fslabNavbar logoLink menuEntries socialLinks

static member FooterIconLink(
iconClass: string,
text: string,
link: string
) =
FooterComponent.footerIconLink iconClass text link

static member FooterBlock(children: HtmlElement list) = FooterComponent.footerBlock children

static member Footer(
?Column1: HtmlElement list,
?Column2: HtmlElement list,
?Column3: HtmlElement list
) =

let c1 = defaultArg Column1 FooterComponent.fslabInfoFooterBlock
let c2 = defaultArg Column2 FooterComponent.fslabMoreFooterBlock
let c3 = defaultArg Column3 FooterComponent.fslabExternalFooterBlock

FooterComponent.fslabFooter c1 c2 c3
14 changes: 14 additions & 0 deletions src/FsLab.Fornax/Components/DefaultLinks.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module internal DefaultHeadTagsComponent

open Html
open FsLab.Fornax

let defaultHeadTags siteTitle = [
meta [CharSet "utf-8"]
meta [Name "viewport"; Content "width=device-width, initial-scale=1"]
title [] [!! siteTitle]
link [Rel "icon"; Type "image/png"; Sizes "32x32"; Href (TemplateConfig.PrefixUrl "/images/favicon.png"]
link [Rel "stylesheet"; Href "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"]
link [Rel "stylesheet"; Href "https://fonts.googleapis.com/css?family=Nunito+Sans"]
script [ Defer true; Src "https://kit.fontawesome.com/0d3e0ea7a6.js"; CrossOrigin "anonymous"] []
]
78 changes: 78 additions & 0 deletions src/FsLab.Fornax/Components/Footer.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
module internal FooterComponent

open Html
open FsLab.Fornax

let footerIconLink (iconClass:string) (text:string) (link:string) =
div [Class "icon-text is-white"] [
span [Class"icon"] [
i [Class iconClass] []
]
span [] [a [Class "footer-link"; Href link] [!! text]]
]

let footerBlock children =
div [Class "block"] children

let fslabInfoFooterBlock =
[
div [Class "block"] [
h3 [Class "subtitle is-white"] [!!"FsLab - the project incubation space for data science in F#"]
]
div [Class "block"] [
p [] [!!"FsLab is only possible due to the joined forces of F# open source contributors."]
]
div [Class "block"] [
p [] [!!"This website is created and maintained by individual FsLab open source contributors."]
]
div [Class "block"] [
footerIconLink "fas fa-code-branch" "website source code" "https://github.com/fslaborg/fslaborg.github.io"
footerIconLink "far fa-handshake" "fslab contributors" "https://github.com/orgs/fslaborg/people"
]
]

let fslabMoreFooterBlock =
[
div [Class "block"] [
h3 [Class "subtitle is-white"] [!!"More"]
]
div [Class "block"] [
div [Class "block"] [
footerIconLink "fab fa-github" "the fslab organisation on github" "https://github.com/fslaborg?type=source"
footerIconLink "fab fa-twitter" "fslab on twitter" "https://twitter.com/fslaborg"
]
div [Class "block"] [
footerIconLink "fas fa-cubes" "endorsed packages" "https://fslab.org/packages.html"
footerIconLink "fas fa-plus" "add a package to the list" "https://github.com/fslaborg/fslaborg.github.io#add-a-project-to-the-packages-site"

]
div [Class "block"] [
footerIconLink "fas fa-graduation-cap" "tutorials and learning resources" "https://fslab.org/tutorials.html"
footerIconLink "fas fa-plus" "add tutorial content" "https://github.com/fslaborg/fslaborg.github.io#add-a-tutorial-guide-or-blogpost"
]
]
]

let fslabExternalFooterBlock =
[
div [Class "block"] [
h3 [Class "subtitle is-white"] [!!"External resources"]
]
div [Class "block"] [
ul [] [
li [] [a [Href "https://github.com/fsprojects?type=source"; Class "footer-link"] [!!"fsprojects - general F# project incubation space"]]
li [] [a [Href "https://fsharp.org/"; Class "footer-link"] [!!"fsharp.org"]]
]
]
]

let fslabFooter col1 col2 col3 =
footer [Class "footer has-bg-darkmagenta"] [
div [Class "container"] [
div [Class "columns"] [
div [Class "column is-4 m-4"] col1
div [Class "column is-4 m-4"] col2
div [Class "column is-4 m-4"] col3
]
]
]
8 changes: 8 additions & 0 deletions src/FsLab.Fornax/Components/Icon.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module internal IconComponent

open Html

let icon (iconClass:string) =
span [Class"icon"] [
i [Class iconClass] []
]
28 changes: 28 additions & 0 deletions src/FsLab.Fornax/Components/Nabvbar.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module internal NavbarComponent

open Html
open FsLab.Fornax

let fslabNavbar (logoLink:string) (menuEntries: HtmlElement list) (socialLinks: HtmlElement list) =
nav [Class "navbar is-fixed-top"] [
div [Class "navbar-brand"] [
a [Class "navbar-item"; Href "/"] [
img [Src logoLink; Alt "Logo"]
]
a [
Class "navbar-burger";
HtmlProperties.Custom ("data-target", "navMenu");
HtmlProperties.Custom ("aria-label", "menu");
HtmlProperties.Role "button"
HtmlProperties.Custom ("aria-expanded", "false")
] [
span [HtmlProperties.Custom ("aria-hidden","true")] []
span [HtmlProperties.Custom ("aria-hidden","true")] []
span [HtmlProperties.Custom ("aria-hidden","true")] []
]
]
div [Id "navMenu"; Class "navbar-menu"] [
div [Class "navbar-start"] menuEntries
div [Class "navbar-end"] socialLinks
]
]
7 changes: 0 additions & 7 deletions src/FsLab.Fornax/Components/Navbar.fs

This file was deleted.

68 changes: 0 additions & 68 deletions src/FsLab.Fornax/Components/Root.fs

This file was deleted.

19 changes: 10 additions & 9 deletions src/FsLab.Fornax/FsLab.Fornax.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="Library.fs" />
<Compile Include="Components\Root.fs" />
<Compile Include="Components/Navbar.fs" />
<Content Include="_lib\Fornax.Core.dll">
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)</PackagePath>
</Content>
<Compile Include="TemplateConfig.fs" />
<Compile Include="Components\DefaultLinks.fs" />
<Compile Include="Components\Icon.fs" />
<Compile Include="Components\Nabvbar.fs" />
<Compile Include="Components\Footer.fs" />
<Compile Include="Components.fs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Fornax">
<HintPath>_lib\Fornax.Core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="_lib\Fornax.Core.dll">
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)</PackagePath>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="5.*" />
<PackageReference Include="Markdig" Version="0.30.2" />
Expand Down
12 changes: 0 additions & 12 deletions src/FsLab.Fornax/Library.fs

This file was deleted.

5 changes: 5 additions & 0 deletions src/FsLab.Fornax/TemplateConfig.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace FsLab.Fornax

module TemplateConfig =

let mutable PrefixUrl: string -> string = id

0 comments on commit 63a1a76

Please sign in to comment.