1use freya::prelude::*;
2use freya_core::{
3 prelude::Border,
4 style::{
5 color::Color,
6 text_shadow::TextShadow,
7 },
8};
9
10#[derive(Clone, PartialEq)]
11pub struct Property {
12 name: String,
13 value: String,
14}
15
16impl Property {
17 pub fn new(name: impl Into<String>, value: impl Into<String>) -> Self {
18 Self {
19 name: name.into(),
20 value: value.into(),
21 }
22 }
23}
24
25impl Render for Property {
26 fn render(&self) -> impl IntoElement {
27 rect()
28 .overflow(Overflow::Clip)
29 .width(Size::fill())
30 .direction(Direction::Horizontal)
31 .cross_align(Alignment::center())
32 .child(
33 paragraph()
34 .width(Size::fill())
35 .font_size(15.)
36 .span(Span::new(self.name.clone()).color((102, 163, 217)))
37 .span(Span::new(": ").color((215, 215, 215)))
38 .span(Span::new(self.value.clone()).color((252, 181, 172))),
39 )
40 }
41}
42
43#[derive(Clone, PartialEq)]
44pub struct GradientProperty {
45 name: String,
46 fill: Fill,
47}
48
49impl GradientProperty {
50 pub fn new(name: impl Into<String>, fill: Fill) -> Self {
51 Self {
52 name: name.into(),
53 fill,
54 }
55 }
56}
57
58impl Render for GradientProperty {
59 fn render(&self) -> impl IntoElement {
60 paragraph()
61 .line_height(1.9)
62 .span(Span::new(self.name.to_string()))
63 .font_size(15.)
64 .color(Color::from_rgb(102, 163, 217))
65 .span(Span::new(": "))
66 .font_size(15.)
67 .color(Color::from_rgb(215, 215, 215))
68 .span(Span::new(format!("{:?}", self.fill)))
69 .font_size(15.)
70 .color(Color::from_rgb(252, 181, 172))
71 }
72}
73
74#[derive(Clone, PartialEq)]
75pub struct ColorProperty {
76 name: String,
77 color: Color,
78}
79
80impl ColorProperty {
81 pub fn new(name: impl Into<String>, color: Color) -> Self {
82 Self {
83 name: name.into(),
84 color,
85 }
86 }
87}
88
89impl Render for ColorProperty {
90 fn render(&self) -> impl IntoElement {
91 rect()
92 .overflow(Overflow::Clip)
93 .width(Size::fill())
94 .direction(Direction::Horizontal)
95 .cross_align(Alignment::center())
96 .child(
97 paragraph()
98 .font_size(15.)
99 .span(Span::new(self.name.clone()).color(Color::from_rgb(102, 163, 217)))
100 .span(Span::new(": ").color(Color::from_rgb(215, 215, 215))),
101 )
102 .child(rect().width(Size::px(5.)))
103 .child(
104 rect()
105 .width(Size::px(17.))
106 .height(Size::px(17.))
107 .corner_radius(CornerRadius::new_all(5.))
108 .background(Color::WHITE)
109 .padding(2.5)
110 .child(
111 rect()
112 .corner_radius(CornerRadius::new_all(3.))
113 .width(Size::fill())
114 .height(Size::fill())
115 .background(self.color),
116 ),
117 )
118 .child(rect().width(Size::px(5.)))
119 .child(
120 label()
121 .font_size(15.)
122 .color(Color::from_rgb(252, 181, 172))
123 .text(self.color.pretty()),
124 )
125 }
126}
127
128#[derive(Clone, PartialEq)]
129pub struct ShadowProperty {
130 name: String,
131 shadow: Shadow,
132}
133
134impl ShadowProperty {
135 pub fn new(name: impl Into<String>, shadow: Shadow) -> Self {
136 Self {
137 name: name.into(),
138 shadow,
139 }
140 }
141}
142
143impl Render for ShadowProperty {
144 fn render(&self) -> impl IntoElement {
145 rect()
146 .overflow(Overflow::Clip)
147 .width(Size::fill())
148 .direction(Direction::Horizontal)
149 .cross_align(Alignment::center())
150 .font_size(15.)
151 .children(vec![
152 paragraph()
153 .span(Span::new(self.name.clone()).color(Color::from_rgb(102, 163, 217)))
154 .span(Span::new(": ").color(Color::from_rgb(215, 215, 215)))
155 .span(Span::new(self.shadow.to_string()).color(Color::from_rgb(252, 181, 172)))
156 .into(),
157 rect().width(Size::px(5.)).into(),
158 rect()
159 .width(Size::px(17.))
160 .height(Size::px(17.))
161 .corner_radius(CornerRadius::new_all(8.))
162 .background(Color::WHITE)
163 .padding(2.5)
164 .child(
165 rect()
166 .corner_radius(CornerRadius::new_all(3.))
167 .width(Size::fill())
168 .height(Size::fill())
169 .background(self.shadow.color),
170 )
171 .into(),
172 rect().width(Size::px(5.)).into(),
173 label()
174 .color(Color::from_rgb(252, 181, 172))
175 .text(format!("{:?}", self.shadow.color))
176 .into(),
177 ])
178 }
179}
180
181#[derive(Clone, PartialEq)]
182pub struct BorderProperty {
183 name: String,
184 border: Border,
185}
186
187impl BorderProperty {
188 pub fn new(name: impl Into<String>, border: Border) -> Self {
189 Self {
190 name: name.into(),
191 border,
192 }
193 }
194}
195
196impl Render for BorderProperty {
197 fn render(&self) -> impl IntoElement {
198 rect()
199 .overflow(Overflow::Clip)
200 .width(Size::fill())
201 .direction(Direction::Horizontal)
202 .cross_align(Alignment::center())
203 .children(vec![
204 paragraph()
205 .font_size(15.)
206 .span(Span::new(self.name.clone()).color((102, 163, 217)))
207 .span(Span::new(": ").color((215, 215, 215)))
208 .span(Span::new(self.border.pretty()).color((252, 181, 172)))
209 .into(),
210 rect().width(Size::px(5.)).into(),
211 rect()
212 .width(Size::px(17.))
213 .height(Size::px(17.))
214 .corner_radius(CornerRadius::new_all(5.))
215 .background(Color::WHITE)
216 .padding(2.5)
217 .child(
218 rect()
219 .corner_radius(CornerRadius::new_all(3.))
220 .width(Size::fill())
221 .height(Size::fill())
222 .background(self.border.fill),
223 )
224 .into(),
225 rect().width(Size::px(5.)).into(),
226 label()
227 .font_size(15.)
228 .color(Color::from_rgb(252, 181, 172))
229 .text(self.border.fill.pretty())
230 .into(),
231 ])
232 }
233}
234
235#[derive(Clone, PartialEq)]
236pub struct TextShadowProperty {
237 name: String,
238 text_shadow: TextShadow,
239}
240
241impl TextShadowProperty {
242 pub fn new(name: impl Into<String>, text_shadow: TextShadow) -> Self {
243 Self {
244 name: name.into(),
245 text_shadow,
246 }
247 }
248}
249
250impl Render for TextShadowProperty {
251 fn render(&self) -> impl IntoElement {
252 let color = self.text_shadow.color;
253
254 rect()
255 .width(Size::fill())
256 .direction(Direction::Horizontal)
257 .cross_align(Alignment::center())
258 .font_size(15.)
259 .children(vec![
260 paragraph()
261 .span(Span::new(self.name.to_string()).color(Color::from_rgb(102, 163, 217)))
262 .span(Span::new(": ").color(Color::from_rgb(215, 215, 215)))
263 .span(
264 Span::new(format!(
265 "{} {} {}",
266 self.text_shadow.offset.0,
267 self.text_shadow.offset.1,
268 self.text_shadow.blur_sigma
269 ))
270 .color(Color::from_rgb(252, 181, 172)),
271 )
272 .into(),
273 rect().width(Size::px(5.)).into(),
274 rect()
275 .width(Size::px(17.))
276 .height(Size::px(17.))
277 .corner_radius(CornerRadius::new_all(5.))
278 .background(Color::WHITE)
279 .padding(2.5)
280 .child(
281 rect()
282 .corner_radius(CornerRadius::new_all(3.))
283 .width(Size::fill())
284 .height(Size::fill())
285 .background(color),
286 )
287 .into(),
288 rect().width(Size::px(5.)).into(),
289 label()
290 .color(Color::from_rgb(252, 181, 172))
291 .text(format!("{:?}", color))
292 .into(),
293 ])
294 }
295}