feat(tweet-card): tabler verified badge (svg source committed) + badge placement next to name

This commit is contained in:
Paulo Castellano 2026-06-17 19:21:19 -03:00
parent 8317b83d6b
commit 9f7b797674
3 changed files with 29 additions and 22 deletions

View file

@ -625,23 +625,21 @@ public function renderTweetCard(Workspace $workspace, SocialAccount $socialAccou
$nameX = $avatarX + $avatarSize + 16;
$nameY = $avatarY + 4;
if ($fontBold) {
$canvas->text($socialAccount->display_name ?? '', $nameX, $nameY, function (FontFactory $font) use ($fontBold, $nameSize) {
$font->filename($fontBold);
$font->size($nameSize);
$font->color('#0f1419');
$font->align('left', 'top');
});
$displayNameText = $socialAccount->display_name ?? '';
$nameBox = $fontBold ? imagettfbbox($nameSize, 0, $fontBold, $displayNameText) : [0, 0, 0, 0, 0, 0, 0, 0];
$nameWidth = abs($nameBox[2] - $nameBox[0]);
$nameAscent = (int) round(abs($nameBox[7]));
$nameBaselineY = $nameY + $nameAscent;
if ($fontBold && $displayNameText !== '') {
$this->drawTextAt($core, $displayNameText, $fontBold, $nameSize, '#0f1419', $nameX, $nameBaselineY);
}
$verifiedPath = public_path('images/ai-templates/verified.png');
if ($fontBold && file_exists($verifiedPath)) {
$displayNameText = $socialAccount->display_name ?? '';
$nameBox = $fontBold ? imagettfbbox($nameSize, 0, $fontBold, $displayNameText) : [0, 0, 0, 0, 0, 0, 0, 0];
$nameWidth = abs($nameBox[2] - $nameBox[0]);
$badgeSize = (int) round($nameSize * 1.1);
$badgeX = $nameX + $nameWidth + 6;
$badgeY = $nameY + (int) round(($nameSize - $badgeSize) / 2);
if ($fontBold && $displayNameText !== '' && file_exists($verifiedPath)) {
$badgeSize = (int) round($nameSize * 1.15);
$badgeX = $nameX + $nameWidth + 8;
$badgeY = $nameY + (int) round(($nameAscent - $badgeSize) / 2);
$verifiedSrc = @imagecreatefrompng($verifiedPath);
if ($verifiedSrc) {
$verifiedResized = imagecreatetruecolor($badgeSize, $badgeSize);
@ -657,14 +655,12 @@ public function renderTweetCard(Workspace $workspace, SocialAccount $socialAccou
}
}
$handleY = $nameY + (int) round($nameSize * 1.35);
if ($fontLight) {
$canvas->text('@'.($socialAccount->username ?? ''), $nameX, $handleY, function (FontFactory $font) use ($fontLight, $handleSize) {
$font->filename($fontLight);
$font->size($handleSize);
$font->color('#536471');
$font->align('left', 'top');
});
$handleText = '@'.($socialAccount->username ?? '');
$handleBox = $fontLight ? imagettfbbox($handleSize, 0, $fontLight, $handleText) : [0, 0, 0, 0, 0, 0, 0, 0];
$handleAscent = (int) round(abs($handleBox[7]));
$handleY = $nameY + (int) round($nameSize * 1.4);
if ($fontLight && $socialAccount->username) {
$this->drawTextAt($core, $handleText, $fontLight, $handleSize, '#536471', $nameX, $handleY + $handleAscent);
}
$bodyStartY = $cardY + $headerH + 8;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,11 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="#1D9BF0"
class="icon icon-tabler icons-tabler-filled icon-tabler-rosette-discount-check"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M12.01 2.011a3.2 3.2 0 0 1 2.113 .797l.154 .145l.698 .698a1.2 1.2 0 0 0 .71 .341l.135 .008h1a3.2 3.2 0 0 1 3.195 3.018l.005 .182v1c0 .27 .092 .533 .258 .743l.09 .1l.697 .698a3.2 3.2 0 0 1 .147 4.382l-.145 .154l-.698 .698a1.2 1.2 0 0 0 -.341 .71l-.008 .135v1a3.2 3.2 0 0 1 -3.018 3.195l-.182 .005h-1a1.2 1.2 0 0 0 -.743 .258l-.1 .09l-.698 .697a3.2 3.2 0 0 1 -4.382 .147l-.154 -.145l-.698 -.698a1.2 1.2 0 0 0 -.71 -.341l-.135 -.008h-1a3.2 3.2 0 0 1 -3.195 -3.018l-.005 -.182v-1a1.2 1.2 0 0 0 -.258 -.743l-.09 -.1l-.697 -.698a3.2 3.2 0 0 1 -.147 -4.382l.145 -.154l.698 -.698a1.2 1.2 0 0 0 .341 -.71l.008 -.135v-1l.005 -.182a3.2 3.2 0 0 1 3.013 -3.013l.182 -.005h1a1.2 1.2 0 0 0 .743 -.258l.1 -.09l.698 -.697a3.2 3.2 0 0 1 2.269 -.944zm3.697 7.282a1 1 0 0 0 -1.414 0l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.32 1.497l2 2l.094 .083a1 1 0 0 0 1.32 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z" />
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB