Skip to content

Commit

Permalink
WIP component library
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Mar 5, 2023
1 parent fbdd4cc commit ee346b1
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 6 deletions.
20 changes: 20 additions & 0 deletions FsLab.Fornax.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7A29E68D-D088-4CA6-BDEE-E94C54A52AC3}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsLab.Fornax", "src\FsLab.Fornax\FsLab.Fornax.fsproj", "{76E264BA-9DD8-47CF-98EF-6C40E99E50FC}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsLab.Fornax.Template", "src\FsLab.Fornax.Template\FsLab.Fornax.Template.fsproj", "{B8759DFA-603B-4CD3-BF22-3C1A6532B360}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -11,4 +17,18 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{76E264BA-9DD8-47CF-98EF-6C40E99E50FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76E264BA-9DD8-47CF-98EF-6C40E99E50FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76E264BA-9DD8-47CF-98EF-6C40E99E50FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76E264BA-9DD8-47CF-98EF-6C40E99E50FC}.Release|Any CPU.Build.0 = Release|Any CPU
{B8759DFA-603B-4CD3-BF22-3C1A6532B360}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8759DFA-603B-4CD3-BF22-3C1A6532B360}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8759DFA-603B-4CD3-BF22-3C1A6532B360}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8759DFA-603B-4CD3-BF22-3C1A6532B360}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{76E264BA-9DD8-47CF-98EF-6C40E99E50FC} = {7A29E68D-D088-4CA6-BDEE-E94C54A52AC3}
{B8759DFA-603B-4CD3-BF22-3C1A6532B360} = {7A29E68D-D088-4CA6-BDEE-E94C54A52AC3}
EndGlobalSection
EndGlobal
3 changes: 2 additions & 1 deletion client/generators/index.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let generate' (ctx : SiteContents) (_: string) =
]
]


// For a generator file to be used in fornax (meaning as a generator in the Fornax config in `config.fsx`),
// it must always end with a `generate` function that returns a string (which is the content that gets written to a file)
let generate (ctx : SiteContents) (projectRoot: string) (page: string) =
generate' ctx page
2 changes: 2 additions & 0 deletions client/globals.fsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


#if WATCH
let urlPrefix =
""
Expand Down
7 changes: 7 additions & 0 deletions src/FsLab.Fornax/Components/Navbar.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace FsLab.Fornax.Components

open Html

type Navbar() =

static member navbar [] [] = ()
68 changes: 68 additions & 0 deletions src/FsLab.Fornax/Components/Root.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace FsLab.Fornax.Components

open Html
open FsLab.Fornax.Helpers


type RootOption =
| Title of string
| PrefixUrl of (string -> string)
| AdditionalHeadTags of HtmlElement list

type internal RootConfig = {
mutable Title : string
mutable PrefixUrl: string -> string
mutable AdditionalHeadTags: HtmlElement list
} with
static member defaultConfig() =
{
Title = ""
PrefixUrl = id
AdditionalHeadTags = []
}
static member ofOptions (opts: RootOption list) =

let config = RootConfig.defaultConfig()

opts
|> List.iter (fun opt ->
match opt with
| Title t -> config.Title <- t
| PrefixUrl f -> config.PrefixUrl <- f
| AdditionalHeadTags t -> config.AdditionalHeadTags <- t
)

config

type Root() =

static member root (rootOptions: RootOption list) (children: HtmlElement list) =

let config = RootConfig.ofOptions rootOptions

html [Class "has-navbar-fixed-top"] [
head [] [
meta [CharSet "utf-8"]
meta [Name "viewport"; Content "width=device-width, initial-scale=1"]
title [] [!! config.Title]
link [Rel "icon"; Type "image/png"; Sizes "32x32"; Href "/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"]
link [Rel "stylesheet"; Href "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.1/css/bulma.min.css"]
link [Rel "stylesheet"; Href "https://cdn.jsdelivr.net/npm/bulma-carousel@4.0.4/dist/css/bulma-carousel.min.css"]
link [Rel "stylesheet"; Type "text/css"; Href (config.PrefixUrl "/style/style.css")]
link [Rel "stylesheet"; Type "text/css"; Href "https://cdn.jsdelivr.net/npm/@creativebulma/bulma-collapsible@1.0.4/dist/css/bulma-collapsible.min.css"]

script [ Defer true; Src "https://kit.fontawesome.com/0d3e0ea7a6.js"; CrossOrigin "anonymous"] []

script [ Defer true; Type "text/javascript"; Src "https://cdn.jsdelivr.net/npm/@creativebulma/bulma-collapsible@1.0.4/dist/js/bulma-collapsible.min.js"] []
script [ Defer true; Type "text/javascript"; Src ("https://cdn.jsdelivr.net/npm/bulma-carousel@4.0.4/dist/js/bulma-carousel.min.js") ] []

script [ Defer true; Type "text/javascript"; Src (config.PrefixUrl "/js/prism.js") ] []
script [ Defer true; Type "text/javascript"; Src (config.PrefixUrl "/js/slider.js") ] []
script [ Defer true; Type "text/javascript"; Src (config.PrefixUrl "/js/navbar.js") ] []

yield! config.AdditionalHeadTags
]
body [] []
]
20 changes: 18 additions & 2 deletions src/FsLab.Fornax/FsLab.Fornax.fsproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="Library.fs" />
<Compile Include="Components\Root.fs" />
<Compile Include="Components/Navbar.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" />
</ItemGroup>

</Project>
13 changes: 10 additions & 3 deletions src/FsLab.Fornax/Library.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
namespace FsLab.Fornax

module Say =
let hello name =
printfn "Hello %s" name
[<AutoOpen>]
module internal Helpers =

[<AutoOpen>]
module List =

let tryFindDefault (predicate: 'T -> bool) (defaultValue: 'T) (list: 'T List) =
list
|> List.tryFind predicate
|> Option.defaultValue defaultValue
Binary file added src/FsLab.Fornax/_lib/Fornax.Core.dll
Binary file not shown.

0 comments on commit ee346b1

Please sign in to comment.