2019-03-16 23:59:28 +00:00
|
|
|
package component
|
|
|
|
|
|
|
|
import (
|
2019-03-24 00:16:59 +00:00
|
|
|
"fmt"
|
2019-03-16 23:59:28 +00:00
|
|
|
ui "github.com/gizak/termui/v3"
|
2019-03-24 00:16:59 +00:00
|
|
|
"github.com/sqshq/sampler/console"
|
2019-03-16 23:59:28 +00:00
|
|
|
)
|
|
|
|
|
2019-03-24 00:16:59 +00:00
|
|
|
func NewBlock(title string, border bool, palette console.Palette) *ui.Block {
|
|
|
|
style := ui.Style{Fg: palette.BaseColor, Bg: ui.ColorClear}
|
2019-03-16 23:59:28 +00:00
|
|
|
block := ui.NewBlock()
|
|
|
|
block.Border = border
|
2019-03-24 00:16:59 +00:00
|
|
|
block.BorderStyle = style
|
|
|
|
block.TitleStyle = style
|
|
|
|
if len(title) > 0 {
|
|
|
|
block.Title = fmt.Sprintf(" %s ", title)
|
|
|
|
}
|
2019-03-16 23:59:28 +00:00
|
|
|
return block
|
|
|
|
}
|