2022-11-25 20:25:03 +00:00
|
|
|
import type { ReactNode } from 'react';
|
|
|
|
import styled, { css } from 'styled-components';
|
2020-07-04 22:19:46 +00:00
|
|
|
import tw from 'twin.macro';
|
2022-11-25 20:25:03 +00:00
|
|
|
|
2020-12-13 19:07:29 +00:00
|
|
|
import Select from '@/components/elements/Select';
|
2022-11-25 20:25:03 +00:00
|
|
|
import Spinner from '@/components/elements/Spinner';
|
|
|
|
import FadeTransition from '@/components/elements/transitions/FadeTransition';
|
2020-12-13 19:07:29 +00:00
|
|
|
|
|
|
|
const Container = styled.div<{ visible?: boolean }>`
|
|
|
|
${tw`relative`};
|
2022-06-26 19:13:52 +00:00
|
|
|
|
2022-11-25 20:25:03 +00:00
|
|
|
${props =>
|
2022-06-26 19:13:52 +00:00
|
|
|
props.visible &&
|
|
|
|
css`
|
|
|
|
& ${Select} {
|
|
|
|
background-image: none;
|
|
|
|
}
|
|
|
|
`};
|
2020-12-13 19:07:29 +00:00
|
|
|
`;
|
2020-04-04 05:39:53 +00:00
|
|
|
|
2022-11-25 20:25:03 +00:00
|
|
|
function InputSpinner({ visible, children }: { visible: boolean; children: ReactNode }) {
|
|
|
|
return (
|
|
|
|
<Container visible={visible}>
|
|
|
|
<FadeTransition show={visible} duration="duration-150" appear unmount>
|
|
|
|
<div css={tw`absolute right-0 h-full flex items-center justify-end pr-3`}>
|
|
|
|
<Spinner size="small" />
|
|
|
|
</div>
|
|
|
|
</FadeTransition>
|
|
|
|
|
|
|
|
{children}
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
2020-04-04 05:39:53 +00:00
|
|
|
|
|
|
|
export default InputSpinner;
|