-
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.
Co-Authored-By: Joaovitor045 <joaovitoralvestf@gmail.com> Co-Authored-By: gsVieiraaa <Gabriel.vieira.santos.110@gmail.com>
- Loading branch information
1 parent
9d02dc3
commit 5978267
Showing
38 changed files
with
7,207 additions
and
1,490 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,74 @@ | ||
"use client" | ||
|
||
import type { GroupProps, SlotRecipeProps } from "@chakra-ui/react" | ||
import { Avatar as ChakraAvatar, Group } from "@chakra-ui/react" | ||
import * as React from "react" | ||
|
||
type ImageProps = React.ImgHTMLAttributes<HTMLImageElement> | ||
|
||
export interface AvatarProps extends ChakraAvatar.RootProps { | ||
name?: string | ||
src?: string | ||
srcSet?: string | ||
loading?: ImageProps["loading"] | ||
icon?: React.ReactElement | ||
fallback?: React.ReactNode | ||
} | ||
|
||
export const Avatar = React.forwardRef<HTMLDivElement, AvatarProps>( | ||
function Avatar(props, ref) { | ||
const { name, src, srcSet, loading, icon, fallback, children, ...rest } = | ||
props | ||
return ( | ||
<ChakraAvatar.Root ref={ref} {...rest}> | ||
<AvatarFallback name={name} icon={icon}> | ||
{fallback} | ||
</AvatarFallback> | ||
<ChakraAvatar.Image src={src} srcSet={srcSet} loading={loading} /> | ||
{children} | ||
</ChakraAvatar.Root> | ||
) | ||
}, | ||
) | ||
|
||
interface AvatarFallbackProps extends ChakraAvatar.FallbackProps { | ||
name?: string | ||
icon?: React.ReactElement | ||
} | ||
|
||
const AvatarFallback = React.forwardRef<HTMLDivElement, AvatarFallbackProps>( | ||
function AvatarFallback(props, ref) { | ||
const { name, icon, children, ...rest } = props | ||
return ( | ||
<ChakraAvatar.Fallback ref={ref} {...rest}> | ||
{children} | ||
{name != null && children == null && <>{getInitials(name)}</>} | ||
{name == null && children == null && ( | ||
<ChakraAvatar.Icon asChild={!!icon}>{icon}</ChakraAvatar.Icon> | ||
)} | ||
</ChakraAvatar.Fallback> | ||
) | ||
}, | ||
) | ||
|
||
function getInitials(name: string) { | ||
const names = name.trim().split(" ") | ||
const firstName = names[0] != null ? names[0] : "" | ||
const lastName = names.length > 1 ? names[names.length - 1] : "" | ||
return firstName && lastName | ||
? `${firstName.charAt(0)}${lastName.charAt(0)}` | ||
: firstName.charAt(0) | ||
} | ||
|
||
interface AvatarGroupProps extends GroupProps, SlotRecipeProps<"avatar"> {} | ||
|
||
export const AvatarGroup = React.forwardRef<HTMLDivElement, AvatarGroupProps>( | ||
function AvatarGroup(props, ref) { | ||
const { size, variant, borderless, ...rest } = props | ||
return ( | ||
<ChakraAvatar.PropsProvider value={{ size, variant, borderless }}> | ||
<Group gap="0" spaceX="-3" ref={ref} {...rest} /> | ||
</ChakraAvatar.PropsProvider> | ||
) | ||
}, | ||
) |
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,40 @@ | ||
import type { ButtonProps as ChakraButtonProps } from "@chakra-ui/react" | ||
import { | ||
AbsoluteCenter, | ||
Button as ChakraButton, | ||
Span, | ||
Spinner, | ||
} from "@chakra-ui/react" | ||
import * as React from "react" | ||
|
||
interface ButtonLoadingProps { | ||
loading?: boolean | ||
loadingText?: React.ReactNode | ||
} | ||
|
||
export interface ButtonProps extends ChakraButtonProps, ButtonLoadingProps {} | ||
|
||
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( | ||
function Button(props, ref) { | ||
const { loading, disabled, loadingText, children, ...rest } = props | ||
return ( | ||
<ChakraButton disabled={loading || disabled} ref={ref} {...rest}> | ||
{loading && !loadingText ? ( | ||
<> | ||
<AbsoluteCenter display="inline-flex"> | ||
<Spinner size="inherit" color="inherit" /> | ||
</AbsoluteCenter> | ||
<Span opacity={0}>{children}</Span> | ||
</> | ||
) : loading && loadingText ? ( | ||
<> | ||
<Spinner size="inherit" color="inherit" /> | ||
{loadingText} | ||
</> | ||
) : ( | ||
children | ||
)} | ||
</ChakraButton> | ||
) | ||
}, | ||
) |
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,25 @@ | ||
import { Checkbox as ChakraCheckbox } from "@chakra-ui/react" | ||
import * as React from "react" | ||
|
||
export interface CheckboxProps extends ChakraCheckbox.RootProps { | ||
icon?: React.ReactNode | ||
inputProps?: React.InputHTMLAttributes<HTMLInputElement> | ||
rootRef?: React.Ref<HTMLLabelElement> | ||
} | ||
|
||
export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>( | ||
function Checkbox(props, ref) { | ||
const { icon, children, inputProps, rootRef, ...rest } = props | ||
return ( | ||
<ChakraCheckbox.Root ref={rootRef} {...rest}> | ||
<ChakraCheckbox.HiddenInput ref={ref} {...inputProps} /> | ||
<ChakraCheckbox.Control> | ||
{icon || <ChakraCheckbox.Indicator />} | ||
</ChakraCheckbox.Control> | ||
{children != null && ( | ||
<ChakraCheckbox.Label>{children}</ChakraCheckbox.Label> | ||
)} | ||
</ChakraCheckbox.Root> | ||
) | ||
}, | ||
) |
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,17 @@ | ||
import type { ButtonProps } from "@chakra-ui/react" | ||
import { IconButton as ChakraIconButton } from "@chakra-ui/react" | ||
import * as React from "react" | ||
import { LuX } from "react-icons/lu" | ||
|
||
export type CloseButtonProps = ButtonProps | ||
|
||
export const CloseButton = React.forwardRef< | ||
HTMLButtonElement, | ||
CloseButtonProps | ||
>(function CloseButton(props, ref) { | ||
return ( | ||
<ChakraIconButton variant="ghost" aria-label="Close" ref={ref} {...props}> | ||
{props.children ?? <LuX />} | ||
</ChakraIconButton> | ||
) | ||
}) |
Oops, something went wrong.