1use phf::phf_map;
2use std::str::FromStr;
3use strum_macros::{AsRefStr, Display, EnumIter, EnumString};
4
5#[derive(Debug, Clone, PartialEq, Default)]
6pub enum Size {
7 Small,
8 #[default]
9 Medium,
10 Large,
11}
12
13#[derive(
15 EnumString, EnumIter, AsRefStr, Display, Debug, Eq, PartialEq, Hash, Clone, Copy, Default,
16)]
17pub enum Type {
18 #[default]
19 Rainbow,
20 Transgender,
21 Bisexual,
22 Lesbian,
23 Pansexual,
24 Asexual,
25 NonBinary,
26 Aromantic,
27 Demisexual,
28 Genderfluid,
29 Agender,
30 Polysexual,
31 Omnisexual,
32 Demiromantic,
33 Graysexual,
34}
35
36#[derive(EnumString, EnumIter, AsRefStr, Display, Debug, Clone, Copy, Default, PartialEq)]
37pub enum Direction {
38 #[default]
39 Horizontal,
40 Vertical,
41}
42
43#[derive(Debug)]
44pub struct FlagConfig {
45 pub colors: &'static [&'static str],
46 pub direction: Direction,
47 pub name: &'static str,
48 pub description: &'static str,
49}
50
51pub static FLAG_CONFIGURATIONS: phf::Map<&'static str, FlagConfig> = phf_map! {
52 "Rainbow" => FlagConfig {
53 colors: &["#e40303", "#ff8c00", "#ffed00", "#008018", "#0066ff", "#732982"],
54 direction: Direction::Horizontal,
55 name: "Pride Rainbow Flag",
56 description: "The original rainbow pride flag representing LGBTQ+ community",
57 },
58 "Transgender" => FlagConfig {
59 colors: &["#5bcffa", "#f5abb9", "#ffffff", "#f5abb9", "#5bcffa"],
60 direction: Direction::Horizontal,
61 name: "Transgender Flag",
62 description: "Flag representing transgender community with light blue, pink, and white stripes",
63 },
64 "Bisexual" => FlagConfig {
65 colors: &["#d60270", "#d60270", "#9b59b6", "#0038a8", "#0038a8"],
66 direction: Direction::Horizontal,
67 name: "Bisexual Flag",
68 description: "Flag representing bisexual community with pink, purple, and blue stripes",
69 },
70 "Lesbian" => FlagConfig {
71 colors: &["#d52d00", "#ef7627", "#ff9a56", "#ffffff", "#d162a4", "#b55690", "#a30262"],
72 direction: Direction::Horizontal,
73 name: "Lesbian Flag",
74 description: "Flag representing lesbian community with orange, white, and pink stripes",
75 },
76 "Pansexual" => FlagConfig {
77 colors: &["#ff1b8d", "#ffda00", "#1bb3ff"],
78 direction: Direction::Horizontal,
79 name: "Pansexual Flag",
80 description: "Flag representing pansexual community with pink, yellow, and blue stripes",
81 },
82 "Asexual" => FlagConfig {
83 colors: &["#000000", "#a4a4a4", "#ffffff", "#810081"],
84 direction: Direction::Horizontal,
85 name: "Asexual Flag",
86 description: "Flag representing asexual community with black, gray, white, and purple stripes",
87 },
88 "NonBinary" => FlagConfig {
89 colors: &["#fcf431", "#fcfcfc", "#9d59d2", "#282828"],
90 direction: Direction::Horizontal,
91 name: "Non-Binary Flag",
92 description: "Flag representing non-binary community with yellow, white, purple, and black stripes",
93 },
94 "Aromantic" => FlagConfig {
95 colors: &["#3ba740", "#a8d47a", "#ffffff", "#ababab", "#000000"],
96 direction: Direction::Horizontal,
97 name: "Aromantic Flag",
98 description: "Flag representing aromantic community with green, light green, white, gray, and black stripes",
99 },
100 "Demisexual" => FlagConfig {
101 colors: &["#000000", "#a4a4a4", "#ffffff", "#810081"],
102 direction: Direction::Horizontal,
103 name: "Demisexual Flag",
104 description: "Flag representing demisexual community with black, gray, white, and purple stripes",
105 },
106 "Genderfluid" => FlagConfig {
107 colors: &["#ff76a4", "#ffffff", "#c011d7", "#000000", "#303cbe"],
108 direction: Direction::Horizontal,
109 name: "Genderfluid Flag",
110 description: "Flag representing genderfluid community with pink, white, purple, black, and blue stripes",
111 },
112 "Agender" => FlagConfig {
113 colors: &["#000000", "#bababa", "#ffffff", "#b7f684", "#ffffff", "#bababa", "#000000"],
114 direction: Direction::Horizontal,
115 name: "Agender Flag",
116 description: "Flag representing agender community with black, gray, white, and green stripes",
117 },
118 "Polysexual" => FlagConfig {
119 colors: &["#f61cb9", "#07d569", "#1c92f6"],
120 direction: Direction::Horizontal,
121 name: "Polysexual Flag",
122 description: "Flag representing polysexual community with pink, green, and blue stripes",
123 },
124 "Omnisexual" => FlagConfig {
125 colors: &["#ff9ace", "#ff6cab", "#85d7f2", "#67cdf0", "#9378ff"],
126 direction: Direction::Horizontal,
127 name: "Omnisexual Flag",
128 description: "Flag representing omnisexual community with pink, blue, and purple stripes",
129 },
130 "Demiromantic" => FlagConfig {
131 colors: &["#000000", "#a4a4a4", "#ffffff", "#3ba740"],
132 direction: Direction::Horizontal,
133 name: "Demiromantic Flag",
134 description: "Flag representing demiromantic community with black, gray, white, and green stripes",
135 },
136 "Graysexual" => FlagConfig {
137 colors: &["#810081", "#a4a4a4", "#ffffff", "#a4a4a4", "#810081"],
138 direction: Direction::Horizontal,
139 name: "Graysexual Flag",
140 description: "Flag representing graysexual community with purple, gray, and white stripes",
141 },
142};
143
144pub(crate) fn get_flag_config_by_type(flag_type: Type) -> Option<&'static FlagConfig> {
145 FLAG_CONFIGURATIONS.get(flag_type.as_ref())
146}
147pub(crate) fn get_flag_config_by_str(flag_str: &str) -> Option<&'static FlagConfig> {
148 if let Ok(flag_type) = Type::from_str(flag_str) {
149 get_flag_config_by_type(flag_type)
150 } else {
151 None
152 }
153}
154
155pub trait FlagLookup {
156 fn config(&self) -> Option<&'static FlagConfig>;
157}
158
159impl FlagLookup for Type {
160 fn config(&self) -> Option<&'static FlagConfig> {
161 get_flag_config_by_type(*self)
162 }
163}
164
165impl FlagLookup for &str {
166 fn config(&self) -> Option<&'static FlagConfig> {
167 get_flag_config_by_str(self)
168 }
169}