* flare tag line height * . * dropdown fix + actions bar fix * actions bar on mob * . * css commented out * . * button fix * preload adjustments * tags * Fixed listings modal to make it semantic HTML via <dialog />. * Refactor an a11y fix. * Removed test that is no longer needed. * Added missing global function for test.. * Fixed broken <ListingFiltersCategories /> tests. * Refactor of mobile dropdown for listing categories. * Updated a TODO. * Made the clear query button a crayons Preact button. * padding * Fixed listings modal for accessiblilty. * Removed rspecs that are no longer valid. * We're no longer using the <dialog /> element, at least for now, so CSS changes aren't necessary. * Wasn't supposed to be committed. Co-authored-by: Nick Taylor <nick@dev.to> Co-authored-by: rhymes <rhymes@hey.com> Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
104 lines
2.6 KiB
JavaScript
104 lines
2.6 KiB
JavaScript
import { h, Component } from 'preact';
|
|
import PropTypes from 'prop-types';
|
|
|
|
import Header from './Header';
|
|
import AuthorInfo from './AuthorInfo';
|
|
import listingPropTypes from './listingPropTypes';
|
|
|
|
export class SingleListing extends Component {
|
|
|
|
listingContent = (listing, currentUserId, onChangeCategory, onOpenModal, onAddTag) => {
|
|
return (
|
|
<div className="relative">
|
|
<Header
|
|
listing={listing}
|
|
currentUserId={currentUserId}
|
|
onTitleClick={onOpenModal}
|
|
onAddTag={onAddTag}
|
|
/>
|
|
<div
|
|
className="mb-4"
|
|
dangerouslySetInnerHTML={{ __html: listing.processed_html }} // eslint-disable-line react/no-danger
|
|
/>
|
|
<AuthorInfo listing={listing} onCategoryClick={onChangeCategory} />
|
|
</div>
|
|
);
|
|
};
|
|
|
|
listingInline = (listing, currentUserId, onChangeCategory, onOpenModal, onAddTag) => {
|
|
return (
|
|
<div
|
|
className="single-listing relative crayons-card"
|
|
id={`single-listing-${listing.id}`}
|
|
data-testid={`single-listing-${listing.id}`}
|
|
>
|
|
<div className="listing-content p-4">
|
|
{this.listingContent(
|
|
listing,
|
|
currentUserId,
|
|
onChangeCategory,
|
|
onOpenModal,
|
|
onAddTag
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
listingModal = (listing, currentUserId, onChangeCategory, onOpenModal, onAddTag) => {
|
|
return (
|
|
<div
|
|
className="single-listing relative"
|
|
id={`single-listing-${listing.id}`}
|
|
data-testid={`single-listing-${listing.id}`}
|
|
>
|
|
<div className="listing-content">
|
|
{this.listingContent(
|
|
listing,
|
|
currentUserId,
|
|
onChangeCategory,
|
|
onOpenModal,
|
|
onAddTag,
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
render() {
|
|
const { listing, currentUserId, onChangeCategory, onOpenModal, isOpen, onAddTag } = this.props;
|
|
return (
|
|
isOpen ?
|
|
this.listingModal(
|
|
listing,
|
|
currentUserId,
|
|
onChangeCategory,
|
|
onOpenModal,
|
|
onAddTag
|
|
)
|
|
:
|
|
this.listingInline(
|
|
listing,
|
|
currentUserId,
|
|
onChangeCategory,
|
|
onOpenModal,
|
|
onAddTag
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
SingleListing.propTypes = {
|
|
listing: listingPropTypes.isRequired,
|
|
onOpenModal: PropTypes.func.isRequired,
|
|
onChangeCategory: PropTypes.func.isRequired,
|
|
isOpen: PropTypes.bool.isRequired,
|
|
currentUserId: PropTypes.number,
|
|
onAddTag: PropTypes.func.isRequired
|
|
};
|
|
|
|
SingleListing.defaultProps = {
|
|
currentUserId: null,
|
|
};
|
|
|
|
SingleListing.displayName = 'SingleListing';
|