This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
about_modal.go
100 lines (90 loc) · 2.05 KB
/
about_modal.go
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
package components
import "github.com/maxence-charriere/go-app/v9/pkg/app"
type AboutModal struct {
app.Compo
Open bool
Close func()
ID string
LogoSrc string
LogoAlt string
Title string
Body app.UI
Footer string
}
func (c *AboutModal) Render() app.UI {
return app.Div().
Class(func() string {
classes := "pf-c-backdrop"
if !c.Open {
classes += " pf-u-display-none"
}
return classes
}()).
Body(
app.Div().
Class("pf-l-bullseye").
Body(
app.Div().
Class("pf-c-about-modal-box").
Aria("role", "dialog").
Aria("modal", true).
Aria("labelledby", c.ID).
Body(
app.Div().
Class("pf-c-about-modal-box__brand").
Body(
app.Img().
Class("pf-c-about-modal-box__brand-image").
Src(c.LogoSrc).
Alt(c.LogoAlt),
),
app.Div().
Class("pf-c-about-modal-box__close").
Body(
app.Button().
Class("pf-c-button pf-m-plain").
Type("button").
Aria("label", "Close dialog").
OnClick(func(ctx app.Context, e app.Event) {
c.Close()
}).
Body(
app.I().
Class("fas fa-times").
Aria("hidden", true),
),
),
app.Div().
Class("pf-c-about-modal-box__header").
Body(
app.H1().
Class("pf-c-title pf-m-4xl").
ID(c.ID).
Text(c.Title),
),
app.Div().Class("pf-c-about-modal-box__hero"),
app.Div().
Class("pf-c-about-modal-box__content").
Body(
app.Div().
Class("pf-c-content").
Body(
app.Dl().
Class("pf-c-content").
Body(c.Body),
),
app.P().
Class("pf-c-about-modal-box__strapline").
Text(c.Footer),
),
),
),
)
}
func (c *AboutModal) OnMount(ctx app.Context) {
app.Window().AddEventListener("keyup", func(ctx app.Context, e app.Event) {
if e.Get("key").String() == "Escape" {
c.Close()
}
})
}