-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c926a3
commit 755a2e7
Showing
8 changed files
with
542 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
package forms | ||
|
||
import htmx "github.com/zeiss/fiber-htmx" | ||
|
||
// FileInputProps represents the properties for a file input element. | ||
type FileInputProps struct { | ||
ClassNames htmx.ClassNames | ||
Disabled bool | ||
} | ||
|
||
// File generates a file input element based on the provided properties. | ||
func FileInput(p FileInputProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Input( | ||
htmx.Attribute("name", "file"), | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"file-input": true, | ||
"w-full": true, | ||
"max-w-xs": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.If(p.Disabled, htmx.Disabled()), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// FileInputBordered is a component that displays a bordered file input. | ||
func FileInputBordered(p FileInputProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Input( | ||
htmx.Attribute("name", "file"), | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"file-input": true, | ||
"file-input-bordered": true, | ||
"w-full": true, | ||
"max-w-xs": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.If(p.Disabled, htmx.Disabled()), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// FileInputGhost is a component that displays a ghost file input. | ||
func FileInputGhost(p FileInputProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Input( | ||
htmx.Attribute("name", "file"), | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"file-input": true, | ||
"file-input-ghost": true, | ||
"w-full": true, | ||
"max-w-xs": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.If(p.Disabled, htmx.Disabled()), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// FileInputPrimary is a component that displays a primary file input. | ||
func FileInputPrimary(p FileInputProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Input( | ||
htmx.Attribute("name", "file"), | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"file-input": true, | ||
"file-input-bordered": true, | ||
"file-input-primary": true, | ||
"w-full": true, | ||
"max-w-xs": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.If(p.Disabled, htmx.Disabled()), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// FileInputSecondary is a component that displays a secondary file input. | ||
func FileInputSecondary(p FileInputProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Input( | ||
htmx.Attribute("name", "file"), | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"file-input": true, | ||
"file-input-bordered": true, | ||
"file-input-secondary": true, | ||
"w-full": true, | ||
"max-w-xs": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.If(p.Disabled, htmx.Disabled()), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// FileInputAccent is a component that displays an accent file input. | ||
func FileInputAccent(p FileInputProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Input( | ||
htmx.Attribute("name", "file"), | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"file-input": true, | ||
"file-input-bordered": true, | ||
"file-input-accent": true, | ||
"w-full": true, | ||
"max-w-xs": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.If(p.Disabled, htmx.Disabled()), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// FileInputInfo is a component that displays an info file input. | ||
func FileInputInfo(p FileInputProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Input( | ||
htmx.Attribute("name", "file"), | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"file-input": true, | ||
"file-input-bordered": true, | ||
"file-input-info": true, | ||
"w-full": true, | ||
"max-w-xs": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.If(p.Disabled, htmx.Disabled()), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// FileInputSuccess is a component that displays a success file input. | ||
func FileInputSuccess(p FileInputProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Input( | ||
htmx.Attribute("name", "file"), | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"file-input": true, | ||
"file-input-bordered": true, | ||
"file-input-success": true, | ||
"w-full": true, | ||
"max-w-xs": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.If(p.Disabled, htmx.Disabled()), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// FileInputWarning is a component that displays a warning file input. | ||
func FileInputWarning(p FileInputProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Input( | ||
htmx.Attribute("name", "file"), | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"file-input": true, | ||
"file-input-bordered": true, | ||
"file-input-warning": true, | ||
"w-full": true, | ||
"max-w-xs": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.If(p.Disabled, htmx.Disabled()), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// FileInputError is a component that displays an error file input. | ||
func FileInputError(p FileInputProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Input( | ||
htmx.Attribute("name", "file"), | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"file-input": true, | ||
"file-input-bordered": true, | ||
"file-input-error": true, | ||
"w-full": true, | ||
"max-w-xs": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.If(p.Disabled, htmx.Disabled()), | ||
htmx.Group(children...), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.