forked from calcom/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,255 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import Link from "next/link"; | ||
import { createElement } from "react"; | ||
|
||
import classNames from "@lib/classNames"; | ||
|
||
export function List(props: JSX.IntrinsicElements["ul"]) { | ||
return ( | ||
<ul {...props} className={classNames("overflow-hidden rounded-sm sm:mx-0", props.className)}> | ||
{props.children} | ||
</ul> | ||
); | ||
} | ||
|
||
export type ListItemProps = { expanded?: boolean } & ({ href?: never } & JSX.IntrinsicElements["li"]); | ||
|
||
export function ListItem(props: ListItemProps) { | ||
const { href, expanded, ...passThroughProps } = props; | ||
|
||
const elementType = href ? "a" : "li"; | ||
|
||
const element = createElement( | ||
elementType, | ||
{ | ||
...passThroughProps, | ||
className: classNames( | ||
"items-center bg-white min-w-0 flex-1 flex border-gray-200", | ||
expanded ? "my-2 border" : "border -mb-px last:mb-0", | ||
props.className, | ||
(props.onClick || href) && "hover:bg-neutral-50" | ||
), | ||
}, | ||
props.children | ||
); | ||
|
||
return href ? ( | ||
<Link passHref href={href}> | ||
{element} | ||
</Link> | ||
) : ( | ||
element | ||
); | ||
} | ||
|
||
export function ListItemTitle<TComponent extends keyof JSX.IntrinsicElements = "span">( | ||
props: JSX.IntrinsicElements[TComponent] & { component?: TComponent } | ||
) { | ||
const { component = "span", ...passThroughProps } = props; | ||
|
||
return createElement( | ||
component, | ||
{ | ||
...passThroughProps, | ||
className: classNames("text-sm font-medium text-neutral-900 truncate", props.className), | ||
}, | ||
props.children | ||
); | ||
} | ||
|
||
export function ListItemText<TComponent extends keyof JSX.IntrinsicElements = "span">( | ||
props: JSX.IntrinsicElements[TComponent] & { component?: TComponent } | ||
) { | ||
const { component = "span", ...passThroughProps } = props; | ||
|
||
return createElement( | ||
component, | ||
{ | ||
...passThroughProps, | ||
className: classNames("text-sm text-gray-500", props.className), | ||
}, | ||
props.children | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { useId } from "@radix-ui/react-id"; | ||
import { forwardRef, ReactNode } from "react"; | ||
import { FormProvider, UseFormReturn } from "react-hook-form"; | ||
|
||
import classNames from "@lib/classNames"; | ||
|
||
export const Input = forwardRef<HTMLInputElement, JSX.IntrinsicElements["input"]>(function Input(props, ref) { | ||
return ( | ||
<input | ||
{...props} | ||
ref={ref} | ||
className={classNames( | ||
"mt-1 block w-full border border-gray-300 rounded-sm shadow-sm py-2 px-3 focus:outline-none focus:ring-neutral-500 focus:border-neutral-500 sm:text-sm", | ||
props.className | ||
)} | ||
/> | ||
); | ||
}); | ||
|
||
export function Label(props: JSX.IntrinsicElements["label"]) { | ||
return ( | ||
<label {...props} className={classNames("block text-sm font-medium text-gray-700", props.className)}> | ||
{props.children} | ||
</label> | ||
); | ||
} | ||
|
||
export const TextField = forwardRef< | ||
HTMLInputElement, | ||
{ | ||
label: ReactNode; | ||
} & React.ComponentProps<typeof Input> & { | ||
labelProps?: React.ComponentProps<typeof Label>; | ||
} | ||
>(function TextField(props, ref) { | ||
const id = useId(); | ||
const { label, ...passThroughToInput } = props; | ||
|
||
// TODO: use `useForm()` from RHF and get error state here too! | ||
return ( | ||
<div> | ||
<Label htmlFor={id} {...props.labelProps}> | ||
{label} | ||
</Label> | ||
<Input id={id} {...passThroughToInput} ref={ref} /> | ||
</div> | ||
); | ||
}); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const Form = forwardRef<HTMLFormElement, { form: UseFormReturn<any> } & JSX.IntrinsicElements["form"]>( | ||
function Form(props, ref) { | ||
const { form, ...passThrough } = props; | ||
|
||
return ( | ||
<FormProvider {...form}> | ||
<form ref={ref} {...passThrough}> | ||
{props.children} | ||
</form> | ||
</FormProvider> | ||
); | ||
} | ||
); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.