-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from verida/feature/19-badge-related-components
Feature/19 badge related components
- Loading branch information
Showing
19 changed files
with
246 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from "react"; | ||
|
||
type HexagonBaseProps = { | ||
rounded?: boolean; | ||
} & React.ComponentPropsWithoutRef<"div">; | ||
|
||
export const HexagonBase: React.FunctionComponent<HexagonBaseProps> = ( | ||
props | ||
) => { | ||
const { rounded = false, ...otherProps } = props; | ||
|
||
// FIXME: Display the Verida Badges correctly in a rounded hexagonal shape and get rid of the 'rounded' prop | ||
|
||
return ( | ||
<div | ||
{...otherProps} | ||
style={{ | ||
clipPath: rounded | ||
? "path('M154.466 13.0153C149.97 5.26921 141.674 0.5 132.698 0.5L61.3019 0.5C52.326 0.5 44.0299 5.26921 39.5341 13.0153L3.88118 74.4438C-0.627062 82.2113 -0.627061 91.7887 3.88118 99.5562L39.5341 160.985C44.0299 168.731 52.326 173.5 61.3019 173.5H132.698C141.674 173.5 149.97 168.731 154.466 160.985L190.119 99.5562C194.627 91.7887 194.627 82.2113 190.119 74.4438L154.466 13.0153Z')" | ||
: "polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)", | ||
// For some reason the tailwind aspect-ratio class was not working, so put it in style | ||
aspectRatio: rounded ? "10/8.969072" : "10/8.66025", | ||
}} | ||
></div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { HexagonBase } from "components/atoms"; | ||
import { Badge } from "lib/types"; | ||
import React from "react"; | ||
import { Link } from "react-router-dom"; | ||
|
||
type HexagonProps = { | ||
badge: Badge; | ||
to: string; | ||
disableShadow?: boolean; | ||
} & Omit<React.ComponentPropsWithoutRef<"li">, "className">; | ||
|
||
export const BadgeMosaicItem: React.FunctionComponent<HexagonProps> = ( | ||
props | ||
) => { | ||
const { badge, to, disableShadow = false, ...otherProps } = props; | ||
|
||
return ( | ||
<li | ||
{...otherProps} | ||
className="relative w-[calc(4/3_*_100%)] -translate-x-[calc(1/8_*_100%)] odd:-translate-y-1/2" | ||
> | ||
<HexagonBase className="flex items-center justify-center"> | ||
<Link to={to} className="h-full w-full"> | ||
<img | ||
src={badge.media} | ||
alt={badge.tokenLabel} | ||
className="h-full w-full object-cover" | ||
/> | ||
</Link> | ||
</HexagonBase> | ||
{!disableShadow && ( | ||
<div className="absolute inset-0 -z-10 w-full blur-lg"> | ||
<HexagonBase className="w-full bg-badge-purple" /> | ||
</div> | ||
)} | ||
</li> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from "react"; | ||
import { Badge } from "lib/types"; | ||
import { BadgeMosaicItem } from "components/molecules"; | ||
|
||
type BadgeMosaicProps = { | ||
badges: Badge[]; | ||
} & React.ComponentPropsWithoutRef<"div">; | ||
|
||
export const BadgeMosaic: React.FunctionComponent<BadgeMosaicProps> = ( | ||
props | ||
) => { | ||
const { badges, ...containerProps } = props; | ||
|
||
// For n columns: | ||
// grid width = (3 * n) / (3 * n + 1) * 100% | ||
// grid margin-top = sqrt(3) / (3 * n + 1) * 100% | ||
return ( | ||
<div {...containerProps}> | ||
<ul className="mx-auto mt-[calc(1.73205/7_*_100%)] grid w-[calc(6/7_*_100%)] grid-cols-2 sm:mt-[calc(1.73205/13_*_100%)] sm:w-[calc(12/13_*_100%)] sm:grid-cols-4"> | ||
{badges.map((badge) => ( | ||
<BadgeMosaicItem | ||
key={`${badge.chainId}/${badge.contractAddress}/${badge.tokenId}`} | ||
badge={badge} | ||
to={`${badge.chainId}/${badge.contractAddress}/${badge.tokenId}`} | ||
/> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.