Skip to content

Commit

Permalink
Merge pull request #71 from YAPP-Github/feature/FE-052
Browse files Browse the repository at this point in the history
feature/FE-052 :  IconButton disabled 에러 수정
  • Loading branch information
naro-Kim authored Jul 4, 2023
2 parents c89e624 + d52ffe4 commit 6ee51c4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
8 changes: 8 additions & 0 deletions public/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions public/spriteIcons/minus-hover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/app/write/components/Counter/Counter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const Counter = ({ control, name, min = 2, max = 20, ...rest }: CounterProps<any
name={name}
render={({ field: { value, onChange } }) => (
<>
<IconButton type="button" iconType="minus" onClick={handleClickSubtract} disabled={value <= 2} />
<IconButton type="button" iconType="minus" onClick={handleClickSubtract} disabled={value <= 2} hover />
<input type="number" min={min} max={max} value={value} onChange={onChange} />
<IconButton type="button" iconType="plus" onClick={handleClickAdd} />
<IconButton type="button" iconType="plus" onClick={handleClickAdd} hover />
</>
)}
/>
Expand Down
1 change: 1 addition & 0 deletions src/app/write/components/Form/FirstStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const FirstStep = ({ nextStep }: stepProps) => {
const { stepOne, setData } = useFormStore();

const method = useForm<StepOneSchema>({
mode: 'onSubmit',
resolver: zodResolver(stepOneSchema),
defaultValues: stepOne || {},
});
Expand Down
6 changes: 5 additions & 1 deletion src/components/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ const IconButton = ({

useEffect(() => {
if (!error) return;
setStatus(error ? ICON_STATUS.ERROR : disabled ? ICON_STATUS.DISABLE : ICON_STATUS.DEFAULT);
setStatus(error ? ICON_STATUS.ERROR : ICON_STATUS.DEFAULT);
}, [error, disabled]);

useEffect(() => {
setStatus(disabled ? ICON_STATUS.DISABLE : ICON_STATUS.DEFAULT);
}, [disabled]);

const handleMouseEnter = () => {
if (error || disabled || status === ICON_STATUS.ACTIVE) return;
hover && setStatus(ICON_STATUS.HOVER);
Expand Down
14 changes: 7 additions & 7 deletions src/components/SvgIcon/SvgIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { SVGProps } from 'react';

interface Props extends SVGProps<SVGSVGElement> {
/** icon id (spriteIcons 폴더하에 있는 svg 파일명과 동일함) */
id: string;
/** icon id (spriteIcons 폴더하에 있는 svg 파일명과 동일함) */
id: string;
}

const SvgIcon = ({ id, width = 16, height = 16, fill = 'none', ...rest }: Props) => {
return (
<svg width={width} height={height} fill={fill} {...rest}>
<use href={`/sprite.svg#${id}`} />
</svg>
);
return (
<svg width={width} height={height} fill={fill} {...rest}>
<use href={`/sprite.svg#${id}`} />
</svg>
);
};

export default SvgIcon;

0 comments on commit 6ee51c4

Please sign in to comment.