Skip to content

Commit

Permalink
feat(tabs): adding separator
Browse files Browse the repository at this point in the history
  • Loading branch information
grampelberg committed Sep 27, 2024
1 parent 0a2988d commit 0c56ac0
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/widget/tabs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bon::Builder;
use eyre::Result;
use itertools::Itertools;
use ratatui::{
buffer::Buffer,
layout::{Constraint, Layout, Position, Rect},
Expand Down Expand Up @@ -85,13 +86,21 @@ impl Widget for Bar {
.collect::<Vec<_>>(),
));

let layout =
Layout::horizontal(std::iter::repeat(Constraint::Fill(1)).take(self.items.len()))
.spacing(1)
.split(border.inner(area));

for (i, (area, txt)) in layout.iter().zip(self.items.iter()).enumerate() {
let style = if i == self.idx {
let layout = Layout::horizontal(
Itertools::intersperse(
std::iter::repeat(Constraint::Fill(1)),
Constraint::Length(1),
)
.take(self.items.len() * 2 - 1),
)
.split(border.inner(area));

for (i, (area, txt)) in layout
.iter()
.zip(Itertools::intersperse(self.items.iter(), &"|".to_string()))
.enumerate()
{
let style = if i == self.idx * 2 {
self.style
} else {
Style::default()
Expand Down

0 comments on commit 0c56ac0

Please sign in to comment.