API reference

API

Methods

  • Get CSS styles (with Models Builder)

    GetCssStyles(this JToken value, bool addStyleTag = true, bool includePseudoElements = false, bool includePseudoClasses = false) : IHtmlString

    This method will return a CSS stylesheet as an Html string and is used on Palette Picker properties of PublishedContentModel objects. It is an extension method for the JToken class, which is the actual type of Palette Picker property returned by Models Builder. It accepts several optional parameters.

    How to use

    @{ var styles = Model.PalettePickerProperty.GetCssStyles(); }
    @Html.Raw(styles)
    

    Parameters

    parameter type mandatory description
    value JToken mandatory The actual Palette Picker value.
    addStyleTag boolean optional (default = true) Whether to add the <style> tag to the returned Html string. If true, it will return the whole CSS stylesheet within the <style> tag. If false, it will return only the CSS rules.
    includePseudoClasses boolean optional (default = false) Whether to include CSS rules for pseudo elements, such as ::after, ::before, etc.
    includePseudoElements boolean optional (default = false) Whether to include CSS rules for pseudo classes, such as :focus, :hover, :last-child, etc.
  • Get CSS styles (without Models Builder)

    IHtmlString GetCssStyles(this IPublishedContent content, string propertyAlias, bool addStyleTag = true, bool includePseudoElements = false, bool includePseudoClasses = false) : IHtmlString

    This method will return a CSS stylesheet as an Html string and is used on IPublishedContent objects. It is an extension method for the IPublishedContent class. It accepts the same optional parameters as the previous method.

    How to use

    @{ var styles = Model.GetCssStyles("palettePickerPropertyAlias"); }
    @Html.Raw(styles)
    

    Parameters

    parameter type mandatory description
    content IPublishedContent mandatory The IPublishedContent from which we want to get the Palette Picker value.
    propertyAlias string mandatory The alias of the Palette Picker property.
    addStyleTag boolean optional (default = true) Wheter to add the <style> tag to the returned Html string. If true, it will return the whole CSS stylesheet within the <style> tag. If false, it will return only the CSS rules.
    includePseudoClasses boolean optional (default = false) Whether to include CSS rules for pseudo elements, such as ::after, ::before, etc.
    includePseudoElements boolean optional (default = false) Whether to include CSS rules for pseudo classes, such as :focus, :hover, :last-child, etc.
  • Get palette (with Models Builder)

    GetPalette(JToken value) : Palette

    This method will return all colours and colour sets information as a Palette object and is used on Palette Picker properties of PublishedContentModel objects. It is an extension method for the JToken class, which is the actual type of Palette Picker property returned by Models Builder.

    How to use

    @{ var palette = Model.PalettePickerProperty.GetPalette(); }
    

    Parameters

    parameter type mandatory description
    value JToken mandatory The actual Palette Picker value.
  • Get palette (without Models Builder)

    GetPalette(this IPublishedContent content, string propertyAlias) : Palette

    This method will return all colours and colour sets information as a Palette Picker object and is used on IPublishedContent objects. It is an extension method for the IPublishedContent class.

    How to use

    @{ var palette = Model.GetPalette("palettePickerPropertyAlias"); }
    

    Parameters

    parameter type mandatory description
    content IPublishedContent mandatory The IPublishedContent from which we want to get the Palette Picker value.
    propertyAlias string mandatory The alias of the Palette Picker property.

Models

  • Palette

    It defines the palette object, containing the list of colour sets (primary, secondary, complement).

    Properties

    • Url : string

      Optional URL indicating the source of the colour palette.

    • ColorSets : IEnumerable<PaletteColorSet>

      The list of colour sets included in the palette.

    Methods

    • ColorSet(string id) : PaletteColorSet

      Returns a colour set by id (i.e. “primary”, “secondary-1”, “secondary-2”, “complement”)

    • Color(string colorId) : PaletteColorSet

      Returns a colour from among all colour sets by colour id (i.e. “primary-0”, “secondary-1-0”, “secondary-2-0”, “complement-0”, etc)

    • Alpha(string colorId, decimal alphaValue) : string

      Returns an alpha colour from among all colour sets by colour id (i.e. “primary-0”, “secondary-1-0”, “secondary-2-0”, “complement-0”, etc) and an alpha value between 0 and 1, as an rgba value.

  • PaletteColorSet

    Individual set of colours (primary, secondary or complement) that compose a Palette object.

    Properties

    • Id : string

      The id of the colour set (primary, secondary-1, secondary-2, complement).

    • Title : string

      Optional title of the colour set.

    • Colors : IEnumerable<PaletteColor>

      The list of colours included in the colour set.

  • PaletteColor

    A single colour within a colour set.

    Properties

    • Id : string.

      The id of the colour (i.e. “primary-0”, “secondary-1-0”, “secondary-2-0”, “complement-0”, etc)

    • Hex : string

    The colour expressed as a hexadecimal value (i.e. AA3939).

    • Red : int

      The red component of the colour as an integer between 0 and 255.

    • Green : int

      The green component of the colour as an integer between 0 and 255.

    • Blue : int

      The blue component of the colour as an integer between 0 and 255.

    • HexColor : string

      The Hex Code (#RRGGBB) of the colour (i.e. #AA3939).

    • RgbColor : string

      The Decimal Code (R, G, B) of the colour (i.e. rgb(170,57,57)).

    Methods

    • Alpha(decimal alphaValue) : string

      Returns the colour with an alpha transparency between 0 and 1, in the form of rgba colour (i.e. rgb(170,57,57,0.5)).