Skip to content

Commit 7bd49f9

Browse files
feat: Easier gradient stacking ( Fixes #21 )
1 parent 6577d1c commit 7bd49f9

1 file changed

Lines changed: 31 additions & 8 deletions

File tree

Types/Gradient/get_CSS.ps1

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,40 @@
1010
param()
1111
# Get our gradient type
1212
$gradientTypes = $this.GradientTypes
13+
14+
$gradientStack = @()
15+
1316
$gradientValues = @(foreach ($in in $this.input) {
17+
if ($in.pstypenames -eq 'gradient') {
18+
$gradientStack += $in
19+
continue
20+
}
1421
if ($in -notmatch $this.GradientTypePattern) {
1522
$in
1623
}
1724
})
1825

19-
if (-not $gradientTypes) { $gradientTypes = 'radial-gradient'}
20-
@(foreach ($gradientType in $gradientTypes) {
21-
"$gradientType($(
22-
@(
23-
$gradientValues
24-
) -join (', ' + [Environment]::NewLine + (' ' * 2))
25-
))"
26-
}) -join ', '
26+
if ($gradientValues) {
27+
if (-not $gradientTypes) { $gradientTypes = 'radial-gradient'}
28+
$gradientCss = @(foreach ($gradientType in $gradientTypes) {
29+
"$gradientType($(
30+
[Environment]::NewLine + (' ' * 2) +
31+
$(
32+
@(
33+
$gradientValues
34+
) -join (', ' + [Environment]::NewLine + (' ' * 2))
35+
)
36+
))"
37+
}) -join ', '
38+
}
39+
if ($gradientStack) {
40+
$deepJoiner = (', ' + [Environment]::NewLine)
41+
if (-not $gradientValues) {
42+
$gradientStack -join $deepJoiner
43+
} else {
44+
@($gradientStack;$gradientCss) -join $deepJoiner
45+
}
46+
} elseif ($gradientValues) {
47+
$gradientCss
48+
}
49+

0 commit comments

Comments
 (0)