mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{{totalWidth}}" height="20" role="img" aria-label="appwrite: {{message}}">
|
||||
<title>appwrite: {{message}}</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{{totalWidth}}" height="20" role="img" aria-label="{{label}}: {{message}}">
|
||||
<title>{{label}}: {{message}}</title>
|
||||
<linearGradient id="s" x2="0" y2="100%">
|
||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
@@ -8,15 +8,15 @@
|
||||
<rect width="{{totalWidth}}" height="20" rx="3" fill="#fff"/>
|
||||
</clipPath>
|
||||
<g clip-path="url(#r)">
|
||||
<rect width="77" height="20" fill="#FD366E"/>
|
||||
<rect x="77" width="100%" height="20" fill="{{colorCode}}"/>
|
||||
<rect width="{{labelWidth}}" height="20" fill="#FD366E"/>
|
||||
<rect x="{{labelWidth}}" width="100%" height="20" fill="{{colorCode}}"/>
|
||||
<rect width="{{totalWidth}}" height="20" fill="url(#s)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
|
||||
<image x="5" y="3" width="14" height="14" href="data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M24.4429 17.4322V22.9096H10.7519C6.76318 22.9096 3.28044 20.7067 1.4171 17.4322C1.14622 16.9561 0.909137 16.4567 0.710264 15.9383C0.319864 14.9225 0.0744552 13.8325 0 12.6952V11.2143C0.0161646 10.9609 0.0416361 10.7094 0.0749451 10.4609C0.143032 9.95105 0.245898 9.45211 0.381093 8.96711C1.66006 4.36909 5.81877 1 10.7519 1C15.6851 1 19.8433 4.36909 21.1223 8.96711H15.2682C14.3072 7.4683 12.6437 6.4774 10.7519 6.4774C8.86017 6.4774 7.19668 7.4683 6.23562 8.96711C5.9427 9.42274 5.71542 9.92516 5.56651 10.4609C5.43425 10.936 5.36371 11.4369 5.36371 11.9548C5.36371 13.5248 6.01324 14.94 7.05463 15.9383C8.01961 16.865 9.32061 17.4322 10.7519 17.4322H24.4429Z' fill='%23ffffff'/%3E%3Cpath d='M24.4429 10.4609V15.9383H14.4492C15.4906 14.94 16.1401 13.5248 16.1401 11.9548C16.1401 11.4369 16.0696 10.936 15.9373 10.4609H24.4429Z' fill='%23ffffff'/%3E%3C/svg%3E"/>
|
||||
<text aria-hidden="true" x="485" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="480">appwrite</text>
|
||||
<text x="485" y="140" transform="scale(.1)" fill="#fff" textLength="480">appwrite</text>
|
||||
<text aria-hidden="true" x="820" y="150" text-anchor="start" fill="#010101" fill-opacity=".3" transform="scale(.1)">{{message}}</text>
|
||||
<text x="820" y="140" text-anchor="start" transform="scale(.1)" fill="#fff">{{message}}</text>
|
||||
<text aria-hidden="true" x="{{labelTextX}}" y="150" text-anchor="start" fill="#010101" fill-opacity=".3" transform="scale(.1)" font-size="{{labelFontSize}}">{{label}}</text>
|
||||
<text x="{{labelTextX}}" y="140" text-anchor="start" transform="scale(.1)" fill="#fff" font-size="{{labelFontSize}}">{{label}}</text>
|
||||
<text aria-hidden="true" x="{{messageTextX}}" y="150" text-anchor="start" fill="#010101" fill-opacity=".3" transform="scale(.1)">{{message}}</text>
|
||||
<text x="{{messageTextX}}" y="140" text-anchor="start" transform="scale(.1)" fill="#fff">{{message}}</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.5 KiB |
@@ -6,7 +6,10 @@ use Utopia\Platform\Action as UtopiaAction;
|
||||
|
||||
abstract class Action extends UtopiaAction
|
||||
{
|
||||
protected const LABEL_WIDTH = 77;
|
||||
protected const LABEL_FONT_SIZE = 110;
|
||||
protected const LABEL_TEXT_X = 260;
|
||||
protected const TEXT_PADDING = 10;
|
||||
protected const FALLBACK_CHAR_WIDTH = 7;
|
||||
protected const COLOR_BRIGHTGREEN = '#4c1';
|
||||
protected const COLOR_GREEN = '#97ca00';
|
||||
protected const COLOR_YELLOW = '#dfb317';
|
||||
|
||||
@@ -11,6 +11,19 @@ use Utopia\Validator\Text;
|
||||
|
||||
class Get extends Action
|
||||
{
|
||||
private const LABEL = 'appwrite functions';
|
||||
private const LABEL_WIDTH = 137;
|
||||
private const MESSAGE_WIDTHS = [
|
||||
'not found' => 75,
|
||||
'disabled' => 75,
|
||||
'no deployment' => 112,
|
||||
'unknown' => 74,
|
||||
'ready' => 60,
|
||||
'building' => 76,
|
||||
'waiting' => 70,
|
||||
'failed' => 60,
|
||||
];
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'getFunctionBadge';
|
||||
@@ -37,6 +50,7 @@ class Get extends Action
|
||||
public function action(string $functionId, Response $response, Database $dbForProject, Authorization $authorization): void
|
||||
{
|
||||
$function = $authorization->skip(fn () => $dbForProject->getDocument('functions', $functionId));
|
||||
$label = self::LABEL;
|
||||
|
||||
switch (true) {
|
||||
case $function->isEmpty():
|
||||
@@ -81,13 +95,20 @@ class Get extends Action
|
||||
}
|
||||
|
||||
$colorCode = self::COLOR_BY_NAME[$color] ?? self::COLOR_LIGHTGREY;
|
||||
$totalWidth = self::LABEL_WIDTH + (\strlen($message) * 6) + 10;
|
||||
$messageWidth = self::MESSAGE_WIDTHS[$message] ?? ((\strlen($message) * self::FALLBACK_CHAR_WIDTH) + (self::TEXT_PADDING * 2));
|
||||
$totalWidth = self::LABEL_WIDTH + $messageWidth;
|
||||
$messageTextX = (self::LABEL_WIDTH + self::TEXT_PADDING) * 10;
|
||||
|
||||
$templatePath = \dirname(__DIR__, 7) . '/app/config/locale/templates/badge.svg.tpl';
|
||||
$template = Template::fromFile($templatePath);
|
||||
$template
|
||||
->setParam('{{label}}', $label)
|
||||
->setParam('{{message}}', $message)
|
||||
->setParam('{{colorCode}}', $colorCode)
|
||||
->setParam('{{labelWidth}}', (string)self::LABEL_WIDTH)
|
||||
->setParam('{{labelFontSize}}', (string)self::LABEL_FONT_SIZE)
|
||||
->setParam('{{labelTextX}}', (string)self::LABEL_TEXT_X)
|
||||
->setParam('{{messageTextX}}', (string)$messageTextX)
|
||||
->setParam('{{totalWidth}}', (string) $totalWidth);
|
||||
|
||||
$svg = $template->render();
|
||||
|
||||
@@ -11,6 +11,19 @@ use Utopia\Validator\Text;
|
||||
|
||||
class Get extends Action
|
||||
{
|
||||
private const LABEL = 'appwrite sites';
|
||||
private const LABEL_WIDTH = 110;
|
||||
private const MESSAGE_WIDTHS = [
|
||||
'not found' => 75,
|
||||
'disabled' => 75,
|
||||
'no deployment' => 112,
|
||||
'unknown' => 74,
|
||||
'ready' => 60,
|
||||
'building' => 76,
|
||||
'waiting' => 70,
|
||||
'failed' => 60,
|
||||
];
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'getSiteBadge';
|
||||
@@ -37,6 +50,7 @@ class Get extends Action
|
||||
public function action(string $siteId, Response $response, Database $dbForProject, Authorization $authorization): void
|
||||
{
|
||||
$site = $authorization->skip(fn () => $dbForProject->getDocument('sites', $siteId));
|
||||
$label = self::LABEL;
|
||||
|
||||
switch (true) {
|
||||
case $site->isEmpty():
|
||||
@@ -81,13 +95,20 @@ class Get extends Action
|
||||
}
|
||||
|
||||
$colorCode = self::COLOR_BY_NAME[$color] ?? self::COLOR_LIGHTGREY;
|
||||
$totalWidth = self::LABEL_WIDTH + (\strlen($message) * 6) + 10;
|
||||
$messageWidth = self::MESSAGE_WIDTHS[$message] ?? ((\strlen($message) * self::FALLBACK_CHAR_WIDTH) + (self::TEXT_PADDING * 2));
|
||||
$totalWidth = self::LABEL_WIDTH + $messageWidth;
|
||||
$messageTextX = (self::LABEL_WIDTH + self::TEXT_PADDING) * 10;
|
||||
|
||||
$templatePath = \dirname(__DIR__, 7) . '/app/config/locale/templates/badge.svg.tpl';
|
||||
$template = Template::fromFile($templatePath);
|
||||
$template
|
||||
->setParam('{{label}}', $label)
|
||||
->setParam('{{message}}', $message)
|
||||
->setParam('{{colorCode}}', $colorCode)
|
||||
->setParam('{{labelWidth}}', (string)self::LABEL_WIDTH)
|
||||
->setParam('{{labelFontSize}}', (string)self::LABEL_FONT_SIZE)
|
||||
->setParam('{{labelTextX}}', (string)self::LABEL_TEXT_X)
|
||||
->setParam('{{messageTextX}}', (string)$messageTextX)
|
||||
->setParam('{{totalWidth}}', (string) $totalWidth);
|
||||
|
||||
$svg = $template->render();
|
||||
|
||||
Reference in New Issue
Block a user