Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T03:34:37.154Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

styled.rs

886 lines · 32.3 KB · rust
1use crate::{
2    self as gpui, AbsoluteLength, AlignContent, AlignItems, AlignSelf, BorderStyle, CursorStyle,
3    DefiniteLength, Display, Fill, FlexDirection, FlexWrap, Font, FontFeatures, FontStyle,
4    FontWeight, GridPlacement, GridTemplate, Hsla, JustifyContent, Length, SharedString,
5    StrikethroughStyle, StyleRefinement, TemplateColumnMinSize, TextAlign, TextOverflow,
6    TextStyleRefinement, UnderlineStyle, WhiteSpace, px, relative, rems,
7};
8pub use gpui_macros::{
9    border_style_methods, box_shadow_style_methods, cursor_style_methods, margin_style_methods,
10    overflow_style_methods, padding_style_methods, position_style_methods,
11    visibility_style_methods,
12};
13const ELLIPSIS: SharedString = SharedString::new_static("…");
14
15/// A trait for elements that can be styled.
16/// Use this to opt-in to a utility CSS-like styling API.
17// gate on rust-analyzer so rust-analyzer never needs to expand this macro, it takes up to 10 seconds to expand due to inefficiencies in rust-analyzers proc-macro srv
18#[cfg_attr(
19    all(any(feature = "inspector", debug_assertions), not(rust_analyzer)),
20    gpui_macros::derive_inspector_reflection
21)]
22pub trait Styled: Sized {
23    /// Returns a reference to the style memory of this element.
24    fn style(&mut self) -> &mut StyleRefinement;
25
26    gpui_macros::style_helpers!();
27    gpui_macros::visibility_style_methods!();
28    gpui_macros::margin_style_methods!();
29    gpui_macros::padding_style_methods!();
30    gpui_macros::position_style_methods!();
31    gpui_macros::overflow_style_methods!();
32    gpui_macros::cursor_style_methods!();
33    gpui_macros::border_style_methods!();
34    gpui_macros::box_shadow_style_methods!();
35
36    /// Sets the display type of the element to `block`.
37    /// [Docs](https://tailwindcss.com/docs/display)
38    fn block(mut self) -> Self {
39        self.style().display = Some(Display::Block);
40        self
41    }
42
43    /// Sets the display type of the element to `flex`.
44    /// [Docs](https://tailwindcss.com/docs/display)
45    fn flex(mut self) -> Self {
46        self.style().display = Some(Display::Flex);
47        self
48    }
49
50    /// Sets the display type of the element to `grid`.
51    /// [Docs](https://tailwindcss.com/docs/display)
52    fn grid(mut self) -> Self {
53        self.style().display = Some(Display::Grid);
54        self
55    }
56
57    /// Sets the display type of the element to `none`.
58    /// [Docs](https://tailwindcss.com/docs/display)
59    fn hidden(mut self) -> Self {
60        self.style().display = Some(Display::None);
61        self
62    }
63
64    /// Set the space to be reserved for rendering the scrollbar.
65    ///
66    /// This will only affect the layout of the element when overflow for this element is set to
67    /// `Overflow::Scroll`.
68    fn scrollbar_width(mut self, width: impl Into<AbsoluteLength>) -> Self {
69        self.style().scrollbar_width = Some(width.into());
70        self
71    }
72
73    /// Sets the whitespace of the element to `normal`.
74    /// [Docs](https://tailwindcss.com/docs/whitespace#normal)
75    fn whitespace_normal(mut self) -> Self {
76        self.text_style().white_space = Some(WhiteSpace::Normal);
77        self
78    }
79
80    /// Sets the whitespace of the element to `nowrap`.
81    /// [Docs](https://tailwindcss.com/docs/whitespace#nowrap)
82    fn whitespace_nowrap(mut self) -> Self {
83        self.text_style().white_space = Some(WhiteSpace::Nowrap);
84        self
85    }
86
87    /// Sets the truncate overflowing text with an ellipsis (…) at the end if needed.
88    /// [Docs](https://tailwindcss.com/docs/text-overflow#ellipsis)
89    fn text_ellipsis(mut self) -> Self {
90        self.text_style().text_overflow = Some(TextOverflow::Truncate(ELLIPSIS));
91        self
92    }
93
94    /// Sets the truncate overflowing text with an ellipsis (…) at the start if needed.
95    /// Typically more adequate for file paths where the end is more important than the beginning.
96    /// Note: This doesn't exist in Tailwind CSS.
97    fn text_ellipsis_start(mut self) -> Self {
98        self.text_style().text_overflow = Some(TextOverflow::TruncateStart(ELLIPSIS));
99        self
100    }
101
102    /// Sets the truncate overflowing text with an ellipsis (…) in the middle if needed.
103    /// Preserves the beginning and end of the text. Useful for filenames.
104    /// Note: This doesn't exist in Tailwind CSS.
105    fn text_ellipsis_middle(mut self) -> Self {
106        self.text_style().text_overflow = Some(TextOverflow::TruncateMiddle(ELLIPSIS));
107        self
108    }
109
110    /// Sets the text overflow behavior of the element.
111    fn text_overflow(mut self, overflow: TextOverflow) -> Self {
112        self.text_style().text_overflow = Some(overflow);
113        self
114    }
115
116    /// Set the text alignment of the element.
117    fn text_align(mut self, align: TextAlign) -> Self {
118        self.text_style().text_align = Some(align);
119        self
120    }
121
122    /// Sets the text alignment to left
123    fn text_left(mut self) -> Self {
124        self.text_align(TextAlign::Left)
125    }
126
127    /// Sets the text alignment to center
128    fn text_center(mut self) -> Self {
129        self.text_align(TextAlign::Center)
130    }
131
132    /// Sets the text alignment to right
133    fn text_right(mut self) -> Self {
134        self.text_align(TextAlign::Right)
135    }
136
137    /// Sets the truncate to prevent text from wrapping and truncate overflowing text with an ellipsis (…) if needed.
138    /// [Docs](https://tailwindcss.com/docs/text-overflow#truncate)
139    fn truncate(mut self) -> Self {
140        self.overflow_hidden().whitespace_nowrap().text_ellipsis()
141    }
142
143    /// Sets number of lines to show before truncating the text.
144    /// [Docs](https://tailwindcss.com/docs/line-clamp)
145    fn line_clamp(mut self, lines: usize) -> Self {
146        let mut text_style = self.text_style();
147        text_style.line_clamp = Some(lines);
148        self.overflow_hidden()
149    }
150
151    /// Sets the flex direction of the element to `column`.
152    /// [Docs](https://tailwindcss.com/docs/flex-direction#column)
153    fn flex_col(mut self) -> Self {
154        self.style().flex_direction = Some(FlexDirection::Column);
155        self
156    }
157
158    /// Sets the flex direction of the element to `column-reverse`.
159    /// [Docs](https://tailwindcss.com/docs/flex-direction#column-reverse)
160    fn flex_col_reverse(mut self) -> Self {
161        self.style().flex_direction = Some(FlexDirection::ColumnReverse);
162        self
163    }
164
165    /// Sets the flex direction of the element to `row`.
166    /// [Docs](https://tailwindcss.com/docs/flex-direction#row)
167    fn flex_row(mut self) -> Self {
168        self.style().flex_direction = Some(FlexDirection::Row);
169        self
170    }
171
172    /// Sets the flex direction of the element to `row-reverse`.
173    /// [Docs](https://tailwindcss.com/docs/flex-direction#row-reverse)
174    fn flex_row_reverse(mut self) -> Self {
175        self.style().flex_direction = Some(FlexDirection::RowReverse);
176        self
177    }
178
179    /// Sets the element to allow a flex item to grow and shrink as needed, ignoring its initial size.
180    /// [Docs](https://tailwindcss.com/docs/flex#flex-1)
181    fn flex_1(mut self) -> Self {
182        self.style().flex_grow = Some(1.);
183        self.style().flex_shrink = Some(1.);
184        self.style().flex_basis = Some(relative(0.).into());
185        self
186    }
187
188    /// Sets the element to allow a flex item to grow and shrink, taking into account its initial size.
189    /// [Docs](https://tailwindcss.com/docs/flex#auto)
190    fn flex_auto(mut self) -> Self {
191        self.style().flex_grow = Some(1.);
192        self.style().flex_shrink = Some(1.);
193        self.style().flex_basis = Some(Length::Auto);
194        self
195    }
196
197    /// Sets the element to allow a flex item to shrink but not grow, taking into account its initial size.
198    /// [Docs](https://tailwindcss.com/docs/flex#initial)
199    fn flex_initial(mut self) -> Self {
200        self.style().flex_grow = Some(0.);
201        self.style().flex_shrink = Some(1.);
202        self.style().flex_basis = Some(Length::Auto);
203        self
204    }
205
206    /// Sets the element to prevent a flex item from growing or shrinking.
207    /// [Docs](https://tailwindcss.com/docs/flex#none)
208    fn flex_none(mut self) -> Self {
209        self.style().flex_grow = Some(0.);
210        self.style().flex_shrink = Some(0.);
211        self.style().flex_basis = Some(Length::Auto);
212        self
213    }
214
215    /// Sets the initial size of flex items for this element.
216    /// [Docs](https://tailwindcss.com/docs/flex-basis)
217    fn flex_basis(mut self, basis: impl Into<Length>) -> Self {
218        self.style().flex_basis = Some(basis.into());
219        self
220    }
221
222    /// Sets the flex item's grow factor.
223    /// [Docs](https://tailwindcss.com/docs/flex-grow)
224    fn flex_grow(mut self, grow: f32) -> Self {
225        self.style().flex_grow = Some(grow);
226        self
227    }
228
229    /// Disables flex item growth (flex-grow: 0).
230    /// [Docs](https://tailwindcss.com/docs/flex-grow#dont-grow)
231    fn flex_grow_0(mut self) -> Self {
232        self.style().flex_grow = Some(0.);
233        self
234    }
235
236    /// Enables flex item growth (flex-grow: 1).
237    /// [Docs](https://tailwindcss.com/docs/flex-grow#grow-1)
238    fn flex_grow_1(mut self) -> Self {
239        self.style().flex_grow = Some(1.);
240        self
241    }
242
243    /// Sets the flex item's shrink factor.
244    /// [Docs](https://tailwindcss.com/docs/flex-shrink)
245    fn flex_shrink(mut self, shrink: f32) -> Self {
246        self.style().flex_shrink = Some(shrink);
247        self
248    }
249
250    /// Disables flex item shrinking (flex-shrink: 0).
251    /// [Docs](https://tailwindcss.com/docs/flex-shrink#dont-shrink)
252    fn flex_shrink_0(mut self) -> Self {
253        self.style().flex_shrink = Some(0.);
254        self
255    }
256
257    /// Enables flex item shrinking (flex-shrink: 1).
258    /// [Docs](https://tailwindcss.com/docs/flex-shrink#shrink-1)
259    fn flex_shrink_1(mut self) -> Self {
260        self.style().flex_shrink = Some(1.);
261        self
262    }
263
264    /// Sets the element to allow flex items to wrap.
265    /// [Docs](https://tailwindcss.com/docs/flex-wrap#wrap-normally)
266    fn flex_wrap(mut self) -> Self {
267        self.style().flex_wrap = Some(FlexWrap::Wrap);
268        self
269    }
270
271    /// Sets the element wrap flex items in the reverse direction.
272    /// [Docs](https://tailwindcss.com/docs/flex-wrap#wrap-reversed)
273    fn flex_wrap_reverse(mut self) -> Self {
274        self.style().flex_wrap = Some(FlexWrap::WrapReverse);
275        self
276    }
277
278    /// Sets the element to prevent flex items from wrapping, causing inflexible items to overflow the container if necessary.
279    /// [Docs](https://tailwindcss.com/docs/flex-wrap#dont-wrap)
280    fn flex_nowrap(mut self) -> Self {
281        self.style().flex_wrap = Some(FlexWrap::NoWrap);
282        self
283    }
284
285    /// Sets the element to align flex items to the start of the container's cross axis.
286    /// [Docs](https://tailwindcss.com/docs/align-items#start)
287    fn items_start(mut self) -> Self {
288        self.style().align_items = Some(AlignItems::FlexStart);
289        self
290    }
291
292    /// Sets the element to align flex items to the end of the container's cross axis.
293    /// [Docs](https://tailwindcss.com/docs/align-items#end)
294    fn items_end(mut self) -> Self {
295        self.style().align_items = Some(AlignItems::FlexEnd);
296        self
297    }
298
299    /// Sets the element to align flex items along the center of the container's cross axis.
300    /// [Docs](https://tailwindcss.com/docs/align-items#center)
301    fn items_center(mut self) -> Self {
302        self.style().align_items = Some(AlignItems::Center);
303        self
304    }
305
306    /// Sets the element to align flex items along the baseline of the container's cross axis.
307    /// [Docs](https://tailwindcss.com/docs/align-items#baseline)
308    fn items_baseline(mut self) -> Self {
309        self.style().align_items = Some(AlignItems::Baseline);
310        self
311    }
312
313    /// Sets the element to stretch flex items to fill the available space along the container's cross axis.
314    /// [Docs](https://tailwindcss.com/docs/align-items#stretch)
315    fn items_stretch(mut self) -> Self {
316        self.style().align_items = Some(AlignItems::Stretch);
317        self
318    }
319
320    /// Sets how this specific element is aligned along the container's cross axis.
321    /// [Docs](https://tailwindcss.com/docs/align-self#start)
322    fn self_start(mut self) -> Self {
323        self.style().align_self = Some(AlignSelf::Start);
324        self
325    }
326
327    /// Sets this element to align against the end of the container's cross axis.
328    /// [Docs](https://tailwindcss.com/docs/align-self#end)
329    fn self_end(mut self) -> Self {
330        self.style().align_self = Some(AlignSelf::End);
331        self
332    }
333
334    /// Sets this element to align against the start of the container's cross axis.
335    /// [Docs](https://tailwindcss.com/docs/align-self#start)
336    fn self_flex_start(mut self) -> Self {
337        self.style().align_self = Some(AlignSelf::FlexStart);
338        self
339    }
340
341    /// Sets this element to align against the end of the container's cross axis.
342    /// [Docs](https://tailwindcss.com/docs/align-self#end)
343    fn self_flex_end(mut self) -> Self {
344        self.style().align_self = Some(AlignSelf::FlexEnd);
345        self
346    }
347
348    /// Sets this element to align along the center of the container's cross axis.
349    /// [Docs](https://tailwindcss.com/docs/align-self#center)
350    fn self_center(mut self) -> Self {
351        self.style().align_self = Some(AlignSelf::Center);
352        self
353    }
354
355    /// Sets this element to align along the baseline of the container's cross axis.
356    /// [Docs](https://tailwindcss.com/docs/align-self#baseline)
357    fn self_baseline(mut self) -> Self {
358        self.style().align_self = Some(AlignSelf::Baseline);
359        self
360    }
361
362    /// Sets this element to stretch to fill the available space along the container's cross axis.
363    /// [Docs](https://tailwindcss.com/docs/align-self#stretch)
364    fn self_stretch(mut self) -> Self {
365        self.style().align_self = Some(AlignSelf::Stretch);
366        self
367    }
368
369    /// Sets the element to justify flex items against the start of the container's main axis.
370    /// [Docs](https://tailwindcss.com/docs/justify-content#start)
371    fn justify_start(mut self) -> Self {
372        self.style().justify_content = Some(JustifyContent::Start);
373        self
374    }
375
376    /// Sets the element to justify flex items against the end of the container's main axis.
377    /// [Docs](https://tailwindcss.com/docs/justify-content#end)
378    fn justify_end(mut self) -> Self {
379        self.style().justify_content = Some(JustifyContent::End);
380        self
381    }
382
383    /// Sets the element to justify flex items along the center of the container's main axis.
384    /// [Docs](https://tailwindcss.com/docs/justify-content#center)
385    fn justify_center(mut self) -> Self {
386        self.style().justify_content = Some(JustifyContent::Center);
387        self
388    }
389
390    /// Sets the element to justify flex items along the container's main axis
391    /// such that there is an equal amount of space between each item.
392    /// [Docs](https://tailwindcss.com/docs/justify-content#space-between)
393    fn justify_between(mut self) -> Self {
394        self.style().justify_content = Some(JustifyContent::SpaceBetween);
395        self
396    }
397
398    /// Sets the element to justify items along the container's main axis such
399    /// that there is an equal amount of space on each side of each item.
400    /// [Docs](https://tailwindcss.com/docs/justify-content#space-around)
401    fn justify_around(mut self) -> Self {
402        self.style().justify_content = Some(JustifyContent::SpaceAround);
403        self
404    }
405
406    /// Sets the element to justify items along the container's main axis such
407    /// that there is an equal amount of space around each item, but also
408    /// accounting for the doubling of space you would normally see between
409    /// each item when using justify-around.
410    /// [Docs](https://tailwindcss.com/docs/justify-content#space-evenly)
411    fn justify_evenly(mut self) -> Self {
412        self.style().justify_content = Some(JustifyContent::SpaceEvenly);
413        self
414    }
415
416    /// Sets the element to pack content items in their default position as if no align-content value was set.
417    /// [Docs](https://tailwindcss.com/docs/align-content#normal)
418    fn content_normal(mut self) -> Self {
419        self.style().align_content = None;
420        self
421    }
422
423    /// Sets the element to pack content items in the center of the container's cross axis.
424    /// [Docs](https://tailwindcss.com/docs/align-content#center)
425    fn content_center(mut self) -> Self {
426        self.style().align_content = Some(AlignContent::Center);
427        self
428    }
429
430    /// Sets the element to pack content items against the start of the container's cross axis.
431    /// [Docs](https://tailwindcss.com/docs/align-content#start)
432    fn content_start(mut self) -> Self {
433        self.style().align_content = Some(AlignContent::FlexStart);
434        self
435    }
436
437    /// Sets the element to pack content items against the end of the container's cross axis.
438    /// [Docs](https://tailwindcss.com/docs/align-content#end)
439    fn content_end(mut self) -> Self {
440        self.style().align_content = Some(AlignContent::FlexEnd);
441        self
442    }
443
444    /// Sets the element to pack content items along the container's cross axis
445    /// such that there is an equal amount of space between each item.
446    /// [Docs](https://tailwindcss.com/docs/align-content#space-between)
447    fn content_between(mut self) -> Self {
448        self.style().align_content = Some(AlignContent::SpaceBetween);
449        self
450    }
451
452    /// Sets the element to pack content items along the container's cross axis
453    /// such that there is an equal amount of space on each side of each item.
454    /// [Docs](https://tailwindcss.com/docs/align-content#space-around)
455    fn content_around(mut self) -> Self {
456        self.style().align_content = Some(AlignContent::SpaceAround);
457        self
458    }
459
460    /// Sets the element to pack content items along the container's cross axis
461    /// such that there is an equal amount of space between each item.
462    /// [Docs](https://tailwindcss.com/docs/align-content#space-evenly)
463    fn content_evenly(mut self) -> Self {
464        self.style().align_content = Some(AlignContent::SpaceEvenly);
465        self
466    }
467
468    /// Sets the element to allow content items to fill the available space along the container's cross axis.
469    /// [Docs](https://tailwindcss.com/docs/align-content#stretch)
470    fn content_stretch(mut self) -> Self {
471        self.style().align_content = Some(AlignContent::Stretch);
472        self
473    }
474
475    /// Sets the aspect ratio of the element.
476    /// [Docs](https://tailwindcss.com/docs/aspect-ratio)
477    fn aspect_ratio(mut self, ratio: f32) -> Self {
478        self.style().aspect_ratio = Some(ratio);
479        self
480    }
481
482    /// Sets the aspect ratio of the element to 1/1 – equal width and height.
483    /// [Docs](https://tailwindcss.com/docs/aspect-ratio)
484    fn aspect_square(mut self) -> Self {
485        self.style().aspect_ratio = Some(1.0);
486        self
487    }
488
489    /// Sets the background color of the element.
490    fn bg<F>(mut self, fill: F) -> Self
491    where
492        F: Into<Fill>,
493        Self: Sized,
494    {
495        self.style().background = Some(fill.into());
496        self
497    }
498
499    /// Sets the border style of the element.
500    fn border_dashed(mut self) -> Self {
501        self.style().border_style = Some(BorderStyle::Dashed);
502        self
503    }
504
505    /// Returns a mutable reference to the text style that has been configured on this element.
506    fn text_style(&mut self) -> &mut TextStyleRefinement {
507        let style: &mut StyleRefinement = self.style();
508        &mut style.text
509    }
510
511    /// Sets the text color of this element.
512    ///
513    /// This value cascades to its child elements.
514    fn text_color(mut self, color: impl Into<Hsla>) -> Self {
515        self.text_style().color = Some(color.into());
516        self
517    }
518
519    /// Sets the font weight of this element
520    ///
521    /// This value cascades to its child elements.
522    fn font_weight(mut self, weight: FontWeight) -> Self {
523        self.text_style().font_weight = Some(weight);
524        self
525    }
526
527    /// Sets the background color of this element.
528    ///
529    /// This value cascades to its child elements.
530    fn text_bg(mut self, bg: impl Into<Hsla>) -> Self {
531        self.text_style().background_color = Some(bg.into());
532        self
533    }
534
535    /// Sets the text size of this element.
536    ///
537    /// This value cascades to its child elements.
538    fn text_size(mut self, size: impl Into<AbsoluteLength>) -> Self {
539        self.text_style().font_size = Some(size.into());
540        self
541    }
542
543    /// Sets the text size to 'extra small'.
544    /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size)
545    fn text_xs(mut self) -> Self {
546        self.text_style().font_size = Some(rems(0.75).into());
547        self
548    }
549
550    /// Sets the text size to 'small'.
551    /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size)
552    fn text_sm(mut self) -> Self {
553        self.text_style().font_size = Some(rems(0.875).into());
554        self
555    }
556
557    /// Sets the text size to 'base'.
558    /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size)
559    fn text_base(mut self) -> Self {
560        self.text_style().font_size = Some(rems(1.0).into());
561        self
562    }
563
564    /// Sets the text size to 'large'.
565    /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size)
566    fn text_lg(mut self) -> Self {
567        self.text_style().font_size = Some(rems(1.125).into());
568        self
569    }
570
571    /// Sets the text size to 'extra large'.
572    /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size)
573    fn text_xl(mut self) -> Self {
574        self.text_style().font_size = Some(rems(1.25).into());
575        self
576    }
577
578    /// Sets the text size to 'extra extra large'.
579    /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size)
580    fn text_2xl(mut self) -> Self {
581        self.text_style().font_size = Some(rems(1.5).into());
582        self
583    }
584
585    /// Sets the text size to 'extra extra extra large'.
586    /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size)
587    fn text_3xl(mut self) -> Self {
588        self.text_style().font_size = Some(rems(1.875).into());
589        self
590    }
591
592    /// Sets the font style of the element to italic.
593    /// [Docs](https://tailwindcss.com/docs/font-style#italicizing-text)
594    fn italic(mut self) -> Self {
595        self.text_style().font_style = Some(FontStyle::Italic);
596        self
597    }
598
599    /// Sets the font style of the element to normal (not italic).
600    /// [Docs](https://tailwindcss.com/docs/font-style#displaying-text-normally)
601    fn not_italic(mut self) -> Self {
602        self.text_style().font_style = Some(FontStyle::Normal);
603        self
604    }
605
606    /// Sets the text decoration to underline.
607    /// [Docs](https://tailwindcss.com/docs/text-decoration-line#underling-text)
608    fn underline(mut self) -> Self {
609        let style = self.text_style();
610        style.underline = Some(UnderlineStyle {
611            thickness: px(1.),
612            ..Default::default()
613        });
614        self
615    }
616
617    /// Sets the decoration of the text to have a line through it.
618    /// [Docs](https://tailwindcss.com/docs/text-decoration-line#adding-a-line-through-text)
619    fn line_through(mut self) -> Self {
620        let style = self.text_style();
621        style.strikethrough = Some(StrikethroughStyle {
622            thickness: px(1.),
623            ..Default::default()
624        });
625        self
626    }
627
628    /// Removes the text decoration on this element.
629    ///
630    /// This value cascades to its child elements.
631    fn text_decoration_none(mut self) -> Self {
632        self.text_style().underline = None;
633        self
634    }
635
636    /// Sets the color for the underline on this element
637    fn text_decoration_color(mut self, color: impl Into<Hsla>) -> Self {
638        let style = self.text_style();
639        let underline = style.underline.get_or_insert_with(Default::default);
640        underline.color = Some(color.into());
641        self
642    }
643
644    /// Sets the text decoration style to a solid line.
645    /// [Docs](https://tailwindcss.com/docs/text-decoration-style)
646    fn text_decoration_solid(mut self) -> Self {
647        let style = self.text_style();
648        let underline = style.underline.get_or_insert_with(Default::default);
649        underline.wavy = false;
650        self
651    }
652
653    /// Sets the text decoration style to a wavy line.
654    /// [Docs](https://tailwindcss.com/docs/text-decoration-style)
655    fn text_decoration_wavy(mut self) -> Self {
656        let style = self.text_style();
657        let underline = style.underline.get_or_insert_with(Default::default);
658        underline.wavy = true;
659        self
660    }
661
662    /// Sets the text decoration to be 0px thick.
663    /// [Docs](https://tailwindcss.com/docs/text-decoration-thickness)
664    fn text_decoration_0(mut self) -> Self {
665        let style = self.text_style();
666        let underline = style.underline.get_or_insert_with(Default::default);
667        underline.thickness = px(0.);
668        self
669    }
670
671    /// Sets the text decoration to be 1px thick.
672    /// [Docs](https://tailwindcss.com/docs/text-decoration-thickness)
673    fn text_decoration_1(mut self) -> Self {
674        let style = self.text_style();
675        let underline = style.underline.get_or_insert_with(Default::default);
676        underline.thickness = px(1.);
677        self
678    }
679
680    /// Sets the text decoration to be 2px thick.
681    /// [Docs](https://tailwindcss.com/docs/text-decoration-thickness)
682    fn text_decoration_2(mut self) -> Self {
683        let style = self.text_style();
684        let underline = style.underline.get_or_insert_with(Default::default);
685        underline.thickness = px(2.);
686        self
687    }
688
689    /// Sets the text decoration to be 4px thick.
690    /// [Docs](https://tailwindcss.com/docs/text-decoration-thickness)
691    fn text_decoration_4(mut self) -> Self {
692        let style = self.text_style();
693        let underline = style.underline.get_or_insert_with(Default::default);
694        underline.thickness = px(4.);
695        self
696    }
697
698    /// Sets the text decoration to be 8px thick.
699    /// [Docs](https://tailwindcss.com/docs/text-decoration-thickness)
700    fn text_decoration_8(mut self) -> Self {
701        let style = self.text_style();
702        let underline = style.underline.get_or_insert_with(Default::default);
703        underline.thickness = px(8.);
704        self
705    }
706
707    /// Sets the font family of this element and its children.
708    fn font_family(mut self, family_name: impl Into<SharedString>) -> Self {
709        self.text_style().font_family = Some(family_name.into());
710        self
711    }
712
713    /// Sets the font features of this element and its children.
714    fn font_features(mut self, features: FontFeatures) -> Self {
715        self.text_style().font_features = Some(features);
716        self
717    }
718
719    /// Sets the font of this element and its children.
720    fn font(mut self, font: Font) -> Self {
721        let Font {
722            family,
723            features,
724            fallbacks,
725            weight,
726            style,
727        } = font;
728
729        let text_style = self.text_style();
730        text_style.font_family = Some(family);
731        text_style.font_features = Some(features);
732        text_style.font_weight = Some(weight);
733        text_style.font_style = Some(style);
734        text_style.font_fallbacks = fallbacks;
735
736        self
737    }
738
739    /// Sets the line height of this element and its children.
740    fn line_height(mut self, line_height: impl Into<DefiniteLength>) -> Self {
741        self.text_style().line_height = Some(line_height.into());
742        self
743    }
744
745    /// Sets the opacity of this element and its children.
746    fn opacity(mut self, opacity: f32) -> Self {
747        self.style().opacity = Some(opacity);
748        self
749    }
750
751    /// Sets the grid columns of this element.
752    fn grid_cols(mut self, cols: u16) -> Self {
753        self.style().grid_cols = Some(GridTemplate {
754            repeat: cols,
755            min_size: TemplateColumnMinSize::Zero,
756        });
757        self
758    }
759
760    /// Sets the grid columns with min-content minimum sizing.
761    /// Unlike grid_cols, it won't shrink to width 0 in AvailableSpace::MinContent constraints.
762    fn grid_cols_min_content(mut self, cols: u16) -> Self {
763        self.style().grid_cols = Some(GridTemplate {
764            repeat: cols,
765            min_size: TemplateColumnMinSize::MinContent,
766        });
767        self
768    }
769
770    /// Sets the grid columns with max-content maximum sizing for content-based column widths.
771    fn grid_cols_max_content(mut self, cols: u16) -> Self {
772        self.style().grid_cols = Some(GridTemplate {
773            repeat: cols,
774            min_size: TemplateColumnMinSize::MaxContent,
775        });
776        self
777    }
778
779    /// Sets the grid rows of this element.
780    fn grid_rows(mut self, rows: u16) -> Self {
781        self.style().grid_rows = Some(GridTemplate {
782            repeat: rows,
783            min_size: TemplateColumnMinSize::Zero,
784        });
785        self
786    }
787
788    /// Sets the column start of this element.
789    fn col_start(mut self, start: i16) -> Self {
790        let grid_location = self.style().grid_location_mut();
791        grid_location.column.start = GridPlacement::Line(start);
792        self
793    }
794
795    /// Sets the column start of this element to auto.
796    fn col_start_auto(mut self) -> Self {
797        let grid_location = self.style().grid_location_mut();
798        grid_location.column.start = GridPlacement::Auto;
799        self
800    }
801
802    /// Sets the column end of this element.
803    fn col_end(mut self, end: i16) -> Self {
804        let grid_location = self.style().grid_location_mut();
805        grid_location.column.end = GridPlacement::Line(end);
806        self
807    }
808
809    /// Sets the column end of this element to auto.
810    fn col_end_auto(mut self) -> Self {
811        let grid_location = self.style().grid_location_mut();
812        grid_location.column.end = GridPlacement::Auto;
813        self
814    }
815
816    /// Sets the column span of this element.
817    fn col_span(mut self, span: u16) -> Self {
818        let grid_location = self.style().grid_location_mut();
819        grid_location.column = GridPlacement::Span(span)..GridPlacement::Span(span);
820        self
821    }
822
823    /// Sets the row span of this element.
824    fn col_span_full(mut self) -> Self {
825        let grid_location = self.style().grid_location_mut();
826        grid_location.column = GridPlacement::Line(1)..GridPlacement::Line(-1);
827        self
828    }
829
830    /// Sets the row start of this element.
831    fn row_start(mut self, start: i16) -> Self {
832        let grid_location = self.style().grid_location_mut();
833        grid_location.row.start = GridPlacement::Line(start);
834        self
835    }
836
837    /// Sets the row start of this element to "auto"
838    fn row_start_auto(mut self) -> Self {
839        let grid_location = self.style().grid_location_mut();
840        grid_location.row.start = GridPlacement::Auto;
841        self
842    }
843
844    /// Sets the row end of this element.
845    fn row_end(mut self, end: i16) -> Self {
846        let grid_location = self.style().grid_location_mut();
847        grid_location.row.end = GridPlacement::Line(end);
848        self
849    }
850
851    /// Sets the row end of this element to "auto"
852    fn row_end_auto(mut self) -> Self {
853        let grid_location = self.style().grid_location_mut();
854        grid_location.row.end = GridPlacement::Auto;
855        self
856    }
857
858    /// Sets the row span of this element.
859    fn row_span(mut self, span: u16) -> Self {
860        let grid_location = self.style().grid_location_mut();
861        grid_location.row = GridPlacement::Span(span)..GridPlacement::Span(span);
862        self
863    }
864
865    /// Sets the row span of this element.
866    fn row_span_full(mut self) -> Self {
867        let grid_location = self.style().grid_location_mut();
868        grid_location.row = GridPlacement::Line(1)..GridPlacement::Line(-1);
869        self
870    }
871
872    /// Draws a debug border around this element.
873    #[cfg(debug_assertions)]
874    fn debug(mut self) -> Self {
875        self.style().debug = Some(true);
876        self
877    }
878
879    /// Draws a debug border on all conforming elements below this element.
880    #[cfg(debug_assertions)]
881    fn debug_below(mut self) -> Self {
882        self.style().debug_below = Some(true);
883        self
884    }
885}
886
Served at tenant.openagents/omega Member data and write actions are omitted.