Skip to content

Implementation of new module to manage styles #5884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 77 additions & 40 deletions DNN Platform/DotNetNuke.Abstractions/Portals/IPortalStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,205 +9,231 @@ namespace DotNetNuke.Abstractions.Portals
/// </summary>
public interface IPortalStyles
{
/// <summary>
/// Gets or sets a value indicating whether the site admins can edit the styles.
/// </summary>
bool AllowAdminEdits { get; set; }

/// <summary>
/// Gets or sets the main shade of the primary color.
/// </summary>
StyleColor ColorPrimary { get; set; }
string ColorPrimary { get; set; }

/// <summary>
/// Gets or sets the light shade of the primary color.
/// </summary>
StyleColor ColorPrimaryLight { get; set; }
string ColorPrimaryLight { get; set; }

/// <summary>
/// Gets or sets the dark shade of the primary color.
/// </summary>
StyleColor ColorPrimaryDark { get; set; }
string ColorPrimaryDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the primary color shades.
/// </summary>
StyleColor ColorPrimaryContrast { get; set; }
string ColorPrimaryContrast { get; set; }

/// <summary>
/// Gets or sets the main shade of the secondary color.
/// </summary>
StyleColor ColorSecondary { get; set; }
string ColorSecondary { get; set; }

/// <summary>
/// Gets or sets the light shade of the secondary color.
/// </summary>
StyleColor ColorSecondaryLight { get; set; }
string ColorSecondaryLight { get; set; }

/// <summary>
/// Gets or sets the dark shade of the secondary color.
/// </summary>
StyleColor ColorSecondaryDark { get; set; }
string ColorSecondaryDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the secondary color shades.
/// </summary>
StyleColor ColorSecondaryContrast { get; set; }
string ColorSecondaryContrast { get; set; }

/// <summary>
/// Gets or sets the main shade of the Tertiary color.
/// </summary>
StyleColor ColorTertiary { get; set; }
string ColorTertiary { get; set; }

/// <summary>
/// Gets or sets the light shade of the Tertiary color.
/// </summary>
StyleColor ColorTertiaryLight { get; set; }
string ColorTertiaryLight { get; set; }

/// <summary>
/// Gets or sets the dark shade of the Tertiary color.
/// </summary>
StyleColor ColorTertiaryDark { get; set; }
string ColorTertiaryDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the Tertiary color shades.
/// </summary>
StyleColor ColorTertiaryContrast { get; set; }
string ColorTertiaryContrast { get; set; }

/// <summary>
/// Gets or sets the main shade of the Neutral color.
/// </summary>
StyleColor ColorNeutral { get; set; }
string ColorNeutral { get; set; }

/// <summary>
/// Gets or sets the light shade of the Neutral color.
/// </summary>
StyleColor ColorNeutralLight { get; set; }
string ColorNeutralLight { get; set; }

/// <summary>
/// Gets or sets the dark shade of the Neutral color.
/// </summary>
StyleColor ColorNeutralDark { get; set; }
string ColorNeutralDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the Neutral color shades.
/// </summary>
StyleColor ColorNeutralContrast { get; set; }
string ColorNeutralContrast { get; set; }

/// <summary>
/// Gets or sets the main shade of the Background color.
/// </summary>
StyleColor ColorBackground { get; set; }
string ColorBackground { get; set; }

/// <summary>
/// Gets or sets the light shade of the Background color.
/// </summary>
StyleColor ColorBackgroundLight { get; set; }
string ColorBackgroundLight { get; set; }

/// <summary>
/// Gets or sets the dark shade of the Background color.
/// </summary>
StyleColor ColorBackgroundDark { get; set; }
string ColorBackgroundDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the Background color shades.
/// </summary>
StyleColor ColorBackgroundContrast { get; set; }
string ColorBackgroundContrast { get; set; }

/// <summary>
/// Gets or sets the main shade of the Foreground color.
/// </summary>
StyleColor ColorForeground { get; set; }
string ColorForeground { get; set; }

/// <summary>
/// Gets or sets the light shade of the Foreground color.
/// </summary>
StyleColor ColorForegroundLight { get; set; }
string ColorForegroundLight { get; set; }

/// <summary>
/// Gets or sets the dark shade of the Foreground color.
/// </summary>
StyleColor ColorForegroundDark { get; set; }
string ColorForegroundDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the Foreground color shades.
/// </summary>
StyleColor ColorForegroundContrast { get; set; }
string ColorForegroundContrast { get; set; }

/// <summary>
/// Gets or sets the main shade of the Info color.
/// </summary>
StyleColor ColorInfo { get; set; }
string ColorInfo { get; set; }

/// <summary>
/// Gets or sets the light shade of the Info color.
/// </summary>
StyleColor ColorInfoLight { get; set; }
string ColorInfoLight { get; set; }

/// <summary>
/// Gets or sets the dark shade of the Info color.
/// </summary>
StyleColor ColorInfoDark { get; set; }
string ColorInfoDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the Info color shades.
/// </summary>
StyleColor ColorInfoContrast { get; set; }
string ColorInfoContrast { get; set; }

/// <summary>
/// Gets or sets the main shade of the Success color.
/// </summary>
StyleColor ColorSuccess { get; set; }
string ColorSuccess { get; set; }

/// <summary>
/// Gets or sets the light shade of the Success color.
/// </summary>
StyleColor ColorSuccessLight { get; set; }
string ColorSuccessLight { get; set; }

/// <summary>
/// Gets or sets the dark shade of the Success color.
/// </summary>
StyleColor ColorSuccessDark { get; set; }
string ColorSuccessDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the Success color shades.
/// </summary>
StyleColor ColorSuccessContrast { get; set; }
string ColorSuccessContrast { get; set; }

/// <summary>
/// Gets or sets the main shade of the Warning color.
/// </summary>
StyleColor ColorWarning { get; set; }
string ColorWarning { get; set; }

/// <summary>
/// Gets or sets the light shade of the Warning color.
/// </summary>
StyleColor ColorWarningLight { get; set; }
string ColorWarningLight { get; set; }

/// <summary>
/// Gets or sets the dark shade of the Warning color.
/// </summary>
StyleColor ColorWarningDark { get; set; }
string ColorWarningDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the Warning color shades.
/// </summary>
StyleColor ColorWarningContrast { get; set; }
string ColorWarningContrast { get; set; }

/// <summary>
/// Gets or sets the main shade of the Danger color.
/// </summary>
StyleColor ColorDanger { get; set; }
string ColorDanger { get; set; }

/// <summary>
/// Gets or sets the light shade of the Danger color.
/// </summary>
StyleColor ColorDangerLight { get; set; }
string ColorDangerLight { get; set; }

/// <summary>
/// Gets or sets the dark shade of the Danger color.
/// </summary>
StyleColor ColorDangerDark { get; set; }
string ColorDangerDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the Danger color shades.
/// </summary>
StyleColor ColorDangerContrast { get; set; }
string ColorDangerContrast { get; set; }

/// <summary>
/// Gets or sets the color of the surface.
/// A surface is an area that is overlaid over the main background (menus, popovers, etc).
/// </summary>
string ColorSurface { get; set; }

/// <summary>
/// Gets or sets the light variation of surface color.
/// </summary>
string ColorSurfaceLight { get; set; }

/// <summary>
/// Gets or sets the dark variation of surface color.
/// </summary>
string ColorSurfaceDark { get; set; }

/// <summary>
/// Gets or sets a color that contrasts well over the surface color.
/// </summary>
string ColorSurfaceContrast { get; set; }

/// <summary>
/// Gets or sets the controls border radius in pixels.
Expand All @@ -223,5 +249,16 @@ public interface IPortalStyles
/// Gets or sets the base font size in pixels.
/// </summary>
double BaseFontSize { get; set; }

/// <summary>
/// Gets or sets the color variation opacity.
/// This can be used to define how opaque a contrasting color should look over another.
/// </summary>
double VariationOpacity { get; set; }

/// <summary>
/// Gets the name of the css file.
/// </summary>
string FileName { get; }
}
}
39 changes: 2 additions & 37 deletions DNN Platform/DotNetNuke.Abstractions/Portals/StyleColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public StyleColor(string hexValue)
{
AssertIsValidCssColor(hexValue);

this.HexValue = ExpandColor(hexValue);
this.HexValue = hexValue;
this.red = byte.Parse(this.HexValue.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
this.green = byte.Parse(this.HexValue.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
this.blue = byte.Parse(this.HexValue.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
Expand Down Expand Up @@ -88,45 +88,10 @@ public string HexValue
set
{
AssertIsValidCssColor(value);
this.hex = ExpandColor(value);
this.hex = value;
}
}

/// <summary>
/// Gets a minified hexadecimal value for the color.
/// </summary>
/// <example>If the color is 0088FF, it should return 08F.</example>
public string MinifiedHex
{
get
{
if (
this.hex[0] == this.hex[1] &&
this.hex[2] == this.hex[3] &&
this.hex[4] == this.hex[5])
{
return $"{this.hex[0]}{this.hex[2]}{this.hex[4]}";
}

return this.hex;
}
}

private static string ExpandColor(string hexValue)
{
if (hexValue.Length == 6)
{
return hexValue.ToUpperInvariant();
}

string value;
var r = hexValue[0];
var g = hexValue[1];
var b = hexValue[2];
value = string.Concat(r, r, g, g, b, b);
return value.ToUpperInvariant();
}

private static void AssertIsValidCssColor(string hexValue)
{
if (string.IsNullOrWhiteSpace(hexValue))
Expand Down
6 changes: 0 additions & 6 deletions DNN Platform/Library/Common/Utilities/DataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ public class DataCache
/// <summary> The portal styles cache key.</summary>
public const string PortalStylesCacheKey = "Dnn_Css_Custom_Properties_{0}";

/// <summary> The portal styles cache priority.</summary>
public const CacheItemPriority PortalStylesCachePriority = CacheItemPriority.High;

/// <summary>The portal styles cache time out.</summary>
public const int PortalStylesCacheTimeOut = 20;

// Tab cache keys
public const string TabCacheKey = "Tab_Tabs{0}";
public const string TabSettingsCacheKey = "TabSettings{0}";
Expand Down
Loading