Newer
Older
/// Props used by the [`Text`] widget
#[derive(WidgetProps, Debug, PartialEq, Clone)]
/// The name of the font to use
///
/// The given font must already be loaded into the [`KayakContext`](kayak_core::KayakContext)
/// The height of a line of text (currently in pixels)
pub focusable: Option<bool>,
}
impl Default for TextProps {
fn default() -> Self {
TextProps {
/// A widget that renders plain text
///
/// # Props
///
/// __Type:__ [`TextProps`]
///
/// | Common Prop | Accepted |
/// | :---------: | :------: |
/// | `children` | ❌ |
/// | `styles` | ✅ |
/// | `on_event` | ✅ |
/// | `focusable` | ✅ |
///
let mut styles = Style {
render_command: StyleProp::Value(RenderCommand::Text {
content: props.content.clone(),
}),
..Default::default()
};
if let Some(ref font) = props.font {
styles.font = StyleProp::Value(font.clone());
}
if props.size >= 0.0 {
styles.font_size = StyleProp::Value(props.size);
if let Some(line_height) = props.line_height {
styles.line_height = StyleProp::Value(line_height);
}
props.styles = Some(styles.with_style(&props.styles).with_style(Style {
cursor: StyleProp::Value(CursorIcon::Text),
..Default::default()
}));