-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <i@innei.in>
- Loading branch information
Showing
12 changed files
with
258 additions
and
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"[javascript][javascriptreact][typescript][typescriptreact][json][jsonc]": { | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
} | ||
}, | ||
// If you do not want to autofix some rules on save | ||
// You can put this in your user settings or workspace settings | ||
"eslint.codeActionsOnSave.rules": [ | ||
"!unused-imports/no-unused-imports", | ||
"*" | ||
], | ||
|
||
// If you want to silent stylistic rules | ||
// You can put this in your user settings or workspace settings | ||
"eslint.rules.customizations": [ | ||
{ "rule": "@stylistic/*", "severity": "off", "fixable": true }, | ||
{ "rule": "antfu/consistent-list-newline", "severity": "off" }, | ||
{ "rule": "hyoban/jsx-attribute-spacing", "severity": "off" }, | ||
{ "rule": "simple-import-sort/*", "severity": "off" }, | ||
{ "rule": "unused-imports/no-unused-imports", "severity": "off" } | ||
] | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// Tremor Button [v0.2.0] | ||
|
||
import { Slot } from '@radix-ui/react-slot' | ||
import { RiLoader2Fill } from '@remixicon/react' | ||
import { m, motion } from 'framer-motion' | ||
import React from 'react' | ||
import type { VariantProps } from 'tailwind-variants' | ||
import { tv } from 'tailwind-variants' | ||
|
||
import { cx, focusRing } from '~/lib/cn' | ||
|
||
const buttonVariants = tv({ | ||
base: [ | ||
'relative inline-flex items-center justify-center whitespace-nowrap rounded-md text-center font-medium transition-all duration-100 ease-in-out', | ||
'disabled:pointer-events-none', | ||
focusRing, | ||
], | ||
variants: { | ||
variant: { | ||
primary: [ | ||
'border-transparent', | ||
'text-white dark:text-white', | ||
'bg-accent dark:bg-accent', | ||
'hover:bg-accent/90 dark:hover:bg-accent/90', | ||
'disabled:bg-accent/50 disabled:text-white/70', | ||
'disabled:dark:bg-accent/30 disabled:dark:text-white/50', | ||
], | ||
secondary: [ | ||
'border border-gray-200 dark:border-gray-700', | ||
'text-gray-700 dark:text-gray-200', | ||
'bg-gray-50 dark:bg-gray-800', | ||
'hover:bg-gray-100 dark:hover:bg-gray-750', | ||
'disabled:bg-gray-50 disabled:text-gray-400', | ||
'disabled:dark:bg-gray-800 disabled:dark:text-gray-500', | ||
], | ||
light: [ | ||
'shadow-none', | ||
'border-transparent', | ||
'text-gray-900 dark:text-gray-50', | ||
'bg-gray-200 dark:bg-gray-900', | ||
'hover:bg-gray-300/70 dark:hover:bg-gray-800/80', | ||
'disabled:bg-gray-100 disabled:text-gray-400', | ||
'disabled:dark:bg-gray-800 disabled:dark:text-gray-600', | ||
], | ||
ghost: [ | ||
'shadow-none', | ||
'border-transparent', | ||
'text-gray-900 dark:text-gray-50', | ||
'bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800/80', | ||
'disabled:text-gray-400', | ||
'disabled:dark:text-gray-600', | ||
], | ||
destructive: [ | ||
'text-white', | ||
'border-transparent', | ||
'bg-red-600 dark:bg-red-700', | ||
'hover:bg-red-700 dark:hover:bg-red-600', | ||
'disabled:bg-red-300 disabled:text-white', | ||
'disabled:dark:bg-red-950 disabled:dark:text-red-400', | ||
], | ||
}, | ||
size: { | ||
xs: 'h-6 px-2 text-xs', | ||
sm: 'h-8 px-3 text-sm', | ||
md: 'h-10 px-4 text-sm', | ||
lg: 'h-11 px-8 text-base', | ||
xl: 'h-12 px-8 text-base', | ||
}, | ||
flat: { | ||
true: 'shadow-none', | ||
false: 'shadow-sm', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'primary', | ||
size: 'sm', | ||
flat: false, | ||
}, | ||
}) | ||
|
||
interface ButtonProps | ||
extends React.ComponentPropsWithoutRef<'button'>, | ||
VariantProps<typeof buttonVariants> { | ||
asChild?: boolean | ||
isLoading?: boolean | ||
loadingText?: string | ||
} | ||
|
||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( | ||
( | ||
{ | ||
asChild, | ||
isLoading = false, | ||
loadingText, | ||
className, | ||
disabled, | ||
variant, | ||
size, | ||
flat, | ||
children, | ||
...props | ||
}: ButtonProps, | ||
forwardedRef, | ||
) => { | ||
const Component = asChild ? Slot : m.button | ||
return ( | ||
// @ts-expect-error | ||
<Component | ||
ref={forwardedRef} | ||
className={cx(buttonVariants({ variant, size, flat }), className)} | ||
disabled={disabled || isLoading} | ||
data-tremor-id="tremor-raw" | ||
whileTap={{ scale: 0.95 }} | ||
{...props} | ||
> | ||
{isLoading ? ( | ||
<span className="pointer-events-none inline-flex items-center justify-center gap-1.5"> | ||
<RiLoader2Fill | ||
className={cx( | ||
'shrink-0 animate-spin', | ||
size === 'xs' || size === 'sm' ? 'size-3' : 'size-4', | ||
)} | ||
aria-hidden="true" | ||
/> | ||
<span className="sr-only">{loadingText ?? 'Loading'}</span> | ||
<span className="inline-block">{loadingText ?? children}</span> | ||
</span> | ||
) : ( | ||
children | ||
)} | ||
</Component> | ||
) | ||
}, | ||
) | ||
|
||
Button.displayName = 'Button' | ||
|
||
export { Button, type ButtonProps, buttonVariants } |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './Button' | ||
export * from './MotionButton' | ||
export * from './StyledButton' |
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 |
---|---|---|
@@ -1,7 +1,22 @@ | ||
import { Button } from '~/components/ui/button/Button' | ||
|
||
export const Component = () => { | ||
return ( | ||
<div className="border rounded-lg p-4"> | ||
<div className="rounded-lg border p-4"> | ||
<h1 className="text-2xl font-bold">Main</h1> | ||
|
||
<div className="flex items-center gap-2"> | ||
<Button> | ||
<span>Button</span> | ||
</Button> | ||
|
||
<Button variant="secondary" isLoading> | ||
<span>Loading</span> | ||
</Button> | ||
<Button variant="secondary"> | ||
<span>Loading</span> | ||
</Button> | ||
</div> | ||
</div> | ||
) | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
@import './tailwind.css'; | ||
@import './theme.css'; |
Oops, something went wrong.