misc_pterodactyl-panel/resources/scripts/components/elements/InputSpinner.tsx

36 lines
1 KiB
TypeScript
Raw Normal View History

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
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';
const Container = styled.div<{ visible?: boolean }>`
${tw`relative`};
2022-11-25 20:25:03 +00:00
${props =>
props.visible &&
css`
& ${Select} {
background-image: none;
}
`};
`;
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>
);
}
export default InputSpinner;