{ heading && (
{ description }
@@ -129,7 +140,7 @@ export const SwitchComponent = (
onChange,
value,
defaultValue = false,
- size = 'lg',
+ size = 'sm',
disabled = false,
label = { heading: '', description: '' },
name,
@@ -138,6 +149,9 @@ export const SwitchComponent = (
}: SwitchProps,
ref: React.ForwardedRef
) => {
+ // For backwards compatibility.
+ const normalSize = ( size as 'sm' | 'md' | 'lg' ) === 'lg' ? 'md' : size;
+
const isControlled = useMemo( () => typeof value !== 'undefined', [ value ] );
const switchId = useMemo( () => ( id ? id : `switch-${ nanoid() }` ), [] );
const [ checked, setChecked ] = useState( defaultValue );
@@ -172,17 +186,15 @@ export const SwitchComponent = (
};
const sizeClassNames = {
- lg: {
- container: 'w-11 h-6',
- toggleDial: 'size-4 peer-checked:translate-x-5',
- },
md: {
- container: 'w-10 h-5',
- toggleDial: 'size-3 peer-checked:translate-x-5',
+ container: 'w-11 h-6',
+ toggleDial:
+ 'size-4 peer-checked:translate-x-5 group-hover/switch:size-5 group-focus-within/switch:size-5 group-focus-within/switch:left-0.5 group-hover/switch:left-0.5',
},
sm: {
- container: 'w-8 h-4',
- toggleDial: 'size-2.5 peer-checked:translate-x-3.5',
+ container: 'w-10 h-5',
+ toggleDial:
+ 'size-3 peer-checked:translate-x-5 group-hover/switch:size-4 group-focus-within/switch:size-4 group-focus-within/switch:left-0.5 group-hover/switch:left-0.5',
},
};
@@ -196,12 +208,12 @@ export const SwitchComponent = (
label={ label }
switchId={ switchId }
disabled={ disabled }
- size={ size }
+ size={ normalSize }
>
@@ -210,7 +222,7 @@ export const SwitchComponent = (
id={ switchId }
type="checkbox"
className={ cn(
- "peer appearance-none absolute bg-blue-gray-100 rounded-full cursor-pointer transition-colors duration-300 h-full w-full before:content-[''] checked:before:content-[''] m-0 checked:[background-image:none]",
+ "peer appearance-none absolute rounded-full cursor-pointer transition-colors duration-300 h-full w-full before:content-[''] checked:before:content-[''] m-0 checked:[background-image:none]",
colorClassNames[ color ].input,
disabled && disabledClassNames.input
) }
@@ -223,8 +235,8 @@ export const SwitchComponent = (
);
@@ -287,16 +291,18 @@ export const Tab = forwardRef[(
};
return (
-
+
);
}
);
diff --git a/src/templates/admin-settings-Spectra/admin-settings-Spectra.stories.jsx b/src/templates/admin-settings-Spectra/admin-settings-Spectra.stories.jsx
index 19f4f61a..b9d628f5 100644
--- a/src/templates/admin-settings-Spectra/admin-settings-Spectra.stories.jsx
+++ b/src/templates/admin-settings-Spectra/admin-settings-Spectra.stories.jsx
@@ -452,7 +452,7 @@ const Template = ( args ) => {
@@ -485,7 +485,7 @@ const Template = ( args ) => {
@@ -518,7 +518,7 @@ const Template = ( args ) => {
@@ -552,7 +552,7 @@ const Template = ( args ) => {
@@ -585,7 +585,7 @@ const Template = ( args ) => {
diff --git a/version.json b/version.json
index 675a1b15..f89dc473 100644
--- a/version.json
+++ b/version.json
@@ -1,3 +1,3 @@
{
- "force-ui": "1.3.0"
+ "force-ui": "1.3.1"
}
]