File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ <#
3+ . SYNOPSIS
4+ Includes a palette selector
5+ . DESCRIPTION
6+ Includes a palette selector in a page. This allows the page to use multiple color palettes.
7+ #>
8+ param (
9+ [uri ]
10+ $PaletteListSource = ' https://4bitcss.com/Palette-List.json' ,
11+
12+ # The Palette CDN. This is the root URL of all palettes.
13+ [uri ]
14+ $PaletteCDN = ' https://cdn.jsdelivr.net/gh/2bitdesigns/4bitcss@latest/css/' ,
15+
16+ # The identifier for the palette `<select>`.
17+ [string ]
18+ $SelectPaletteId = ' SelectPalette' ,
19+
20+ # The identifier for the stylesheet. By default, palette.
21+ [string ]
22+ $PaletteId = ' palette'
23+ )
24+
25+
26+ $JavaScript = @"
27+ function GetRandomPalette() {
28+ var SelectPalette = document.getElementById('$SelectPaletteId ')
29+ if (SelectPalette) {
30+ var randomNumber = Math.floor(Math.random() * SelectPalette.length);
31+ SelectPalette.selectedIndex = randomNumber
32+ SetPalette()
33+ }
34+ }
35+ "@
36+
37+ $HTML = @"
38+ <script>
39+ $JavaScript
40+ </script>
41+ <button onclick='GetRandomPalette()'>Random Palette</button>
42+ "@
43+
44+ $HTML
45+
You can’t perform that action at this time.
0 commit comments