Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'

- name: Install prettier and plugin-php
run: npm i

Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor
**/*.min.js
**/*.min.js
.prettierrc
4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

13 changes: 13 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
printWidth: 120,
endOfLine: "auto",
plugins: ["@prettier/plugin-php"],
overrides: [
{
files: "*.php",
options: {
parser: "php",
},
},
],
};
2 changes: 1 addition & 1 deletion scripts/translation-progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ function updateReadme(string $path, string $start, string $end, string $content)
__DIR__ . "/../README.md",
"<!-- TRANSLATION_PROGRESS_START -->",
"<!-- TRANSLATION_PROGRESS_END -->",
$badges
$badges,
);
exit($update === false ? 1 : 0);
10 changes: 5 additions & 5 deletions src/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function formatDate(string $dateString, string|null $format, string $locale): st
$locale,
IntlDateFormatter::MEDIUM,
IntlDateFormatter::NONE,
pattern: $pattern
pattern: $pattern,
);
$formatted = $dateFormatter->format($date);
}
Expand All @@ -44,7 +44,7 @@ function formatDate(string $dateString, string|null $format, string $locale): st
$locale,
IntlDateFormatter::MEDIUM,
IntlDateFormatter::NONE,
pattern: $pattern
pattern: $pattern,
);
$formatted = $dateFormatter->format($date);
}
Expand Down Expand Up @@ -75,7 +75,7 @@ function translateDays(array $days, string $locale): array
$locale,
IntlDateFormatter::NONE,
IntlDateFormatter::NONE,
pattern: $pattern
pattern: $pattern,
);
$translatedDays = [];
foreach ($days as $day) {
Expand Down Expand Up @@ -250,7 +250,7 @@ function splitLines(string $text, int $maxChars, int $line1Offset): string
return preg_replace(
"/^(.*)\n(.*)/",
"<tspan x='0' dy='{$line1Offset}'>$1</tspan><tspan x='0' dy='16'>$2</tspan>",
$text
$text,
);
}

Expand Down Expand Up @@ -752,7 +752,7 @@ function ($matches) {
$opacity = $result["opacity"];
return "{$attribute}='{$color}' {$opacityAttribute}='{$opacity}'";
},
$svg
$svg,
);

return $svg;
Expand Down
13 changes: 10 additions & 3 deletions src/demo/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ html {

body {
background: var(--background);
font-family: Segoe UI, Ubuntu, sans-serif;
font-family:
Segoe UI,
Ubuntu,
sans-serif;
padding-top: 10px;
color: var(--text);
}
Expand Down Expand Up @@ -105,7 +108,9 @@ h2 {
border-radius: 6px;
cursor: pointer;
font-family: inherit;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
box-shadow:
0 1px 3px rgba(0, 0, 0, 0.12),
0 1px 2px rgba(0, 0, 0, 0.24);
transition: 0.2s ease-in-out;
}

Expand All @@ -115,7 +120,9 @@ h2 {

.btn:hover {
background-color: var(--blue-dark);
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
box-shadow:
0 3px 6px rgba(0, 0, 0, 0.16),
0 3px 6px rgba(0, 0, 0, 0.23);
}

.btn:disabled {
Expand Down
8 changes: 6 additions & 2 deletions src/demo/css/toggle-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ a.darkmode {
justify-content: center;
border-radius: 50%;
border: 2px solid var(--border);
box-shadow: 0 0 3px rgb(0 0 0 / 12%), 0 1px 2px rgb(0 0 0 / 24%);
box-shadow:
0 0 3px rgb(0 0 0 / 12%),
0 1px 2px rgb(0 0 0 / 24%);
transition: 0.2s ease-in box-shadow;
}

a.darkmode:hover {
box-shadow: 0 0 6px rgb(0 0 0 / 16%), 0 3px 6px rgb(0 0 0 / 23%);
box-shadow:
0 0 6px rgb(0 0 0 / 16%),
0 3px 6px rgb(0 0 0 / 23%);
}

@media only screen and (max-width: 600px) {
Expand Down
2 changes: 1 addition & 1 deletion src/demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function camelToSkewer(string $str): string
function ($matches) {
return "-" . strtolower($matches[0]);
},
$str
$str,
);
}
?>
Expand Down
4 changes: 2 additions & 2 deletions src/demo/js/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Accordion {
{
duration: 400,
easing: "ease-out",
}
},
);
// When the animation is complete, call onAnimationFinish()
this.animation.onfinish = () => this.onAnimationFinish(false);
Expand Down Expand Up @@ -93,7 +93,7 @@ class Accordion {
{
duration: 400,
easing: "ease-out",
}
},
);
// When the animation is complete, call onAnimationFinish()
this.animation.onfinish = () => this.onAnimationFinish(true);
Expand Down
6 changes: 3 additions & 3 deletions src/demo/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const preview = {
format: "hexa",
onChange: `preview.pickerChange(this, '${color1.id}')`,
onInput: `preview.pickerChange(this, '${color1.id}')`,
})
}),
);
const color2 = document.createElement("input");
color2.className = "param jscolor";
Expand All @@ -154,7 +154,7 @@ const preview = {
format: "hexa",
onChange: `preview.pickerChange(this, '${color2.id}')`,
onInput: `preview.pickerChange(this, '${color2.id}')`,
})
}),
);
rotate.name = color1.name = color2.name = propertyName;
color1.value = color1Value;
Expand Down Expand Up @@ -484,5 +484,5 @@ window.addEventListener(
// update previews
preview.update();
},
false
false,
);
4 changes: 2 additions & 2 deletions src/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function removeGitHubToken(string $token): void
if (empty($GLOBALS["ALL_TOKENS"])) {
throw new AssertionError(
"We are being rate-limited! Check <a href='https://git.io/streak-ratelimit' font-weight='bold'>git.io/streak-ratelimit</a> for details.",
429
429,
);
}
}
Expand Down Expand Up @@ -287,7 +287,7 @@ function normalizeDays(array $days): array
$dayOfWeek = substr(ucfirst(strtolower(trim($dayOfWeek))), 0, 3);
// return day if valid, otherwise return null
return in_array($dayOfWeek, ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]) ? $dayOfWeek : null;
}, $days)
}, $days),
);
}

Expand Down
10 changes: 5 additions & 5 deletions tests/OptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testThemesHaveValidParameters(): void
$this->assertEquals(
array_diff_key($colors, $this->defaultTheme),
[],
"The theme '$theme' contains invalid parameters."
"The theme '$theme' contains invalid parameters.",
);
# check that no parameters are missing and all values are valid
foreach (array_keys($this->defaultTheme) as $param) {
Expand All @@ -85,21 +85,21 @@ public function testThemesHaveValidParameters(): void
$this->assertMatchesRegularExpression(
$backgroundRegex,
$colors[$param],
"The parameter '$param' of '$theme' is not a valid background value."
"The parameter '$param' of '$theme' is not a valid background value.",
);
continue;
}
// check that the key is a valid hex color
$this->assertMatchesRegularExpression(
$hexRegex,
strtoupper($colors[$param]),
"The parameter '$param' of '$theme' is not a valid hex color."
"The parameter '$param' of '$theme' is not a valid hex color.",
);
// check that the key is a valid hex color in uppercase
$this->assertMatchesRegularExpression(
$hexRegex,
$colors[$param],
"The parameter '$param' of '$theme' should not contain lowercase letters."
"The parameter '$param' of '$theme' should not contain lowercase letters.",
);
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ public function testAllThemeNamesNormalized(): void
$this->assertEquals(
$theme,
$normalized,
"Theme name '$theme' is not normalized. It should contain only lowercase letters, numbers, and dashes. Consider renaming it to '$normalized'."
"Theme name '$theme' is not normalized. It should contain only lowercase letters, numbers, and dashes. Consider renaming it to '$normalized'.",
);
}
}
Expand Down
16 changes: 8 additions & 8 deletions tests/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testBorderRadius(): void
$this->assertStringContainsString("<rect width='495' height='195' rx='16'/>", $render);
$this->assertStringContainsString(
"<rect stroke='#111111' fill='#000000' rx='16' x='0.5' y='0.5' width='494' height='194'/>",
$render
$render,
);
}

Expand All @@ -126,19 +126,19 @@ public function testSplitLines(): void
// Check label that is too long, split
$this->assertEquals(
"<tspan x='0' dy='-9'>Chuỗi đóng góp hiện</tspan><tspan x='0' dy='16'>tại</tspan>",
splitLines("Chuỗi đóng góp hiện tại", 22, -9)
splitLines("Chuỗi đóng góp hiện tại", 22, -9),
);
// Check label with manually inserted line break, split
$this->assertEquals(
"<tspan x='0' dy='-9'>Chuỗi đóng góp</tspan><tspan x='0' dy='16'>hiện tại</tspan>",
splitLines("Chuỗi đóng góp\nhiện tại", 22, -9)
splitLines("Chuỗi đóng góp\nhiện tại", 22, -9),
);
// Check date range label, no split
$this->assertEquals("Mar 28, 2019 – Apr 12, 2019", splitLines("Mar 28, 2019 – Apr 12, 2019", 28, 0));
// Check date range label that is too long, split
$this->assertEquals(
"<tspan x='0' dy='0'>19 de dez. de 2021</tspan><tspan x='0' dy='16'>- 14 de mar.</tspan>",
splitLines("19 de dez. de 2021 - 14 de mar.", 24, 0)
splitLines("19 de dez. de 2021 - 14 de mar.", 24, 0),
);
}

Expand Down Expand Up @@ -194,7 +194,7 @@ public function testGradientBackground(): void
$this->assertStringContainsString("fill='url(#gradient)'", $render);
$this->assertStringContainsString(
"<linearGradient id='gradient' gradientTransform='rotate(45)' gradientUnits='userSpaceOnUse'><stop offset='0%' stop-color='#f00' /><stop offset='100%' stop-color='#e11' /></linearGradient>",
$render
$render,
);
}

Expand All @@ -208,7 +208,7 @@ public function testGradientBackgroundWithMoreThan2Colors(): void
$this->assertStringContainsString("fill='url(#gradient)'", $render);
$this->assertStringContainsString(
"<linearGradient id='gradient' gradientTransform='rotate(-45)' gradientUnits='userSpaceOnUse'><stop offset='0%' stop-color='#f00' /><stop offset='33.333333333333%' stop-color='#4e5' /><stop offset='66.666666666667%' stop-color='#ddd' /><stop offset='100%' stop-color='#fff' /></linearGradient>",
$render
$render,
);
}

Expand Down Expand Up @@ -263,11 +263,11 @@ public function testFirstAndThirdColumnsSwappedWhenDirectionIsRtl(): void
$render = generateOutput($this->testStats, $this->testParams)["body"];
$this->assertMatchesRegularExpression(
"/<!-- Total Contributions big number -->\\s*<g transform='translate\\(412\\.5, 48\\)'>/",
$render
$render,
);
$this->assertMatchesRegularExpression(
"/<!-- Longest Streak big number -->\\s*<g transform='translate\\(82\\.5, 48\\)'>/",
$render
$render,
);
}

Expand Down