docbrown/app/javascript/listings/singleListing/AuthorInfo.jsx
ludwiczakpawel 313cd61ee3
Listings redesign (#9349)
* 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>
2020-07-30 17:53:35 -04:00

78 lines
1.7 KiB
JavaScript

import PropTypes from 'prop-types';
import { h } from 'preact';
import listingPropTypes from './listingPropTypes';
const LocationText = ({ location }) => {
return location ? (
<a
data-testid="single-listing-location"
className="crayons-link crayons-link--secondary"
href={`/listings/?q=${location}`}
>
{'・'}
{location}
</a>
) : (
''
);
};
LocationText.propTypes = {
location: PropTypes.string,
};
LocationText.defaultProps = {
location: null,
};
const AuthorInfo = ({ listing, onCategoryClick }) => {
const { category, location, author = {} } = listing;
const { username, name, profile_image_90 } = author;
return (
<footer className="fs-s flex items-center">
<a
href={`/${username}`}
className="crayons-avatar crayons-avatar--l mr-2"
>
<img
src={profile_image_90}
alt={name}
width="32"
height="32"
className="crayons-avatar__image"
/>
</a>
<div>
<a
href={`/${username}`}
className="crayons-link fw-medium"
>
{name}
</a>
<p className="fs-xs">
<a
href={`/listings/${category}`}
onClick={(e) => onCategoryClick(e, category)}
data-no-instant
className="crayons-link crayons-link--secondary"
>
{category}
</a>
<LocationText location={location} />
</p>
</div>
</footer>
);
};
AuthorInfo.propTypes = {
listing: listingPropTypes.isRequired,
onCategoryClick: PropTypes.func,
};
AuthorInfo.defaultProps = {
onCategoryClick: () => {},
};
export default AuthorInfo;