Skip to content

Commit 71089b0

Browse files
committed
refactor: Port copyable input, expandable sections and switch to PatternFly V6
Signed-off-by: Felicitas Pojtinger <[email protected]>
1 parent 4575e00 commit 71089b0

File tree

5 files changed

+61
-40
lines changed

5 files changed

+61
-40
lines changed

pkg/components/copyable_input.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ func (c *CopyableInput) Render() app.UI {
1616
app.Div().
1717
Class("pf-v6-c-clipboard-copy__group").
1818
Body(
19-
c.Component,
19+
app.Span().
20+
Class("pf-v6-c-form-control").
21+
Body(
22+
c.Component,
23+
),
2024
app.Button().
2125
Class("pf-v6-c-button pf-m-control").
2226
Type("button").

pkg/components/expandable_section.go

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,37 @@ func (c *ExpandableSection) Render() app.UI {
2525
return classes
2626
}()).
2727
Body(
28-
app.Button().
29-
Type("button").
28+
app.Div().
3029
Class("pf-v6-c-expandable-section__toggle").
31-
Aria("label", func() string {
32-
message := c.ClosedTitle
33-
34-
if c.Open {
35-
message = c.OpenTitle
36-
}
37-
38-
return message
39-
}()).
40-
Aria("expanded", c.Open).
41-
OnClick(func(ctx app.Context, e app.Event) {
42-
c.OnToggle()
43-
}).
4430
Body(
45-
app.Span().
46-
Class("pf-v6-c-expandable-section__toggle-icon").
31+
app.Button().
32+
Type("button").
33+
Class("pf-v6-c-button pf-m-link").
34+
Aria("label", func() string {
35+
message := c.ClosedTitle
36+
37+
if c.Open {
38+
message = c.OpenTitle
39+
}
40+
41+
return message
42+
}()).
43+
Aria("expanded", c.Open).
44+
OnClick(func(ctx app.Context, e app.Event) {
45+
c.OnToggle()
46+
}).
4747
Body(
48-
app.I().
49-
Class("fas fa-angle-right").
50-
Aria("hidden", true),
48+
app.Span().
49+
Class("pf-v6-c-button__icon pf-m-start").
50+
Body(
51+
app.I().
52+
Class("fas fa-angle-right").
53+
Aria("hidden", true),
54+
),
55+
app.Span().
56+
Class("pf-v6-c-button__text").
57+
Text(c.Title),
5158
),
52-
app.Span().
53-
Class("pf-v6-c-expandable-section__toggle-text").
54-
Text(c.Title),
5559
),
5660
app.Div().
5761
Class("pf-v6-c-expandable-section__content").

pkg/components/file_explorer.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,8 @@ func (c *FileExplorer) Render() app.UI {
855855
Class("pf-v6-c-form pf-m-horizontal pf-v6-u-mb-md").
856856
Body(
857857
&FormGroup{
858-
NoTopPadding: true,
858+
NoTopPadding: true,
859+
NoControlWrapper: true,
859860
Label: app.Label().
860861
For("use-advertised-ip-for-webdav").
861862
Class("pf-v6-c-form__label").
@@ -878,7 +879,8 @@ func (c *FileExplorer) Render() app.UI {
878879
},
879880
},
880881
&FormGroup{
881-
NoTopPadding: true,
882+
NoTopPadding: true,
883+
NoControlWrapper: true,
882884
Label: app.Label().
883885
For("use-davs").
884886
Class("pf-v6-c-form__label").
@@ -1015,7 +1017,8 @@ func (c *FileExplorer) Render() app.UI {
10151017
Class("pf-v6-c-form pf-m-horizontal pf-v6-u-mb-md").
10161018
Body(
10171019
&FormGroup{
1018-
NoTopPadding: true,
1020+
NoTopPadding: true,
1021+
NoControlWrapper: true,
10191022
Label: app.Label().
10201023
For("use-advertised-ip").
10211024
Class("pf-v6-c-form__label").
@@ -1038,7 +1041,8 @@ func (c *FileExplorer) Render() app.UI {
10381041
},
10391042
},
10401043
&FormGroup{
1041-
NoTopPadding: true,
1044+
NoTopPadding: true,
1045+
NoControlWrapper: true,
10421046
Label: app.Label().
10431047
For("use-https").
10441048
Class("pf-v6-c-form__label").

pkg/components/form_group.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import "github.com/maxence-charriere/go-app/v10/pkg/app"
55
type FormGroup struct {
66
app.Compo
77

8-
Required bool
9-
Label app.UI
10-
Input app.UI
11-
NoTopPadding bool
8+
Required bool
9+
Label app.UI
10+
Input app.UI
11+
NoTopPadding bool
12+
NoControlWrapper bool
1213
}
1314

1415
func (c *FormGroup) Render() app.UI {
@@ -38,12 +39,20 @@ func (c *FormGroup) Render() app.UI {
3839
app.Div().
3940
Class("pf-v6-c-form__group-control").
4041
Body(
41-
app.
42-
Span().
43-
Class("pf-v6-c-form-control").
44-
Body(
45-
c.Input,
46-
),
42+
app.If(
43+
c.NoControlWrapper,
44+
func() app.UI {
45+
return c.Input
46+
},
47+
).Else(
48+
func() app.UI {
49+
return app.
50+
Span().
51+
Class("pf-v6-c-form-control").
52+
Body(
53+
c.Input,
54+
)
55+
}),
4756
),
4857
)
4958
}

pkg/components/switch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (c *Switch) Render() app.UI {
3434
app.Span().
3535
Class("pf-v6-c-switch__toggle"),
3636
app.If(
37-
c.OnMessage != "",
37+
c.OnMessage != "" && c.Open,
3838
func() app.UI {
3939
return app.Span().
4040
Class("pf-v6-c-switch__label pf-m-on").
@@ -44,7 +44,7 @@ func (c *Switch) Render() app.UI {
4444
},
4545
),
4646
app.If(
47-
c.OffMessage != "",
47+
c.OffMessage != "" && !c.Open,
4848
func() app.UI {
4949
return app.Span().
5050
Class("pf-v6-c-switch__label pf-m-off").

0 commit comments

Comments
 (0)