Scripts/New-UDScrollSpy.ps1

<#
.SYNOPSIS
    Sample control for UniversalDashboard.
.DESCRIPTION
    Sample control function for UniversalDashboard. This function must have an ID and return a hash table.
.PARAMETER Id
    An id for the component default value will be generated by new-guid.
.EXAMPLE
    PS C:\> <example usage>
    Explanation of what the example does
.INPUTS
    Inputs (if any)
.OUTPUTS
    Output (if any)
.NOTES
    General notes
#>

function New-UDScrollSpy {
    param(
        [Parameter()]
        [string]$Id = (New-Guid).ToString(),
        [Parameter()]
        [string]$BackgroundColor = "#3f51b5", #Backgroundcolour for the scrollspy navbar
        [Parameter()]
        [string]$FontColor = "#ffffff", #Font colour to be displayed on the scrollspy navbar
        [Parameter()]
        [int]$MarginTop = -50, #How far down the page you want the navbar to be visible
        [Parameter()]
        [int]$MarginLeft = -50, #How far to pull the navbar over to the left
        [Parameter()]
        [int]$Offset = 50, #When scrolling to element on the page this is the offset
        [Parameter()]
        [int]$ScollDuration = 800, #How slow or fast to make the scroll animation
        [Parameter()]
        [array]$ScrollTargetIds, #You need to give the components IDs then specify an array of IDs
        [Parameter()]
        [scriptblock]$Links, #See the demo on how to specify the links to be shown in navbar
        [Parameter()]
        [int]$Height = 30, #Height of the navbar
        [Parameter()]
        [int]$Top = 60, #How far down the scroll navbar appears
        [Parameter()]
        [int]$zIndex = 20, #Position behind UDnavbar
        [Parameter()]
        [string]$Width = "100%" #Width of the scollspy navbar
    )

    End {

        @{
            # The AssetID of the main JS File
            assetId         = $AssetId
            # Tell UD this is a plugin
            isPlugin        = $true
            # This ID must be the same as the one used in the JavaScript to register the control with UD
            type            = "UD-ScrollSpy"
            # An ID is mandatory
            id              = $Id

            # This is where you can put any other properties. They are passed to the React control's props
            # The keys are case-sensitive in JS.
            backgroundColor = $BackgroundColor
            color           = $FontColor
            offset          = $Offset
            marginTop       = $MarginTop
            marginLeft      = $MarginLeft
            scrollDuration  = $ScollDuration
            scrollTargetIds = $ScrollTargetIds
            links           = $Links.Invoke()
            height          = $Height
            width           = $Width
            top             = $Top
            zIndex          = $zIndex
        }

    }
}