-
Notifications
You must be signed in to change notification settings - Fork 0
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
514bcb2
commit bdca132
Showing
5 changed files
with
101 additions
and
62 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,14 @@ | ||
package utils | ||
|
||
// FirstN returns the first n characters of a string. | ||
func FirstN(s string, n int) string { | ||
i := 0 | ||
for j := range s { | ||
if i == n { | ||
return s[:j] | ||
} | ||
i++ | ||
} | ||
|
||
return s | ||
} |
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,57 @@ | ||
package nkeys | ||
|
||
import ( | ||
htmx "github.com/zeiss/fiber-htmx" | ||
"github.com/zeiss/fiber-htmx/components/icons" | ||
"github.com/zeiss/fiber-htmx/components/tooltips" | ||
"github.com/zeiss/typhoon/internal/utils" | ||
) | ||
|
||
// NKeyProps are the properties of the NKey display component. | ||
type NKeyProps struct { | ||
ClassNames htmx.ClassNames | ||
PublicKey string | ||
Title string | ||
} | ||
|
||
// NKey renders the NKey display component. | ||
func NKey(props NKeyProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Div( | ||
htmx.Merge( | ||
htmx.ClassNames{ | ||
"flex": true, | ||
"flex-col": true, | ||
"py-2": true, | ||
}, | ||
props.ClassNames, | ||
), | ||
htmx.H4( | ||
htmx.ClassNames{ | ||
"text-neutral-content": true, | ||
"flex": true, | ||
"items-center": true, | ||
}, | ||
htmx.Text(props.Title), | ||
tooltips.Tooltip( | ||
tooltips.TooltipProps{ | ||
ClassNames: htmx.ClassNames{}, | ||
DataTip: "Public NKey is the public key of the operator", | ||
}, | ||
icons.InformationCircleOutline( | ||
icons.IconProps{}, | ||
), | ||
), | ||
), | ||
htmx.H3( | ||
tooltips.Tooltip( | ||
tooltips.TooltipProps{ | ||
ClassNames: htmx.ClassNames{}, | ||
DataTip: props.PublicKey, | ||
}, | ||
htmx.Text( | ||
utils.FirstN(props.PublicKey, 8), | ||
), | ||
), | ||
), | ||
) | ||
} |
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