danceinterpreter_rs/ui/widgets/
color_swatch.rs1use iced::widget::button::Status;
2use iced::widget::button::Style;
3use iced::{Background, Color, Element, Length, Theme, widget::Button};
4
5pub fn color_swatch<'a, Message: Clone + 'a>(
6 color: Color,
7 on_press: Message,
8) -> Element<'a, Message, Theme, iced::Renderer> {
9 Button::new(
10 iced::widget::Space::new()
11 .width(Length::Fixed(16.0))
12 .height(Length::Fixed(16.0)),
13 )
14 .on_press(on_press)
15 .style(move |_theme: &Theme, _status: Status| Style {
16 background: Some(Background::Color(color)),
17 border: iced::Border {
18 color: Color::WHITE,
19 width: 1.0,
20 radius: 3.0.into(),
21 },
22 ..Style::default()
23 })
24 .padding(4)
25 .into()
26}