Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chino/emld 667 dedicated nft page w filtering #215

Open
wants to merge 22 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cc30ebd
feat: get all NFTs Treasury for `p/[projectId]/nft-treasury` page
IgnacioDebat Apr 11, 2024
049873e
feat: get all NFTs from treasury of a collection for `p/[projectId]/n…
IgnacioDebat Apr 11, 2024
4414af9
Merge pull request #197 from emerald-dao/chino/get-data-through-pages
mateoroldos Apr 11, 2024
94450ec
feat: move daoDataStore to +layout.svelte
IgnacioDebat Apr 12, 2024
c631306
feat: +page.svelte improvements
IgnacioDebat Apr 16, 2024
e12f52c
feat: small adaptations on NFTs related components
IgnacioDebat Apr 16, 2024
4927038
Merge branch 'dev' into chino/emld-667-dedicated-nft-page-w-filtering
IgnacioDebat Apr 16, 2024
3f1bf0b
feat: possibility to scroll window to top on Pagination
IgnacioDebat Apr 29, 2024
cd39d2c
feat: small changes on old components for NFT treasury page
IgnacioDebat Apr 29, 2024
2159642
feat: NBA filters functions and enums
IgnacioDebat Apr 29, 2024
818c8dc
feat: NFL filters functions and enums
IgnacioDebat Apr 29, 2024
4cd9879
feat: NFTs [collectionId] treasury
IgnacioDebat Apr 29, 2024
519021f
feat: Project NFT Treasury
IgnacioDebat Apr 29, 2024
f410975
Merge branch 'chino/emld-667-dedicated-nft-page-w-filtering' into chi…
IgnacioDebat Apr 29, 2024
710a730
fix: spelling
IgnacioDebat Apr 29, 2024
b6e5759
feat: NFT treasury cleanup
mateoroldos Apr 30, 2024
0fad298
feat: modify filters sidebar for small screens
IgnacioDebat May 3, 2024
252466f
Merge pull request #210 from emerald-dao/chino/basic-ui
IgnacioDebat May 7, 2024
d9fa82f
style: button style on collections filters
IgnacioDebat May 7, 2024
a30f7f6
Merge branch 'chino/emld-667-dedicated-nft-page-w-filtering' into mat…
IgnacioDebat May 7, 2024
a3e9f27
Merge pull request #211 from emerald-dao/mateo/nft-treasury-design
IgnacioDebat May 7, 2024
c20b420
Merge branch 'dev' into chino/emld-667-dedicated-nft-page-w-filtering
IgnacioDebat May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions frontend/src/lib/components/atoms/Pagination.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@
import Icon from '@iconify/svelte';

export let amountOfItems: number;

export let pageSize = 6;

export let pageStart = 0;
export let pageEnd = pageSize;
export let scrollToTopOnChange: boolean = false;

$: currentPage = Math.ceil(pageEnd / pageSize);

const nextPage = () => {
pageStart += pageSize;
pageEnd += pageSize;
if (scrollToTopOnChange) {
window.scrollTo(0, 0);
}
};
const prevPage = () => {
pageStart -= pageSize;
pageEnd -= pageSize;
if (scrollToTopOnChange) {
window.scrollTo(0, 0);
}
};

$: if (amountOfItems <= pageStart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
export let sortNFTs: boolean = false;
export let pageSize = 5;
export let clickable = false;
export let selectedCollection: string;
export let selectedCollection: string | null;
export let nftUuidOwnerMap: { [uuid: string]: string } = {};
export let selectedNFTIds: string[] = [];
export let nftTreasuryPage: boolean = false;

if (sortNFTs && selectedCollection === 'NFLAllDay') {
let tierRating = {
Expand Down Expand Up @@ -43,35 +44,64 @@
$: currentPageNFTs = filteredNfts.slice(pageStart, pageEnd);
</script>

<AnimatedSearchBar
items={NFTs}
bind:filteredItems={filteredNfts}
searchTerms={['name', 'serial']}
placeholder="Search NFT name or serial..."
/>
{#if filteredNfts.length === 0}
{#if !nftTreasuryPage}
<AnimatedSearchBar
items={NFTs}
bind:filteredItems={filteredNfts}
searchTerms={['name', 'serial']}
placeholder="Search NFT name or serial..."
/>
{/if}
{#if currentPageNFTs.length === 0}
<p class="small off">
<em> Sorry! We didn't find NFTs from this collection. </em>
</p>
{:else}
<div class="nfts-grid">
<div
class:treasury-page={nftTreasuryPage}
class:treasury-widget={!nftTreasuryPage}
class="nfts-grid"
>
{#each currentPageNFTs as nft (nft.id)}
<NFTCard
{nft}
{clickable}
on:click={() => handleNFTClick(nft.id)}
isSelected={selectedNFTIds.includes(nft.id)}
{selectedCollection}
donatedBy={nftUuidOwnerMap[nft.uuid]}
{nftTreasuryPage}
{selectedCollection}
/>
{/each}
</div>
<Pagination bind:pageStart bind:pageEnd amountOfItems={filteredNfts.length} {pageSize} />
<Pagination
bind:pageStart
bind:pageEnd
amountOfItems={filteredNfts.length}
{pageSize}
scrollToTopOnChange={nftTreasuryPage}
/>
{/if}

<style lang="scss">
.nfts-grid {
display: grid;
}
.treasury-page {
display: grid;
grid-template-columns: repeat(1, 1fr);
gap: var(--space-4);

@include mq('small') {
grid-template-columns: repeat(2, 1fr);
}

@include mq('medium') {
grid-template-columns: repeat(4, 1fr);
}
}

.treasury-widget {
grid-gap: var(--space-3);
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { createEventDispatcher } from 'svelte';

export let selectedCollection: string;
export let selectedCollection: string | undefined;
export let collectionIdentifiers: string[];
export let forExternalPage: boolean = false;
export let label: string = 'Collection';

const dispatch = createEventDispatcher();

const handleCollectionChange = () => {
dispatch('collectionChange', selectedCollection);
};

const redirectToExternalLink = () => {
if (selectedCollection) {
goto(`${$page.url.origin}/p/${$page.params.projectId}/nft-treasury/${selectedCollection}`);
}
};
</script>

<div class="column-1">
<label for="collection">Collection</label>
<select bind:value={selectedCollection} on:change={handleCollectionChange} name="collection">
<option value="" disabled selected hidden>Select one collection...</option>
<label for="collection">{label}</label>
<select
style={!forExternalPage ? `max-width: 250px;` : ''}
bind:value={selectedCollection}
on:change={forExternalPage ? redirectToExternalLink : handleCollectionChange}
name="collection"
>
<option value={undefined} disabled selected hidden>Select collection...</option>
{#each collectionIdentifiers as collection}
<option value={collection}>{collection}</option>
{/each}
</select>
</div>

<style lang="scss">
select {
max-width: 250px;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@
import UserAvatar from '$components/atoms/user/UserAvatar.svelte';
import Image from '$lib/components/Image.svelte';
import type { Nft } from '$lib/features/nft-treasury/types/nft.interface';
import Icon from '@iconify/svelte';
import NFTCardDetails from './NFTCardDetails.svelte';
import NBATopShot from './projects/NBATopShot.svelte';
import NFLAllDay from './projects/NFLAllDay.svelte';
import NBATopShotCard from './projects/NBATopShotCard.svelte';
import NFLAllDayCard from './projects/NFLAllDayCard.svelte';

export let nft: Nft;
export let isSelected: boolean;
export let clickable: boolean;
export let selectedCollection: string;
export let donatedBy: string | undefined;
export let nftTreasuryPage: boolean = false;
export let selectedCollection: string | null = null;

let resolvedCollectionId = selectedCollection || nft.collectionId;

let imgSrc = nft.thumbnail.startsWith('ipfs://')
? `https://nftstorage.link/ipfs/${nft.thumbnail.slice(7)}`
: nft.thumbnail;

let cardDetailComponents = {
NFLAllDay: NFLAllDay,
NBATopShot: NBATopShot
};
</script>

<div class="nft-wrapper" class:clickable class:selected={isSelected} on:click>
Expand All @@ -30,19 +27,18 @@
</div>
{/if}
<div class="image-wrapper">
<Image src={imgSrc} alt="NFT" width="100%" height="120px" />
<Image src={imgSrc} alt="NFT" width="100%" height={nftTreasuryPage ? '200px' : '150px'} />
</div>
<svelte:component
this={cardDetailComponents[selectedCollection] || NFTCardDetails}
{nft}
{donatedBy}
/>
{#if resolvedCollectionId === 'NBATopShot'}
<NBATopShotCard {nft} />
{:else if resolvedCollectionId === 'NFLAllDay'}
<NFLAllDayCard {nft} />
{:else}
<NFTCardDetails {nft} />
{/if}
{#if donatedBy}
<div class="donated-by">
<p class="xsmall">
<!-- <Icon icon="tabler:gift" /> -->
Donated by
</p>
<p class="xsmall">Donated by</p>
<UserAvatar
address={donatedBy}
imageSize="33px"
Expand All @@ -67,13 +63,18 @@

.donated-by {
width: 100%;
padding: var(--space-1) var(--space-2);
padding-inline: var(--space-4);
padding-block: var(--space-1) var(--space-4);
display: flex;
flex-direction: column;
gap: var(--space-1);

p {
font-style: italic;
display: flex;
justify-content: left;
align-items: center;
gap: var(--space-1);
color: var(--clr-text-off);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<style lang="scss">
.content-wrapper {
width: 100%;
padding: var(--space-4) var(--space-2);
padding: var(--space-4) var(--space-4);
border-top: 1px solid var(--clr-neutral-badge);
flex-grow: 1;

Expand All @@ -23,6 +23,7 @@
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
word-break: break-word;
text-align: left;
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<style lang="scss">
.content-wrapper {
width: 100%;
padding: var(--space-4) var(--space-2);
padding: var(--space-4) var(--space-4);
border-top: 1px solid var(--clr-neutral-badge);
display: flex;
flex-direction: column;
Expand All @@ -27,6 +27,7 @@
.heading {
text-align: left;
font-size: var(--font-size-2);
padding-bottom: var(--space-2);
}

.text {
Expand Down
Loading