charmbracelet / lipgloss

Style definitions for nice terminal layouts 👄
MIT License
7.89k stars 225 forks source link

Setting `BorderTop(false)` disappears entire border #194

Open haarts opened 1 year ago

haarts commented 1 year ago

Hi all!

I'm having a blast with Bubbletea and Lipgloss, but I misunderstood something.

leftOnly = lipgloss.NewStyle().
        BorderStyle(lipgloss.Border{Left: "   new             "}).
        BorderTop(false). //these are the problem
        BorderRight(false). //
        BorderBottom(false).  //
                BorderForeground(neonOrange);
leftOnly.Render("some cyberpunk text");

Without these Border{Top,Right,Bottom} calls I get a lovely neon orange border around my text. But as soon as I call one of these the border disappears entirely. I would have expected that the respective border would not have been rendered?

(I don't think it has anything to do with the hack I used to display the text "new" vertically in the left border.)

meowgorithm commented 1 year ago

Good catch! I'd classify this as a bug. This also begs reexamining the behavior here in general:

Right now, if a style has a border set, but no specific top/bottom/left/right rules, the border applies to the entire box. As soon as one of the sides has a border true value, the other borders are treated as false.

Irrespective of breaking API changes, do we think this type of logic still makes sense?

haarts commented 1 year ago

In general, I would like to have more control over the borders (I'm massively biased because I'm trying to create a 'cyberpunk' feel to the interface I'm writing). In that sense, the behaviour you are describing would be suboptimal. (To paraphrase you in order to check if I understand correctly: if you use a border with a true value (via BorderBottom(true) for example) the other borders disappear. I would like the ability to true off and on each individual border.

On a slightly related note: adding Blink(true) to a border didn't have any effect. Perhaps intentional?

meowgorithm commented 1 year ago

Oh, to clarify, you can always turn borders back on once they’re auto-set to false. What I’m describing is just default behavior which can always be overridden.

As for blink, it won’t affect borders however it is possible to make borders blink (with a little work) using Bubble Tea.