Skip to content

Commit

Permalink
feat: add detail page (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Oct 20, 2023
1 parent ba2daca commit 72bda40
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/generic/sub-header/SubHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SubHeader = ({
<small className="sub-header-title-subtitle">{subtitle}</small>
{title}
{titleActions && (
<ActionRow className="ml-auto">
<ActionRow className="ml-auto mt-1">
{titleActions}
</ActionRow>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/generic/sub-header/SubHeader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 1.5rem;
margin-bottom: 12px;
}

2 changes: 1 addition & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const App = () => {
render={({ match }) => {
const { params: { taxonomyId } } = match;
return (
<TaxonomyDetailPage taxonomyId={taxonomyId} />
<TaxonomyDetailPage taxonomyId={Number(taxonomyId)} />
);
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/taxonomy/TaxonomyCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const TaxonomyCard = ({ className, original, intl }) => {
);

return (
<Card className={classNames('taxonomy-card', className)} data-testid={`taxonomy-card-${id}`}>
<Card className={classNames('taxonomy-card', className)} data-testid={`taxonomy-card-${id}`} isClickable>
<Link ariaLabel="view taxonomy details" className="stretched-link" to={`/taxonomy-list/${id}`} />
<Card.Header
title={name}
Expand Down
42 changes: 42 additions & 0 deletions src/taxonomy/taxonomy-detail/TagListTable.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {
DataTable,
TextFilter,
} from '@edx/paragon';
import Proptypes from 'prop-types';

const tagsSample = [
{ name: 'Tag 1' },
{ name: 'Tag 2' },
{ name: 'Tag 3' },
{ name: 'Tag 4' },
{ name: 'Tag 5' },
{ name: 'Tag 6' },
{ name: 'Tag 7' },
];

const TagListTable = ({ tags }) => (

Check failure on line 17 in src/taxonomy/taxonomy-detail/TagListTable.jsx

View workflow job for this annotation

GitHub Actions / tests

'tags' is defined but never used
<DataTable
isFilterable
isSortable
defaultColumnValues={{ Filter: TextFilter }}
itemCount={tagsSample.length}
data={tagsSample}
columns={[
{
Header: 'Name',
accessor: 'name',
},
]}
>
<DataTable.TableControlBar />
<DataTable.Table />
<DataTable.EmptyTable content="No results found" />
<DataTable.TableFooter />
</DataTable>
);

TagListTable.propTypes = {
tags: Proptypes.array.isRequired,

Check failure on line 39 in src/taxonomy/taxonomy-detail/TagListTable.jsx

View workflow job for this annotation

GitHub Actions / tests

Prop type "array" is forbidden
};

export default TagListTable;
29 changes: 19 additions & 10 deletions src/taxonomy/taxonomy-detail/TaxonomyDetailPage.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from 'react';
import {
Container,
Layout,
} from '@edx/paragon';
import Proptypes from 'prop-types';

import PermissionDeniedAlert from '../../generic/PermissionDeniedAlert';
import Loading from '../../generic/Loading';
import Header from '../../header';
import SubHeader from '../../generic/sub-header/SubHeader';
import TaxonomyDetailSideCard from './TaxonomyDetailSideCard';
import TagListTable from './TagListTable';
import { useTaxonomyDetailDataResponse, useTaxonomyDetailDataStatus } from '../api/hooks/selectors';

const TaxonomyDetailContent = ({ taxonomyId }) => {
Expand Down Expand Up @@ -42,16 +45,22 @@ const TaxonomyDetailContent = ({ taxonomyId }) => {
/>
</Container>
</div>
<div className="bg-light-400 mt-1">
<Container size="xl">
{
taxonomy ? (
<div>
<pre>{JSON.stringify(taxonomy, null, 2)}</pre>
</div>
) : (<>Taxonomy not found</>)
}
</Container>
<div className="bg-light-400 m-4">
<Layout
lg={[{ span: 9 }, { span: 3 }]}
md={[{ span: 9 }, { span: 3 }]}
sm={[{ span: 9 }, { span: 3 }]}
xs={[{ span: 9 }, { span: 3 }]}
xl={[{ span: 9 }, { span: 3 }]}
>
<Layout.Element>
<TagListTable />
</Layout.Element>
<Layout.Element>
<TaxonomyDetailSideCard taxonomy={taxonomy} />
</Layout.Element>

</Layout>
</div>
</>
);
Expand Down
27 changes: 27 additions & 0 deletions src/taxonomy/taxonomy-detail/TaxonomyDetailSideCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
Card,
} from '@edx/paragon';
import Proptypes from 'prop-types';

const TaxonomyDetailSideCard = ({ taxonomy }) => (
<Card>
<Card.Header title="Taxonomy details" />
<Card.Section title="Title">
{taxonomy.name}
</Card.Section>
<Card.Divider className="ml-3 mr-3" />
<Card.Section title="Description">
{taxonomy.description}
</Card.Section>
<Card.Divider className="ml-3 mr-3" />
<Card.Section title="Copyright">
No copyright added
</Card.Section>
</Card>
);

TaxonomyDetailSideCard.propTypes = {
taxonomy: Proptypes.object.isRequired,

Check failure on line 24 in src/taxonomy/taxonomy-detail/TaxonomyDetailSideCard.jsx

View workflow job for this annotation

GitHub Actions / tests

Prop type "object" is forbidden
};

export default TaxonomyDetailSideCard;

0 comments on commit 72bda40

Please sign in to comment.