* feat: adding create bot functionality Signed-off-by: James <james@jan.ai> * update the temperature progress bar Signed-off-by: James <james@jan.ai> * WIP baselayout * Mapping plugins with available preferences * Added loader component * WIP working another screen * Cleanup types and avoid import one by one * Prepare bottom bar * Add css variables colors to enable user select the accent * Enable change accent color * Seperate css variable * Fix conflict * Add blank state of my model empty * Restyle explore models page * Enable user config left sidebar * Restyle my models page * WIP styling chat page * Restyling chat message * Fix conflict * Adde form preferences setting plugins * Fixed form bot info * Sidebar bot chat * Showing rightbar for both setting when user created bot * Fix style bot info * Using overflow auto intead of scroll * Remove script built UI from root package * Fix missig import * Resolve error linter * fix e2e tests Signed-off-by: James <james@jan.ai> --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai>
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import React from 'react'
|
|
import { Switch } from '@headlessui/react'
|
|
import { Controller } from 'react-hook-form'
|
|
|
|
function classNames(...classes: any) {
|
|
return classes.filter(Boolean).join(' ')
|
|
}
|
|
|
|
type Props = {
|
|
id: string
|
|
title: string
|
|
control: any
|
|
required?: boolean
|
|
}
|
|
|
|
const ToggleSwitch: React.FC<Props> = ({
|
|
id,
|
|
title,
|
|
control,
|
|
required = false,
|
|
}) => (
|
|
<div className="flex items-center justify-between">
|
|
<div className="text-bold">{title}</div>
|
|
<Controller
|
|
name={id}
|
|
control={control}
|
|
rules={{ required }}
|
|
render={({ field: { value, onChange } }) => (
|
|
<Switch
|
|
checked={value}
|
|
onChange={onChange}
|
|
className={classNames(
|
|
value ? 'bg-accent' : 'bg-gray-200',
|
|
'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-indigo-600 focus:ring-offset-2'
|
|
)}
|
|
>
|
|
<span className="sr-only">Use setting</span>
|
|
<span
|
|
aria-hidden="true"
|
|
className={classNames(
|
|
value ? 'translate-x-5' : 'translate-x-0',
|
|
'pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out'
|
|
)}
|
|
/>
|
|
</Switch>
|
|
)}
|
|
/>
|
|
</div>
|
|
)
|
|
|
|
export default ToggleSwitch
|