Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions packages/datatrak-web/src/layout/Header/SyncButton.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
import React from 'react';
import { IconButton, useTheme } from '@material-ui/core';
import { RefreshCcw } from 'lucide-react';
import { RefreshCw } from 'lucide-react';
import React from 'react';
import styled from 'styled-components';

import { RouterLink } from '@tupaia/ui-components';

import { ROUTES } from '../../constants/url';
import { useIsSyncing } from '../../sync/useIsSyncing';

export const StyledSyncButton = styled(IconButton)<{
component: React.ElementType;
to: string;
}>`
padding: 0.5rem;

@keyframes --spin-sync-button {
to {
transform: rotate(1turn);
}
}
`;

export const SyncButton = () => {
const secondaryColor = useTheme().palette.secondary.main;
const isSyncing = useIsSyncing();

return (
<StyledSyncButton to={ROUTES.SYNC} component={RouterLink}>
<RefreshCcw size={25} color={secondaryColor} />
<RefreshCw
size={25}
color={secondaryColor}
style={{ animation: isSyncing ? '--spin-sync-button 1150ms linear infinite' : undefined }}
/>
</StyledSyncButton>
);
};
Loading