Skip to content

Commit efd309c

Browse files
Merge pull request #112 from 2bitdesigns/4bitcss-docker
4bitcss 0.1.5
2 parents 87e85b9 + 015ae0e commit efd309c

File tree

1,782 files changed

+30434
-3155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,782 files changed

+30434
-3155
lines changed

.github/workflows/Build4bitcss.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
Install-Module -Name Pester -Repository PSGallery -Force -Scope CurrentUser -MaximumVersion $PesterMaxVersion -SkipPublisherCheck -AllowClobber
3636
Import-Module Pester -Force -PassThru -MaximumVersion $PesterMaxVersion} @Parameters
3737
- name: Check out repository
38-
uses: actions/checkout@v2
38+
uses: actions/checkout@v4
3939
- name: RunPester
4040
id: RunPester
4141
shell: pwsh
@@ -92,9 +92,6 @@ jobs:
9292
$result =
9393
Invoke-Pester -PassThru -Verbose -OutputFile ".\$moduleName.TestResults.xml" -OutputFormat NUnitXml @codeCoverageParameters
9494
95-
"::set-output name=TotalCount::$($result.TotalCount)",
96-
"::set-output name=PassedCount::$($result.PassedCount)",
97-
"::set-output name=FailedCount::$($result.FailedCount)" | Out-Host
9895
if ($result.FailedCount -gt 0) {
9996
"::debug:: $($result.FailedCount) tests failed"
10097
foreach ($r in $result.TestResult) {
@@ -106,7 +103,7 @@ jobs:
106103
}
107104
} @Parameters
108105
- name: PublishTestResults
109-
uses: actions/upload-artifact@v2
106+
uses: actions/upload-artifact@v3
110107
with:
111108
name: PesterResults
112109
path: '**.TestResults.xml'
@@ -493,7 +490,7 @@ jobs:
493490
if: ${{ success() }}
494491
steps:
495492
- name: Check out repository
496-
uses: actions/checkout@v2
493+
uses: actions/checkout@v4
497494
- name: Use PSSVG Action
498495
uses: StartAutomating/PSSVG@main
499496
id: PSSVG

4bit.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

4bitcss.psd1

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@{
2-
ModuleVersion = '0.1.4'
2+
ModuleVersion = '0.1.5'
33
RootModule = '4bitcss.psm1'
4-
Description = 'CSS3 Color Schemes'
4+
Description = 'CSS3 Color Schemes for 4-bit color palettes'
55
Guid = '93e1d6ab-ce88-4751-bb14-b21fbb9f66f3'
66
CompanyName = 'Start-Automating'
77
Author = 'James Brundage'
@@ -14,36 +14,26 @@
1414
> Like It? [Star It](https://github.com/2bitdesigns/4bitcss)
1515
> Love It? [Support It](https://github.com/sponsors/StartAutomating)
1616
17-
## 0.1.4:
17+
## 0.1.5:
1818
19-
* So many more new palettes!
20-
* `-background` classes (#42)
21-
* `$psStyle` compatibility (#43, #52, #53, #54, #55, #56, #57, #58)
22-
* Producing additional files:
23-
* A .txt file per palette (#61)
24-
* Palettes.json (#60)
25-
* Palette-List.json, Dark-Palette-List.json, Bright-Palette-List.json
26-
* `<select>` support (#39)
27-
* Fixing strokes (#59)
28-
* Adding Docker Image (#49, #50, #51)
29-
* Module Improvements
30-
* Mounting 4bitcss (#48)
31-
* Exporting `$4bitcss` (#47)
32-
* Repository Cleanup (#44, #45, #46)
33-
* New Commands
34-
* Convert-4bitName (#33)
35-
* Export-4bitJS (#32)
36-
* Export-4bitSVG (#34)
37-
* Allowing color palettes without `selectioncolor` or `cursorcolor` (#31)
38-
* Putting Palettes into directories (#30)
19+
* 336 color palettes (and counting)!
20+
* Improved functionality
21+
* Support for `<button>` (#96)
22+
* `carat-color` support (#97)
23+
* HighlightJS support (#104, #105, #107)
24+
* Added json data files and credits (#79, #80)
25+
* Adding `--Luma` and `--Contrast` to CSS (#94, #95)
26+
* 4bitcss Docker Container (#74, #75, #76, #77)
27+
* Animated Palette Example (#109, #111)
28+
* Improved documentation and examples
3929
4030
---
4131
4232
Additional History in [Changelog](https://github.com/2bitdesigns/4bitcss/blob/main/CHANGELOG.md)
4333
'@
44-
WebSite = @{
34+
Website = @{
4535
Url = 'https://4bitcss.com/'
46-
Tech = 'Jekyll'
36+
Platform = 'Jekyll'
4737
Root = '/docs'
4838
}
4939
}

Build/4bitcss.PSSVG.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,45 @@ svg -ViewBox 640, 240 @(
9393
}
9494
) -OutputPath (Join-Path $docsRoot .\4bitpreviewtemplate.svg) -Class background-fill
9595

96+
svg -ViewBox 1920, 1080 @(
97+
svg.rect -Width 300% -Height 300% -X -100% -Y -100% -Class 'background-fill'
98+
99+
$initialRadius = (1080/2) - 42
100+
$wobble = .23
101+
$flipFlop = 1
102+
$duration = "04.2s"
103+
filter wobbler {
104+
$initialRadius * (($wobble * $flipFlop) + 1)
105+
}
106+
SVG.ellipse -Id 'foregroundCircle' -Cx 50% -Cy 50% -RX $initialRadius -Ry $initialRadius -Class 'foreground-fill' -Children @(
107+
SVG.animate -Values "$initialRadius;$(wobbler);$initialRadius" -AttributeName 'rx' -Dur $duration -RepeatCount indefinite
108+
$flipFlop *= -1
109+
SVG.animate -Values "$initialRadius;$(wobbler);$initialRadius" -AttributeName 'ry' -Dur $duration -RepeatCount indefinite
110+
111+
SVG.animate -Values "1;.42;1" -AttributeName 'opacity' -Dur $duration -RepeatCount indefinite
112+
)
113+
114+
foreach ($n in 0..7) {
115+
$initialRadius -= 23
116+
SVG.ellipse -Id "ANSI${N}-Ellipse" -cx 50% -cy 50% -rx $initialRadius -ry $initialRadius -Class "ansi$n-fill" -Fill $($colors[$n]) -Children @(
117+
SVG.animate -Values "$initialRadius;$(wobbler);$initialRadius" -AttributeName 'rx' -Dur $duration -RepeatCount indefinite
118+
$flipFlop *= -1
119+
SVG.animate -Values "$initialRadius;$(wobbler);$initialRadius" -AttributeName 'ry' -Dur $duration -RepeatCount indefinite
120+
121+
SVG.animate -Values "1;.42;1" -AttributeName 'opacity' -Dur $duration -RepeatCount indefinite
122+
)
123+
$initialRadius -= 16
124+
SVG.ellipse -Id "ANSI$($N + 8)-Ellipse" -Cx 50% -Cy 50% -RX $initialRadius -Ry $initialRadius -Class "ansi$($n + 8)-fill" -Fill $($colors[$n]) -Children @(
125+
SVG.animate -Values "$initialRadius;$(wobbler);$initialRadius" -AttributeName 'rx' -Dur $duration -RepeatCount indefinite
126+
127+
$flipFlop *= -1
128+
SVG.animate -Values "$initialRadius;$(wobbler);$initialRadius" -AttributeName 'ry' -Dur $duration -RepeatCount indefinite
129+
130+
SVG.animate -Values "1;.42;1" -AttributeName 'opacity' -Dur $duration -RepeatCount indefinite
131+
)
132+
}
133+
) -OutputPath (Join-Path $includesRoot .\Animated-Palette.svg) -Class background-fill
134+
96135
Copy-Item -Path (Join-Path $docsRoot .\4bitpreviewtemplate.svg) -Destination (Join-Path $assetsRoot ..\4bitpreviewtemplate.svg) -Force -PassThru
97136
Copy-Item -Path (Join-Path $docsRoot .\4bitpreviewtemplate.svg) -Destination (Join-Path $includesRoot .\4bitpreviewtemplate.svg) -Force -PassThru
98137

Build/4bitcss.build.ps1

Lines changed: 88 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,44 @@
11
Push-Location ($PSScriptRoot | Split-Path)
2-
# If running in a github workflow or not on C: drive, clone the repo.
3-
if ($env:GITHUB_WORKSPACE -or ($home -notmatch '^C:')) {
4-
# clone the iTermColorSchemes repo
5-
git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git | Out-Host
6-
7-
# and get all of the JSON files from it
8-
$jsonFiles = Get-ChildItem -Path iTerm2-Color-Schemes -Recurse -Filter *.json |
9-
Where-Object Fullname -like '*terminal*' |
10-
Where-Object FullName -notlike '*templates*'
11-
} else {
12-
# Otherwise get them locally
13-
$jsonFiles = Get-ChildItem $home\documents\git\iTerm2-Color-Schemes -Recurse -Filter *.json |
14-
Where-Object Fullname -like '*terminal*' |
15-
Where-Object FullName -notlike '*templates*'
2+
# clone the iTermColorSchemes repo
3+
git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git | Out-Host
4+
5+
# and get all of the JSON files from it
6+
$jsonFiles = Get-ChildItem -Path iTerm2-Color-Schemes -Recurse -Filter *.json |
7+
Where-Object Fullname -like '*terminal*' |
8+
Where-Object FullName -notlike '*templates*'
9+
10+
# Get the credits from the CREDITS.md file in the iTerm2-Color-Schemes repo
11+
$creditLines = Get-Content -Path (Join-Path iTerm2-Color-Schemes CREDITS.md)
12+
# and declare a small pattern to match markdown links
13+
$markdownLinkPattern = '\[(?<text>.+?)\]\((?<link>.+?)\)'
14+
# and a filter to get the credits from the CREDITS.md file
15+
filter GetCredits {
16+
$colorSchemeName = $_
17+
$colorSchemePattern = [Regex]::Escape($colorSchemeName) -replace '\\ ', '\s'
18+
foreach ($line in $creditLines) {
19+
if (-not $line ) { continue }
20+
if ($line -notmatch $colorSchemePattern) {
21+
continue
22+
}
23+
if ($line -notmatch $markdownLinkPattern) {
24+
continue
25+
}
26+
[Ordered]@{credit=$Matches.text; link=$Matches.link}
27+
}
1628
}
1729

30+
filter GetLuma {
31+
$colorString = $_
32+
# Convert the background color to a uint32
33+
$rgb = ($colorString -replace "#", "0x" -replace ';') -as [UInt32]
34+
# then make it into a percentage red, green, and blue.
35+
$r, $g, $b = ([float][byte](($rgb -band 0xff0000) -shr 16)/255),
36+
([float][byte](($rgb -band 0x00ff00) -shr 8)/255),
37+
([float][byte]($rgb -band 0x0000ff)/255)
38+
39+
# Calculate the luma of the background color
40+
0.2126 * $R + 0.7152 * $G + 0.0722 * $B
41+
}
1842

1943
# Import the module
2044
Import-Module .\4bitcss.psd1 -Global
@@ -39,35 +63,64 @@ $allColorSchemes = @()
3963
$brightColorSchemes = @()
4064
$darkColorSchemes = @()
4165

42-
$allPalletes = [Ordered]@{}
66+
$allPalettes = [Ordered]@{}
4367

4468
# Walk thru each json file of a color scheme
4569
foreach ($jsonFile in $jsonFiles) {
46-
# convert the contents from JSON
47-
$jsonObject = [IO.File]::ReadAllText($jsonFile.FullName) | ConvertFrom-Json
70+
# convert the contents from JSON
71+
$jsonContent = [IO.File]::ReadAllText($jsonFile.FullName)
72+
$jsonObject = $jsonContent | ConvertFrom-Json
4873
# and determine the name of the scheme and it's files.
4974
$colorSchemeName = $jsonObject.Name
5075
$colorSchemeFileName =
5176
$jsonObject.Name | Convert-4BitName
77+
78+
$creditInfo = @($colorSchemeName | GetCredits)[0]
79+
$jsonObject |
80+
Add-Member NoteProperty creditTo -Force -PassThru -Value $creditInfo.credit |
81+
Add-Member NoteProperty creditToLink -Force -Value $creditInfo.link
82+
83+
if ($jsonObject.background) {
84+
$jsonObject |
85+
Add-Member NoteProperty luma -Force -Value $($jsonObject.Background | GetLuma)
86+
}
87+
88+
if ($jsonObject.foreground -and $jsonObject.background) {
89+
$jsonObject |
90+
Add-Member NoteProperty contrast -Force -Value $(
91+
[Math]::Abs(
92+
($jsonObject.background | GetLuma) - ($jsonObject.foreground | GetLuma)
93+
)
94+
)
95+
}
96+
97+
$jsonObject |
98+
Add-Member NoteProperty contrast -Force -PassThru -Value @($jsonObject.Background | GetLuma)
5299

53100
if (-not $colorSchemeFileName) { continue }
54101
$distinctColors = @($jsonObject.psobject.Properties.value) -match '^#[0-9a-fA-F]{6}' | Select-Object -Unique
55102

56-
$allPalletes[$colorSchemeFileName] = $jsonObject
103+
$allPalettes[$colorSchemeFileName] = $jsonObject
57104
# If the name wasn't there, continue.
58105
if (-not $jsonObject.Name) { continue }
59106
# If it wasn't legal, continue.
60107
if ($jsonObject.Name -match '^\{') { continue }
61108
$cssPath = (Join-Path $pwd css)
109+
$jsonPath = (Join-Path $pwd json)
62110
# Export the theme to /css (so that repo-based CDNs have a logical link)
63111
$jsonObject | Export-4BitCSS -OutputPath $cssPath -OutVariable colorSchemeCssFile
64-
112+
$jsonObject | Export-4BitJSON -OutputPath (
113+
Join-Path $jsonPath "$colorSchemeFileName.json"
114+
) -OutVariable colorSchemeJsonFile
65115
$ColorSchemePath = Join-Path $docsPath $colorSchemeFileName
66116
if (-not (Test-Path $ColorSchemePath)) {
67117
$null = New-Item -ItemType Directory -Path $ColorSchemePath
68118
}
69119
# Then export it again to /docs (so the GitHub page works)
70120
$jsonObject | Export-4BitCSS -OutputPath $ColorSchemePath
121+
$jsonObject | Export-4BitJSON -OutputPath (
122+
Join-Path $ColorSchemePath "$colorSchemeFileName.json"
123+
) -OutVariable colorSchemeJsonFile
71124
$dotTextPath = Join-Path $ColorSchemePath "$colorSchemeFileName.txt"
72125
$distinctColors -join ';' | Set-Content -Path $dotTextPath -Encoding utf8
73126
Get-Item -Path $dotTextPath
@@ -84,6 +137,7 @@ foreach ($jsonFile in $jsonFiles) {
84137

85138
# Create a preview file. All we need to change is the stylesheet.
86139
$previewFilePath = Join-Path $ColorSchemePath "$colorSchemeFileName.md"
140+
87141
@"
88142
---
89143
stylesheet: /$colorSchemeFileName/$colorSchemeFileName.css
@@ -144,13 +198,13 @@ Get-Item -Path $allDarkSchemesPath
144198
Get-Item -Path $allDarkSchemesPath |
145199
Copy-Item -Destination $DataPath -Force -PassThru
146200

147-
$allPalletesPath = Join-Path $docsPath "Palletes.json"
148-
$allPalletes |
201+
$allPalettesPath = Join-Path $docsPath "Palettes.json"
202+
$allPalettes |
149203
ConvertTo-Json -Depth 4 -Compress |
150-
Set-Content -Path $allPalletesPath
204+
Set-Content -Path $allPalettesPath
151205

152-
Get-Item -Path $allPalletesPath
153-
Get-Item -Path $allPalletesPath |
206+
Get-Item -Path $allPalettesPath
207+
Get-Item -Path $allPalettesPath |
154208
Copy-Item -Destination $DataPath -Force -PassThru
155209

156210
$4bitJS = Export-4BitJS -ColorSchemeName $allColorSchemes -DarkColorSchemeName $darkColorSchemes -LightColorSchemeName $LightColorSchemeName
@@ -168,6 +222,7 @@ if (-not (Test-Path $IncludesPath)) {
168222
}
169223

170224
Export-4BitSVG -SVG https://raw.githubusercontent.com/feathericons/feather/master/icons/download.svg -Stroke "ansi6" -OutputPath (Join-Path $IncludesPath "download-icon.svg")
225+
Export-4BitSVG -SVG https://raw.githubusercontent.com/feathericons/feather/master/icons/github.svg -Stroke "ansi6" -OutputPath (Join-Path $IncludesPath "github-icon.svg")
171226
Export-4BitSVG -SVG https://raw.githubusercontent.com/feathericons/feather/master/icons/download-cloud.svg -Stroke "ansi6" -OutputPath (Join-Path $IncludesPath "download-cloud-icon.svg")
172227
Export-4BitSVG -SVG https://raw.githubusercontent.com/feathericons/feather/master/icons/shuffle.svg -Stroke "ansi6" -OutputPath (Join-Path $IncludesPath "shuffle-icon.svg")
173228
Export-4BitSVG -SVG https://raw.githubusercontent.com/feathericons/feather/master/icons/help-circle.svg -Stroke "ansi6" -OutputPath (Join-Path $IncludesPath "help-circle-icon.svg")
@@ -177,8 +232,10 @@ Export-4BitSVG -SVG https://raw.githubusercontent.com/feathericons/feather/maste
177232
Get-Module 4bitcss |
178233
Split-Path |
179234
Join-Path -ChildPath Assets |
180-
Get-ChildItem -Filter 4bitpreview.svg |
181-
Copy-Item -Destination (Join-Path $IncludesPath "4bitpreview.svg") -Force -PassThru
235+
Get-ChildItem -Filter 4bit*.svg |
236+
Copy-Item -Destination {
237+
Join-Path $IncludesPath "$($_.Name)"
238+
} -Force -PassThru
182239

183240
$defaultColorScheme = 'Konsolas'
184241
@"
@@ -194,4 +251,8 @@ $transpiledText
194251
"@ |
195252
Set-Content (Join-Path $docsPath "index.md") -Encoding utf8
196253
Get-item -Path (Join-Path $docsPath "index.md")
197-
#endregion Icons
254+
#endregion Icons
255+
256+
if ($env:GITHUB_WORKSPACE) {
257+
Remove-Item -Path iTerm2-Color-Schemes -Recurse -Force
258+
}

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## 0.1.5:
2+
3+
* 336 color palettes (and counting)!
4+
* Improved functionality
5+
* Support for `<button>` (#96)
6+
* `carat-color` support (#97)
7+
* HighlightJS support (#104, #105, #107)
8+
* Added json data files and credits (#79, #80)
9+
* Adding `--Luma` and `--Contrast` to CSS (#94, #95)
10+
* 4bitcss Docker Container (#74, #75, #76, #77)
11+
* Animated Palette Example (#109, #111)
12+
* Improved documentation and examples
13+
14+
---
15+
116
## 0.1.4:
217

318
* So many more new palettes!
@@ -14,7 +29,7 @@
1429
* Mounting 4bitcss (#48)
1530
* Exporting `$4bitcss` (#47)
1631
* Repository Cleanup (#44, #45, #46)
17-
* New Commands
32+
* New Commands
1833
* Convert-4bitName (#33)
1934
* Export-4bitJS (#32)
2035
* Export-4bitSVG (#34)

0 commit comments

Comments
 (0)