-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
table: reviewing themes from thematic tables
- Loading branch information
Showing
18 changed files
with
320 additions
and
192 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 was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
src/lib/components/list/thematic/MoreLikeThisRecords.stories.js
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
src/lib/components/list/thematic/MoreLikeThisRecords.test.js
This file was deleted.
Oops, something went wrong.
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
11 changes: 11 additions & 0 deletions
11
src/lib/components/table/thematic/RecordsTable/RecordsTable.css
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 @@ | ||
/* | ||
* This file is part of GEO-Components-React. | ||
* Copyright (C) 2022 GEO Secretariat. | ||
* | ||
* GEO-Components-React is free software; you can redistribute it and/or modify it | ||
* under the terms of the MIT License; see LICENSE file for more details. | ||
*/ | ||
|
||
.table-records .ui.container .grid p { | ||
overflow-wrap: break-word; | ||
} |
154 changes: 154 additions & 0 deletions
154
src/lib/components/table/thematic/RecordsTable/RecordsTable.js
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,154 @@ | ||
/* | ||
* This file is part of GEO-Components-React. | ||
* Copyright (C) 2022 GEO Secretariat. | ||
* | ||
* GEO-Components-React is free software; you can redistribute it and/or modify it | ||
* under the terms of the MIT License; see LICENSE file for more details. | ||
*/ | ||
|
||
import React, { useMemo } from 'react'; | ||
import { PaginableTable } from '../../moldure'; | ||
|
||
import _get from 'lodash/get'; | ||
|
||
import regeneratorRuntime from 'regenerator-runtime'; | ||
import { useAsyncDebounce } from 'react-table'; | ||
|
||
import { Grid, Button, Icon, Input, Header, Label } from 'semantic-ui-react'; | ||
|
||
import './RecordsTable.css'; | ||
import { mutateRecordData } from '../../../list/base/mutations'; | ||
|
||
|
||
/** | ||
* Table of Records component. | ||
*/ | ||
export const RecordsTable = ({ tableData, tableConfig }) => { | ||
const tableColumnsDefinition = useMemo(() => { | ||
return [ | ||
// Defining invisible columns that are used as the index for the table filter | ||
{ | ||
Header: () => null, | ||
id: 'idx_title', | ||
accessor: 'title', | ||
}, | ||
{ | ||
Header: () => null, | ||
id: 'idx_relation_type', | ||
accessor: 'relation_type.title_l10n', | ||
}, | ||
{ | ||
Header: () => null, | ||
id: 'idx_resource_type', | ||
accessor: 'resource_type.title_l10n', | ||
}, | ||
{ | ||
Header: () => null, | ||
id: 'idx_scheme', | ||
accessor: 'scheme', | ||
}, | ||
// Content column | ||
{ | ||
Header: () => null, | ||
id: 'table-see-also-records', | ||
Cell: ({ row }) => { | ||
// Getting data | ||
const { original: rowData } = row; | ||
|
||
// Preparing data | ||
// Title and date | ||
const rowTitle = _get(rowData, 'title'); | ||
const rowDate = _get(rowData, 'date'); | ||
|
||
// URL | ||
const rowUrl = _get(rowData, 'url'); | ||
|
||
// Resource Type | ||
const rowLabel = _get(rowData, 'label'); | ||
const rowLabelColor = _get(rowData, 'labelColor'); | ||
|
||
return ( | ||
<Grid> | ||
<Grid.Row verticalAlign="middle"> | ||
<Grid.Column | ||
widescreen={13} | ||
largeScreen={13} | ||
computer={13} | ||
tablet={13} | ||
mobile={12} | ||
> | ||
<div> | ||
<Label size={'tiny'} color={rowLabelColor}> | ||
{rowLabel} | ||
</Label> | ||
</div> | ||
|
||
<Grid className={'user-stories-metadata'}> | ||
<Grid.Row columns={1}> | ||
<Grid.Column> | ||
<Header>{rowTitle}</Header> | ||
</Grid.Column> | ||
</Grid.Row> | ||
<Grid.Row columns={1}> | ||
<Grid.Column> | ||
<p className="content-description"> | ||
{rowDate} | ||
</p> | ||
</Grid.Column> | ||
</Grid.Row> | ||
</Grid> | ||
</Grid.Column> | ||
|
||
<Grid.Column | ||
widescreen={3} | ||
largeScreen={3} | ||
computer={3} | ||
tablet={3} | ||
mobile={3} | ||
> | ||
<Button.Group size={'mini'} floated={'right'}> | ||
<Button | ||
content={'Access'} | ||
as={'a'} | ||
size={'mini'} | ||
href={rowUrl} | ||
> | ||
Access | ||
</Button> | ||
</Button.Group> | ||
</Grid.Column> | ||
|
||
</Grid.Row> | ||
</Grid> | ||
); | ||
}, | ||
}, | ||
]; | ||
}); | ||
|
||
const tableDataMemoized = useMemo(() => tableData.map((row) => | ||
mutateRecordData(row, 'resourceType', 'gray') | ||
)); | ||
|
||
return ( | ||
<div className={'table-records'}> | ||
<PaginableTable | ||
unstackable | ||
fixed={true} | ||
padded={true} | ||
data={tableDataMemoized} | ||
columnsConfiguration={tableColumnsDefinition} | ||
initialState={{ | ||
hiddenColumns: [ | ||
'idx_title', | ||
'idx_relation_type', | ||
'idx_resource_type', | ||
'idx_scheme', | ||
], | ||
}} | ||
showHeader={false} | ||
{...tableConfig} | ||
/> | ||
</div> | ||
); | ||
}; |
31 changes: 31 additions & 0 deletions
31
src/lib/components/table/thematic/RecordsTable/RecordsTable.stories.js
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,31 @@ | ||
/* | ||
* This file is part of GEO-Components-React. | ||
* Copyright (C) 2022 GEO Secretariat. | ||
* | ||
* GEO-Components-React is free software; you can redistribute it and/or modify it | ||
* under the terms of the MIT License; see LICENSE file for more details. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { RecordsTable as RecordsTableComponent } from './RecordsTable'; | ||
|
||
import recordsApiData from '../../../../../mocks/list/records-api.json'; | ||
|
||
export default { | ||
title: 'Table/Thematic/Records table', | ||
component: RecordsTableComponent, | ||
}; | ||
|
||
/** | ||
* Component template | ||
*/ | ||
const Template = (args) => <RecordsTableComponent {...args} />; | ||
|
||
/** | ||
* Component stories | ||
*/ | ||
export const Base = Template.bind({}); | ||
Base.args = { | ||
tableData: recordsApiData.hits.hits, | ||
}; |
Oops, something went wrong.