diff --git a/src/components/datepicker/datepicker-component.tsx b/src/components/datepicker/datepicker-component.tsx index 7ddc8913..4c45f865 100644 --- a/src/components/datepicker/datepicker-component.tsx +++ b/src/components/datepicker/datepicker-component.tsx @@ -204,9 +204,10 @@ const DatePickerComponent = ( { onClick={ handlePrevButtonClick } className="bg-background-primary border-none cursor-pointer" aria-label="Previous Button" - > - - + icon={ + + } + /> + icon={ + + } + /> { showYearSelect && ( @@ -255,7 +257,9 @@ const DatePickerComponent = ( { yearValue === selectedYear && yearValue !== new Date().getFullYear() && - 'bg-background-brand text-text-on-color hover:bg-background-brand hover:text-black' + 'bg-background-brand text-text-on-color hover:bg-background-brand hover:text-black', + yearValue === new Date().getFullYear() && + 'font-semibold' ) } > { yearValue } @@ -287,7 +291,11 @@ const DatePickerComponent = ( { customMonthProps.calendarMonth.date.getFullYear() && customMonthProps.calendarMonth.date.getFullYear() !== new Date().getFullYear() && - 'bg-background-brand text-text-on-color hover:bg-background-brand hover:text-black' + 'bg-background-brand text-text-on-color hover:bg-background-brand hover:text-black', + monthIndex === new Date().getMonth() && + new Date().getFullYear() === + selectedYear && + 'font-semibold' ) } > { format( new Date( 0, monthIndex ), 'MMM' ) } @@ -312,7 +320,7 @@ const DatePickerComponent = ( { { weekdays.map( ( weekday, weekdayIndex ) => ( @@ -362,7 +370,7 @@ const DatePickerComponent = ( { 'bg-transperant opacity-50 text-text-disabled cursor-auto'; const buttonClasses = cn( - 'h-10 w-10 flex items-center justify-center transition text-text-secondary relative', + 'h-10 w-10 flex items-center justify-center transition text-text-secondary relative text-sm', 'border-none rounded', ( isSelected || isPartOfRange ) && ( ! isOutside || isPreviousMonth ) ? 'bg-background-brand text-text-on-color' @@ -383,7 +391,7 @@ const DatePickerComponent = ( { return ( @@ -218,7 +218,7 @@ const DatePicker = ( { width="w-auto" numberOfMonths={ 2 } footer={ -
+
diff --git a/src/components/radio-button/radio-button.tsx b/src/components/radio-button/radio-button.tsx index f07a3869..77ebf8e1 100644 --- a/src/components/radio-button/radio-button.tsx +++ b/src/components/radio-button/radio-button.tsx @@ -455,7 +455,7 @@ export const RadioButtonComponent = ( <> { if ( ! multiSelection ) { // Toggle the switch on or off diff --git a/src/components/select/select.tsx b/src/components/select/select.tsx index ca8637d3..d3d6ed02 100644 --- a/src/components/select/select.tsx +++ b/src/components/select/select.tsx @@ -296,7 +296,7 @@ export function SelectOptions( { const initialSelectedValueIndex = useMemo( () => { const currentValue = getValues(); - let indexValue = 0; + let indexValue = -1; if ( currentValue ) { indexValue = Children.toArray( children ).findIndex( @@ -315,7 +315,7 @@ export function SelectOptions( { ); } - return indexValue === -1 ? 0 : indexValue; + return indexValue; }, [ value, selected, children ] ); useLayoutEffect( () => { diff --git a/src/components/sidebar/sidebar.tsx b/src/components/sidebar/sidebar.tsx index e68c4063..bf696f50 100644 --- a/src/components/sidebar/sidebar.tsx +++ b/src/components/sidebar/sidebar.tsx @@ -36,8 +36,6 @@ export interface SidebarProps extends SidebarCommonProps { onCollapseChange?: ( isCollapsed: boolean ) => void; /** Determines if the Sidebar can be collapsed or not. If true, a collapse button is shown. */ collapsible?: boolean; - /** Determines whether the Sidebar should occupy the full screen height. */ - screenHeight?: boolean; /** Controls whether a border should appear on the right of the Sidebar. */ borderOn?: boolean; } @@ -55,7 +53,6 @@ export const Sidebar = ( { className, onCollapseChange, collapsible = true, - screenHeight = true, borderOn = true, ...props }: SidebarProps ) => { @@ -88,14 +85,6 @@ export const Sidebar = ( { const storedState = safeLocalStorage.get( 'sidebar-collapsed' ); setIsCollapsed( storedState ? storedState : false ); } - - if ( sideBarRef.current ) { - if ( !! screenHeight ) { - sideBarRef.current.style.height = `${ window.innerHeight }px`; - } else { - sideBarRef.current.style.height = 'auto'; - } - } }; window.addEventListener( 'resize', handleScreenResize ); @@ -104,7 +93,7 @@ export const Sidebar = ( { return () => { window.removeEventListener( 'resize', handleScreenResize ); }; - }, [ screenHeight, collapsible ] ); + }, [ collapsible ] ); return ( = ( { defaultValue, size, ...args } ) => { export const Basic = Template.bind( {} ); Basic.args = { defaultValue: false, - size: 'lg', + size: 'sm', disabled: false, }; export const WithLabel = Template.bind( {} ); WithLabel.args = { defaultValue: true, - size: 'lg', + size: 'sm', disabled: false, label: { heading: 'Switch Label', description: 'Switch Description' }, }; export const Disabled = Template.bind( {} ); Disabled.args = { - size: 'lg', + size: 'sm', disabled: true, label: { heading: 'Disabled Switch', diff --git a/src/components/switch/switch.tsx b/src/components/switch/switch.tsx index 38491d7e..f969adff 100644 --- a/src/components/switch/switch.tsx +++ b/src/components/switch/switch.tsx @@ -22,8 +22,11 @@ export interface SwitchProps { /** Initial value of the switch (checked or unchecked) when used as an uncontrolled component. */ defaultValue?: boolean; - /** Defines the size of the switch (e.g., 'sm', 'md', 'lg'). */ - size?: 'sm' | 'md' | 'lg'; + /** + * Defines the size of the switch (e.g., 'sm', 'md'). + * @default 'sm' + */ + size?: 'sm' | 'md'; /** Disables the switch if true. */ disabled?: boolean; @@ -55,12 +58,19 @@ export const SwitchLabel = ( { switchId: string; disabled?: boolean; children: ReactNode; - size: 'sm' | 'md' | 'lg'; + size: 'sm' | 'md'; } ) => { const headingClasses = { - sm: 'text-sm leading-4 font-medium', - md: 'text-base leading-5 font-medium', - lg: 'text-lg leading-6 font-medium', + sm: 'text-sm leading-5 font-medium', + md: 'text-base leading-6 font-medium', + }; + const descriptionClasses = { + sm: 'text-xs leading-4 font-normal', + md: 'text-sm leading-5 font-normal', + }; + const gapClassNames = { + sm: 'space-y-0.5', + md: 'space-y-1', }; const isLabelAComponent = isValidElement( label ); if ( isLabelAComponent ) { @@ -76,11 +86,11 @@ export const SwitchLabel = ( { const renderLabel = () => { const { heading = '', description = '' } = label || {}; return ( -
+
{ 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 ) => {