-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove org feature (something different will likely come back later under the same name). All this feature did was ensure that a user's orgs were loaded and store the current org in the browsers URL * move layout to features directory * add org loader to layout * implement new spinner * replace legacy HtSpinner with Spinner component * update spinner * add org select to sidenav
- Loading branch information
1 parent
fb69f28
commit 40f6a0a
Showing
35 changed files
with
293 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { render } from '@testing-library/react'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { Spinner } from './Spinner'; | ||
|
||
describe('Spinner', () => { | ||
it('renders with default size and show true', () => { | ||
const { container } = render(<Spinner />); | ||
expect(container.querySelector('span')).toHaveClass('tw-flex'); | ||
expect(container.querySelector('svg')).toHaveClass('tw-animate-spin'); | ||
}); | ||
|
||
it('renders hidden with show false', () => { | ||
const { container } = render(<Spinner show={false} />); | ||
expect(container.querySelector('span')).toHaveClass('tw-hidden'); | ||
}); | ||
|
||
it('renders with custom className', () => { | ||
const { container } = render(<Spinner className="custom-class" />); | ||
expect(container.querySelector('svg')).toHaveClass('custom-class'); | ||
}); | ||
|
||
it('renders children correctly', () => { | ||
const { getByText } = render(<Spinner>Loading...</Spinner>); | ||
expect(getByText('Loading...')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders asChild when true', () => { | ||
const { container } = render( | ||
<Spinner asChild> | ||
<div>Child Element</div> | ||
</Spinner> | ||
); | ||
expect(container.querySelector('div')).toHaveClass('tw-animate-spin'); | ||
expect(container.querySelector('div')).toHaveTextContent('Child Element'); | ||
}); | ||
|
||
it('renders with additional props', () => { | ||
const { container } = render(<Spinner data-testid="spinner-test" />); | ||
expect(container.querySelector('span')).toHaveAttribute('data-testid', 'spinner-test'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { cva, VariantProps } from 'class-variance-authority'; | ||
import * as React from 'react'; | ||
import { FaGear } from 'react-icons/fa6'; | ||
import { cn } from '~/lib/utils'; | ||
|
||
const spinnerVariants = cva('tw-flex-col tw-items-center tw-justify-center', { | ||
variants: { | ||
show: { | ||
true: 'tw-flex', | ||
false: 'tw-hidden', | ||
}, | ||
}, | ||
defaultVariants: { | ||
show: true, | ||
}, | ||
}); | ||
|
||
const loaderVariants = cva('tw-text-reset tw-animate-spin', { | ||
variants: { | ||
size: { | ||
sm: 'tw-size-6', | ||
md: 'tw-size-8', | ||
lg: 'tw-size-24', | ||
xl: 'tw-size-32', | ||
}, | ||
}, | ||
defaultVariants: { | ||
size: 'md', | ||
}, | ||
}); | ||
|
||
interface SpinnerContentProps | ||
extends VariantProps<typeof spinnerVariants>, | ||
VariantProps<typeof loaderVariants> { | ||
className?: string; | ||
children?: React.ReactNode; | ||
asChild?: boolean; | ||
} | ||
|
||
type SpinnerElement = React.ElementRef<'span'>; | ||
|
||
const Spinner = React.forwardRef<SpinnerElement, SpinnerContentProps>( | ||
({ size, show, children, className, asChild, ...props }, ref) => { | ||
return ( | ||
<span ref={ref} className={cn(spinnerVariants({ show }), className)} {...props}> | ||
{asChild && children ? ( | ||
React.cloneElement(children as React.ReactElement, { | ||
className: cn(loaderVariants({ size }), children), | ||
}) | ||
) : ( | ||
<> | ||
<FaGear className={cn(loaderVariants({ size }), className)} data-testid="spinner" /> | ||
{children} | ||
</> | ||
)} | ||
</span> | ||
); | ||
} | ||
); | ||
|
||
Spinner.displayName = 'Spinner'; | ||
|
||
export { Spinner }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.