-
Notifications
You must be signed in to change notification settings - Fork 11
/
modal.go
56 lines (49 loc) · 1.09 KB
/
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
package stories
import (
"github.com/maxence-charriere/go-app/v9/pkg/app"
"github.com/pojntfx/keygaen/pkg/components"
)
type ModalStory struct {
Story
modalOpen bool
}
func (c *ModalStory) Render() app.UI {
c.EnableShallowReflection()
return c.WithRoot(
app.Div().Body(
app.Button().
Class("pf-c-button pf-m-primary").
Type("button").
Text("Open modal").
OnClick(func(ctx app.Context, e app.Event) {
c.modalOpen = !c.modalOpen
}),
app.If(
c.modalOpen,
&components.Modal{
ID: "success-modal-story",
Icon: "fas fa-check",
Title: "Key successfully generated!",
Class: "pf-m-success",
Body: []app.UI{
app.Text("It has been added to the key list."),
},
Footer: []app.UI{
app.Button().
Aria("disabled", "false").
Class("pf-c-button pf-m-primary").
Type("button").
Text("Continue to key list").
OnClick(func(ctx app.Context, e app.Event) {
c.modalOpen = false
}),
},
OnClose: func() {
c.modalOpen = false
c.Update()
},
},
),
),
)
}