Skip to content

Commit

Permalink
fix input focus bug (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliang-stripe authored Jun 18, 2024
1 parent ec67206 commit e6ec9e7
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 73 deletions.
2 changes: 1 addition & 1 deletion app/components/Screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Screen({
{/* Tools Panel container */}
<div
className={`${open ? 'translate-y-0 md:translate-x-0' : 'translate-y-full md:-translate-x-full md:translate-y-0'}
fixed bottom-0 z-[50] w-full overflow-hidden rounded-t-2xl bg-screen-foreground shadow-[0px_-4px_32px_rgba(0,0,0,0.15)] transition duration-500 ease-in-out md:h-screen md:w-[300px] md:rounded-none md:border-r md:shadow-none`}
z-45 fixed bottom-0 w-full overflow-hidden rounded-t-2xl bg-screen-foreground shadow-[0px_-4px_32px_rgba(0,0,0,0.15)] transition duration-500 ease-in-out md:h-screen md:w-[300px] md:rounded-none md:border-r md:shadow-none`}
>
<ToolsPanel />
</div>
Expand Down
70 changes: 34 additions & 36 deletions app/components/testdata/CreateCheckoutSessionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,28 @@ export default function CreateCheckoutSessionButton({
}
};

const CreateCheckoutSessionForm = () => {
return (
<>
return (
<Dialog>
<DialogTrigger asChild>
<Button className={`${classes || 'border'}`} variant="ghost" size="sm">
Create test Checkout Session
</Button>
</DialogTrigger>
<DialogContent className="p-4 text-primary sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Create test Checkout Session</DialogTitle>
<DialogDescription>
Simulate a grooming payment by creating a{' '}
<a
target="blank"
className="font-medium text-accent"
href="https://stripe.com/docs/api/checkout/sessions"
>
Checkout Session
</a>
.
</DialogDescription>
</DialogHeader>
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
<FormField
Expand All @@ -150,12 +169,18 @@ export default function CreateCheckoutSessionButton({
<FormItem>
<FormLabel>Amount</FormLabel>
<FormControl>
<Input
{...field}
placeholder="Leave blank for a random amount"
type="number"
step="0.01"
/>
<div className="relative">
<div className="absolute left-3 top-1/2 -translate-y-1/2">
$
</div>
<Input
{...field}
placeholder="Leave blank for a random amount"
className="pl-7"
type="number"
step="0.01"
/>
</div>
</FormControl>
<FormMessage />
</FormItem>
Expand Down Expand Up @@ -192,33 +217,6 @@ export default function CreateCheckoutSessionButton({
</div>
</form>
</Form>
</>
);
};

return (
<Dialog>
<DialogTrigger asChild>
<Button className={`${classes || 'border'}`} variant="ghost" size="sm">
Create test Checkout Session
</Button>
</DialogTrigger>
<DialogContent className="p-4 text-primary sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Create test Checkout Session</DialogTitle>
<DialogDescription>
Simulate a grooming payment by creating a{' '}
<a
target="blank"
className="font-medium text-accent"
href="https://stripe.com/docs/api/checkout/sessions"
>
Checkout Session
</a>
.
</DialogDescription>
</DialogHeader>
<CreateCheckoutSessionForm />
</DialogContent>
</Dialog>
);
Expand Down
71 changes: 35 additions & 36 deletions app/components/testdata/CreatePaymentsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,29 @@ export default function CreatePaymentsButton({classes}: {classes?: string}) {
}
};

const CreatePaymentsForm = () => {
return (
<>
return (
<Dialog>
<DialogTrigger asChild>
<Button className={`${classes || 'border'}`} variant="ghost" size="sm">
Create test payments
</Button>
</DialogTrigger>
<DialogContent className="p-4 text-primary sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Create test payments</DialogTitle>
<DialogDescription>
Simulate a grooming session by using a testmode payment method to{' '}
<a
target="blank"
className="font-medium text-accent"
href="https://stripe.com/docs/api/payment_intents"
>
create a payment intent
</a>
.
</DialogDescription>
</DialogHeader>

<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
<FormField
Expand All @@ -176,12 +196,18 @@ export default function CreatePaymentsButton({classes}: {classes?: string}) {
<FormItem>
<FormLabel>Amount</FormLabel>
<FormControl>
<Input
{...field}
placeholder="Leave blank for a random amount"
type="number"
step="0.01"
/>
<div className="relative">
<div className="absolute left-3 top-1/2 -translate-y-1/2">
$
</div>
<Input
{...field}
placeholder="Leave blank for a random amount"
className="pl-7"
type="number"
step="0.01"
/>
</div>
</FormControl>
<FormMessage />
</FormItem>
Expand Down Expand Up @@ -247,33 +273,6 @@ export default function CreatePaymentsButton({classes}: {classes?: string}) {
</div>
</form>
</Form>
</>
);
};

return (
<Dialog>
<DialogTrigger asChild>
<Button className={`${classes || 'border'}`} variant="ghost" size="sm">
Create test payments
</Button>
</DialogTrigger>
<DialogContent className="p-4 text-primary sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Create test payments</DialogTitle>
<DialogDescription>
Simulate a grooming session by using a testmode payment method to{' '}
<a
target="blank"
className="font-medium text-accent"
href="https://stripe.com/docs/api/payment_intents"
>
create a payment intent
</a>
.
</DialogDescription>
</DialogHeader>
<CreatePaymentsForm />
</DialogContent>
</Dialog>
);
Expand Down

0 comments on commit e6ec9e7

Please sign in to comment.