Skip to content

Commit

Permalink
Fixes #687 (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll authored Mar 8, 2019
1 parent 35cea2c commit 1f17fe3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/UniversalDashboard.Materialize/Scripts/layout.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ function New-UDLayout {
)

$Components = $Content.Invoke()
$columnSize = 12 / $Columns
$LargeColumnSize = 12 / $Columns
$MediumColumnSize = (12 / $Columns) * 2
$SmallColumnSize = 12
$Offset = 0
$ComponentCount = ($Components | Measure-Object).Count

while ($Offset -lt $ComponentCount) {
$ColumnObjects = $Components | Select-Object -Skip $Offset -First $Columns | ForEach-Object {
New-UDColumn -Size $ColumnSize -Content {
New-UDColumn -SmallSize $SmallColumnSize -MediumSize $MediumColumnSize -LargeSize $LargeColumnSize -Content {
$_
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/UniversalDashboard.Materialize/Tests/layout.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,17 @@ Describe "New-UDLayout" {
(Find-SeElement -ClassName 'col' -Driver $Driver).Count | Should be 4
}
}

Context "Should set mobile friendly column sizes" {
$Layout = New-UDLayout -Columns 3 -Content {
New-UDCard -Title "Test" -Content {}
New-UDCard -Title "Test" -Content {}
New-UDCard -Title "Test" -Content {}
New-UDCard -Title "Test" -Content {}
}

$Layout[0].Content[0].Attributes["className"].Contains("s12") | should be $true
$Layout[0].Content[0].Attributes["className"].Contains("m8") | should be $true
$Layout[0].Content[0].Attributes["className"].Contains("l4") | should be $true
}
}

0 comments on commit 1f17fe3

Please sign in to comment.