-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
170 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from "react"; | ||
import { Avatar } from "antd"; | ||
import useDashboardEvent from "../Hooks/useDashboardEvent.jsx"; | ||
|
||
|
||
const AntdAvatar = props => { | ||
const [state, reload] = useDashboardEvent(props.id, props); | ||
const { content, attributes } = state; | ||
|
||
const contentProps = { | ||
children: content | ||
} | ||
|
||
const imageProps = { | ||
src: attributes.src, | ||
srcSet: attributes.srcSet, | ||
alt: attributes.alt | ||
} | ||
|
||
const iconProps = { | ||
children: UniversalDashboard.renderComponent(content) | ||
} | ||
|
||
let propsToUse | ||
switch(attributes.parameterSet){ | ||
case 'Icon': | ||
propsToUse = {...iconProps} | ||
break | ||
case 'Image': | ||
propsToUse = {...imageProps} | ||
break | ||
case 'Content': | ||
propsToUse = {...contentProps} | ||
break | ||
default: | ||
console.log('No ParameterSet Was Selected!, Please Select One Of The Following: Content,Image,Icon') | ||
break | ||
} | ||
|
||
return ( | ||
<Avatar {...attributes} {...propsToUse} /> | ||
); | ||
}; | ||
|
||
export default AntdAvatar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
function New-UDAntdAvatar { | ||
[CmdletBinding(DefaultParameterSetName = 'Icon')] | ||
[OutputType('UDAntd.Avatar')] | ||
Param( | ||
[Parameter()] | ||
[string]$Id = (New-Guid).ToString(), | ||
[Parameter()] | ||
[string]$ClassName, | ||
[Parameter()] | ||
[ValidateSet('circle', 'square')] | ||
[string]$Shape, | ||
[Parameter()] | ||
[ValidateSet('small', 'default', 'large')] | ||
[string]$Size, | ||
[Parameter()] | ||
[hashtable]$Style, | ||
[Parameter()] | ||
[scriptblock]$OnError, | ||
[Parameter(ParameterSetName = 'Icon')] | ||
[object]$Icon, | ||
[Parameter(ParameterSetName = 'Image')] | ||
[string]$Alt, | ||
[Parameter(ParameterSetName = 'Image')] | ||
[string]$Src, | ||
[Parameter(ParameterSetName = 'Image')] | ||
[string[]]$SrcSet, | ||
[Parameter(ParameterSetName = 'Content')] | ||
[object]$Content | ||
) | ||
End { | ||
if ($null -ne $OnError) { | ||
if ($OnError -is [scriptblock] -or $OnError -is [UniversalDashboard.Models.Endpoint]) { | ||
$OnError = New-UDEndpoint -Endpoint $OnError -Id ($Id + "OnError") | ||
} | ||
} | ||
|
||
if($PSCmdlet.ParameterSetName.Contains('Icon')){ | ||
$Content = $Icon | ||
} | ||
|
||
$UDAntdAvatar = @{ | ||
assetId = $AssetId | ||
isPlugin = $true | ||
type = "ud-antd-avatar" | ||
id = $Id | ||
className = $ClassName | ||
style = $Style | ||
size = $Size | ||
src = $Src | ||
srcSet = $SrcSet | ||
shape = $Shape | ||
alt = $Alt | ||
content = $Content | ||
parameterSet = $PSCmdlet.ParameterSetName | ||
hasCallBack = $null -ne $OnError | ||
} | ||
$UDAntdAvatar.PSTypeNames.Insert(0, 'UDAntd.Avatar') | ||
$UDAntdAvatar | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters