Skip to content

Commit a203efb

Browse files
committed
table view
1 parent 1748bd9 commit a203efb

File tree

3 files changed

+143
-3
lines changed

3 files changed

+143
-3
lines changed

comp.go

+3
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ func (a *App) SchemaMessage() comp.SchemaMessage { return icomp.NewSchemaMessa
220220
func (a *App) SchemaPopOver() comp.SchemaPopOver { return icomp.NewSchemaPopOver() }
221221
func (a *App) State() comp.State { return icomp.NewState() }
222222
func (a *App) Step() comp.Step { return icomp.NewStep() }
223+
func (a *App) Tr() comp.Tr { return icomp.NewTr() }
224+
func (a *App) Td() comp.Td { return icomp.NewTd() }
225+
func (a *App) Tcol() comp.Tcol { return icomp.NewTCol() }
223226
func (a *App) TableColumn() comp.TableColumn { return icomp.NewTableColumn() }
224227
func (a *App) Toast() comp.Toast { return icomp.NewToast() }
225228
func (a *App) ToastItem() comp.ToastItem { return icomp.NewToastItem() }

comp/comp.go

+3
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ type (
153153
Table = comp.Table
154154
Table2 = comp.Table
155155
TableView = comp.TableView
156+
Tr = comp.Tr
157+
Td = comp.Td
158+
Tcol = comp.Tcol
156159
Tabs = comp.Tabs
157160
TabsTransfer = comp.TabsTransfer
158161
TabsTransferPicker = comp.TabsTransferPicker

internal/comp/tableView.go

+137-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,150 @@ package comp
22

33
import "github.com/zrcoder/amisgo/schema"
44

5-
type TableView schema.Schema
5+
type (
6+
TableView schema.Schema
7+
Tr schema.Schema
8+
Td schema.Schema
9+
Tcol schema.Schema
10+
)
611

712
func NewTableView() TableView {
813
return TableView{"type": "table-view"}
914
}
1015

11-
// set assigns a value to a key in the tableView schema.Schema
16+
func NewTr() Tr {
17+
return Tr{}
18+
}
19+
20+
func NewTd() Td {
21+
return Td{}
22+
}
23+
24+
func NewTCol() Tcol {
25+
return Tcol{}
26+
}
27+
28+
func (tv TableView) Width(value any) TableView {
29+
return tv.set("width", value)
30+
}
31+
32+
func (tv TableView) Padding(value any) TableView {
33+
return tv.set("padding", value)
34+
}
35+
36+
func (tv TableView) Border(value bool) TableView {
37+
return tv.set("border", value)
38+
}
39+
40+
func (tv TableView) BorderColor(value string) TableView {
41+
return tv.set("borderColor", value)
42+
}
43+
44+
func (tv TableView) Cols(value ...Tcol) TableView {
45+
return tv.set("cols", value)
46+
}
47+
48+
func (tv TableView) Trs(value ...Tr) TableView {
49+
return tv.set("trs", value)
50+
}
51+
52+
func (tv TableView) Caption(value string) TableView {
53+
return tv.set("caption", value)
54+
}
55+
56+
// CaptionSide sets the caption position, top or bottom, default is top
57+
func (tv TableView) CaptionSide(value string) TableView {
58+
return tv.set("captionSide", value)
59+
}
60+
61+
func (t Tcol) Span(value int) Tcol {
62+
return t.set("span", value)
63+
}
64+
65+
func (t Tcol) Style(value any) Tcol {
66+
return t.set("style", value)
67+
}
68+
69+
func (t Tr) Height(value any) Tr {
70+
return t.set("height", value)
71+
}
72+
73+
func (t Tr) Background(value string) Tr {
74+
return t.set("background", value)
75+
}
76+
77+
func (t Tr) Tds(value ...Td) Tr {
78+
return t.set("tds", value)
79+
}
80+
81+
func (t Tr) VisibleOn(value string) Tr {
82+
return t.set("visibleOn", value)
83+
}
84+
85+
func (t Td) VisibleOn(value string) Td {
86+
return t.set("visibleOn", value)
87+
}
88+
89+
func (t Td) Background(value string) Td {
90+
return t.set("background", value)
91+
}
92+
93+
func (t Td) Color(value string) Td {
94+
return t.set("color", value)
95+
}
96+
97+
func (t Td) Bold(value bool) Td {
98+
return t.set("bold", value)
99+
}
100+
101+
func (t Td) Width(value any) Td {
102+
return t.set("width", value)
103+
}
104+
105+
func (t Td) Padding(value any) Td {
106+
return t.set("padding", value)
107+
}
108+
109+
func (t Td) Align(value string) Td {
110+
return t.set("align", value)
111+
}
112+
113+
func (t Td) Valign(value string) Td {
114+
return t.set("valign", value)
115+
}
116+
117+
func (t Td) Colspan(value int) Td {
118+
return t.set("colspan", value)
119+
}
120+
121+
func (t Td) Rowspan(value int) Td {
122+
return t.set("rowspan", value)
123+
}
124+
125+
func (t Td) Body(value any) Td {
126+
return t.set("body", value)
127+
}
128+
129+
func (t Td) Style(value any) Td {
130+
return t.set("style", value)
131+
}
132+
12133
func (tv TableView) set(key string, value any) TableView {
13134
tv[key] = value
14135
return tv
15136
}
16137

17-
// TODO
138+
func (t Tcol) set(key string, value any) Tcol {
139+
t[key] = value
140+
return t
141+
}
142+
143+
func (t Tr) set(key string, value any) Tr {
144+
t[key] = value
145+
return t
146+
}
147+
148+
func (t Td) set(key string, value any) Td {
149+
t[key] = value
150+
return t
151+
}

0 commit comments

Comments
 (0)