-
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
42f86f5
commit 01f61e0
Showing
3 changed files
with
234 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package progress | ||
|
||
import htmx "github.com/zeiss/fiber-htmx" | ||
|
||
// ProgressProps is a struct that contains the props of the progress component | ||
type ProgressProps struct { | ||
ClassNames htmx.ClassNames | ||
Value int | ||
Max int | ||
|
||
htmx.Ctx | ||
} | ||
|
||
// Progress is a component that renders a progress element | ||
func Progress(p ProgressProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Progress( | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"progress": true, | ||
"w-56": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.Attribute("max", htmx.IntAsString(p.Max)), | ||
htmx.Attribute("value", htmx.IntAsString(p.Value)), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// ProgressPrimary is a component that renders a primary progress element | ||
func ProgressPrimary(p ProgressProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Progress( | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"progress": true, | ||
"w-56": true, | ||
"bg-primary": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.Attribute("max", htmx.IntAsString(p.Max)), | ||
htmx.Attribute("value", htmx.IntAsString(p.Value)), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// ProgressSecondary is a component that renders a secondary progress element | ||
func ProgressSecondary(p ProgressProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Progress( | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"progress": true, | ||
"w-56": true, | ||
"progress-secondary": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.Attribute("max", htmx.IntAsString(p.Max)), | ||
htmx.Attribute("value", htmx.IntAsString(p.Value)), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// ProgressSuccess is a component that renders a success progress element | ||
func ProgressSuccess(p ProgressProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Progress( | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"progress": true, | ||
"w-56": true, | ||
"progress-success": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.Attribute("max", htmx.IntAsString(p.Max)), | ||
htmx.Attribute("value", htmx.IntAsString(p.Value)), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// ProgressInfo is a component that renders a info progress element | ||
func ProgressInfo(p ProgressProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Progress( | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"progress": true, | ||
"w-56": true, | ||
"progress-info": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
htmx.Attribute("max", htmx.IntAsString(p.Max)), | ||
htmx.Attribute("value", htmx.IntAsString(p.Value)), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// ProgressWarning is a component that renders a warning progress element | ||
func ProgressWarning(p ProgressProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Progress( | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"progress": true, | ||
"w-56": true, | ||
"progress-warning": true, | ||
}, | ||
), | ||
htmx.Attribute("max", htmx.IntAsString(p.Max)), | ||
htmx.Attribute("value", htmx.IntAsString(p.Value)), | ||
htmx.Group(children...), | ||
) | ||
} | ||
|
||
// ProgressIntermediate is a component that renders a intermediate progress element | ||
func ProgressIntermediate(p ProgressProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Progress( | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"progress": true, | ||
"w-56": true, | ||
}, | ||
p.ClassNames, | ||
), | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package skeletons | ||
|
||
import ( | ||
"fmt" | ||
|
||
htmx "github.com/zeiss/fiber-htmx" | ||
) | ||
|
||
// SkeletonProps is a struct that contains the props of the skeleton component | ||
type SkeletonProps struct { | ||
ClassNames htmx.ClassNames | ||
Width int | ||
Height int | ||
|
||
htmx.Ctx | ||
} | ||
|
||
// Skeleton is a component that renders a skeleton element | ||
func Skeleton(p SkeletonProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Div( | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"skeleton": true, | ||
fmt.Sprintf("w-%d", p.Width): true, | ||
fmt.Sprintf("h-%d", p.Height): true, | ||
}, | ||
p.ClassNames, | ||
), | ||
) | ||
} |
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