-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07cc998
commit 1073e07
Showing
16 changed files
with
394 additions
and
21,096 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"FSharp.inlayHints.parameterNames": false | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,41 +1,40 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Content Include="styles\styles.css" /> | ||
<None Include="styles\styles_dark.scss" /> | ||
<None Include="styles\styles_light.scss" /> | ||
<Compile Include="Literals.fs" /> | ||
<Compile Include="Extensions.fs" /> | ||
<Compile Include="Routing.fs" /> | ||
<Compile Include="Classes.fs" /> | ||
<Compile Include="Dice\Dice.Icon.fs" /> | ||
<Compile Include="Dice\Dice.Roll.fs" /> | ||
<Compile Include="Dice\Dice.Parsing.fs" /> | ||
<Compile Include="Dice\Dice.HtmlAux.fs" /> | ||
<Compile Include="LocalStorage.fs" /> | ||
<Compile Include="States.fs" /> | ||
<Compile Include="Components\Component.DarkModeButton.fs" /> | ||
<Compile Include="Components\Component.Shake.fs" /> | ||
<Compile Include="Components\Component.QuickAccess.fs" /> | ||
<Compile Include="Components\Component.History.fs" /> | ||
<Compile Include="Components\Component.DiceStorageModal.fs" /> | ||
<Compile Include="Components\Component.Footer.fs" /> | ||
<Compile Include="Components\Component.Navbar.fs" /> | ||
<Compile Include="Pages\Page.Reference.fs" /> | ||
<Compile Include="Pages\Page.Dicacle.fs" /> | ||
<Compile Include="Components.fs" /> | ||
<Compile Include="Main.fs" /> | ||
<None Include="index.html" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Fable.SimpleJson" Version="3.24.0" /> | ||
<PackageReference Include="Feliz" Version="2.6.0" /> | ||
<PackageReference Include="Feliz.Bulma" Version="3.0.0" /> | ||
<PackageReference Include="Feliz.Router" Version="4.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Update="FSharp.Core" Version="[6.0.7]" /> | ||
</ItemGroup> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Content Include="styles\styles.scss" /> | ||
<Compile Include="Literals.fs" /> | ||
<Compile Include="Extensions.fs" /> | ||
<Compile Include="Routing.fs" /> | ||
<Compile Include="State.ColorMode.fs" /> | ||
<Compile Include="Classes.fs" /> | ||
<Compile Include="Dice\Dice.Icon.fs" /> | ||
<Compile Include="Dice\Dice.Roll.fs" /> | ||
<Compile Include="Dice\Dice.Parsing.fs" /> | ||
<Compile Include="Dice\Dice.HtmlAux.fs" /> | ||
<Compile Include="LocalStorage.fs" /> | ||
<Compile Include="States.fs" /> | ||
<Compile Include="Components\Component.DarkModeButton.fs" /> | ||
<Compile Include="Components\Component.Shake.fs" /> | ||
<Compile Include="Components\Component.QuickAccess.fs" /> | ||
<Compile Include="Components\Component.History.fs" /> | ||
<Compile Include="Components\Component.DiceStorageModal.fs" /> | ||
<Compile Include="Components\Component.Footer.fs" /> | ||
<Compile Include="Components\Component.Navbar.fs" /> | ||
<Compile Include="Pages\Page.Reference.fs" /> | ||
<Compile Include="Pages\Page.Dicacle.fs" /> | ||
<Compile Include="Components.fs" /> | ||
<Compile Include="Main.fs" /> | ||
<None Include="index.html" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Fable.SimpleJson" Version="3.24.0" /> | ||
<PackageReference Include="Feliz" Version="2.6.0" /> | ||
<PackageReference Include="Feliz.Bulma" Version="3.0.0" /> | ||
<PackageReference Include="Feliz.Router" Version="4.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Update="FSharp.Core" Version="[6.0.7]" /> | ||
</ItemGroup> | ||
</Project> |
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
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,92 @@ | ||
module rec LocalStorage.Darkmode | ||
|
||
open Feliz | ||
open Fable.Core.JsInterop | ||
|
||
[<RequireQualifiedAccess>] | ||
module private Attribute = | ||
let getDataTheme() = | ||
let v = Browser.Dom.document.documentElement.getAttribute("data-theme") | ||
if isNull v then | ||
None | ||
else | ||
DataTheme.ofString v |> Some | ||
|
||
let setDataTheme(theme: string) = | ||
Browser.Dom.document.documentElement.setAttribute("data-theme", theme.ToLower() ) | ||
|
||
[<RequireQualifiedAccess>] | ||
module private BrowserSetting = | ||
let getDefault() = | ||
let m : bool = Browser.Dom.window?matchMedia("(prefers-color-scheme: dark)")?matches | ||
// Browser.Dom.console.log(m) | ||
if m then Dark else Light | ||
|
||
[<RequireQualifiedAccess>] | ||
module private LocalStorage = | ||
|
||
open Browser | ||
|
||
let [<Literal>] DataTheme_Key = "DataTheme" | ||
|
||
let write(dt: DataTheme) = | ||
let s = string dt | ||
WebStorage.localStorage.setItem(DataTheme_Key, s) | ||
|
||
let load() = | ||
try | ||
WebStorage.localStorage.getItem(DataTheme_Key) | ||
|> DataTheme.ofString | ||
|> Some | ||
with | ||
|_ -> | ||
WebStorage.localStorage.removeItem(DataTheme_Key) | ||
printfn "Could not find %s" DataTheme_Key | ||
None | ||
|
||
type DataTheme = | ||
| Dark | ||
| Light | ||
static member ofString (str: string) = | ||
match str.ToLower() with | ||
| "dark" -> Dark | ||
| "light" | _ -> Light | ||
|
||
static member SET(theme:DataTheme) = | ||
Attribute.setDataTheme <| string theme | ||
LocalStorage.write <| theme // This helps remember | ||
|
||
static member GET() = | ||
// Check local storage | ||
let localStorage = LocalStorage.load() | ||
// check data theme attribute | ||
let dataTheme = Attribute.getDataTheme() | ||
match localStorage, dataTheme with | ||
| _, Some dt -> dt // this value actually decides the theme via styles.scss | ||
| Some dt, _ -> dt // this value is set by website but does not reflect actual styling directly | ||
| _, _ -> BrowserSetting.getDefault() // if all fails we check for the browser setting | ||
member this.isDark = this = Dark | ||
|
||
member this.toIcon : ReactElement = | ||
let c = | ||
match this with | ||
| Light -> "fa-solid fa-lightbulb" | ||
| Dark -> "fa-solid fa-moon" | ||
Html.i [ | ||
prop.className (sprintf "%s fa-xl" c) | ||
] | ||
|
||
[<RequireQualifiedAccess>] | ||
type State = { | ||
Theme: DataTheme | ||
SetTheme: State -> unit | ||
} with | ||
static member init() = | ||
let dt = DataTheme.GET() | ||
DataTheme.SET dt | ||
{ | ||
Theme = dt | ||
SetTheme = fun (state) -> failwith "This is not implemented and serves as placeholder" | ||
} | ||
|
||
let themeContext = React.createContext(name="Theme", defaultValue=State.init()) |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
@use "../../node_modules/bulma/bulma.scss"; | ||
|
||
.hero { | ||
max-height: calc(100vh - 3.25rem) | ||
} | ||
|
Oops, something went wrong.