Skip to content

Commit

Permalink
Merge pull request #98 from mavdotso/collection-descriptions
Browse files Browse the repository at this point in the history
feat: Full collection descriptions modal
  • Loading branch information
NickJ202 authored Jul 1, 2024
2 parents 5ad167c + 15a172a commit 742445a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/helpers/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const language = {
assetQuantityInfo: `Slide for asset quantity`,
balances: `Balances`,
bio: `Bio`,
description: `Description`,
blockHeight: `Block Height`,
buy: `Buy`,
cancel: `Cancel`,
Expand Down Expand Up @@ -136,6 +137,7 @@ export const language = {
useLightDisplay: `Use light display`,
viewAllCollections: `View all collections`,
viewFullBio: `View full bio`,
viewFullDescription: `View full description`,
viewOnArweave: `View on Arweave`,
viewProfile: `View profile`,
},
Expand Down
20 changes: 19 additions & 1 deletion src/views/Collection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getCollectionById } from 'api';

import { CurrencyLine } from 'components/atoms/CurrencyLine';
import { Loader } from 'components/atoms/Loader';
import { Modal } from 'components/molecules/Modal';
import { OwnerLine } from 'components/molecules/OwnerLine';
import { AssetsTable } from 'components/organisms/AssetsTable';
import { DEFAULTS, PAGINATORS, URLS } from 'helpers/config';
Expand All @@ -15,6 +16,8 @@ import { useLanguageProvider } from 'providers/LanguageProvider';

import * as S from './styles';

const MAX_DESCRIPTION_LENGTH = 50;

export default function Collection() {
const { id } = useParams();
const navigate = useNavigate();
Expand All @@ -25,6 +28,7 @@ export default function Collection() {
const [collection, setCollection] = React.useState<CollectionDetailType | null>(null);
const [collectionLoading, setCollectionLoading] = React.useState<boolean>(false);
const [collectionErrorResponse, setCollectionErrorResponse] = React.useState<string | null>(null);
const [showFullDescription, setShowFullDescription] = React.useState<boolean>(false);

React.useEffect(() => {
(async function () {
Expand Down Expand Up @@ -108,7 +112,14 @@ export default function Collection() {
</S.InfoCreator>
{collection.description && (
<S.InfoDescription>
<p>{collection.description}</p>
<S.DescriptionText>
{collection.description.length > MAX_DESCRIPTION_LENGTH
? collection.description.substring(0, MAX_DESCRIPTION_LENGTH) + '...'
: collection.description}
</S.DescriptionText>
{collection.description.length > MAX_DESCRIPTION_LENGTH && (
<button onClick={() => setShowFullDescription(true)}>{language.viewFullDescription}</button>
)}
</S.InfoDescription>
)}
</S.InfoFooter>
Expand All @@ -119,6 +130,13 @@ export default function Collection() {
<AssetsTable ids={collection.assetIds} type={'grid'} pageCount={PAGINATORS.collection.assets} />
)}
</S.AssetsWrapper>
{showFullDescription && collection.description && (
<Modal header={language.description} handleClose={() => setShowFullDescription(false)}>
<div className={'modal-wrapper'}>
<p>{collection.description}</p>
</div>
</Modal>
)}
</>
);
} else {
Expand Down
31 changes: 21 additions & 10 deletions src/views/Collection/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,32 @@ export const InfoCreator = styled.div`
`;

export const InfoDescription = styled.div`
width: fit-content;
width: 100%;
max-width: 460px;
p {
font-size: ${(props) => props.theme.typography.size.base};
font-family: ${(props) => props.theme.typography.family.primary};
font-weight: ${(props) => props.theme.typography.weight.bold};
position: relative;
button {
color: ${(props) => props.theme.colors.font.light1};
line-height: 1.65;
max-width: 100%;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
font-size: ${(props) => props.theme.typography.size.small};
font-weight: ${(props) => props.theme.typography.weight.bold};
&:hover {
color: ${(props) => props.theme.colors.font.light2};
}
}
`;

export const DescriptionText = styled.p`
font-size: ${(props) => props.theme.typography.size.base};
font-family: ${(props) => props.theme.typography.family.primary};
font-weight: ${(props) => props.theme.typography.weight.bold};
color: ${(props) => props.theme.colors.font.light1};
line-height: 1.65;
margin: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;

export const AssetsWrapper = styled.div`
margin: 60px 0 0 0;
`;
4 changes: 1 addition & 3 deletions src/views/Profile/ProfileHeader/ProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ export default function ProfileHeader(props: IProps) {
{showBio && props.profile && props.profile.bio && (
<Modal header={language.bio} handleClose={() => setShowBio(false)}>
<div className={'modal-wrapper'}>
<S.HeaderInfoBio>
<p>{props.profile.bio}</p>
</S.HeaderInfoBio>
<p>{props.profile.bio}</p>
</div>
</Modal>
)}
Expand Down

0 comments on commit 742445a

Please sign in to comment.