Skip to content
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

Dynamic Loading #675

Merged
merged 2 commits into from
Mar 3, 2019
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
13 changes: 6 additions & 7 deletions src/UniversalDashboard.MaterialUI/Components/icon.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import React from 'react'
import Icon from '@material-ui/core/Icon'
import { icon,findIconDefinition } from '@fortawesome/fontawesome-svg-core/index.es'
import { icon } from '@fortawesome/fontawesome-svg-core/index.es'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome/index.es'
import findSolidIcon from './faSolid'

import * as fas from '@fortawesome/free-solid-svg-icons';
import * as fab from '@fortawesome/free-brands-svg-icons';

export default class UdMuIcon extends React.Component {

state = {
Expand All @@ -28,21 +25,23 @@ export default class UdMuIcon extends React.Component {
setFontAwesomeIcon = (faIcon) => {
var i = null
const name = `fa${faIcon}`
if (findSolidIcon(name) === true) {
findSolidIcon(name) === true ?
import(`@fortawesome/free-solid-svg-icons/index.es.js`).then(({fas}) => {
let fai = icon(fas[name])
i = fai
this.setState({
icon: i,
...this.state
})
} else {
}) : import(`@fortawesome/free-brands-svg-icons/index.es.js`).then(({fab}) => {
let fai = icon(fab[name])
i = fai
this.setState({
icon: i,
...this.state
})
}

})
}

componentWillMount(){
Expand Down
2 changes: 1 addition & 1 deletion src/UniversalDashboard.MaterialUI/Components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import Paper from "./paper";

UniversalDashboard.register("mu-chip", Chip);
UniversalDashboard.register("mu-icon", Icon);
UniversalDashboard.register("mu-paper", Paper);
UniversalDashboard.register("mu-paper", Paper);
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@

$JsFile = Get-ChildItem "$PSScriptRoot\index.*.bundle.js"
$JsFiles = Get-ChildItem "$PSScriptRoot\*.bundle.js"
$Maps = Get-ChildItem "$PSScriptRoot\*.bundle.map"
$CSSFile = Get-ChildItem "$PSScriptRoot\*.css"

# Register our style sheet with UD
[UniversalDashboard.Services.AssetService]::Instance.RegisterStyleSheet($CSSFile.FullName)

$JsFiles | ForEach-Object {
[UniversalDashboard.Services.AssetService]::Instance.RegisterScript($_.FullName)
}

$Maps | ForEach-Object {
[UniversalDashboard.Services.AssetService]::Instance.RegisterScript($_.FullName) | Out-Null
}

$MUAssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterScript($JSFile.FullName)

# Load out controls
Get-ChildItem (Join-Path $PSScriptRoot "Scripts") -File -Filter "*.ps1" | ForEach-Object {
. $_.FullName
}

}
1 change: 1 addition & 0 deletions src/UniversalDashboard.MaterialUI/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ npm install
npm run build

Copy-Item $BuildFolder\public\*.bundle.js $OutputPath
Copy-Item $BuildFolder\public\*.bundle.map $OutputPath
Copy-Item $BuildFolder\UniversalDashboard.MaterialUI.psm1 $OutputPath
Copy-Item $BuildFolder\Scripts $OutputPath\Scripts -Recurse -Force

Expand Down
Loading