2020-04-04 05:39:53 +00:00
|
|
|
import React from 'react';
|
|
|
|
import Spinner from '@/components/elements/Spinner';
|
2020-07-04 22:19:46 +00:00
|
|
|
import Fade from '@/components/elements/Fade';
|
|
|
|
import tw from 'twin.macro';
|
2020-12-13 19:07:29 +00:00
|
|
|
import styled, { css } from 'styled-components/macro';
|
|
|
|
import Select from '@/components/elements/Select';
|
|
|
|
|
|
|
|
const Container = styled.div<{ visible?: boolean }>`
|
|
|
|
${tw`relative`};
|
2022-06-26 19:13:52 +00:00
|
|
|
|
|
|
|
${(props) =>
|
|
|
|
props.visible &&
|
|
|
|
css`
|
|
|
|
& ${Select} {
|
|
|
|
background-image: none;
|
|
|
|
}
|
|
|
|
`};
|
2020-12-13 19:07:29 +00:00
|
|
|
`;
|
2020-04-04 05:39:53 +00:00
|
|
|
|
2022-06-26 19:13:52 +00:00
|
|
|
const InputSpinner = ({ visible, children }: { visible: boolean; children: React.ReactNode }) => (
|
2020-12-13 19:07:29 +00:00
|
|
|
<Container visible={visible}>
|
2020-10-16 04:21:38 +00:00
|
|
|
<Fade appear unmountOnExit in={visible} timeout={150}>
|
2020-07-04 22:19:46 +00:00
|
|
|
<div css={tw`absolute right-0 h-full flex items-center justify-end pr-3`}>
|
2022-06-26 19:13:52 +00:00
|
|
|
<Spinner size={'small'} />
|
2020-04-04 05:39:53 +00:00
|
|
|
</div>
|
2020-07-04 22:19:46 +00:00
|
|
|
</Fade>
|
2020-04-04 05:39:53 +00:00
|
|
|
{children}
|
2020-12-13 19:07:29 +00:00
|
|
|
</Container>
|
2020-04-04 05:39:53 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
export default InputSpinner;
|