- Added internal/vault/client.go for creating a Vault client with configuration settings. - Introduced internal/vault/errors.go to classify Vault API errors for better UI handling. - Created internal/vault/kv.go to manage KV secrets, including listing, reading, writing, and deleting operations. - Implemented internal/vault/mounts.go to list and describe secret engine mounts. - Developed internal/vault/service.go to provide a unified entry point for Vault operations. - Added internal/vault/kv_test.go for comprehensive testing of KV operations. - Introduced internal/ui/toast.go for transient notifications in the UI. - Added renovate.json for dependency management and updates.
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package ui
|
|
|
|
import "charm.land/lipgloss/v2"
|
|
|
|
// overlay composites box on top of base, centered over the current
|
|
// terminal size, using lipgloss/v2's real layer compositor. This is what
|
|
// makes confirm dialogs, the help screen, and the profile picker float
|
|
// over the current screen instead of being appended below it.
|
|
func (m *Model) overlay(base, box string) string {
|
|
bw, bh := lipgloss.Size(box)
|
|
x := (m.lay.w - bw) / 2
|
|
y := (m.lay.h - bh) / 2
|
|
if x < 0 {
|
|
x = 0
|
|
}
|
|
if y < 0 {
|
|
y = 0
|
|
}
|
|
return lipgloss.NewCompositor(
|
|
lipgloss.NewLayer(base),
|
|
lipgloss.NewLayer(box).X(x).Y(y).Z(1),
|
|
).Render()
|
|
}
|
|
|
|
const (
|
|
modalMaxContentWidth = 64
|
|
modalFrameWidth = 10 // border(2) + padding(4, from Padding(1,2)) + a little breathing room
|
|
modalMinContentWidth = 24
|
|
)
|
|
|
|
// modalWrapWidth is the text-wrap width a screen should use before handing
|
|
// content to styles.Modal/ModalDanger — keeps the box from ever exceeding
|
|
// the terminal or the design's max modal width.
|
|
func (m *Model) modalWrapWidth() int {
|
|
w := m.lay.w - modalFrameWidth
|
|
if w > modalMaxContentWidth {
|
|
w = modalMaxContentWidth
|
|
}
|
|
if w < modalMinContentWidth {
|
|
w = modalMinContentWidth
|
|
}
|
|
return w
|
|
}
|