also looking at this
fix(auth): keep sign-in inputs at 16px so iOS does not zoom on focus
#8
2 files
+24
-2
| @@ -0,0 +1,22 @@ | ||
| 1 | import { describe, expect, it } from 'bun:test' | |
| 2 | import { readFileSync } from 'node:fs' | |
| 3 | import { join } from 'node:path' | |
| 4 | ||
| 5 | const auth = readFileSync(join(import.meta.dir, '../../resources/views/layouts/auth.stx'), 'utf8') | |
| 6 | ||
| 7 | // iOS Safari zooms the page when a focused input's font-size is under 16px, | |
| 8 | // and leaves it zoomed and scrolled sideways afterwards. The sign-in and | |
| 9 | // sign-up forms are the first thing a phone user types into. | |
| 10 | describe('mobile layout contracts', () => { | |
| 11 | it('keeps auth inputs at 16px so iOS does not zoom on focus', () => { | |
| 12 | const field = auth.match(/\.field\s*\{[^}]*\}/)?.[0] ?? '' | |
| 13 | const size = Number(field.match(/font:\s*\d+\s+(\d+(?:\.\d+)?)px/)?.[1]) | |
| 14 | expect(size).toBeGreaterThanOrEqual(16) | |
| 15 | }) | |
| 16 | ||
| 17 | it('leaves pinch-zoom available on the auth pages', () => { | |
| 18 | const viewport = auth.match(/<meta name="viewport" content="([^"]+)"/)?.[1] ?? '' | |
| 19 | expect(viewport).toContain('width=device-width') | |
| 20 | expect(viewport).not.toMatch(/user-scalable=no|maximum-scale=1(?![.\d])/) | |
| 21 | }) | |
| 22 | }) | |