Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tuify] Add styling support so that selected and unselected styles can be passed in #116

Closed
nazmulidris opened this issue Sep 8, 2023 · 3 comments · Fixed by #136
Closed
Assignees
Labels

Comments

@nazmulidris nazmulidris transferred this issue from another repository Sep 10, 2023
@nazmulidris nazmulidris added good first issue Good for newcomers help wanted Extra attention is needed labels Sep 10, 2023
@nazmulidris nazmulidris changed the title Add styling support so that selected and unselected styles can be passed in [tuify] Add styling support so that selected and unselected styles can be passed in Sep 10, 2023
@nazmulidris nazmulidris changed the title [tuify] Add styling support so that selected and unselected styles can be passed in Add styling support so that selected and unselected styles can be passed in Sep 10, 2023
@nazmulidris nazmulidris changed the title Add styling support so that selected and unselected styles can be passed in [tuify] Add styling support so that selected and unselected styles can be passed in Sep 12, 2023
@nazmulidris
Copy link
Member Author

@johnmcl001 I am assigning this to you 🙏🏽

@johnmcl001
Copy link
Contributor

johnmcl001 commented Sep 18, 2023

Thanks, I've also accepted the invitation to be a contributer so you should be able to assign issues to me without waiting for me to comment.

Just have 3 questions about the implementation:

  1. There's an existing Style class found in /core/src/tui_core/styles/style.rs, should I use that? .
  2. Should there be a specific selection_color?
  3. Is this expected to be used as user input similar to selection mode, e.g: --fg_color <some_color> --bg_color <some_color>

@nazmulidris
Copy link
Member Author

nazmulidris commented Sep 18, 2023

@johnmcl001 Thanks for accepting the invitation! 🎉

Re: Use Style from r3bl_rs_utils_core

While that is a good idea since the Style struct has support for other ANSI attributes like bold, italic, etc., unfortunately the Style struct hasn't yet been updated to use the r3bl_ansi_color crate which needs to be done. Basically the r3bl_ansi_color crate handles ANSI 256 colors properly across macos, linux, and windows, and also has accurate detection of terminal capabilities.

I propose that we make a struct that is similar to Style knowing that we will use the one from r3bl_rs_utils_core. But we do not re-use the one from r3bl_rs_utils_core just yet. This means that we can follow this shape.

pub struct Style {
    pub bold: bool,
    pub italic: bool,
    pub dim: bool,
    pub underline: bool,
    pub reverse: bool,
    pub hidden: bool,
    pub strikethrough: bool,
    pub color_fg: Color,
    pub color_bg: Color,
}

The Color struct to use comes from:
https://github.com/r3bl-org/r3bl_rs_utils/blob/main/ansi_color/src/color.rs#L38

Re: specific selection color

Yes, I think we should allow the user to pass in the following style sheet.

pub struct StyleSheet {
    pub normal_style: Style,
    pub selected_style: Style,
}

This way, a user can choose what color palette they would like to use in the app, along w/ ANSI attributes like bold, italic, etc.

Also, we can do a lot more to decorate the selection with nice glyphs, instead of just ">" prefix. So it looks more like a real app. Here's an example of glyphs we can use. https://github.com/r3bl-org/r3bl-ts-utils/blob/8751aadef6a110ae409e5c5a0ecfc263a95b2741/src/tui-figures/symbols.ts#L217
Here is a new issue for this:

Re: command line args for colors

I think we should avoid passing colors as args, it is cumbersome. Best to use the Rust API in this case, and we can provide some nice looking defaults for the binary target rt. Currently we just use some colors that were developed for testing ANSI 256 colors easily on macos, linux, and windows. They don't look the best 😄 .

PLMK if you have more questions. We can also chat on discord if you need immediate feedback.

nazmulidris pushed a commit to johnmcl001/r3bl_rs_utils that referenced this issue Sep 23, 2023
- Create style.rs, apply_style_macro.rs
- Update select_component.rs to make use of them
- Style is now an arg for public_api

Fixes: r3bl-org#116
nazmulidris pushed a commit that referenced this issue Sep 23, 2023
- Create style.rs, apply_style_macro.rs
- Update select_component.rs to make use of them
- Style is now an arg for public_api

Fixes: #116
nazmulidris pushed a commit that referenced this issue Sep 23, 2023
- Create style.rs, apply_style_macro.rs
- Update select_component.rs to make use of them
- Style is now an arg for public_api

Fixes: #116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants