FIXED: Icon button with toggle

This commit is contained in:
doryan04 2024-02-01 23:37:22 +04:00
parent 43381e4a7b
commit df7901a779
2 changed files with 13 additions and 16 deletions

View File

@ -44,21 +44,18 @@ export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
const buttonRef = useRef<HTMLButtonElement>(null);
const callback = useCallback(
() => (event: MouseEventHandler<HTMLButtonElement>) => {
if (toggled) {
if (toggleIcon.state === 'selected') {
toggle('', toggled.unselected ?? 'add_circle');
} else {
toggle('selected', toggled.selected ?? 'add_circle');
}
const callback = event => {
if (toggled) {
if (toggleIcon.state === 'selected') {
toggle('', toggled.unselected ?? 'add_circle');
} else {
toggle('selected', toggled.selected ?? 'add_circle');
}
if (props.onClick) {
props.onClick.apply(null, event);
}
},
[toggleIcon],
);
}
if (props.onClick) {
props.onClick.apply(null, event);
}
};
useImperativeHandle(ref, () => buttonRef.current);

View File

@ -1,8 +1,8 @@
'use client';
import { bool, oneOf, string } from 'prop-types';
import React, { FocusEvent, forwardRef, useState } from 'react';
import { TextFieldInterface } from './text-field.types';
import React, { FocusEvent, forwardRef, useState } from 'react';
export const TextField = forwardRef<HTMLInputElement, TextFieldInterface>(
(
@ -43,7 +43,7 @@ export const TextField = forwardRef<HTMLInputElement, TextFieldInterface>(
<div className={`m3 m3-text-field ${variant}`.trimEnd()}>
{variant === 'outlined' && (
<fieldset>
<legend className={raised && 'raised'}>
<legend className={raised ? 'raised' : ''}>
<span>Label</span>
</legend>
</fieldset>