Skip to content

Comments

feat: add select widget#14

Open
swetar-mecha wants to merge 11 commits intomecha-org:mainfrom
swetar-mecha:feat/select-widget
Open

feat: add select widget#14
swetar-mecha wants to merge 11 commits intomecha-org:mainfrom
swetar-mecha:feat/select-widget

Conversation

@swetar-mecha
Copy link
Contributor

@swetar-mecha swetar-mecha commented May 12, 2025

  1. Headless Select widget
  • Select button with drop down options

  • on an item selection, close drop down

  • size variants ( extra small , small, medium, large, extra large)

  • on outside click of select, close drop down

  • Preview
    Screenshot from 2025-05-12 16-14-34

  • on trigger of select button & hover on select item
    Screenshot from 2025-05-12 16-14-41

  • update after styles & size support:
    image

@swetar-mecha swetar-mecha reopened this May 13, 2025
use super::ThemeColors;

#[derive(Debug, Clone)]
pub struct SelectButtonStyles {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to SelectStyles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

pub struct SelectButtonStyles {
// Colors
// trigger
pub button_background: Color,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to background

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

// Colors
// trigger
pub button_background: Color,
pub button_text_color: Color,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

// trigger
pub button_background: Color,
pub button_text_color: Color,
pub button_border_color: Color,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

self
}

pub fn key<S: Into<String>>(mut self, key: S) -> Self {
Copy link
Contributor

@akshayr-mecha akshayr-mecha May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also create a common method for this
like key_val() take both key and value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are two properties :
label: Option,
key: String,
hence it has two different method

padding: UiRect::axes(Val::Px(0.0), Val::Px(4.0)),
..default()
},
GlobalZIndex(99),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add comment why is z index needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

pub selected: bool,
pub on_change: Option<SystemId<In<bool>>>,
pub disabled: bool,
pub key: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we rename to label?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, changed to label

let height = select_button_size_style.min_height;
let font_size = select_button_size_style.font_size;

let key = self.key.clone().unwrap_or_else(|| "".to_string());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is key is label in terms of html
then if it is not present and value was given
then value will become key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

height: Val::Px(height),
..default()
},
Name::new(self.key.clone().unwrap_or("".to_string())),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check here also

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is modified to take value if label is not given

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants