Skip to content

Commit

Permalink
Merge pull request #432 from sarub0b0/revert-431-430-improve-highligh…
Browse files Browse the repository at this point in the history
…ting-logic-for-active-components

Revert "feat(ui): Improve highlighting logic for active components."
  • Loading branch information
sarub0b0 authored Nov 21, 2023
2 parents ab5b0ef + 3ecfefd commit 3101dcf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
8 changes: 2 additions & 6 deletions src/ui/widget/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,7 @@ impl RenderTrait for Table<'_> {
self.widget_config.clone()
};

let block = widget_config.render_block(
self.can_activate() && !self.mode.is_filter_input() && is_active,
is_mouse_over,
);
let block = widget_config.render_block(self.can_activate() && is_active, is_mouse_over);

let constraints = constraints(self.items.digits());

Expand All @@ -659,8 +656,7 @@ impl RenderTrait for Table<'_> {
}

Mode::FilterInput | Mode::FilterConfirm => {
self.filter_widget
.render(f, self.mode.is_filter_input() && is_active);
self.filter_widget.render(f, self.mode.is_filter_input());

f.render_stateful_widget(widget, self.chunk(), &mut self.state);
}
Expand Down
15 changes: 7 additions & 8 deletions src/ui/widget/table/filter_form.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crossterm::event::KeyEvent;
use ratatui::{
layout::{Constraint, Direction, Layout, Rect},
widgets::{Block, Paragraph},
widgets::{Block, BorderType, Borders, Paragraph},
Frame,
};

Expand All @@ -18,7 +18,7 @@ struct Chunk {

#[derive(Debug)]
pub struct FilterForm {
widget_config: WidgetConfig,
block: Block<'static>,
input_widget: InputForm,
chunk: Chunk,
layout: Layout,
Expand All @@ -27,7 +27,9 @@ pub struct FilterForm {
impl Default for FilterForm {
fn default() -> Self {
Self {
widget_config: WidgetConfig::default(),
block: Block::default()
.border_type(BorderType::Plain)
.borders(Borders::ALL),
input_widget: InputForm::new(WidgetConfig::builder().block(Block::default()).build()),
chunk: Chunk::default(),
layout: Layout::default()
Expand All @@ -44,7 +46,7 @@ impl FilterForm {
pub fn update_chunk(&mut self, chunk: Rect) {
let block_chunk = Rect::new(chunk.x, chunk.y, chunk.width, FILTER_HEIGHT);

let inner_chunk = self.widget_config.block().inner(block_chunk);
let inner_chunk = self.block.inner(block_chunk);

let chunks = self.layout.split(inner_chunk);

Expand Down Expand Up @@ -73,10 +75,7 @@ impl FilterForm {
}

pub fn render(&mut self, f: &mut Frame<'_>, is_active: bool) {
f.render_widget(
self.widget_config.render_block(is_active, false),
self.chunk.block,
);
f.render_widget(self.block.clone(), self.chunk.block);

f.render_widget(Paragraph::new("FILTER: "), self.chunk.header);

Expand Down
5 changes: 2 additions & 3 deletions src/ui/widget/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ use crate::{
use self::{
highlight_content::{HighlightArea, HighlightContent, Point},
item::TextItem,
render::{Render, Scroll},
search_form::SearchForm,
render::{Render, Scroll}, search_form::SearchForm,
};

use super::{
Expand Down Expand Up @@ -815,7 +814,7 @@ impl RenderTrait for Text {

self.search_widget.render(
f,
self.mode.is_search_input() && is_active,
self.mode.is_search_input(),
self.item.highlight_status(),
);
}
Expand Down

0 comments on commit 3101dcf

Please sign in to comment.