# Create gradient stop factories with semantic color supportfrom_dui = GradientStopFactoryDaisyUI("from", "Gradient from color utilities for defining the starting color of a gradient with semantic colors") # Semantic gradient from color factoryvia_dui = GradientStopFactoryDaisyUI("via", "Gradient via color utilities for defining the middle color of a gradient with semantic colors") # Semantic gradient via color factoryto_dui = GradientStopFactoryDaisyUI("to", "Gradient to color utilities for defining the ending color of a gradient with semantic colors") # Semantic gradient to color factory
Exported source
def test_semantic_gradients_basic_examples():"""Test gradient utilities with semantic colors."""# Test gradient from colorsassertstr(from_dui.primary) =="from-primary"assertstr(from_dui.secondary) =="from-secondary"assertstr(from_dui.base_100) =="from-base-100"assertstr(from_dui.error) =="from-error"# Test gradient via colorsassertstr(via_dui.accent) =="via-accent"assertstr(via_dui.neutral) =="via-neutral"assertstr(via_dui.info) =="via-info"# Test gradient to colorsassertstr(to_dui.success) =="to-success"assertstr(to_dui.warning) =="to-warning"assertstr(to_dui.base_content) =="to-base-content"# Test with opacityassertstr(from_dui.primary.opacity(50)) =="from-primary/50"assertstr(via_dui.secondary.opacity(75)) =="via-secondary/75"assertstr(to_dui.base_content.opacity(30)) =="to-base-content/30"# Test with percentagesassertstr(from_dui._0) =="from-0%"assertstr(from_dui._50) =="from-50%"assertstr(from_dui._100) =="from-100%"assertstr(from_dui(25)) =="from-25%"assertstr(from_dui("33%")) =="from-33%"assertstr(via_dui._50) =="via-50%"assertstr(via_dui(75)) =="via-75%"assertstr(to_dui._100) =="to-100%"assertstr(to_dui(90)) =="to-90%"# Test with modifiersassertstr(from_dui.primary.hover) =="hover:from-primary"assertstr(to_dui.error.dark) =="dark:to-error"# Run the testtest_semantic_gradients_basic_examples()
Practical Examples
Test with FastHTML components to show practical usage: