Skip to content
Open
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
91 changes: 91 additions & 0 deletions frontend/documentation/components/Paging.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import React from 'react'
import type { Meta, StoryObj } from 'storybook'

import Paging from 'components/Paging'
import Panel from 'components/base/grid/Panel'

const meta: Meta = {
parameters: {
chromatic: { disableSnapshot: false },
docs: {
description: {
component:
'Pagination controls used by paginated lists (identities, audit log, change requests, etc.). Renders previous/next arrows, the page numbers around the current page, and the "x-y of n" summary.',
},
},
layout: 'padded',
},
title: 'Components/Patterns/Paging',
}
export default meta

type Story = StoryObj

const noop = () => undefined

const paging = {
count: 45,
currentPage: 3,
next: 'next',
pageSize: 10,
previous: 'previous',
}

export const Default: Story = {
render: () => (
<Paging goToPage={noop} nextPage={noop} paging={paging} prevPage={noop} />
),
}

export const InsidePanel: Story = {
parameters: {
docs: {
description: {
story:
'Paging as rendered at the bottom of a list panel, e.g. the identities tab. Switch the toolbar theme to dark to check the arrows stay visible.',
},
},
},
render: () => (
<Panel title='Identities'>
<p className='mb-0'>List content</p>
<Paging goToPage={noop} nextPage={noop} paging={paging} prevPage={noop} />
</Panel>
),
}

export const FirstPage: Story = {
parameters: {
docs: {
description: {
story: 'On the first page the previous arrow is disabled.',
},
},
},
render: () => (
<Panel title='Identities'>
<p className='mb-0'>List content</p>
<Paging
goToPage={noop}
nextPage={noop}
paging={{ ...paging, currentPage: 1, previous: null }}
prevPage={noop}
/>
</Panel>
),
}

export const Loading: Story = {
render: () => (
<Panel title='Identities'>
<p className='mb-0'>List content</p>
<Paging
goToPage={noop}
isLoading
nextPage={noop}
paging={paging}
prevPage={noop}
/>
</Panel>
),
}
4 changes: 2 additions & 2 deletions frontend/web/styles/components/_paging.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
display: flex;
justify-content: center;
align-items: center;
border: 1px solid $hr-border-color;
border: 1px solid var(--color-border-default);
text-align: center;
padding: 0;
background: transparent;
color: $text-icon-grey;
color: var(--color-icon-secondary);
&:hover {
color: $primary;
}
Expand Down
3 changes: 0 additions & 3 deletions frontend/web/styles/components/_panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
}
.dark {
.panel {
.icon {
color: $hr-border-color;
}
.panel-content {
background-color: transparent;
.search-list {
Expand Down
Loading