diff --git a/src/components/Accordion/index.tsx b/src/components/Accordion/index.tsx index 8cbc304..3666e2d 100644 --- a/src/components/Accordion/index.tsx +++ b/src/components/Accordion/index.tsx @@ -1,18 +1,31 @@ -import React, { useState } from 'react'; +import React, { useRef, useState } from 'react'; import * as S from './styled'; import { arrowBottom, arrowTop } from '../../assets/icons'; -import TGIcon from '../../components/TGIcon'; +import Icon from '../../components/Icon'; interface AccordionProps { title: string; children: React.ReactNode; + maxHeight?: number; } -const Accordion = ({ title, children }: AccordionProps) => { +const Accordion = ({ title, children, maxHeight = 200 }: AccordionProps) => { + const panelRef = useRef(null); const [isOpenPanel, setIsOpenPanel] = useState(false); const handleToggle = () => { setIsOpenPanel(!isOpenPanel); + + if (!panelRef.current) return; + if (isOpenPanel) { + panelRef.current.style.overflow = 'hidden'; + + return; + } + setTimeout(() => { + if (!panelRef.current) return; + panelRef.current.style.overflow = 'visible'; + }, 300); }; return ( @@ -21,14 +34,16 @@ const Accordion = ({ title, children }: AccordionProps) => {

{title}

{isOpenPanel ? ( - + ) : ( - + )} {children} diff --git a/src/components/Accordion/styled.tsx b/src/components/Accordion/styled.tsx index 6ac6c10..4d3e64a 100644 --- a/src/components/Accordion/styled.tsx +++ b/src/components/Accordion/styled.tsx @@ -32,9 +32,12 @@ export const AccordionTopContainer = styled.div` } `; -export const AccordionPanelContainer = styled.div<{ isOpen: boolean }>` +export const AccordionPanelContainer = styled.div<{ + isOpen: boolean; + maxHeight: number; +}>` background-color: #fff; transition: max-height 0.2s linear; - overflow: ${({ isOpen }) => (isOpen ? 'visible' : 'hidden')}; - max-height: ${({ isOpen }) => (isOpen ? '200px' : '0')}; + overflow: hidden; + max-height: ${({ isOpen, maxHeight }) => (isOpen ? `${maxHeight}px` : '0')}; `; diff --git a/src/components/TG.styled.ts b/src/components/TG.styled.ts index 3a8aca6..867fac4 100644 --- a/src/components/TG.styled.ts +++ b/src/components/TG.styled.ts @@ -86,6 +86,10 @@ export const TGHeaderWrapper = styled.div` button { cursor: pointer; + transition: transform 0.2s; + &:hover { + transform: rotate(90deg); + } } `; @@ -115,7 +119,8 @@ export const TGTextarea = styled.textarea` color: #cccccc; } - &:focus { + &:focus, + &:hover { border: 1px solid #0e1b30; } `; @@ -188,6 +193,10 @@ export const SelectInput = styled.div<{ isOpenSelect: boolean }>` justify-content: center; font-size: 0.9rem; } + + &:hover { + border: 1px solid #0e1b30; + } `; export const SelectItemContainer = styled.ul` @@ -235,19 +244,18 @@ export const TGInputTextContainer = styled.div<{ width: number | string }>` margin-top: 1px; width: ${({ width }) => `${width}px`}; - &:focus { + &:focus, + &:hover { border: 1px solid #0e1b30; } &:disabled { color: #cccccc; + border: 1px solid #cccccc; } } `; -// TG Icon -export const TGIConImage = styled.img``; - // TG InputFile export const TGInputFileWrapper = styled.div` background: #fff; diff --git a/src/components/TGHeader.tsx b/src/components/TGHeader.tsx index 36c8de3..eccb515 100644 --- a/src/components/TGHeader.tsx +++ b/src/components/TGHeader.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { TGHeaderWrapper, TGLimitSizeText } from './TG.styled'; -import TGIcon from './TGIcon'; import { close } from '../assets/icons'; import { IconButton } from './Icon/styled'; +import Icon from './Icon'; interface TGHeaderProps { onToggle: () => void; @@ -17,10 +17,10 @@ const TGHeader = ({ onToggle }: TGHeaderProps) => { href="https://github.com/ssi02014/react-thumbnail-generator" target="_blank" rel="noreferrer"> - Simple Thumbnail Generator + Thumbnail Generator - + diff --git a/src/components/TGIcon.tsx b/src/components/TGIcon.tsx deleted file mode 100644 index 7c9a53d..0000000 --- a/src/components/TGIcon.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import { TGIConImage } from './TG.styled'; - -interface TGIconProps { - src: string; - width: number; - height: number; -} -const TGIcon = ({ src, width, height }: TGIconProps) => { - return ; -}; - -export default TGIcon; diff --git a/src/components/TGSelect.tsx b/src/components/TGSelect.tsx index 12f4d98..5327128 100644 --- a/src/components/TGSelect.tsx +++ b/src/components/TGSelect.tsx @@ -7,7 +7,7 @@ import React, { ComponentProps, } from 'react'; import { SelectWrapper, SelectInput, SelectItemContainer } from './TG.styled'; -import TGIcon from './TGIcon'; +import Icon from './Icon'; interface SelectContextProps { color?: string; @@ -79,9 +79,9 @@ const TGSelect = ({

{value}

{isOpenSelect ? ( - + ) : ( - + )}

diff --git a/src/lib/ThumbnailGenerator.tsx b/src/lib/ThumbnailGenerator.tsx index 7b66626..db88b8d 100644 --- a/src/lib/ThumbnailGenerator.tsx +++ b/src/lib/ThumbnailGenerator.tsx @@ -2,9 +2,9 @@ import TG from '../components/TG'; import { TGOpenButton } from '../components/TG.styled'; import React, { useState } from 'react'; import { toggleButton } from '../assets/icons'; -import TGIcon from '../components/TGIcon'; import { Position, getIconSize } from '../utils/style'; import TGPortal from '../components/TGPortal'; +import Icon from '../components/Icon'; interface ThumbnailGeneratorProps { id?: string; @@ -42,7 +42,7 @@ const ThumbnailGenerator = ({ /> ) : ( - + )}