Procházet zdrojové kódy

Show the store logo in the footer and as the browser tab icon

- Footer: the logo replaces the store name in the "columns" layout and sits above the text in the others
- Tab icon: a roughly square uploaded logo becomes a 180px PNG (also the phone home-screen icon), made at upload time
- Otherwise the tab shows the store's initials on its main colour, so stores never show our own icon
- The dashboard keeps the AI Commerce icon
- Logo box: "In the browser tab" preview
- Fix an Overview test that failed on the 1st of each month
feature/store-logo-icon
fahmisaad před 19 hodinami
rodič
revize
875124e880

+ 5
- 3
PROGRESS.md Zobrazit soubor

4
 Update it at the end of every work session.
4
 Update it at the end of every work session.
5
 
5
 
6
 **Last updated:** 2026-11-30
6
 **Last updated:** 2026-11-30
7
-**Current step:** On branch `feature/stripe-connect` (not committed yet): Stripe Connect (tested with card and FPX), restyled shopper emails, store contact email, and store logos (upload, ready designs, Claude drawings with a lifetime limit). EasyParcel courier booking is done on branch `feature/easyparcel` (not committed yet). Step 9 part 8 on hold
8
-**Next action:** Commit, then merge `feature/stripe-connect` (it includes `feature/easyparcel`) into `main` and run `php artisan migrate`. Later: live courier rate at checkout, tracking updates, a lawyer reads the legal pages, backup AI provider, hosting
7
+**Current step:** Stripe Connect, shopper emails, store contact email, store logos and EasyParcel are on `main`. On `main` (not committed yet): the logo in the store footer and as the browser tab icon. Step 9 part 8 on hold
8
+**Next action:** Commit the footer and tab icon work. Later: live courier rate at checkout, tracking updates, a lawyer reads the legal pages, backup AI provider, hosting
9
 
9
 
10
 Status marks: `[ ]` not started · `[~]` in progress · `[x]` done
10
 Status marks: `[ ]` not started · `[~]` in progress · `[x]` done
11
 
11
 
171
 - **Drawn by Claude (decided 2026-11-30):** each try draws 3 SVG logos from the brand name, category, description, colours and heading font (AI task `logo`, Claude Sonnet by default). **Lifetime limit: 3 tries per store** (`AI_LOGO_LIFETIME_TRIES`); a try is taken in one database step so quick double clicks cannot pass the limit, and a try that brings back nothing usable is given back. Every drawing is kept (up to 12) so the merchant can switch later. Real test: Claude drew 3 logos for Luna Skin in about 20 seconds, including a crescent moon for "Luna".
171
 - **Drawn by Claude (decided 2026-11-30):** each try draws 3 SVG logos from the brand name, category, description, colours and heading font (AI task `logo`, Claude Sonnet by default). **Lifetime limit: 3 tries per store** (`AI_LOGO_LIFETIME_TRIES`); a try is taken in one database step so quick double clicks cannot pass the limit, and a try that brings back nothing usable is given back. Every drawing is kept (up to 12) so the merchant can switch later. Real test: Claude drew 3 logos for Luna Skin in about 20 seconds, including a crescent moon for "Luna".
172
 - **Safety:** Claude's SVG is rebuilt by `App\Storefront\Logos\LogoSvg`: only simple shapes, text and gradients, checked attribute values, no scripts, links, pictures, styles, event handlers or outside addresses; ids get a random prefix; text always uses the store's heading font (`var(--sf-font-heading)`).
172
 - **Safety:** Claude's SVG is rebuilt by `App\Storefront\Logos\LogoSvg`: only simple shapes, text and gradients, checked attribute values, no scripts, links, pictures, styles, event handlers or outside addresses; ids get a random prefix; text always uses the store's heading font (`var(--sf-font-heading)`).
173
 - **Emails:** an uploaded logo shows at the top of the order emails (at most 48 pixels high). Ready designs and AI drawings are not pictures email apps can show, so those emails keep the store name.
173
 - **Emails:** an uploaded logo shows at the top of the order emails (at most 48 pixels high). Ready designs and AI drawings are not pictures email apps can show, so those emails keep the store name.
174
-- Not done yet: logo as the browser tab icon; logo in the store footer.
174
+- **Footer (added 2026-12-01):** the logo shows in every footer layout (in place of the store name in "columns", above the footer text in the others). Without a logo, footers stay as before.
175
+- **Browser tab icon (decided 2026-12-01):** store pages never show our own icon. An uploaded logo that is not much wider than tall (at most 2 to 1, after plain edges are cut off) becomes a 180-pixel square PNG (`…-icon.png`, also the phone home-screen icon), made at upload time. Otherwise (no logo, a ready design, an AI drawing, or a wide upload) the tab shows the store's initials on its main colour as an SVG, round for the round monogram design, with the store's corner rounding for the rest. AI drawings are wide pictures that cannot be read at tab size, so they also use the initials. The icon goes into the page head in `app.blade.php` from `shop.icon`; the dashboard keeps our icon. The Logo box shows an "In the browser tab" preview. Code: `StoreLogos::icon()`.
175
 
176
 
176
 ### How discount codes work (added in Step 8)
177
 ### How discount codes work (added in Step 8)
177
 
178
 
719
 | 2026-11-30 | Restyled the shopper emails (order paid, order shipped) in each store's own colours, fonts and corners, with View order, WhatsApp and Track parcel buttons and plain-text versions. Checked on desktop and phone width for Luna Skin, Sambal Nenek (Malay, serif) and Crunch & Co. 349 tests pass.                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Commit and merge                                                |
720
 | 2026-11-30 | Restyled the shopper emails (order paid, order shipped) in each store's own colours, fonts and corners, with View order, WhatsApp and Track parcel buttons and plain-text versions. Checked on desktop and phone width for Luna Skin, Sambal Nenek (Malay, serif) and Crunch & Co. 349 tests pass.                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Commit and merge                                                |
720
 | 2026-11-30 | Store contact email: "How shoppers reach you" card in Settings (WhatsApp + email for shoppers); order emails are sent under the store's name with replies to that email, shown in the footer. 352 tests pass; saved and checked for Luna Skin.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Commit and merge                                                |
721
 | 2026-11-30 | Store contact email: "How shoppers reach you" card in Settings (WhatsApp + email for shoppers); order emails are sent under the store's name with replies to that email, shown in the footer. 352 tests pass; saved and checked for Luna Skin.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Commit and merge                                                |
721
 | 2026-11-30 | Store logos: Logo box in the Design tab (upload, 8 ready designs, Claude draws 3 per try with 3 lifetime tries per store), shown in the store header and (uploads) in order emails; Claude's SVG cleaned by LogoSvg. Real Claude test drew a moon logo for Luna Skin. 360 tests pass.                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Commit and merge                                                |
722
 | 2026-11-30 | Store logos: Logo box in the Design tab (upload, 8 ready designs, Claude draws 3 per try with 3 lifetime tries per store), shown in the store header and (uploads) in order emails; Claude's SVG cleaned by LogoSvg. Real Claude test drew a moon logo for Luna Skin. 360 tests pass.                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Commit and merge                                                |
723
+| 2026-12-01 | Store logo in the footer and as the browser tab icon (uploaded logo as a square PNG, otherwise the store's initials on its main colour); "In the browser tab" preview in the Logo box. Fixed an Overview test that failed on the 1st of each month. 362 tests pass; checked on Luna Skin. | Commit |

+ 2
- 0
app/Http/Controllers/Concerns/RendersStorefront.php Zobrazit soubor

75
                 'whatsapp' => $store->whatsapp_number,
75
                 'whatsapp' => $store->whatsapp_number,
76
                 // The store's logo (uploaded, a ready design, or drawn by AI), or null to show the name.
76
                 // The store's logo (uploaded, a ready design, or drawn by AI), or null to show the name.
77
                 'logo' => app(StoreLogos::class)->present($store),
77
                 'logo' => app(StoreLogos::class)->present($store),
78
+                // The browser tab icon, put in the page head by app.blade.php.
79
+                'icon' => app(StoreLogos::class)->icon($store),
78
                 // In ringgit, or null when shipping is never free.
80
                 // In ringgit, or null when shipping is never free.
79
                 'free_shipping_over' => $store->free_shipping_over !== null ? $store->free_shipping_over / 100 : null,
81
                 'free_shipping_over' => $store->free_shipping_over !== null ? $store->free_shipping_over / 100 : null,
80
                 // Lines for the slim bar above the header. Empty when the merchant switched it off.
82
                 // Lines for the slim bar above the header. Empty when the merchant switched it off.

+ 1
- 0
app/Http/Controllers/StoreController.php Zobrazit soubor

79
             // The Logo box: the current logo, ready designs, Claude's drawings and the tries left.
79
             // The Logo box: the current logo, ready designs, Claude's drawings and the tries left.
80
             'logo' => [
80
             'logo' => [
81
                 'current' => $logos->present($store),
81
                 'current' => $logos->present($store),
82
+                'icon' => $logos->icon($store),
82
                 'name' => $logos->name($store),
83
                 'name' => $logos->name($store),
83
                 'designs' => StoreLogos::DESIGNS,
84
                 'designs' => StoreLogos::DESIGNS,
84
                 'drafts' => $store->logo_drafts ?? [],
85
                 'drafts' => $store->logo_drafts ?? [],

+ 103
- 4
app/Storefront/Logos/StoreLogos.php Zobrazit soubor

4
 
4
 
5
 use App\Ai\AiException;
5
 use App\Ai\AiException;
6
 use App\Ai\AiManager;
6
 use App\Ai\AiManager;
7
+use App\Mail\StoreBrand;
7
 use App\Models\Store;
8
 use App\Models\Store;
8
 use App\StorePlan\Ai\JsonAnswer;
9
 use App\StorePlan\Ai\JsonAnswer;
9
 use App\StorePlan\PlanSchema;
10
 use App\StorePlan\PlanSchema;
31
 
32
 
32
     public const int MIN_SIDE = 64;
33
     public const int MIN_SIDE = 64;
33
 
34
 
35
+    /** The square browser tab and home screen icon made from an uploaded logo, in pixels. */
36
+    public const int ICON_SIDE = 180;
37
+
38
+    /** Uploaded logos wider than this (width to height) are too thin to read as a tab icon. */
39
+    private const float ICON_MAX_RATIO = 2.0;
40
+
34
     /** How many logos one "Draw with AI" try asks for. */
41
     /** How many logos one "Draw with AI" try asks for. */
35
     public const int PER_TRY = 3;
42
     public const int PER_TRY = 3;
36
 
43
 
107
         imagefill($canvas, 0, 0, imagecolorallocatealpha($canvas, 0, 0, 0, 127));
114
         imagefill($canvas, 0, 0, imagecolorallocatealpha($canvas, 0, 0, 0, 127));
108
         imagecopyresampled($canvas, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
115
         imagecopyresampled($canvas, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
109
 
116
 
110
-        $path = 'logos/'.$store->id.'-'.Str::random(12).'.webp';
117
+        $name = 'logos/'.$store->id.'-'.Str::random(12);
111
         ob_start();
118
         ob_start();
112
         imagewebp($canvas, null, 90);
119
         imagewebp($canvas, null, 90);
113
-        Storage::disk('public')->put($path, (string) ob_get_clean());
120
+        Storage::disk('public')->put($name.'.webp', (string) ob_get_clean());
121
+
122
+        $icon = $this->squareIcon($canvas);
123
+
124
+        if ($icon !== null) {
125
+            Storage::disk('public')->put($name.'-icon.png', $icon);
126
+        }
127
+
128
+        $this->replace($store, array_filter([
129
+            'type' => 'upload',
130
+            'path' => $name.'.webp',
131
+            'icon_path' => $icon !== null ? $name.'-icon.png' : null,
132
+            'width' => $newWidth,
133
+            'height' => $newHeight,
134
+        ], fn ($value) => $value !== null));
135
+    }
136
+
137
+    /**
138
+     * The browser tab icon: the uploaded logo when it is square enough to read at a small size,
139
+     * otherwise the store's initials on its main colour. The same icon is used for every logo type,
140
+     * and for stores with no logo, so a shop never shows our own icon.
141
+     *
142
+     * @return array{href: string, type: string, touch: string|null}
143
+     */
144
+    public function icon(Store $store): array
145
+    {
146
+        $logo = $store->logo;
147
+
148
+        if (($logo['type'] ?? null) === 'upload' && is_string($logo['icon_path'] ?? null)) {
149
+            $url = Storage::disk('public')->url($logo['icon_path']);
150
+
151
+            return ['href' => $url, 'type' => 'image/png', 'touch' => $url];
152
+        }
153
+
154
+        $brand = StoreBrand::for($store);
155
+        $initials = $this->initials($brand->name);
156
+        $letters = htmlspecialchars($initials, ENT_XML1);
157
+        $size = mb_strlen($initials) > 1 ? 28 : 36;
158
+        $round = ($logo['type'] ?? null) === 'design' && ($logo['key'] ?? null) === 'monogram-circle';
159
+        $radius = $round ? 32 : min(32, (int) round($brand->radius * 1.5));
160
+        $font = htmlspecialchars($brand->headingFont, ENT_XML1 | ENT_QUOTES);
161
+
162
+        $svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">'
163
+            .'<rect width="64" height="64" rx="'.$radius.'" fill="'.$brand->color('primary').'"/>'
164
+            .'<text x="32" y="33" text-anchor="middle" dominant-baseline="central" font-family="'.$font.'"'
165
+            .' font-size="'.$size.'" font-weight="700" fill="'.$brand->color('primaryForeground').'">'.$letters.'</text>'
166
+            .'</svg>';
167
+
168
+        return ['href' => 'data:image/svg+xml,'.rawurlencode($svg), 'type' => 'image/svg+xml', 'touch' => null];
169
+    }
170
+
171
+    /**
172
+     * Up to two letters: the first letters of the first two words. Keep in step with initials() in logo.tsx.
173
+     */
174
+    public function initials(string $name): string
175
+    {
176
+        $words = preg_split('/\s+/u', trim((string) preg_replace('/[^\p{L}\p{N}\s]/u', ' ', $name)), -1, PREG_SPLIT_NO_EMPTY) ?: [];
177
+
178
+        $letters = count($words) > 1
179
+            ? mb_substr($words[0], 0, 1).mb_substr($words[1], 0, 1)
180
+            : mb_substr($words[0] ?? '?', 0, 2);
181
+
182
+        return mb_strtoupper($letters);
183
+    }
184
+
185
+    /**
186
+     * The logo on a square see-through canvas, with plain edges (see-through or one solid colour) cut off first. Null when the logo is too wide to read.
187
+     */
188
+    private function squareIcon(GdImage $image): ?string
189
+    {
190
+        $trimmed = @imagecropauto($image, IMG_CROP_SIDES);
191
+        $image = $trimmed instanceof GdImage ? $trimmed : $image;
192
+        $width = imagesx($image);
193
+        $height = imagesy($image);
194
+
195
+        if ($width / max(1, $height) > self::ICON_MAX_RATIO || $height / max(1, $width) > self::ICON_MAX_RATIO) {
196
+            return null;
197
+        }
198
+
199
+        // A little room around the logo, so it does not touch the edges of the tab icon.
200
+        $inner = (int) round(self::ICON_SIDE * 0.9);
201
+        $scale = min($inner / $width, $inner / $height);
202
+        $newWidth = max(1, (int) round($width * $scale));
203
+        $newHeight = max(1, (int) round($height * $scale));
204
+
205
+        $canvas = imagecreatetruecolor(self::ICON_SIDE, self::ICON_SIDE);
206
+        imagealphablending($canvas, false);
207
+        imagesavealpha($canvas, true);
208
+        imagefill($canvas, 0, 0, imagecolorallocatealpha($canvas, 0, 0, 0, 127));
209
+        imagecopyresampled($canvas, $image, intdiv(self::ICON_SIDE - $newWidth, 2), intdiv(self::ICON_SIDE - $newHeight, 2), 0, 0, $newWidth, $newHeight, $width, $height);
210
+
211
+        ob_start();
212
+        imagepng($canvas, null, 9);
114
 
213
 
115
-        $this->replace($store, ['type' => 'upload', 'path' => $path, 'width' => $newWidth, 'height' => $newHeight]);
214
+        return (string) ob_get_clean();
116
     }
215
     }
117
 
216
 
118
     public function useDesign(Store $store, string $key): void
217
     public function useDesign(Store $store, string $key): void
192
         $store->save();
291
         $store->save();
193
 
292
 
194
         if (($old['type'] ?? null) === 'upload' && ($old['path'] ?? null) !== ($logo['path'] ?? null)) {
293
         if (($old['type'] ?? null) === 'upload' && ($old['path'] ?? null) !== ($logo['path'] ?? null)) {
195
-            Storage::disk('public')->delete($old['path']);
294
+            Storage::disk('public')->delete(array_filter([$old['path'], $old['icon_path'] ?? null]));
196
         }
295
         }
197
     }
296
     }
198
 
297
 

+ 29
- 0
resources/js/components/stores/logo-box.tsx Zobrazit soubor

19
 import type {
19
 import type {
20
     FontMap,
20
     FontMap,
21
     LogoDesignKey,
21
     LogoDesignKey,
22
+    StoreIcon,
22
     StoreLogoData,
23
     StoreLogoData,
23
     Theme,
24
     Theme,
24
 } from '@/storefront/types';
25
 } from '@/storefront/types';
26
 
27
 
27
 export type LogoSettings = {
28
 export type LogoSettings = {
28
     current: StoreLogoData | null;
29
     current: StoreLogoData | null;
30
+    /** The browser tab icon made from the logo, or from the store's initials. */
31
+    icon: StoreIcon;
29
     /** The words the logo shows: the store header's words. */
32
     /** The words the logo shows: the store header's words. */
30
     name: string;
33
     name: string;
31
     designs: LogoDesignKey[];
34
     designs: LogoDesignKey[];
166
                     <InputError message={errors.logo} />
169
                     <InputError message={errors.logo} />
167
                 </div>
170
                 </div>
168
 
171
 
172
+                {/* The browser tab */}
173
+                <div className="space-y-2">
174
+                    <p className="text-sm font-medium">In the browser tab</p>
175
+                    <div
176
+                        className="inline-flex max-w-full items-center gap-2 rounded-t-lg border border-b-0 bg-muted/60 px-3 py-2 text-xs"
177
+                        data-test="tab-icon"
178
+                    >
179
+                        <img
180
+                            src={logo.icon.href}
181
+                            alt=""
182
+                            width={16}
183
+                            height={16}
184
+                            className="size-4 shrink-0"
185
+                        />
186
+                        <span className="truncate">{logo.name}</span>
187
+                    </div>
188
+                    <p className="text-xs text-muted-foreground">
189
+                        {logo.current?.type === 'upload' &&
190
+                        logo.icon.type === 'image/png'
191
+                            ? 'Made from your uploaded logo.'
192
+                            : logo.current?.type === 'upload'
193
+                              ? 'Your logo is too wide to read this small, so the tab shows your initials in your main colour. Upload a squarer logo to use it here.'
194
+                              : 'Your initials in your main colour. Upload a squarish logo to use it here instead.'}
195
+                    </p>
196
+                </div>
197
+
169
                 {/* Upload */}
198
                 {/* Upload */}
170
                 <form onSubmit={send} className="space-y-2" noValidate>
199
                 <form onSubmit={send} className="space-y-2" noValidate>
171
                     <p className="text-sm font-medium">Upload your own</p>
200
                     <p className="text-sm font-medium">Upload your own</p>

+ 27
- 4
resources/js/storefront/sections/footer.tsx Zobrazit soubor

1
 import { cn } from '@/lib/utils';
1
 import { cn } from '@/lib/utils';
2
 import { useStorefront } from '../context';
2
 import { useStorefront } from '../context';
3
+import { StoreLogo } from '../logo';
3
 import { storefrontText } from '../text';
4
 import { storefrontText } from '../text';
4
 import type { FooterSection } from '../types';
5
 import type { FooterSection } from '../types';
5
 import { Container, SfLink } from '../ui';
6
 import { Container, SfLink } from '../ui';
24
             >
25
             >
25
                 <Container className="grid gap-10 py-14 text-sm sm:grid-cols-2 md:grid-cols-[2fr_1fr_1fr]">
26
                 <Container className="grid gap-10 py-14 text-sm sm:grid-cols-2 md:grid-cols-[2fr_1fr_1fr]">
26
                     <div>
27
                     <div>
27
-                        <p className="sf-heading text-2xl font-semibold">
28
-                            {storeName}
29
-                        </p>
28
+                        {shop.logo ? (
29
+                            <StoreLogo
30
+                                logo={shop.logo}
31
+                                name={storeName}
32
+                                className="h-10 md:h-11"
33
+                            />
34
+                        ) : (
35
+                            <p className="sf-heading text-2xl font-semibold">
36
+                                {storeName}
37
+                            </p>
38
+                        )}
30
                         <p className="mt-3 max-w-sm text-(--sf-muted)">
39
                         <p className="mt-3 max-w-sm text-(--sf-muted)">
31
                             {text}
40
                             {text}
32
                         </p>
41
                         </p>
99
                         : 'sm:flex-row sm:items-center sm:justify-between',
108
                         : 'sm:flex-row sm:items-center sm:justify-between',
100
                 )}
109
                 )}
101
             >
110
             >
102
-                <p>{text}</p>
111
+                <div
112
+                    className={cn(
113
+                        'flex flex-col gap-3',
114
+                        centered ? 'items-center' : 'items-start',
115
+                    )}
116
+                >
117
+                    {shop.logo && (
118
+                        <StoreLogo
119
+                            logo={shop.logo}
120
+                            name={storeName}
121
+                            className="h-8 md:h-9"
122
+                        />
123
+                    )}
124
+                    <p>{text}</p>
125
+                </div>
103
                 {links.length > 0 && (
126
                 {links.length > 0 && (
104
                     <nav aria-label="Footer" className="flex flex-wrap gap-5">
127
                     <nav aria-label="Footer" className="flex flex-wrap gap-5">
105
                         {links.map((link) => (
128
                         {links.map((link) => (

+ 9
- 0
resources/js/storefront/types.ts Zobrazit soubor

366
     whatsapp: string | null;
366
     whatsapp: string | null;
367
     /** The store's logo, or null to show its name. */
367
     /** The store's logo, or null to show its name. */
368
     logo?: StoreLogoData | null;
368
     logo?: StoreLogoData | null;
369
+    /** The browser tab icon: the uploaded logo, or the store's initials. */
370
+    icon?: StoreIcon;
369
     /** In ringgit. Orders at or above this ship free. */
371
     /** In ringgit. Orders at or above this ship free. */
370
     free_shipping_over: number | null;
372
     free_shipping_over: number | null;
371
     /** Collections with at least one product shoppers can see. */
373
     /** Collections with at least one product shoppers can see. */
412
 };
414
 };
413
 
415
 
414
 /** A store's logo: an uploaded picture, one of the ready designs, or a cleaned drawing by the AI. */
416
 /** A store's logo: an uploaded picture, one of the ready designs, or a cleaned drawing by the AI. */
417
+export type StoreIcon = {
418
+    href: string;
419
+    type: string;
420
+    /** For phone home screens; only when the merchant uploaded a logo. */
421
+    touch: string | null;
422
+};
423
+
415
 export type StoreLogoData =
424
 export type StoreLogoData =
416
     | { type: 'upload'; url: string; width: number; height: number }
425
     | { type: 'upload'; url: string; width: number; height: number }
417
     | { type: 'design'; key: LogoDesignKey }
426
     | { type: 'design'; key: LogoDesignKey }

+ 12
- 3
resources/views/app.blade.php Zobrazit soubor

30
             }
30
             }
31
         </style>
31
         </style>
32
 
32
 
33
-        <link rel="icon" href="/favicon.ico" sizes="any">
34
-        <link rel="icon" href="/favicon.svg" type="image/svg+xml">
35
-        <link rel="apple-touch-icon" href="/apple-touch-icon.png">
33
+        {{-- A store's pages show the store's own icon, made from its logo or its initials. --}}
34
+        @php($storeIcon = $page['props']['shop']['icon'] ?? null)
35
+        @if (is_array($storeIcon))
36
+            <link rel="icon" href="{{ $storeIcon['href'] }}" type="{{ $storeIcon['type'] }}">
37
+            @if ($storeIcon['touch'])
38
+                <link rel="apple-touch-icon" href="{{ $storeIcon['touch'] }}">
39
+            @endif
40
+        @else
41
+            <link rel="icon" href="/favicon.ico" sizes="any">
42
+            <link rel="icon" href="/favicon.svg" type="image/svg+xml">
43
+            <link rel="apple-touch-icon" href="/apple-touch-icon.png">
44
+        @endif
36
 
45
 
37
         @fonts
46
         @fonts
38
 
47
 

+ 2
- 1
tests/Feature/Dashboard/OverviewTest.php Zobrazit soubor

217
         config(['ai.tasks.pulse.provider' => 'missing']);
217
         config(['ai.tasks.pulse.provider' => 'missing']);
218
         $user = User::factory()->create();
218
         $user = User::factory()->create();
219
         $store = Store::factory()->for($user)->create();
219
         $store = Store::factory()->for($user)->create();
220
-        $this->paidOrder($store, 12000, '-1 day');
220
+        // Paid now, not yesterday: on the 1st of a month, yesterday is last month.
221
+        $this->paidOrder($store, 12000);
221
 
222
 
222
         $pulse = app(StorePulse::class)->today($user, null);
223
         $pulse = app(StorePulse::class)->today($user, null);
223
 
224
 

+ 50
- 0
tests/Feature/Stores/StoreLogoTest.php Zobrazit soubor

74
         Storage::disk('public')->assertMissing($logo['path']);
74
         Storage::disk('public')->assertMissing($logo['path']);
75
     }
75
     }
76
 
76
 
77
+    public function test_a_squarish_uploaded_logo_becomes_the_browser_tab_icon()
78
+    {
79
+        $this->post(route('stores.logo.upload', $this->store->slug), ['logo' => $this->png(1600, 400)]);
80
+
81
+        // The see-through edges are cut off, so the small red square fills the icon.
82
+        $logo = $this->store->fresh()->logo;
83
+        Storage::disk('public')->assertExists($logo['icon_path']);
84
+        $this->assertSame([180, 180], array_slice(getimagesizefromstring(Storage::disk('public')->get($logo['icon_path'])), 0, 2));
85
+
86
+        $url = Storage::disk('public')->url($logo['icon_path']);
87
+        $this->get(route('stores.preview', $this->store->slug))
88
+            ->assertSee('<link rel="icon" href="'.$url.'" type="image/png">', false)
89
+            ->assertSee('<link rel="apple-touch-icon" href="'.$url.'">', false)
90
+            ->assertDontSee('/favicon.svg', false);
91
+
92
+        // Removing the logo removes its icon too.
93
+        $this->delete(route('stores.logo.destroy', $this->store->slug));
94
+        Storage::disk('public')->assertMissing($logo['icon_path']);
95
+    }
96
+
97
+    public function test_a_store_without_a_usable_picture_shows_its_initials_in_the_tab()
98
+    {
99
+        // No logo: the initials on the store's main colour, never our own icon.
100
+        $primary = $this->store->plan['theme']['colors']['primary'];
101
+        $this->get(route('stores.preview', $this->store->slug))
102
+            ->assertSee('data:image/svg+xml,', false)
103
+            ->assertSee(rawurlencode('>KA</text>'), false)
104
+            ->assertSee(rawurlencode('fill="'.$primary.'"'), false)
105
+            ->assertDontSee('/favicon.svg', false)
106
+            ->assertDontSee('apple-touch-icon', false);
107
+
108
+        // The round monogram design gets a round icon.
109
+        $this->put(route('stores.logo.choose', $this->store->slug), ['design' => 'monogram-circle']);
110
+        $this->get(route('stores.preview', $this->store->slug))->assertSee(rawurlencode('rx="32"'), false);
111
+
112
+        // A wide, solid logo is too thin to read as an icon.
113
+        $image = imagecreatetruecolor(900, 200);
114
+        imagefill($image, 0, 0, imagecolorallocate($image, 20, 120, 60));
115
+        $path = tempnam(sys_get_temp_dir(), 'logo').'.png';
116
+        imagepng($image, $path);
117
+        $this->post(route('stores.logo.upload', $this->store->slug), ['logo' => new UploadedFile($path, 'wide.png', 'image/png', null, true)])
118
+            ->assertSessionHasNoErrors();
119
+
120
+        $this->assertArrayNotHasKey('icon_path', $this->store->fresh()->logo);
121
+        $this->get(route('stores.show', $this->store->slug))
122
+            ->assertInertia(fn (Assert $page) => $page->where('logo.icon.type', 'image/svg+xml'))
123
+            // The merchant's own dashboard keeps our icon.
124
+            ->assertSee('/favicon.svg', false);
125
+    }
126
+
77
     public function test_uploads_are_checked()
127
     public function test_uploads_are_checked()
78
     {
128
     {
79
         $this->post(route('stores.logo.upload', $this->store->slug), ['logo' => $this->png(40, 40)])
129
         $this->post(route('stores.logo.upload', $this->store->slug), ['logo' => $this->png(40, 40)])

Načítá se…
Zrušit
Uložit