Skip to content

Commit 991bf9c

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Easier gradient stacking ( Fixes #21 )
1 parent 7bd49f9 commit 991bf9c

1 file changed

Lines changed: 32 additions & 8 deletions

File tree

Gradient.types.ps1xml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,44 @@ return "$($this.CSS)"
4646
param()
4747
# Get our gradient type
4848
$gradientTypes = $this.GradientTypes
49+
50+
$gradientStack = @()
51+
4952
$gradientValues = @(foreach ($in in $this.input) {
53+
if ($in.pstypenames -eq 'gradient') {
54+
$gradientStack += $in
55+
continue
56+
}
5057
if ($in -notmatch $this.GradientTypePattern) {
5158
$in
5259
}
5360
})
5461

55-
if (-not $gradientTypes) { $gradientTypes = 'radial-gradient'}
56-
@(foreach ($gradientType in $gradientTypes) {
57-
"$gradientType($(
58-
@(
59-
$gradientValues
60-
) -join (', ' + [Environment]::NewLine + (' ' * 2))
61-
))"
62-
}) -join ', '
62+
if ($gradientValues) {
63+
if (-not $gradientTypes) { $gradientTypes = 'radial-gradient'}
64+
$gradientCss = @(foreach ($gradientType in $gradientTypes) {
65+
"$gradientType($(
66+
[Environment]::NewLine + (' ' * 2) +
67+
$(
68+
@(
69+
$gradientValues
70+
) -join (', ' + [Environment]::NewLine + (' ' * 2))
71+
)
72+
))"
73+
}) -join ', '
74+
}
75+
if ($gradientStack) {
76+
$deepJoiner = (', ' + [Environment]::NewLine)
77+
if (-not $gradientValues) {
78+
$gradientStack -join $deepJoiner
79+
} else {
80+
@($gradientStack;$gradientCss) -join $deepJoiner
81+
}
82+
} elseif ($gradientValues) {
83+
$gradientCss
84+
}
85+
86+
6387
</GetScriptBlock>
6488
</ScriptProperty>
6589
<ScriptProperty>

0 commit comments

Comments
 (0)