-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/create-the-form-elements-of-the-d…
…esign-system
- Loading branch information
Showing
6 changed files
with
131 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Table } from '../../../../src/sections/ui/table/Table' | ||
|
||
describe('Table', () => { | ||
it('should render children', () => { | ||
cy.mount( | ||
<Table> | ||
<tbody> | ||
<tr> | ||
<td>Row 1, Column 1</td> | ||
<td>Row 1, Column 2</td> | ||
</tr> | ||
<tr> | ||
<td>Row 2, Column 1</td> | ||
<td>Row 2, Column 2</td> | ||
</tr> | ||
</tbody> | ||
</Table> | ||
) | ||
|
||
cy.findByText('Row 1, Column 1').should('exist') | ||
cy.findByText('Row 1, Column 2').should('exist') | ||
cy.findByText('Row 2, Column 1').should('exist') | ||
cy.findByText('Row 2, Column 2').should('exist') | ||
}) | ||
}) |
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,3 @@ | ||
.table > thead { | ||
text-align: center; | ||
} |
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,11 @@ | ||
import { PropsWithChildren } from 'react' | ||
import { Table as TableBS } from 'react-bootstrap' | ||
import styles from './Table.module.scss' | ||
|
||
export function Table({ children }: PropsWithChildren) { | ||
return ( | ||
<TableBS striped bordered className={styles.table}> | ||
{children} | ||
</TableBS> | ||
) | ||
} |
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,62 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { Table } from '../../../sections/ui/table/Table' | ||
|
||
/** | ||
* ## Description | ||
* A table is a UI element that displays data in a structured format, typically in rows and columns. Tables can be used | ||
* to organize and present large amounts of data in a user-friendly and easily readable format. | ||
* | ||
* ## Usage guidelines | ||
* This table is not intended to be used for complex data manipulation. It is intended to be used for displaying data | ||
* | ||
* ### Dos | ||
* - Use clear and concise table headings that accurately describe the data being presented | ||
* - Use tables to display data that is related to each other | ||
* - Use tables to display data that is not easily displayed in a list | ||
* | ||
* ### Don'ts | ||
* - Don't use tables for layout purposes, such as aligning images or text. Use CSS instead. | ||
*/ | ||
const meta: Meta<typeof Table> = { | ||
title: 'UI/Table', | ||
component: Table, | ||
tags: ['autodocs'] | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof Table> | ||
|
||
export const Default: Story = { | ||
render: () => ( | ||
<Table> | ||
<thead> | ||
<tr> | ||
<th>Dataset Version</th> | ||
<th>Summary</th> | ||
<th>Contributors</th> | ||
<th>Published On</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>1.0</td> | ||
<td>This is a dataset summary</td> | ||
<td>Mark</td> | ||
<td>April 20, 2023</td> | ||
</tr> | ||
<tr> | ||
<td>1.1</td> | ||
<td>This is a dataset summary</td> | ||
<td>Jacob</td> | ||
<td>May 3, 2023</td> | ||
</tr> | ||
<tr> | ||
<td>1.2</td> | ||
<td>This is a dataset summary</td> | ||
<td>Frank</td> | ||
<td>June 4, 2023</td> | ||
</tr> | ||
</tbody> | ||
</Table> | ||
) | ||
} |
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,25 @@ | ||
import { render } from '@testing-library/react' | ||
import { Table } from '../../../../src/sections/ui/table/Table' | ||
|
||
describe('Table', () => { | ||
it('should render children', () => { | ||
const { getByText } = render( | ||
<Table> | ||
<tbody> | ||
<tr> | ||
<td>Row 1, Column 1</td> | ||
<td>Row 1, Column 2</td> | ||
</tr> | ||
<tr> | ||
<td>Row 2, Column 1</td> | ||
<td>Row 2, Column 2</td> | ||
</tr> | ||
</tbody> | ||
</Table> | ||
) | ||
expect(getByText('Row 1, Column 1')).toBeInTheDocument() | ||
expect(getByText('Row 1, Column 2')).toBeInTheDocument() | ||
expect(getByText('Row 2, Column 1')).toBeInTheDocument() | ||
expect(getByText('Row 2, Column 2')).toBeInTheDocument() | ||
}) | ||
}) |