-
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.
feat(motion): add auto motion sensor calibration to ui (#172)
- Loading branch information
1 parent
493e282
commit 3d61fda
Showing
14 changed files
with
347 additions
and
43 deletions.
There are no files selected for viewing
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
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
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,78 @@ | ||
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'; | ||
import cx from 'classnames'; | ||
import { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
type AlertDialogProps = Omit< | ||
AlertDialogPrimitive.AlertDialogProps, | ||
'open' | 'onOpenChange' | ||
> & { | ||
title: React.ReactNode; | ||
description: React.ReactNode; | ||
onConfirm: () => void; | ||
}; | ||
|
||
export const AlertDialog = ({ | ||
children, | ||
title, | ||
description, | ||
onConfirm, | ||
...props | ||
}: AlertDialogProps): JSX.Element => { | ||
const { t } = useTranslation(); | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
return ( | ||
<AlertDialogPrimitive.Root | ||
open={isOpen} | ||
onOpenChange={setIsOpen} | ||
{...props} | ||
> | ||
<AlertDialogPrimitive.Trigger asChild> | ||
{children} | ||
</AlertDialogPrimitive.Trigger> | ||
|
||
<AlertDialogPrimitive.Portal> | ||
<AlertDialogPrimitive.Overlay className="fixed inset-0 z-20 bg-black/50" /> | ||
<AlertDialogPrimitive.Content | ||
className={cx( | ||
'fixed z-50', | ||
'w-[95vw] max-w-md rounded-lg p-4 md:w-full', | ||
'top-[50%] left-[50%] -translate-x-[50%] -translate-y-[50%]', | ||
'bg-cloud dark:bg-gray', | ||
'text-slate dark:text-white', | ||
'focus:outline-none focus-visible:ring focus-visible:ring-sky focus-visible:ring-opacity-75', | ||
)} | ||
> | ||
<AlertDialogPrimitive.Title className="text-sm font-medium"> | ||
{title} | ||
</AlertDialogPrimitive.Title> | ||
<AlertDialogPrimitive.Description className="mt-2 text-sm font-normal"> | ||
{description} | ||
</AlertDialogPrimitive.Description> | ||
<div className="mt-4 flex justify-end space-x-2"> | ||
<AlertDialogPrimitive.Cancel | ||
className={cx( | ||
'inline-flex select-none justify-center rounded-md px-4 py-2 text-sm font-medium', | ||
'border border-gray bg-transparent dark:border-white/10', | ||
'focus:outline-none focus-visible:ring focus-visible:ring-sky focus-visible:ring-opacity-75', | ||
)} | ||
> | ||
{t('alertDialog.close')} | ||
</AlertDialogPrimitive.Cancel> | ||
<AlertDialogPrimitive.Action | ||
onClick={onConfirm} | ||
className={cx( | ||
'inline-flex select-none justify-center rounded-md px-4 py-2 text-sm font-medium', | ||
'bg-sky text-white', | ||
'focus:outline-none focus-visible:ring focus-visible:ring-sky focus-visible:ring-opacity-75', | ||
)} | ||
> | ||
{t('alertDialog.confirm')} | ||
</AlertDialogPrimitive.Action> | ||
</div> | ||
</AlertDialogPrimitive.Content> | ||
</AlertDialogPrimitive.Portal> | ||
</AlertDialogPrimitive.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 |
---|---|---|
@@ -1,30 +1,32 @@ | ||
import { forwardRef } from 'react'; | ||
import { twMerge } from 'tailwind-merge'; | ||
|
||
type ButtonProps = { | ||
export type ButtonProps = { | ||
variant?: 'primary' | 'secondary'; | ||
size?: 'small'; | ||
} & React.ButtonHTMLAttributes<HTMLButtonElement>; | ||
|
||
export const Button = ({ | ||
children, | ||
className, | ||
variant, | ||
size, | ||
...props | ||
}: ButtonProps) => ( | ||
<button | ||
{...props} | ||
className={twMerge( | ||
'w-full rounded-md', | ||
size === 'small' ? ' py-1' : 'py-2', | ||
'disabled:opacity-50', | ||
'focus:outline-none focus-visible:ring focus-visible:ring-sky focus-visible:ring-opacity-75', | ||
props.type === 'reset' || variant === 'secondary' | ||
? 'border border-gray bg-transparent' | ||
: 'bg-sky text-white', | ||
className, | ||
)} | ||
> | ||
{children} | ||
</button> | ||
const Button = forwardRef<HTMLButtonElement, ButtonProps>( | ||
({ children, className, variant, size, ...props }, forwardedRef) => ( | ||
<button | ||
{...props} | ||
ref={forwardedRef} | ||
className={twMerge( | ||
'w-full rounded-md', | ||
size === 'small' ? ' px-2 py-1' : 'px-4 py-2', | ||
'disabled:opacity-50', | ||
'focus:outline-none focus-visible:ring focus-visible:ring-sky focus-visible:ring-opacity-75', | ||
props.type === 'reset' || variant === 'secondary' | ||
? 'border border-gray bg-transparent' | ||
: 'bg-sky text-white', | ||
className, | ||
)} | ||
> | ||
{children} | ||
</button> | ||
), | ||
); | ||
|
||
Button.displayName = 'Button'; | ||
|
||
export { Button }; |
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 |
---|---|---|
|
@@ -49,5 +49,3 @@ export const Collapsible = ({ | |
</CollapsiblePrimitive.Root> | ||
); | ||
}; | ||
|
||
export default Collapsible; |
Oops, something went wrong.