This repository has been archived by the owner on Sep 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathShared.fs
114 lines (102 loc) · 4.34 KB
/
Shared.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
namespace BlazorApp1.Shared
open Microsoft.AspNetCore.Blazor
open Microsoft.AspNetCore.Blazor.Components
open Microsoft.AspNetCore.Blazor.Routing
open Trail
type NavMenu () =
inherit Trail.Component()
let mutable collapseNavMenu = true
let toggleNavMenu (ev:UIMouseEventArgs) =
collapseNavMenu <- not collapseNavMenu
override __.Render() =
Dom.Fragment [
Dom.div [Attr.className "top-row pl-4 navbar navbar-dark"] [
Dom.a [Attr.className "navbar-brand"; Attr.href "/"] [
Dom.text "BlazorApp1"
]
Dom.button [
Attr.className "navbar-toggler"
Attr.onclick toggleNavMenu
] [
Dom.span [Attr.className "navbar-toggler-icon"] []
]
]
Dom.div [
Attr.className (if collapseNavMenu then "collapse" else null)
Attr.onclick toggleNavMenu
] [
Dom.ul [Attr.className "nav flex-column"] [
Dom.li [Attr.className "nav-item px-3"] [
Dom.comp<NavLink> [
Attr.className "nav-link"
Attr.href "/"
Dom.BlazorObjAttribute("Match", NavLinkMatch.All)
] [
Dom.span [Attr.className "oi oi-home"; Dom.HtmlAttribute("aria-hidden", "true")] []
Dom.text "Home"
]
]
Dom.li [Attr.className "nav-item px-3"] [
Dom.comp<NavLink> [
Attr.className "nav-link"
Attr.href "/counter"
] [
Dom.span [Attr.className "oi oi-plus"; Dom.HtmlAttribute("aria-hidden", "true")] []
Dom.text "Counter"
]
]
Dom.li [Attr.className "nav-item px-3"] [
Dom.comp<NavLink> [
Attr.className "nav-link"
Attr.href "/fetchdata"
] [
Dom.span [Attr.className "oi oi-list-rich"; Dom.HtmlAttribute("aria-hidden", "true")] []
Dom.text "Fetch data"
]
]
]
]
]
type MainLayout () =
inherit Trail.LayoutComponent()
override this.Render() =
Dom.Fragment [
Dom.div [Attr.className "sidebar"] [
Dom.comp<NavMenu> [] []
]
Dom.div [Attr.className "main"] [
Dom.div [Attr.className "top-row px-4"] [
Dom.a [
Attr.href "http://blazor.net"
Dom.HtmlAttribute("target", "_blank")
Attr.className "ml-md-auto"
] [
Dom.text "About"
]
]
Dom.div [Attr.className "content px-4"] [
Dom.content this.Body
]
]
]
type SurveyPrompt () =
inherit Trail.Component()
override this.Render() =
Dom.div [Dom.HtmlAttribute("class", "alert alert-secondary mt-4"); Dom.HtmlAttribute("role", "alert")] [
Dom.span [Dom.HtmlAttribute("class", "oi oi-pencil mr-2"); Dom.HtmlAttribute("aria-hidden", "true")] []
Dom.strong [] [Dom.text this.Title]
Dom.span [Attr.className "text-nowrap"] [
Dom.text "Please take our "
Dom.a [
Dom.HtmlAttribute("target", "_blank")
Attr.className "font-weight-bold"
Attr.href "https://go.microsoft.com/fwlink/?linkid=2006382"
] [
Dom.text "brief survey"
]
]
Dom.text " and tell us what you think."
]
// This is to demonstrate how a parent component can supply parameters
[<Parameter>]
member val Title : string = Unchecked.defaultof<string> with get, set