Skip to content

Commit

Permalink
feat: add stories
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Jul 12, 2024
1 parent 83c9b49 commit c553178
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sections/new-collection/NewCollectionSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton'
import { Col, Row } from '@iqss/dataverse-design-system'
import { Col, Row, Stack } from '@iqss/dataverse-design-system'
import { BreadcrumbsSkeleton } from '../shared/hierarchy/BreadcrumbsSkeleton'
import 'react-loading-skeleton/dist/skeleton.css'
import { SeparationLine } from '../shared/layout/SeparationLine/SeparationLine'
Expand Down Expand Up @@ -71,6 +71,11 @@ export const NewCollectionSkeleton = () => (

<Skeleton height={145} width="100%" style={{ marginBottom: 16 }} />
<Skeleton height={145} width="100%" style={{ marginBottom: 16 }} />

<Stack direction="horizontal" className="pt-3">
<Skeleton width={120} height={38} />
<Skeleton width={120} height={38} />
</Stack>
</section>
</SkeletonTheme>
)
17 changes: 17 additions & 0 deletions src/stories/collection/Collection.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const Default: Story = {
repository={new CollectionMockRepository()}
datasetRepository={new DatasetMockRepository()}
id="collection"
created={false}
/>
)
}
Expand All @@ -40,6 +41,7 @@ export const InfiniteScrollingEnabled: Story = {
datasetRepository={new DatasetMockRepository()}
id="collection"
infiniteScrollEnabled={true}
created={false}
/>
)
}
Expand All @@ -50,6 +52,7 @@ export const Loading: Story = {
repository={new CollectionLoadingMockRepository()}
datasetRepository={new DatasetLoadingMockRepository()}
id="collection"
created={false}
/>
)
}
Expand All @@ -60,6 +63,7 @@ export const NoResults: Story = {
repository={new NoCollectionMockRepository()}
datasetRepository={new NoDatasetsMockRepository()}
id="collection"
created={false}
/>
)
}
Expand All @@ -71,6 +75,19 @@ export const LoggedIn: Story = {
repository={new CollectionMockRepository()}
datasetRepository={new DatasetMockRepository()}
id="collection"
created={false}
/>
)
}

export const Created: Story = {
decorators: [WithLoggedInUser],
render: () => (
<Collection
repository={new CollectionMockRepository()}
datasetRepository={new NoDatasetsMockRepository()}
id="collection"
created={true}
/>
)
}
43 changes: 43 additions & 0 deletions src/stories/new-collection/NewCollection.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Meta, StoryObj } from '@storybook/react'
import { NewCollection } from '../../sections/new-collection/NewCollection'
import { WithI18next } from '../WithI18next'
import { WithLayout } from '../WithLayout'
import { WithLoggedInUser } from '../WithLoggedInUser'
import { CollectionMockRepository } from '../collection/CollectionMockRepository'
import { CollectionLoadingMockRepository } from '../collection/CollectionLoadingMockRepository'
import { NoCollectionMockRepository } from '../collection/NoCollectionMockRepository'

const meta: Meta<typeof NewCollection> = {
title: 'Pages/New Collection',
component: NewCollection,
decorators: [WithI18next, WithLayout, WithLoggedInUser],
parameters: {
// Sets the delay for all stories.
chromatic: { delay: 15000, pauseAnimationAtEnd: true }
}
}
export default meta
type Story = StoryObj<typeof NewCollection>

export const Default: Story = {
render: () => (
<NewCollection collectionRepository={new CollectionMockRepository()} ownerCollectionId="root" />
)
}
export const Loading: Story = {
render: () => (
<NewCollection
collectionRepository={new CollectionLoadingMockRepository()}
ownerCollectionId="root"
/>
)
}

export const OwnerCollectionNotFound: Story = {
render: () => (
<NewCollection
collectionRepository={new NoCollectionMockRepository()}
ownerCollectionId="root"
/>
)
}

0 comments on commit c553178

Please sign in to comment.