Skip to content

Commit c2fa10c

Browse files
wip
1 parent c22f2b0 commit c2fa10c

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/Enums/Badge.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@ enum Badge: string
77
case INLINE = 'inline';
88
case BOTTOMLEFT = 'bottomleft';
99
case BOTTOMRIGHT = 'bottomright';
10-
11-
// TODO
12-
// case HIDDEN = 'hidden';
10+
case HIDDEN = 'hidden';
1311
}

src/GoogleRecaptchaV3.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,32 @@ private function getJsTokenScript(): string
5757
JS;
5858
}
5959

60+
private function getHiddenBadgeStyle(): string
61+
{
62+
return <<<'CSS'
63+
.grecaptcha-badge {
64+
visibility: hidden;
65+
}
66+
CSS;
67+
}
68+
6069
private function toHtml(Badge $badge): string
6170
{
6271
if (! Config::isEnabled()) {
6372
return '';
6473
}
6574

66-
return implode("\n\n", [
75+
$parts = [
6776
str($this->getJsScriptUrl($badge))->wrap('<script>', '</script>'),
6877
str($this->getJsTokenScript())->wrap('<script>', '</script>'),
69-
// TODO: add style
70-
]);
71-
}
78+
];
7279

73-
// <style>
74-
// .grecaptcha-badge {
75-
// bottom: 90px !important;
76-
// }
77-
// </style>
80+
return collect($parts)
81+
->when($badge === Badge::HIDDEN, fn ($collection) => (
82+
$collection->push(str(
83+
$this->getHiddenBadgeStyle()
84+
)->wrap('<style>', '</style>'))
85+
))
86+
->implode("\n\n");
87+
}
7888
}

0 commit comments

Comments
 (0)