Skip to content

Commit

Permalink
chore(ui): Add ios-support conditions for inputs to prevent zoom (#4111)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcarpenter authored Sep 6, 2024
1 parent 126f8da commit 3c22b10
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .changeset/gold-crabs-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
8 changes: 4 additions & 4 deletions packages/ui/src/common/phone-number-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const PhoneNumberField = React.forwardRef(function PhoneNumberField(
// - To create the overlapping border/shadow effect"
// - `ring` – "focus ring"
// - `ring-offset` - border
'[--phone-number-field-py:theme(spacing[1.5])]',
'supports-ios:[--phone-number-field-py:theme(spacing.1)] [--phone-number-field-py:theme(spacing[1.5])]',
'[--phone-number-field-px:theme(spacing.3)]',
'ring ring-transparent ring-offset-1 ring-offset-[--cl-phone-number-field-border]',
'text-gray-12 relative flex min-w-0 rounded-md bg-white text-base outline-none',
Expand Down Expand Up @@ -237,7 +237,7 @@ export const PhoneNumberField = React.forwardRef(function PhoneNumberField(
<Command.Input
ref={commandInputRef}
placeholder='Search country or code'
className='leading-small bg-gray-2 placeholder:text-gray-9 text-gray-12 border-gray-4 w-full rounded-[calc(theme(borderRadius.md)-2px)] border px-2 py-1.5 text-base outline-none'
className='leading-small bg-gray-2 placeholder:text-gray-9 text-gray-12 border-gray-4 supports-ios:py-1 supports-ios:text-[length:1rem] w-full rounded-[calc(theme(borderRadius.md)-2px)] border px-2 py-1.5 text-base outline-none'
/>
</div>
<Command.List
Expand Down Expand Up @@ -277,7 +277,7 @@ export const PhoneNumberField = React.forwardRef(function PhoneNumberField(
type='button'
// Prevent tab stop
tabIndex={-1}
className='grid cursor-text place-content-center bg-white px-1 text-base'
className='supports-ios:text-[length:1rem] grid cursor-text place-content-center bg-white px-1 text-base'
onClick={() => inputRef.current?.focus()}
disabled={props.disabled}
>
Expand All @@ -296,7 +296,7 @@ export const PhoneNumberField = React.forwardRef(function PhoneNumberField(
onPaste={handlePaste}
onChange={handlePhoneNumberChange}
{...props}
className='w-full rounded-r-md bg-white py-[--phone-number-field-py] pr-[--phone-number-field-px] text-base outline-none'
className='supports-ios:text-[length:1rem] w-full rounded-r-md bg-white py-[--phone-number-field-py] pr-[--phone-number-field-px] text-base outline-none'
data-field-input
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/primitives/field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Root = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDi
className={cx(
'[--field-input-height:1.875rem]',
'[--field-input-px:theme(spacing.3)]',
'[--field-input-py:theme(spacing[1.5])]',
'supports-ios:[--field-input-py:theme(spacing.1)] [--field-input-py:theme(spacing[1.5])]',
'[--field-input-group-end-size:--field-input-height]',
'has-[[data-field-checkbox]]:[--cl-field-label-cursor:pointer]',
'has-[[data-field-input][disabled]]:[--cl-field-label-opacity:0.5]',
Expand Down Expand Up @@ -175,6 +175,7 @@ export const Input = React.forwardRef(function FieldInput(
'text-gray-12 relative flex min-w-0 items-center rounded-md bg-white text-base outline-none ring ring-offset-1',
'shadow-[0px_1px_1px_0px_theme(colors.gray.a3)]',
'disabled:cursor-not-allowed disabled:opacity-50',
'supports-ios:text-[length:1rem] supports-ios:min-h-[1.875rem]',
// variant
{
default: 'w-full justify-start',
Expand Down
7 changes: 6 additions & 1 deletion packages/ui/src/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const config = {
},
},
plugins: [
plugin(function ({ addBase, theme }) {
plugin(function ({ addBase, addVariant, theme }) {
/**
* Extends Tailwind's built-in `addBase` function by scoping styles to
* only affect components within the `@clerk/ui` package.
Expand Down Expand Up @@ -469,6 +469,11 @@ const config = {
fontFamily: 'var(--cl-font-family)',
},
});

/**
* Conditionally apply CSS to ios devices
*/
addVariant('supports-ios', '@supports (-webkit-touch-callout: none)');
}),
],
} satisfies Config;
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/theme-builder/app/theme-builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export function ThemeBuilder({ children }: { children: React.ReactNode }) {
</div>
</header>

<aside className='relative isolate flex h-full w-[17rem] flex-col justify-between gap-8 overflow-y-auto border-e bg-white p-4'>
<aside className='relative isolate hidden h-full w-[17rem] flex-col justify-between gap-8 overflow-y-auto border-e bg-white p-4 sm:flex'>
<div className='space-y-4'>
<AppearanceOptions />
{appearance === 'light' ? (
Expand Down Expand Up @@ -265,7 +265,7 @@ export function ThemeBuilder({ children }: { children: React.ReactNode }) {
</aside>

<figure
className={cx('relative isolate grid items-center overflow-y-auto p-8', {
className={cx('relative isolate grid items-center overflow-y-auto p-8 max-sm:[grid-column:1/-1]', {
'bg-white': appearance === 'light',
'dark bg-neutral-950': appearance === 'dark',
})}
Expand Down

0 comments on commit 3c22b10

Please sign in to comment.