-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.go
58 lines (47 loc) · 1.44 KB
/
page.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
package main
import (
"github.com/johnfercher/maroto/v2"
"github.com/johnfercher/maroto/v2/pkg/components/row"
"github.com/johnfercher/maroto/v2/pkg/components/text"
"github.com/johnfercher/maroto/v2/pkg/config"
"github.com/johnfercher/maroto/v2/pkg/consts/align"
"github.com/johnfercher/maroto/v2/pkg/consts/border"
"github.com/johnfercher/maroto/v2/pkg/consts/breakline"
"github.com/johnfercher/maroto/v2/pkg/consts/linestyle"
"github.com/johnfercher/maroto/v2/pkg/core"
"github.com/johnfercher/maroto/v2/pkg/props"
)
// Styles
var colStyle = &props.Cell{
BorderType: border.Full,
BorderColor: &props.BlackColor,
LineStyle: linestyle.Solid,
BorderThickness: 0.5,
}
func getMaroto(cards []Card, questionFontSize, answerFontSize float64) core.Maroto {
var questionTextStyle = props.Text{
Size: questionFontSize,
Align: align.Center,
Top: 10,
BreakLineStrategy: breakline.EmptyLineStrategy,
}
var answerTextStyle = props.Text{
Size: answerFontSize,
Align: align.Center,
Top: 10,
}
cfg := config.NewBuilder().Build()
m := maroto.New(cfg)
rows := []core.Row{}
//Create list of card rows to add to the
for _, card := range cards {
rows = append(rows,
row.New(80).Add(
text.NewCol(6, card.question, questionTextStyle).WithStyle(colStyle),
text.NewCol(6, card.answer, answerTextStyle).WithStyle(colStyle)),
row.New(5),
)
}
m.AddRows(rows...)
return m
}