@@ -2,7 +2,7 @@ import { combineClassNames } from "@/submodules/javascript-functions/general";
22import { Switch } from "@headlessui/react" ;
33import { Tooltip } from "@nextui-org/react" ;
44import { useMemo } from "react" ;
5- import { MemoIconAlertCircle , MemoIconAlertTriangle } from "./kern-icons/icons" ;
5+ import { MemoIconAlertTriangle } from "./kern-icons/icons" ;
66
77
88type Props = {
@@ -14,17 +14,17 @@ type Props = {
1414 colorInactive ?: string ;
1515 addClassesGroup ?: string ;
1616 tooltip ?: string ;
17+ disabled ?: boolean ;
1718}
1819
1920export default function SwitchWithLabel ( props : Props ) {
20-
2121 const finalColorActive = props . colorActive || 'bg-green-600' ;
2222 const finalColorInactive = props . colorInactive || 'bg-gray-200' ;
2323 const finalColorLabel = props . colorLabel || 'text-gray-700' ;
2424
2525 const tooltip = useMemo ( ( ) => props . tooltip ? < Tooltip content = { props . tooltip } color = "invert" placement = "top" > < MemoIconAlertTriangle className = "w-6 h-6" /> </ Tooltip > : null , [ props . tooltip ] )
2626
27- return < Switch . Group as = "div" className = { combineClassNames ( "flex items-center justify-between" , props . addClassesGroup ) } >
27+ return < Switch . Group as = "div" className = { combineClassNames ( "flex items-center justify-between disabled-within:opacity-50 disabled-within:cursor-not-allowed " , props . addClassesGroup ) } >
2828 < Switch . Description as = "span" className = { `font-medium ${ finalColorLabel } ` } >
2929 { props . label }
3030 </ Switch . Description >
@@ -34,8 +34,9 @@ export default function SwitchWithLabel(props: Props) {
3434 onChange = { props . onChange }
3535 className = { combineClassNames (
3636 props . checked ? finalColorActive : finalColorInactive ,
37- 'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2'
37+ 'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer disabled:cursor-not-allowed rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2'
3838 ) }
39+ disabled = { props . disabled }
3940 >
4041 < span
4142 aria-hidden = "true"
0 commit comments