1mod build;
2mod state;
3
4use crate::text::TypographyStyle;
5use bevy::prelude::*;
6
7#[derive(SystemSet, Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub enum LinkSet {
9 Build,
10}
11
12#[derive(Component, Debug, Clone, Default)]
13pub struct Link {
14 pub name: String,
15 pub href: String,
16}
17
18#[derive(Component, Debug, Clone, Default)]
19pub struct DisabledLink;
20
21#[derive(Component, Debug, Clone, Copy)]
22pub struct LinkLabel {
23 pub entity: Entity,
24}
25
26#[derive(Component, Debug, Clone)]
27pub struct AddLink {
28 pub name: String,
29 pub href: String,
30 pub text: String,
31 pub class: Option<String>,
32 pub label_class: Option<String>,
33 pub label_typography: TypographyStyle,
34 pub visible: bool,
35 pub disabled: bool,
36}
37
38impl Default for AddLink {
39 fn default() -> Self {
40 Self {
41 name: String::new(),
42 href: String::new(),
43 text: String::new(),
44 class: None,
45 label_class: None,
46 label_typography: TypographyStyle::default(),
47 visible: true,
48 disabled: false,
49 }
50 }
51}
52
53#[derive(Message, Debug, Clone, PartialEq, Eq)]
54pub struct LinkActivatedMessage {
55 pub entity: Entity,
56 pub name: String,
57 pub href: String,
58}
59
60pub struct LinkPlugin;
61
62impl Plugin for LinkPlugin {
63 fn build(&self, app: &mut App) {
64 app.add_message::<LinkActivatedMessage>()
65 .add_systems(
66 Update,
67 (build::add_link.in_set(LinkSet::Build), state::link_keyboard_activate),
68 );
69 }
70}