Modules/UniversalDashboard.MaterialUI/Scripts/typography.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
function New-UDMuTypography {
    [CmdletBinding(DefaultParameterSetName = "text")]
    param(
        [Parameter()]
        [string]$Id = ([Guid]::NewGuid()).ToString(),

        [Parameter()]
        [ValidateSet ("h1", "h2", "h3", "h4", "h5", "h6", "subtitle1", "subtitle2", "body1", "body2", "caption", "button", "overline", "srOnly", "inherit", "display4", "display3", "display2", "display1", "headline", "title", "subheading")]
        [string]$Variant,

        [Parameter(ParameterSetName = "text")]
        [string]$Text,

        [Parameter(ParameterSetName = "endpoint")]
        [scriptblock]$Content,

        [Parameter()]
        [Hashtable]$Style,

        [Parameter()]
        [string]$ClassName,

        [Parameter()]
        [ValidateSet ("inherit", "left", "center", "right", "justify")]
        [string]$Align,

        [Parameter()]
        [switch]$IsEndPoint,

        [Parameter()]
        [Switch]$GutterBottom,

        [Parameter()]
        [Switch]$NoWrap,

        [Parameter()]
        [Switch]$IsParagraph,

        [Parameter(ParameterSetName = "endpoint")]
        [switch]$AutoRefresh,

        [Parameter(ParameterSetName = "endpoint")]
        [int]$RefreshInterval = 5

    )

    End {

        if($IsEndPoint){
            $TextEndpoint = New-UDEndpoint -Endpoint $Content -Id $id
            if($null -ne $Content){
                $TextContent = $Content.Invoke()
            }else{
                $TextContent = $null
            }
        }
        
        $MUTypography = @{
            #This needs to match what is in the register function call of chips.jsx
            type = "mu-typography"
            #Eventually everything will be a plugin so we wont need this.
            isPlugin = $true
            #This was set in the UniversalDashboard.MaterialUI.psm1 file
            assetId = $MUAssetId

            id = $Id
            className = $ClassName
            variant = $Variant
            noWrap = $NoWrap.IsPresent
            isParagraph = $IsParagraph.IsPresent
            text = $Text
            style = $Style
            align = $Align
            content = $TextContent 
            isEndpoint = $IsEndPoint.IsPresent
            gutterBottom = $GutterBottom.IsPresent
            refreshInterval = $RefreshInterval
            autoRefresh = $AutoRefresh.IsPresent
        }

        $MUTypography.PSTypeNames.Insert(0, 'UniversalDashboard.MaterialUI.Typography') | Out-Null

        $MUTypography
    }
}