Skip to content

Commit

Permalink
chore: move AltinnContentLoader (#13932)
Browse files Browse the repository at this point in the history
  • Loading branch information
wrt95 authored Oct 31, 2024
1 parent 1c91aa5 commit 2e24dfb
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { AltinnContentLoader } from './AltinnContentLoader';

describe('AltinnContentLoader', () => {
it('should render with default height and width', () => {
render(<AltinnContentLoader />);

const loader = screen.getByRole('img', { hidden: true });
expect(loader).toHaveAttribute('height', '200');
expect(loader).toHaveAttribute('width', '400');
});

it('should render with custom height and width', () => {
render(<AltinnContentLoader height={300} width={500} />);

const loader = screen.getByRole('img', { hidden: true });
expect(loader).toHaveAttribute('height', '300');
expect(loader).toHaveAttribute('width', '500');
});

it('should render children', () => {
render(
<AltinnContentLoader>
<rect x='0' y='0' width='100' height='100' />
</AltinnContentLoader>,
);
expect(screen.getByRole('img')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import React, { type ReactNode } from 'react';
import React, { type ReactElement } from 'react';
import type { IContentLoaderProps } from 'react-content-loader';
import ContentLoader from 'react-content-loader';

export type IAltinnContentLoaderProps = {
/** The height of the loader, defaults to 200 */
height?: number;
/** The width of the loader, defaults to 400 */
width?: number;
children: ReactNode;
} & IContentLoaderProps;

export const AltinnContentLoader = ({
height,
width,
children,
...rest
}: IAltinnContentLoaderProps) => {
}: IContentLoaderProps): ReactElement => {
return (
<ContentLoader height={height ? height : 200} width={width ? width : 400} {...rest}>
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { AltinnContentLoader } from './AltinnContentLoader';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useMemo } from 'react';
import classes from './DeploymentContainer.module.css';
import { AltinnContentLoader } from 'app-shared/components/molecules/AltinnContentLoader';
import { AltinnContentLoader } from '../components/AltinnContentLoader';
import {
useOrgListQuery,
useEnvironmentsQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { InfoCard } from '../components/InfoCard';
import { ReleaseContainer } from '../containers/ReleaseContainer';
import { useDeployPermissionsQuery, useOrgListQuery } from '../../../hooks/queries';
import { Trans, useTranslation } from 'react-i18next';
import { AltinnContentLoader } from 'app-shared/components/molecules/AltinnContentLoader';
import { AltinnContentLoader } from '../components/AltinnContentLoader';
import { useInvalidator } from '../../../hooks/useInvalidator';
import { useStudioEnvironmentParams } from 'app-shared/hooks/useStudioEnvironmentParams';
import { Link } from '@digdir/designsystemet-react';
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 2e24dfb

Please sign in to comment.