File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 1- import React , { useState , InputHTMLAttributes } from 'react' ;
1+ import React , { useState , InputHTMLAttributes , useEffect } from 'react' ;
22import uniqid from 'uniqid' ;
33
44import * as S from './styles' ;
@@ -30,6 +30,7 @@ export const Input = ({
3030} : InputProps ) => {
3131 const identifier = id || uniqid ( 'appetizer-input__' ) ;
3232 const [ active , setActive ] = useState ( ! ! props . placeholder ) ;
33+ const hasValue = ! ! props . value || ! ! props . defaultValue ;
3334
3435 const handleOnFocus = ( e : React . FocusEvent < HTMLInputElement > ) => {
3536 if ( onFocus ) onFocus ( e ) ;
@@ -41,6 +42,10 @@ export const Input = ({
4142 setActive ( e . target ?. value . length !== 0 || ! ! props . placeholder ) ;
4243 } ;
4344
45+ useEffect ( ( ) => {
46+ if ( hasValue ) setActive ( true ) ;
47+ } , [ hasValue ] ) ;
48+
4449 return (
4550 < S . Container >
4651 < S . InputContainer >
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ const GlobalStyles = createGlobalStyle`
3838 ::-webkit-scrollbar {
3939 width: 0;
4040 }
41+
4142 ::-webkit-scrollbar-track {
4243 background: transparent;
4344 }
@@ -55,9 +56,8 @@ const GlobalStyles = createGlobalStyle`
5556 ` }
5657
5758 .ReactModal__Overlay {
58- opacity: 0;
59- transition: opacity 500ms ease-in-out;
60- }
59+ opacity: 0;
60+ transition: opacity 500ms ease-in-out;
6161
6262 .ReactModal__Overlay--after-open {
6363 opacity: 1;
@@ -76,8 +76,6 @@ const GlobalStyles = createGlobalStyle`
7676 bottom: 0;
7777 background-color: rgba(0,0,0,0.5);
7878 }
79-
80-
8179` ;
8280
8381export default GlobalStyles ;
You can’t perform that action at this time.
0 commit comments