tailwind-rs-core 0.15.4

Core types and utilities for tailwind-rs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
//! Background utilities for tailwind-rs
//!
//! This module provides utilities for background colors, background images,
//! background gradients, background positioning, background sizing, and background repeat.

use crate::classes::ClassBuilder;
use serde::{Deserialize, Serialize};
use std::fmt;

/// Background attachment values
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BackgroundAttachment {
    /// Fixed attachment
    Fixed,
    /// Local attachment
    Local,
    /// Scroll attachment
    Scroll,
}

/// Background clip values
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BackgroundClip {
    /// Border clip
    Border,
    /// Padding clip
    Padding,
    /// Content clip
    Content,
    /// Text clip
    Text,
}

/// Background origin values
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BackgroundOrigin {
    /// Border origin
    Border,
    /// Padding origin
    Padding,
    /// Content origin
    Content,
}

/// Background position values
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BackgroundPosition {
    /// Bottom position
    Bottom,
    /// Center position
    Center,
    /// Left position
    Left,
    /// Left bottom position
    LeftBottom,
    /// Left top position
    LeftTop,
    /// Right position
    Right,
    /// Right bottom position
    RightBottom,
    /// Right top position
    RightTop,
    /// Top position
    Top,
}

/// Background repeat values
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BackgroundRepeat {
    /// No repeat
    NoRepeat,
    /// Repeat
    Repeat,
    /// Repeat X
    RepeatX,
    /// Repeat Y
    RepeatY,
    /// Round repeat
    Round,
    /// Space repeat
    Space,
}

/// Background size values
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BackgroundSize {
    /// Auto size
    Auto,
    /// Cover size
    Cover,
    /// Contain size
    Contain,
}

/// Background image values
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BackgroundImage {
    /// None image
    None,
    /// Linear gradient
    LinearGradient,
    /// Radial gradient
    RadialGradient,
    /// Conic gradient
    ConicGradient,
}

/// Gradient direction values
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum GradientDirection {
    /// To right
    ToRight,
    /// To left
    ToLeft,
    /// To top
    ToTop,
    /// To bottom
    ToBottom,
    /// To top right
    ToTopRight,
    /// To top left
    ToTopLeft,
    /// To bottom right
    ToBottomRight,
    /// To bottom left
    ToBottomLeft,
}

/// Gradient stop values
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum GradientStop {
    /// From stop
    From,
    /// Via stop
    Via,
    /// To stop
    To,
}

impl BackgroundAttachment {
    pub fn to_class_name(&self) -> String {
        match self {
            BackgroundAttachment::Fixed => "fixed".to_string(),
            BackgroundAttachment::Local => "local".to_string(),
            BackgroundAttachment::Scroll => "scroll".to_string(),
        }
    }

    pub fn to_css_value(&self) -> String {
        match self {
            BackgroundAttachment::Fixed => "fixed".to_string(),
            BackgroundAttachment::Local => "local".to_string(),
            BackgroundAttachment::Scroll => "scroll".to_string(),
        }
    }
}

impl BackgroundClip {
    pub fn to_class_name(&self) -> String {
        match self {
            BackgroundClip::Border => "border".to_string(),
            BackgroundClip::Padding => "padding".to_string(),
            BackgroundClip::Content => "content".to_string(),
            BackgroundClip::Text => "text".to_string(),
        }
    }

    pub fn to_css_value(&self) -> String {
        match self {
            BackgroundClip::Border => "border-box".to_string(),
            BackgroundClip::Padding => "padding-box".to_string(),
            BackgroundClip::Content => "content-box".to_string(),
            BackgroundClip::Text => "text".to_string(),
        }
    }
}

impl BackgroundOrigin {
    pub fn to_class_name(&self) -> String {
        match self {
            BackgroundOrigin::Border => "border".to_string(),
            BackgroundOrigin::Padding => "padding".to_string(),
            BackgroundOrigin::Content => "content".to_string(),
        }
    }

    pub fn to_css_value(&self) -> String {
        match self {
            BackgroundOrigin::Border => "border-box".to_string(),
            BackgroundOrigin::Padding => "padding-box".to_string(),
            BackgroundOrigin::Content => "content-box".to_string(),
        }
    }
}

impl BackgroundPosition {
    pub fn to_class_name(&self) -> String {
        match self {
            BackgroundPosition::Bottom => "bottom".to_string(),
            BackgroundPosition::Center => "center".to_string(),
            BackgroundPosition::Left => "left".to_string(),
            BackgroundPosition::LeftBottom => "left-bottom".to_string(),
            BackgroundPosition::LeftTop => "left-top".to_string(),
            BackgroundPosition::Right => "right".to_string(),
            BackgroundPosition::RightBottom => "right-bottom".to_string(),
            BackgroundPosition::RightTop => "right-top".to_string(),
            BackgroundPosition::Top => "top".to_string(),
        }
    }

    pub fn to_css_value(&self) -> String {
        match self {
            BackgroundPosition::Bottom => "bottom".to_string(),
            BackgroundPosition::Center => "center".to_string(),
            BackgroundPosition::Left => "left".to_string(),
            BackgroundPosition::LeftBottom => "left bottom".to_string(),
            BackgroundPosition::LeftTop => "left top".to_string(),
            BackgroundPosition::Right => "right".to_string(),
            BackgroundPosition::RightBottom => "right bottom".to_string(),
            BackgroundPosition::RightTop => "right top".to_string(),
            BackgroundPosition::Top => "top".to_string(),
        }
    }
}

impl BackgroundRepeat {
    pub fn to_class_name(&self) -> String {
        match self {
            BackgroundRepeat::NoRepeat => "no-repeat".to_string(),
            BackgroundRepeat::Repeat => "repeat".to_string(),
            BackgroundRepeat::RepeatX => "repeat-x".to_string(),
            BackgroundRepeat::RepeatY => "repeat-y".to_string(),
            BackgroundRepeat::Round => "round".to_string(),
            BackgroundRepeat::Space => "space".to_string(),
        }
    }

    pub fn to_css_value(&self) -> String {
        match self {
            BackgroundRepeat::NoRepeat => "no-repeat".to_string(),
            BackgroundRepeat::Repeat => "repeat".to_string(),
            BackgroundRepeat::RepeatX => "repeat-x".to_string(),
            BackgroundRepeat::RepeatY => "repeat-y".to_string(),
            BackgroundRepeat::Round => "round".to_string(),
            BackgroundRepeat::Space => "space".to_string(),
        }
    }
}

impl BackgroundSize {
    pub fn to_class_name(&self) -> String {
        match self {
            BackgroundSize::Auto => "auto".to_string(),
            BackgroundSize::Cover => "cover".to_string(),
            BackgroundSize::Contain => "contain".to_string(),
        }
    }

    pub fn to_css_value(&self) -> String {
        match self {
            BackgroundSize::Auto => "auto".to_string(),
            BackgroundSize::Cover => "cover".to_string(),
            BackgroundSize::Contain => "contain".to_string(),
        }
    }
}

impl BackgroundImage {
    pub fn to_class_name(&self) -> String {
        match self {
            BackgroundImage::None => "none".to_string(),
            BackgroundImage::LinearGradient => "gradient-to-r".to_string(),
            BackgroundImage::RadialGradient => "radial-gradient".to_string(),
            BackgroundImage::ConicGradient => "conic-gradient".to_string(),
        }
    }

    pub fn to_css_value(&self) -> String {
        match self {
            BackgroundImage::None => "none".to_string(),
            BackgroundImage::LinearGradient => {
                "linear-gradient(to right, var(--tw-gradient-stops))".to_string()
            }
            BackgroundImage::RadialGradient => {
                "radial-gradient(ellipse at center, var(--tw-gradient-stops))".to_string()
            }
            BackgroundImage::ConicGradient => {
                "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))".to_string()
            }
        }
    }
}

impl GradientDirection {
    pub fn to_class_name(&self) -> String {
        match self {
            GradientDirection::ToRight => "to-r".to_string(),
            GradientDirection::ToLeft => "to-l".to_string(),
            GradientDirection::ToTop => "to-t".to_string(),
            GradientDirection::ToBottom => "to-b".to_string(),
            GradientDirection::ToTopRight => "to-tr".to_string(),
            GradientDirection::ToTopLeft => "to-tl".to_string(),
            GradientDirection::ToBottomRight => "to-br".to_string(),
            GradientDirection::ToBottomLeft => "to-bl".to_string(),
        }
    }

    pub fn to_css_value(&self) -> String {
        match self {
            GradientDirection::ToRight => "to right".to_string(),
            GradientDirection::ToLeft => "to left".to_string(),
            GradientDirection::ToTop => "to top".to_string(),
            GradientDirection::ToBottom => "to bottom".to_string(),
            GradientDirection::ToTopRight => "to top right".to_string(),
            GradientDirection::ToTopLeft => "to top left".to_string(),
            GradientDirection::ToBottomRight => "to bottom right".to_string(),
            GradientDirection::ToBottomLeft => "to bottom left".to_string(),
        }
    }
}

impl GradientStop {
    pub fn to_class_name(&self) -> String {
        match self {
            GradientStop::From => "from".to_string(),
            GradientStop::Via => "via".to_string(),
            GradientStop::To => "to".to_string(),
        }
    }

    pub fn to_css_value(&self) -> String {
        match self {
            GradientStop::From => "from".to_string(),
            GradientStop::Via => "via".to_string(),
            GradientStop::To => "to".to_string(),
        }
    }
}

impl fmt::Display for BackgroundAttachment {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.to_class_name())
    }
}

impl fmt::Display for BackgroundClip {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.to_class_name())
    }
}

impl fmt::Display for BackgroundOrigin {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.to_class_name())
    }
}

impl fmt::Display for BackgroundPosition {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.to_class_name())
    }
}

impl fmt::Display for BackgroundRepeat {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.to_class_name())
    }
}

impl fmt::Display for BackgroundSize {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.to_class_name())
    }
}

impl fmt::Display for BackgroundImage {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.to_class_name())
    }
}

impl fmt::Display for GradientDirection {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.to_class_name())
    }
}

impl fmt::Display for GradientStop {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.to_class_name())
    }
}

/// Trait for adding background attachment utilities to a class builder
pub trait BackgroundAttachmentUtilities {
    fn background_attachment(self, attachment: BackgroundAttachment) -> Self;
}

impl BackgroundAttachmentUtilities for ClassBuilder {
    fn background_attachment(self, attachment: BackgroundAttachment) -> Self {
        self.class(format!("bg-{}", attachment.to_class_name()))
    }
}

/// Trait for adding background clip utilities to a class builder
pub trait BackgroundClipUtilities {
    fn background_clip(self, clip: BackgroundClip) -> Self;
}

impl BackgroundClipUtilities for ClassBuilder {
    fn background_clip(self, clip: BackgroundClip) -> Self {
        self.class(format!("bg-clip-{}", clip.to_class_name()))
    }
}

/// Trait for adding background origin utilities to a class builder
pub trait BackgroundOriginUtilities {
    fn background_origin(self, origin: BackgroundOrigin) -> Self;
}

impl BackgroundOriginUtilities for ClassBuilder {
    fn background_origin(self, origin: BackgroundOrigin) -> Self {
        self.class(format!("bg-origin-{}", origin.to_class_name()))
    }
}

/// Trait for adding background position utilities to a class builder
pub trait BackgroundPositionUtilities {
    fn background_position(self, position: BackgroundPosition) -> Self;
}

impl BackgroundPositionUtilities for ClassBuilder {
    fn background_position(self, position: BackgroundPosition) -> Self {
        self.class(format!("bg-{}", position.to_class_name()))
    }
}

/// Trait for adding background repeat utilities to a class builder
pub trait BackgroundRepeatUtilities {
    fn background_repeat(self, repeat: BackgroundRepeat) -> Self;
}

impl BackgroundRepeatUtilities for ClassBuilder {
    fn background_repeat(self, repeat: BackgroundRepeat) -> Self {
        self.class(format!("bg-{}", repeat.to_class_name()))
    }
}

/// Trait for adding background size utilities to a class builder
pub trait BackgroundSizeUtilities {
    fn background_size(self, size: BackgroundSize) -> Self;
}

impl BackgroundSizeUtilities for ClassBuilder {
    fn background_size(self, size: BackgroundSize) -> Self {
        self.class(format!("bg-{}", size.to_class_name()))
    }
}

/// Trait for adding background image utilities to a class builder
pub trait BackgroundImageUtilities {
    fn background_image(self, image: BackgroundImage) -> Self;
}

impl BackgroundImageUtilities for ClassBuilder {
    fn background_image(self, image: BackgroundImage) -> Self {
        self.class(format!("bg-{}", image.to_class_name()))
    }
}

/// Trait for adding gradient direction utilities to a class builder
pub trait GradientDirectionUtilities {
    fn gradient_direction(self, direction: GradientDirection) -> Self;
}

impl GradientDirectionUtilities for ClassBuilder {
    fn gradient_direction(self, direction: GradientDirection) -> Self {
        self.class(format!("bg-gradient-{}", direction.to_class_name()))
    }
}

/// Trait for adding gradient stop utilities to a class builder
pub trait GradientStopUtilities {
    fn gradient_from(self, color: crate::utilities::colors::Color) -> Self;
    fn gradient_via(self, color: crate::utilities::colors::Color) -> Self;
    fn gradient_to(self, color: crate::utilities::colors::Color) -> Self;
}

impl GradientStopUtilities for ClassBuilder {
    fn gradient_from(self, color: crate::utilities::colors::Color) -> Self {
        self.class(format!("from-{}", color.to_class_name()))
    }

    fn gradient_via(self, color: crate::utilities::colors::Color) -> Self {
        self.class(format!("via-{}", color.to_class_name()))
    }

    fn gradient_to(self, color: crate::utilities::colors::Color) -> Self {
        self.class(format!("to-{}", color.to_class_name()))
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::utilities::colors::{Color, ColorPalette, ColorShade};

    #[test]
    fn test_background_attachment_utilities() {
        let classes = ClassBuilder::new()
            .background_attachment(BackgroundAttachment::Fixed)
            .background_attachment(BackgroundAttachment::Local)
            .background_attachment(BackgroundAttachment::Scroll)
            .build();

        let css_classes = classes.to_css_classes();
        assert!(css_classes.contains("bg-fixed"));
        assert!(css_classes.contains("bg-local"));
        assert!(css_classes.contains("bg-scroll"));
    }

    #[test]
    fn test_background_clip_utilities() {
        let classes = ClassBuilder::new()
            .background_clip(BackgroundClip::Border)
            .background_clip(BackgroundClip::Padding)
            .background_clip(BackgroundClip::Content)
            .background_clip(BackgroundClip::Text)
            .build();

        let css_classes = classes.to_css_classes();
        assert!(css_classes.contains("bg-clip-border"));
        assert!(css_classes.contains("bg-clip-padding"));
        assert!(css_classes.contains("bg-clip-content"));
        assert!(css_classes.contains("bg-clip-text"));
    }

    #[test]
    fn test_background_origin_utilities() {
        let classes = ClassBuilder::new()
            .background_origin(BackgroundOrigin::Border)
            .background_origin(BackgroundOrigin::Padding)
            .background_origin(BackgroundOrigin::Content)
            .build();

        let css_classes = classes.to_css_classes();
        assert!(css_classes.contains("bg-origin-border"));
        assert!(css_classes.contains("bg-origin-padding"));
        assert!(css_classes.contains("bg-origin-content"));
    }

    #[test]
    fn test_background_position_utilities() {
        let classes = ClassBuilder::new()
            .background_position(BackgroundPosition::Bottom)
            .background_position(BackgroundPosition::Center)
            .background_position(BackgroundPosition::Left)
            .background_position(BackgroundPosition::Right)
            .background_position(BackgroundPosition::Top)
            .build();

        let css_classes = classes.to_css_classes();
        assert!(css_classes.contains("bg-bottom"));
        assert!(css_classes.contains("bg-center"));
        assert!(css_classes.contains("bg-left"));
        assert!(css_classes.contains("bg-right"));
        assert!(css_classes.contains("bg-top"));
    }

    #[test]
    fn test_background_repeat_utilities() {
        let classes = ClassBuilder::new()
            .background_repeat(BackgroundRepeat::NoRepeat)
            .background_repeat(BackgroundRepeat::Repeat)
            .background_repeat(BackgroundRepeat::RepeatX)
            .background_repeat(BackgroundRepeat::RepeatY)
            .background_repeat(BackgroundRepeat::Round)
            .background_repeat(BackgroundRepeat::Space)
            .build();

        let css_classes = classes.to_css_classes();
        assert!(css_classes.contains("bg-no-repeat"));
        assert!(css_classes.contains("bg-repeat"));
        assert!(css_classes.contains("bg-repeat-x"));
        assert!(css_classes.contains("bg-repeat-y"));
        assert!(css_classes.contains("bg-round"));
        assert!(css_classes.contains("bg-space"));
    }

    #[test]
    fn test_background_size_utilities() {
        let classes = ClassBuilder::new()
            .background_size(BackgroundSize::Auto)
            .background_size(BackgroundSize::Cover)
            .background_size(BackgroundSize::Contain)
            .build();

        let css_classes = classes.to_css_classes();
        assert!(css_classes.contains("bg-auto"));
        assert!(css_classes.contains("bg-cover"));
        assert!(css_classes.contains("bg-contain"));
    }

    #[test]
    fn test_background_image_utilities() {
        let classes = ClassBuilder::new()
            .background_image(BackgroundImage::None)
            .background_image(BackgroundImage::LinearGradient)
            .background_image(BackgroundImage::RadialGradient)
            .background_image(BackgroundImage::ConicGradient)
            .build();

        let css_classes = classes.to_css_classes();
        assert!(css_classes.contains("bg-none"));
        assert!(css_classes.contains("bg-gradient-to-r"));
        assert!(css_classes.contains("bg-radial-gradient"));
        assert!(css_classes.contains("bg-conic-gradient"));
    }

    #[test]
    fn test_gradient_direction_utilities() {
        let classes = ClassBuilder::new()
            .gradient_direction(GradientDirection::ToRight)
            .gradient_direction(GradientDirection::ToLeft)
            .gradient_direction(GradientDirection::ToTop)
            .gradient_direction(GradientDirection::ToBottom)
            .gradient_direction(GradientDirection::ToTopRight)
            .gradient_direction(GradientDirection::ToTopLeft)
            .gradient_direction(GradientDirection::ToBottomRight)
            .gradient_direction(GradientDirection::ToBottomLeft)
            .build();

        let css_classes = classes.to_css_classes();
        assert!(css_classes.contains("bg-gradient-to-r"));
        assert!(css_classes.contains("bg-gradient-to-l"));
        assert!(css_classes.contains("bg-gradient-to-t"));
        assert!(css_classes.contains("bg-gradient-to-b"));
        assert!(css_classes.contains("bg-gradient-to-tr"));
        assert!(css_classes.contains("bg-gradient-to-tl"));
        assert!(css_classes.contains("bg-gradient-to-br"));
        assert!(css_classes.contains("bg-gradient-to-bl"));
    }

    #[test]
    fn test_gradient_stop_utilities() {
        let classes = ClassBuilder::new()
            .gradient_from(Color::new(ColorPalette::Blue, ColorShade::Shade500))
            .gradient_via(Color::new(ColorPalette::Purple, ColorShade::Shade500))
            .gradient_to(Color::new(ColorPalette::Pink, ColorShade::Shade500))
            .build();

        let css_classes = classes.to_css_classes();
        assert!(css_classes.contains("from-blue-500"));
        assert!(css_classes.contains("via-purple-500"));
        assert!(css_classes.contains("to-pink-500"));
    }

    #[test]
    fn test_complex_background_combination() {
        let classes = ClassBuilder::new()
            .background_attachment(BackgroundAttachment::Fixed)
            .background_clip(BackgroundClip::Padding)
            .background_origin(BackgroundOrigin::Border)
            .background_position(BackgroundPosition::Center)
            .background_repeat(BackgroundRepeat::NoRepeat)
            .background_size(BackgroundSize::Cover)
            .background_image(BackgroundImage::LinearGradient)
            .gradient_direction(GradientDirection::ToRight)
            .gradient_from(Color::new(ColorPalette::Blue, ColorShade::Shade500))
            .gradient_to(Color::new(ColorPalette::Red, ColorShade::Shade500))
            .build();

        let css_classes = classes.to_css_classes();
        assert!(css_classes.contains("bg-fixed"));
        assert!(css_classes.contains("bg-clip-padding"));
        assert!(css_classes.contains("bg-origin-border"));
        assert!(css_classes.contains("bg-center"));
        assert!(css_classes.contains("bg-no-repeat"));
        assert!(css_classes.contains("bg-cover"));
        assert!(css_classes.contains("bg-gradient-to-r"));
        assert!(css_classes.contains("from-blue-500"));
        assert!(css_classes.contains("to-red-500"));
    }

    /// Test that all Week 8 background utilities are implemented
    #[test]
    fn test_week8_background_utilities() {
        // Test all Week 8 background utilities
        let classes = ClassBuilder::new()
            // Background Properties
            .background_attachment(BackgroundAttachment::Fixed)
            .background_attachment(BackgroundAttachment::Local)
            .background_attachment(BackgroundAttachment::Scroll)
            .background_clip(BackgroundClip::Border)
            .background_clip(BackgroundClip::Padding)
            .background_clip(BackgroundClip::Content)
            .background_clip(BackgroundClip::Text)
            .background_position(BackgroundPosition::Bottom)
            .background_position(BackgroundPosition::Center)
            .background_position(BackgroundPosition::Left)
            .background_position(BackgroundPosition::Right)
            .background_position(BackgroundPosition::Top)
            .background_repeat(BackgroundRepeat::Repeat)
            .background_repeat(BackgroundRepeat::NoRepeat)
            .background_repeat(BackgroundRepeat::RepeatX)
            .background_repeat(BackgroundRepeat::RepeatY)
            .background_repeat(BackgroundRepeat::Round)
            .background_repeat(BackgroundRepeat::Space)
            .background_size(BackgroundSize::Auto)
            .background_size(BackgroundSize::Cover)
            .background_size(BackgroundSize::Contain)
            .build();

        let css_classes = classes.to_css_classes();

        // Background Properties
        assert!(css_classes.contains("bg-fixed"));
        assert!(css_classes.contains("bg-local"));
        assert!(css_classes.contains("bg-scroll"));
        assert!(css_classes.contains("bg-clip-border"));
        assert!(css_classes.contains("bg-clip-padding"));
        assert!(css_classes.contains("bg-clip-content"));
        assert!(css_classes.contains("bg-clip-text"));
        assert!(css_classes.contains("bg-bottom"));
        assert!(css_classes.contains("bg-center"));
        assert!(css_classes.contains("bg-left"));
        assert!(css_classes.contains("bg-right"));
        assert!(css_classes.contains("bg-top"));
        assert!(css_classes.contains("bg-repeat"));
        assert!(css_classes.contains("bg-no-repeat"));
        assert!(css_classes.contains("bg-repeat-x"));
        assert!(css_classes.contains("bg-repeat-y"));
        assert!(css_classes.contains("bg-round"));
        assert!(css_classes.contains("bg-space"));
        assert!(css_classes.contains("bg-auto"));
        assert!(css_classes.contains("bg-cover"));
        assert!(css_classes.contains("bg-contain"));
    }
}