Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added: Drag and Reject effect on upload component #174

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/docs/components/button/button.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { KeepButtonTypeCode, KeepButtonType } from './variant/KeepButtonType'
import { KeepButtonColor, KeepButtonColorCode } from './variant/KeepButtonColor'
import { KeepButtonSize, KeepButtonSizeCode } from './variant/KeepButtonSize'
import { KeepButtonLink, KeepButtonLinkCode } from './variant/KeepButtonLink'
import { KeepButtonShape, KeepButtonShapeCode } from './variant/KeepButtonShape'
import { KeepButtonIcon, KeepButtonIconCode } from './variant/KeepButtonIcon'
import { DefaultButton, DefaultButtonCode } from './variant/DefaultButton'
Expand Down Expand Up @@ -29,6 +30,14 @@ You can customize your buttons with different color schemes to match your design
<KeepButtonColor />
</CodeHighlightPreview>

## Button with link

You can add a link to a button component by passing asChild props.

<CodeHighlightPreview code={KeepButtonLinkCode}>
<KeepButtonLink />
</CodeHighlightPreview>

## Button Variant Type

Choose from different button types depending on your use case. The available types include: `default` `softBg` `outline` and `link`.
Expand Down
7 changes: 7 additions & 0 deletions app/docs/components/button/buttonApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ export const buttonApiData = [
propsDescription: 'Size variant of the button.',
default: 'md',
},
{
id: 7,
propsName: 'asChild',
propsType: ['true', 'false'],
propsDescription: 'Set button styles and functionality to her child component.',
default: 'false',
},
]
29 changes: 29 additions & 0 deletions app/docs/components/button/variant/KeepButtonLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use client'
import Link from 'next/link'
import { Button } from '../../../../src'

const KeepButtonLink = () => {
return (
<div className="flex items-center justify-center gap-x-5 px-5 py-3">
<Button asChild>
<Link href="#">Link Button</Link>
</Button>
</div>
)
}

const KeepButtonLinkCode = {
'ButtonComponent.tsx': `
import { Button } from 'keep-react'

export const ButtonComponent = () => {
return (
<Button asChild>
<Link href="#">Link Button</Link>
</Button>
)
}
`,
}

export { KeepButtonLink, KeepButtonLinkCode }
5 changes: 4 additions & 1 deletion app/docs/components/modal/variant/DefaultModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Button,
Modal,
ModalAction,
ModalClose,
ModalContent,
ModalDescription,
ModalFooter,
Expand Down Expand Up @@ -31,7 +32,9 @@ const DefaultModal = () => {
</div>
</ModalHeader>
<ModalFooter>
<Button variant="outline">Cancel</Button>
<ModalClose asChild>
<Button variant="outline">Cancel</Button>
</ModalClose>
<Button>Confirm</Button>
</ModalFooter>
</ModalContent>
Expand Down
8 changes: 6 additions & 2 deletions app/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client'
import { ButtonHTMLAttributes, Ref, forwardRef } from 'react'
import { Slot } from '@radix-ui/react-slot'
import { cn } from '../../utils/cn'
import { ButtonColorVariant, ButtonSizeVariant, buttonVariants } from './theme'

Expand All @@ -9,6 +10,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'link' | 'outline' | 'softBg' | 'default'
shape?: 'circle' | 'icon'
position?: 'start' | 'end' | 'center'
asChild?: boolean
radius?: 'default' | 'full'
}

Expand All @@ -22,18 +24,20 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
variant = 'default',
radius = 'default',
shape,
asChild = false,
position,
...props
},
ref: Ref<HTMLButtonElement>,
) => {
const Comp = asChild ? Slot : 'button'
return (
<button
<Comp
{...props}
ref={ref}
className={cn(buttonVariants({ size, color, variant, shape, position, radius }), className)}>
{children}
</button>
</Comp>
)
},
)
Expand Down
4 changes: 3 additions & 1 deletion app/src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'
import { Portal, Trigger } from '@radix-ui/react-dialog'
import { Close, Portal, Trigger } from '@radix-ui/react-dialog'
import type { ModalProps } from './Modal'
import { Modal } from './Modal'
import { ModalContent } from './ModalContent'
Expand All @@ -11,9 +11,11 @@ import { ModalTitle } from './ModalTitle'

const ModalAction = Trigger
const ModalPortal = Portal
const ModalClose = Close

export {
Modal,
ModalClose,
ModalAction,
ModalContent,
ModalDescription,
Expand Down
9 changes: 5 additions & 4 deletions app/src/components/Upload/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import { useUploadContext } from './UploadContext'
const UploadBody = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ children, className, ...props }, ref: Ref<HTMLDivElement>) => {
const { options, horizontal } = useUploadContext()
const { getRootProps, getInputProps } = useDropzone(options)
const { getRootProps, getInputProps, isDragActive, isDragReject } = useDropzone(options)
return (
<div
{...props}
ref={ref}
{...getRootProps()}
className={cn(
horizontal
? 'flex cursor-pointer items-center gap-4 rounded-xl border border-dashed bg-white px-3 transition-all duration-300 hover:bg-metal-25 dark:border-metal-800 dark:bg-metal-900 dark:hover:bg-metal-900'
: 'flex cursor-pointer flex-col items-center rounded-xl border border-dashed border-metal-50 bg-white p-3 text-center transition-all duration-300 hover:bg-metal-25 dark:border-metal-800 dark:bg-metal-900 dark:hover:bg-metal-900',
'flex cursor-pointer items-center rounded-xl border border-dashed bg-white transition-all duration-300 hover:bg-metal-25 dark:border-metal-800 dark:bg-metal-900 dark:hover:bg-metal-900',
horizontal ? 'gap-4 px-3' : 'flex-col border-metal-50 p-3 text-center',
isDragActive && 'border-primary-500 dark:border-primary-400',
isDragReject && 'border-error-500 dark:border-error-500',
className,
)}>
<input {...getInputProps()} />
Expand Down
Loading