Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit 2967221

Browse files
committed
docs: Add description of complete public API
1 parent b33e206 commit 2967221

23 files changed

+209
-176
lines changed

pkg/components/autofocused.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"github.com/maxence-charriere/go-app/v9/pkg/app"
55
)
66

7+
// Autofocused calls `focus` on the encapsulated component after it is mounted
78
type Autofocused struct {
89
app.Compo
910

10-
Disable bool
11-
Component app.UI
11+
Disable bool // Disable the focus
12+
Component app.UI // The component to be focused
1213
}
1314

1415
func (c *Autofocused) Render() app.UI {

pkg/components/confirmation_modal.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ import (
44
"github.com/maxence-charriere/go-app/v9/pkg/app"
55
)
66

7+
// ConfirmationModal is a modal with callbacks intended to enable confirm destructive operations such as deleting something
78
type ConfirmationModal struct {
89
app.Compo
910

10-
ID string
11-
Icon string
12-
Title string
13-
Class string
14-
Body string
15-
ActionClass string
16-
ActionLabel string
17-
CancelLabel string
18-
CancelLink string
11+
ID string // HTML ID of the modal; must be unique across the page
12+
Icon string // Class of the icon to use to the left of the title; may be empty
13+
Title string // Title of the modal
14+
Class string // Class to be applied to the modal's outmost component
15+
Body string // Body text of the modal
16+
ActionClass string // Class to be applied to the modal's primary action
17+
ActionLabel string // Text to display on the modal's primary action
18+
CancelLabel string // Text to display on the modal's cancel action
19+
CancelLink string // Link to display as the cancel action; if empty, `OnClose` is being called
1920

20-
OnClose func()
21-
OnAction func()
21+
OnClose func() // Handler to call when closing/cancelling the modal
22+
OnAction func() // Handler to call when triggering the modal's primary action
2223
}
2324

2425
func (c *ConfirmationModal) Render() app.UI {

pkg/components/controlled.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package components
22

33
import "github.com/maxence-charriere/go-app/v9/pkg/app"
44

5+
// Controlled sets DOM properties of the encapsulated component after it is mounted
56
type Controlled struct {
67
app.Compo
78

8-
Component app.UI
9-
Properties map[string]interface{}
9+
Component app.UI // The component to be focused
10+
Properties map[string]interface{} // Map of properties to set
1011
}
1112

1213
func (c *Controlled) Render() app.UI {

pkg/components/create_key_modal.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import (
44
"github.com/maxence-charriere/go-app/v9/pkg/app"
55
)
66

7+
// CreateKeyModal is a modal which provides the information needed to create a key
78
type CreateKeyModal struct {
89
app.Compo
910

1011
OnSubmit func(
1112
fullName string,
1213
email string,
1314
password string,
14-
)
15-
OnCancel func(dirty bool, clear chan struct{})
15+
) // Handler to call to create the key
16+
OnCancel func(dirty bool, clear chan struct{}) // Handler to call when closing/cancelling the modal
1617

1718
fullName string
1819
email string

pkg/components/decrypt_and_verify_modal.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ const (
99
selectDetachedSignatureFileInput = "select-detached-signature-file-input"
1010
)
1111

12+
// DecryptAndVerifyModal is a modal to provide the information needed to decrypt/verify something
1213
type DecryptAndVerifyModal struct {
1314
app.Compo
1415

15-
Keys []GPGKey
16+
Keys []GPGKey // GPG keys to be available for decryption/verification
1617

1718
OnSubmit func(
1819
file []byte,
1920
publicKeyID string,
2021
privateKeyID string,
2122
detachedSignature []byte,
22-
)
23-
OnCancel func(dirty bool, clear chan struct{})
23+
) // Handler to call to decrypt/verify
24+
OnCancel func(dirty bool, clear chan struct{}) // Handler to call when closing/cancelling the modal
2425

2526
fileContents []byte
2627

@@ -73,12 +74,12 @@ func (c *DecryptAndVerifyModal) Render() app.UI {
7374
Class("pf-c-form__group").
7475
Body(
7576
&FileUpload{
76-
ID: selectDecryptionFileInput,
77-
FileSelectionLabel: "Drag and drop a file or select one",
78-
ClearLabel: "Clear",
79-
TextEntryLabel: "Or enter text here",
80-
TextEntryBlockedLabel: "File has been selected.",
81-
FileContents: c.fileContents,
77+
ID: selectDecryptionFileInput,
78+
FileSelectionLabel: "Drag and drop a file or select one",
79+
ClearLabel: "Clear",
80+
TextEntryInputPlaceholder: "Or enter text here",
81+
TextEntryInputBlockedLabel: "File has been selected.",
82+
FileContents: c.fileContents,
8283

8384
OnChange: func(fileContents []byte) {
8485
c.fileContents = fileContents
@@ -282,12 +283,12 @@ func (c *DecryptAndVerifyModal) Render() app.UI {
282283
Class("pf-c-check__body pf-u-w-100").
283284
Body(
284285
&FileUpload{
285-
ID: selectDetachedSignatureFileInput,
286-
FileSelectionLabel: "Drag and drop a detached signature or select one",
287-
ClearLabel: "Clear",
288-
TextEntryLabel: "Or enter the detached signature's content here",
289-
TextEntryBlockedLabel: "File has been selected.",
290-
FileContents: []byte(c.detachedSignature),
286+
ID: selectDetachedSignatureFileInput,
287+
FileSelectionLabel: "Drag and drop a detached signature or select one",
288+
ClearLabel: "Clear",
289+
TextEntryInputPlaceholder: "Or enter the detached signature's content here",
290+
TextEntryInputBlockedLabel: "File has been selected.",
291+
FileContents: []byte(c.detachedSignature),
291292

292293
OnChange: func(fileContents []byte) {
293294
c.detachedSignature = fileContents

pkg/components/download_or_view_modal.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ import (
44
"github.com/maxence-charriere/go-app/v9/pkg/app"
55
)
66

7+
// DownloadOrViewModal is a modal which provides the actions needed to download or view text
78
type DownloadOrViewModal struct {
89
app.Compo
910

10-
SubjectA bool
11-
SubjectANoun string
12-
SubjectAVerb string
11+
SubjectA bool // Whether to display the first subject to download or view
12+
SubjectANoun string // Noun form the first subject to download or view (i.e. "signature")
13+
SubjectAAdjective string // Adjective of the first subject to download or view (i.e. "signed")
1314

14-
SubjectB bool
15-
SubjectBNoun string
16-
SubjectBVerb string
15+
SubjectB bool // Whether to display the second subject to download or view
16+
SubjectBNoun string // Noun form the second subject to download or view (i.e. "signature")
17+
SubjectBAdjective string // Adjective of the second subject to download or view (i.e. "signed")
1718

18-
OnClose func(used bool)
19-
OnDownload func()
20-
OnView func()
19+
OnClose func(used bool) // Handler to call when closing/cancelling the modal
20+
OnDownload func() // Handler to call to download the subject(s)
21+
OnView func() // Handler to view to download the subject(s)
2122

22-
ShowView bool
23+
ShowView bool // Whether to show the view action
2324

2425
used bool
2526
}
@@ -30,7 +31,7 @@ func (c *DownloadOrViewModal) Render() app.UI {
3031
viewLabel := "View "
3132
body := "You may now download or view "
3233
if c.SubjectA && c.SubjectB {
33-
title += c.SubjectBVerb + " and " + c.SubjectAVerb
34+
title += c.SubjectBAdjective + " and " + c.SubjectAAdjective
3435

3536
if c.SubjectANoun == "" {
3637
downloadLabel += c.SubjectBNoun
@@ -46,12 +47,12 @@ func (c *DownloadOrViewModal) Render() app.UI {
4647
body += "them"
4748
}
4849
} else if c.SubjectA {
49-
title += c.SubjectAVerb
50+
title += c.SubjectAAdjective
5051
downloadLabel += c.SubjectANoun
5152
viewLabel += c.SubjectANoun
5253
body += "it"
5354
} else {
54-
title += c.SubjectBVerb
55+
title += c.SubjectBAdjective
5556
downloadLabel += c.SubjectBNoun
5657
viewLabel += c.SubjectBNoun
5758
body += "it"

pkg/components/empty_state.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package components
22

33
import "github.com/maxence-charriere/go-app/v9/pkg/app"
44

5+
// EmptyState is the initial placeholder of the key list
56
type EmptyState struct {
67
app.Compo
78

8-
OnCreateKey func()
9-
OnImportKey func()
9+
OnCreateKey func() // OnCreateKey is the handler to call to create a key
10+
OnImportKey func() // OnCreateKey is the handler to call to import a key
1011
}
1112

1213
func (c *EmptyState) Render() app.UI {

pkg/components/encrypt_and_sign_modal.go

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,20 @@ const (
88
selectEncryptionFileInput = "select-encryption-file-input"
99
)
1010

11-
type GPGKey struct {
12-
ID string `json:"id"`
13-
Label string `json:"label"`
14-
FullName string `json:"fullName"`
15-
Email string `json:"email"`
16-
Private bool `json:"private"`
17-
Public bool `json:"public"`
18-
Content []byte `json:"content"`
19-
}
20-
11+
// EncryptAndSignModal is a modal which provides the information needed to encrypt/sign something
2112
type EncryptAndSignModal struct {
2213
app.Compo
2314

24-
Keys []GPGKey
15+
Keys []GPGKey // GPG keys to be available for encryption/signing
2516

2617
OnSubmit func(
2718
file []byte,
2819
publicKeyID string,
2920
privateKeyID string,
3021
createDetachedSignature bool,
3122
armor bool,
32-
)
33-
OnCancel func(dirty bool, clear chan struct{})
23+
) // Handle to call to encrypt/sign
24+
OnCancel func(dirty bool, clear chan struct{}) // Handler to call when closing/cancelling the modal
3425

3526
fileIsBinary bool
3627
fileContents []byte
@@ -85,12 +76,12 @@ func (c *EncryptAndSignModal) Render() app.UI {
8576
Class("pf-c-form__group").
8677
Body(
8778
&FileUpload{
88-
ID: selectEncryptionFileInput,
89-
FileSelectionLabel: "Drag and drop a file or select one",
90-
ClearLabel: "Clear",
91-
TextEntryLabel: "Or enter text here",
92-
TextEntryBlockedLabel: "File has been selected.",
93-
FileContents: c.fileContents,
79+
ID: selectEncryptionFileInput,
80+
FileSelectionLabel: "Drag and drop a file or select one",
81+
ClearLabel: "Clear",
82+
TextEntryInputPlaceholder: "Or enter text here",
83+
TextEntryInputBlockedLabel: "File has been selected.",
84+
FileContents: c.fileContents,
9485

9586
OnChange: func(fileContents []byte) {
9687
c.fileContents = fileContents

pkg/components/error_modal.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@ import (
66
"github.com/maxence-charriere/go-app/v9/pkg/app"
77
)
88

9+
// ErrorModal is a modal to display an error
910
type ErrorModal struct {
1011
app.Compo
1112

12-
ID string
13-
Icon string
14-
Title string
15-
Class string
16-
Body string
17-
Error error
18-
ActionLabel string
13+
ID string // HTML ID of the modal; must be unique across the page
14+
Icon string // Class of the icon to use to the left of the title; may be empty
15+
Title string // Title of the modal
16+
Class string // Class to be applied to the modal's outmost component
17+
Body string // Body text of the modal
18+
Error error // The error display (must not be nil)
19+
ActionLabel string // Text to display on the modal's primary action
1920

20-
OnClose func()
21-
OnAction func()
21+
OnClose func() // Handler to call when closing/cancelling the modal
22+
OnAction func() // Handler to call when triggering the modal's primary action
2223
}
2324

2425
func (c *ErrorModal) Render() app.UI {

pkg/components/export_key_modal.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ const (
99
exportPrivateKeyForm = "export-private-key-form"
1010
)
1111

12+
// ExportKeyModal is a modal which provides the actions needed to export a key
1213
type ExportKeyModal struct {
1314
app.Compo
1415

15-
PublicKey bool
16-
OnDownloadPublicKey func(armor bool)
17-
OnViewPublicKey func()
16+
PublicKey bool // Whether to display the options for a public key
17+
OnDownloadPublicKey func(armor bool) // Handler to call to download the public key
18+
OnViewPublicKey func() // Handler to call to view the public key
1819

19-
PrivateKey bool
20-
OnDownloadPrivateKey func(armor bool)
21-
OnViewPrivateKey func()
20+
PrivateKey bool // Whether to display the options for a private key
21+
OnDownloadPrivateKey func(armor bool) // Handler to call to download the private key
22+
OnViewPrivateKey func() // Handler to call to view the private key
2223

23-
OnOK func()
24+
OnOK func() // Handler to call when dismissing the modal
2425

2526
skipPublicKeyArmor bool
2627
skipPrivateKeyArmor bool

0 commit comments

Comments
 (0)