/// <summary> /// Creates a custom theme definition which can be used with the Customizer. /// </summary> /// <param name="theme">Partial theme object.</param> /// <param name="depComments">Whether to include deprecated tags as comments for deprecated slots.</param> /// <returns></returns> public Theme CreateTheme(Theme theme, bool depComments = false) { var newPalette = new Palette(); newPalette = newPalette.MergeValues(Palette.DefaultPalette, theme.Palette); if (theme.Palette == null || theme.Palette.Accent == null) { newPalette.Accent = newPalette.ThemePrimary; } var newSemacticColors = new SemanticColors().MergeValues(newPalette.MakeSemanticColors(theme?.IsInverted == true, depComments), theme.SemanticColors); var typography = new Typography().MergeValues(Typography.DefaultTypography, theme.Typography); var types = typography.Types; foreach (var typeName in types) { var type = typeName.Value; string fontFamily; if (!string.IsNullOrWhiteSpace(type.FontFamily) && typography.Families.TryGetValue(type.FontFamily, out fontFamily)) { type.FontFamily = fontFamily; } string fontSize; if (type.FontSize != null && typography.Sizes.TryGetValue((string)type.FontSize, out fontSize)) { type.FontSize = typography.Sizes[fontSize]; } string fontWeight; if (type.FontWeight != null && typography.Families.TryGetValue((string)type.FontWeight, out fontWeight)) { type.FontWeight = fontWeight; } } return(new Theme() { Palette = newPalette, Fonts = new FontStyles().MergeValues(FontStyles.DefaultFontStyle, theme.Fonts), SemanticColors = newSemacticColors, IsInverted = theme?.IsInverted == true, DisableGlobalCalssNames = theme?.DisableGlobalCalssNames == true, Typography = typography }); }
private SemanticColors fixSlots(SemanticColors s, bool depComments) { var dep = ""; if (depComments) { dep = "/* @deprecated */"; } #pragma warning disable CS0618 // Type or member is obsolete s.ListTextColor = s.ListText + dep; #pragma warning restore CS0618 // Type or member is obsolete #pragma warning disable CS0618 // Type or member is obsolete s.MenuItemBackgroundChecked += dep; #pragma warning restore CS0618 // Type or member is obsolete return(s); }