-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1398 from coveo/new-table-in-loading
Demo Only: New table in loading
- Loading branch information
Showing
71 changed files
with
1,905 additions
and
395 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 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
1 change: 0 additions & 1 deletion
1
packages/react-vapor/src/components/flatSelect/FlatSelectConnected.tsx
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
21 changes: 21 additions & 0 deletions
21
packages/react-vapor/src/components/flatSelect/FlatSelectWithPrepend.tsx
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,21 @@ | ||
import * as classNames from 'classnames'; | ||
import {FunctionComponent} from 'react'; | ||
import * as React from 'react'; | ||
import {IFlatSelectOwnProps} from './FlatSelect'; | ||
import {FlatSelectConnected} from './FlatSelectConnected'; | ||
|
||
export interface IFlatSelectWithPrependProps extends IFlatSelectOwnProps { | ||
prepend?: React.ReactNode; | ||
prependClassName?: string; | ||
} | ||
|
||
export const FlatSelectWithPrepend: FunctionComponent<IFlatSelectWithPrependProps> = ({ | ||
prepend, | ||
prependClassName = '', | ||
...flatSelectProps | ||
}) => ( | ||
<div className={classNames('prepended-flat-select', prependClassName)}> | ||
<div className="flat-select-prepend">{prepend}</div> | ||
<FlatSelectConnected {...flatSelectProps} /> | ||
</div> | ||
); |
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
11 changes: 11 additions & 0 deletions
11
packages/react-vapor/src/components/loading/components/ContentLoadingPlaceholder.tsx
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 * as classNames from 'classnames'; | ||
import * as React from 'react'; | ||
|
||
export interface IContentLoadingPlaceholder { | ||
className?: string; | ||
} | ||
|
||
export const ContentLoadingPlaceholder: React.FunctionComponent<IContentLoadingPlaceholder> = ({ | ||
className = '', | ||
children, | ||
}) => <div className={classNames('text-content-placeholder', className)}>{children}</div>; |
43 changes: 24 additions & 19 deletions
43
packages/react-vapor/src/components/loading/components/PaginationLoading.tsx
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
41 changes: 23 additions & 18 deletions
41
packages/react-vapor/src/components/loading/components/TableLoading.tsx
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 |
---|---|---|
@@ -1,32 +1,37 @@ | ||
import * as classNames from 'classnames'; | ||
import * as React from 'react'; | ||
import * as _ from 'underscore'; | ||
|
||
export const TableLoading = ({ | ||
numberOfColumn = 4, | ||
numberOfRow = 10, | ||
}: { | ||
numberOfColumn?: number; | ||
numberOfRow?: number; | ||
}) => { | ||
const Table = ({numberOfColumns = 4, numberOfRow = 10}: {numberOfColumns?: number; numberOfRow?: number}) => { | ||
return ( | ||
<> | ||
<table className="table big-table"> | ||
<tbody> | ||
{_.times(numberOfRow, () => ( | ||
<tr className="mod-border-bottom no-hover"> | ||
{_.times(numberOfColumn, () => ( | ||
<TableRowLoading /> | ||
))} | ||
</tr> | ||
))} | ||
</tbody> | ||
<Body numberOfColumns={numberOfColumns} numberOfRow={numberOfRow} /> | ||
</table> | ||
</> | ||
); | ||
}; | ||
|
||
const TableRowLoading = () => ( | ||
const Body = ({numberOfColumns = 4, numberOfRow = 10}: {numberOfColumns?: number; numberOfRow?: number}) => ( | ||
<tbody> | ||
{_.times(numberOfRow, (nColumn: number) => ( | ||
<tr key={`table-row-loading-${nColumn}`} className="mod-border-bottom no-hover"> | ||
{_.times(numberOfColumns, (nRow: number) => ( | ||
<Row key={`table-row-loading-${nRow}`} num={nColumn} /> | ||
))} | ||
</tr> | ||
))} | ||
</tbody> | ||
); | ||
|
||
const Row = ({num}: {num: number}) => ( | ||
<td className="table-cell-loading"> | ||
<div className="table-cell-content-loading" /> | ||
<div className={classNames('table-cell-content-loading', {'mod-half': num % 2})} /> | ||
</td> | ||
); | ||
|
||
export const TableLoading = { | ||
Table, | ||
Body, | ||
Row, | ||
}; |
23 changes: 23 additions & 0 deletions
23
packages/react-vapor/src/components/loading/components/TextLoadingPlaceholder.tsx
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,23 @@ | ||
import * as classNames from 'classnames'; | ||
import * as React from 'react'; | ||
|
||
export interface ITextLoadingPlaceholder { | ||
small?: boolean; | ||
word?: boolean; | ||
large?: boolean; | ||
className?: string; | ||
} | ||
|
||
export const TextLoadingPlaceholder = ({small, word, large, className = ''}: ITextLoadingPlaceholder) => ( | ||
<div | ||
className={classNames( | ||
'text-content-placeholder', | ||
{ | ||
'mod-small': small, | ||
'mod-word': word, | ||
'mod-large': large, | ||
}, | ||
className | ||
)} | ||
/> | ||
); |
14 changes: 14 additions & 0 deletions
14
packages/react-vapor/src/components/loading/components/tests/ActionBarLoading.spec.tsx
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,14 @@ | ||
import {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {ActionBarLoading} from '../ActionBarLoading'; | ||
|
||
describe('ActionBarLoading tests', () => { | ||
describe('<ActionBarLoading />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<ActionBarLoading />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/react-vapor/src/components/loading/components/tests/BasicHeaderLoading.spec.tsx
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,14 @@ | ||
import {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {BasicHeaderLoading} from '../BasicHeaderLoading'; | ||
|
||
describe('BasicHeaderLoading tests', () => { | ||
describe('<BasicHeaderLoading />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<BasicHeaderLoading />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
...es/react-vapor/src/components/loading/components/tests/ContentLoadingPlaceholder.spec.tsx
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,19 @@ | ||
import {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {ContentLoadingPlaceholder} from '../ContentLoadingPlaceholder'; | ||
|
||
describe('ContentLoadingPlaceholder tests', () => { | ||
describe('<ContentLoadingPlaceholder />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow( | ||
<ContentLoadingPlaceholder> | ||
<div>Test</div> | ||
</ContentLoadingPlaceholder>, | ||
{} | ||
); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/react-vapor/src/components/loading/components/tests/PaginationLoading.spec.tsx
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,14 @@ | ||
import {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {PaginationLoading} from '../PaginationLoading'; | ||
|
||
describe('PaginationLoading tests', () => { | ||
describe('<PaginationLoading />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<PaginationLoading />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
packages/react-vapor/src/components/loading/components/tests/TableLoading.spec.tsx
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,52 @@ | ||
import {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {TableLoading} from '../TableLoading'; | ||
|
||
describe('TableLoading tests', () => { | ||
describe('<TableLoading.Table />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<TableLoading.Table />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('<TableLoading.Body />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<TableLoading.Body />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
|
||
it('should render <tr/> equal of the the number of columns sent as parameter', () => { | ||
const wrapper = shallow(<TableLoading.Body numberOfRow={10} />, {}); | ||
expect(wrapper.find('tr').length).toBe(10); | ||
}); | ||
|
||
it('should render <Row/> equal of the the number of columns sent as parameter', () => { | ||
const wrapper = shallow(<TableLoading.Body numberOfColumns={8} numberOfRow={1} />, {}); | ||
expect(wrapper.find(TableLoading.Row).length).toBe(8); | ||
}); | ||
}); | ||
|
||
describe('<TableLoading.Row />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<TableLoading.Row num={0} />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
|
||
it('should add the class mod-haft if the number is odd', () => { | ||
const wrapper = shallow(<TableLoading.Row num={1} />, {}); | ||
expect(wrapper.find('div').hasClass('mod-half')).toBe(true); | ||
}); | ||
|
||
it('should not add the class mod-haft if the number is even', () => { | ||
const wrapper = shallow(<TableLoading.Row num={2} />, {}); | ||
expect(wrapper.find('div').hasClass('mod-half')).toBe(false); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.