| | | 1 | | namespace Allyaria.Theming.Helpers; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Applies outline-related styles for focusable or interactive components within the Allyaria theming system. |
| | | 5 | | /// </summary> |
| | | 6 | | /// <remarks> |
| | | 7 | | /// <para> |
| | | 8 | | /// The <see cref="ThemeOutlineApplier" /> constructs outline configurations — including color, style, width, and |
| | | 9 | | /// offset — based on brand-defined palettes and accessibility rules. |
| | | 10 | | /// </para> |
| | | 11 | | /// <para> |
| | | 12 | | /// It ensures that focus indicators meet accessibility contrast requirements and visual clarity standards, especial |
| | | 13 | | /// in high-contrast or system accessibility modes. |
| | | 14 | | /// </para> |
| | | 15 | | /// <para> |
| | | 16 | | /// Typically used within <see cref="ThemeBuilder" /> to define focus outlines for components like links, inputs, an |
| | | 17 | | /// interactive surfaces. |
| | | 18 | | /// </para> |
| | | 19 | | /// </remarks> |
| | | 20 | | internal sealed class ThemeOutlineApplier : ThemeApplierBase |
| | | 21 | | { |
| | | 22 | | /// <summary> |
| | | 23 | | /// Initializes a new instance of the <see cref="ThemeOutlineApplier" /> class, creating a focus outline with color |
| | | 24 | | /// style derived from the specified <see cref="PaletteType" />. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <param name="themeMapper">The <see cref="ThemeMapper" /> instance used to retrieve brand color mappings.</param> |
| | | 27 | | /// <param name="isHighContrast">Specifies whether this applier should operate in high-contrast mode.</param> |
| | | 28 | | /// <param name="componentType">The <see cref="ComponentType" /> representing the component being styled.</param> |
| | | 29 | | /// <param name="paletteType">The <see cref="PaletteType" /> defining which color group to use for outlines.</param> |
| | | 30 | | public ThemeOutlineApplier(ThemeMapper themeMapper, |
| | | 31 | | bool isHighContrast, |
| | | 32 | | ComponentType componentType, |
| | | 33 | | PaletteType paletteType) |
| | 19 | 34 | | : base(themeMapper: themeMapper, isHighContrast: isHighContrast, componentType: componentType) |
| | | 35 | | { |
| | | 36 | | // Apply outline color mapping based on palette and theme variant. |
| | 19 | 37 | | AddRange( |
| | 19 | 38 | | collection: new ThemeColorApplier( |
| | 19 | 39 | | themeMapper: themeMapper, |
| | 19 | 40 | | isHighContrast: isHighContrast, |
| | 19 | 41 | | componentType: componentType, |
| | 19 | 42 | | paletteType: paletteType, |
| | 19 | 43 | | isVariant: true, |
| | 19 | 44 | | hasBackground: false, |
| | 19 | 45 | | isOutline: true |
| | 19 | 46 | | ) |
| | 19 | 47 | | ); |
| | | 48 | | |
| | | 49 | | // Apply outline offset (distance between element and outline). |
| | 19 | 50 | | Add(item: CreateUpdater(styleType: StyleType.OutlineOffset, value: new StyleLength(value: Sizing.Size1))); |
| | | 51 | | |
| | | 52 | | // Apply outline style (e.g., solid). |
| | 19 | 53 | | Add( |
| | 19 | 54 | | item: CreateUpdater( |
| | 19 | 55 | | styleType: StyleType.OutlineStyle, |
| | 19 | 56 | | value: new StyleBorderOutlineStyle(kind: StyleBorderOutlineStyle.Kind.Solid) |
| | 19 | 57 | | ) |
| | 19 | 58 | | ); |
| | | 59 | | |
| | | 60 | | // Apply outline width (thickness of focus ring). |
| | 19 | 61 | | Add(item: CreateUpdater(styleType: StyleType.OutlineWidth, value: new StyleLength(value: Sizing.Thick))); |
| | 19 | 62 | | } |
| | | 63 | | } |