forked from decentraland/marketplace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add parcel coordinates (decentraland#354)
* Add ParcelCoordinates and Coordinates components * Add links * On hover and visited changes * Use a different gama for the hover * Change colors * Change parcel views to grids * Gridify the chips & modularize the ParcelCoordinates component * Modularize coordinate * Add classnames, add locales * Change LANDs to Parcels * Remove commented import * Add the collapsible component, fix push of URLs * Remove CSS * Fix imports * Fix imports * Fix ES translation * Fix collapsible by checking if the children changed * Remove atlas popup badge's css * Use Badge from decentraland-ui * Collapse when the childrens change
- Loading branch information
1 parent
320172b
commit 17592af
Showing
22 changed files
with
276 additions
and
31,510 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.Collapsible { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
} | ||
|
||
.showMore { | ||
margin-top: 15px; | ||
justify-content: center; | ||
} | ||
|
||
.showMore span { | ||
font-size: 15px; | ||
color: var(--primary); | ||
cursor: pointer; | ||
} | ||
|
||
.children { | ||
width: 100%; | ||
} | ||
|
||
.collapsibleWrapper { | ||
overflow: hidden; | ||
width: 100%; | ||
} |
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,55 @@ | ||
import React, { useCallback, useRef, useState, useEffect } from 'react' | ||
import { t } from 'decentraland-dapps/dist/modules/translation/utils' | ||
import { Row } from '../Layout/Row' | ||
import styles from './Collapsible.module.css' | ||
import { Props } from './Collapsible.types' | ||
|
||
const Collapsible = (props: Props) => { | ||
const { children, collapsedHeight } = props | ||
const [isCollapsed, setIsCollapsed] = useState(true) | ||
const [isCollapsible, setIsCollapsible] = useState(false) | ||
const mainElement = useRef<HTMLDivElement>(null) | ||
const handleChangeShowMore = useCallback(() => setIsCollapsed(!isCollapsed), [ | ||
isCollapsed | ||
]) | ||
|
||
useEffect(() => { | ||
setIsCollapsed(true) | ||
}, [children]) | ||
|
||
useEffect(() => { | ||
function setCollapsableUsingHeight() { | ||
if (!mainElement.current) return | ||
|
||
setIsCollapsible(mainElement.current.offsetHeight > collapsedHeight) | ||
} | ||
|
||
setCollapsableUsingHeight() | ||
window.addEventListener('resize', setCollapsableUsingHeight) | ||
return () => window.removeEventListener('resize', setCollapsableUsingHeight) | ||
}, [collapsedHeight, children, setIsCollapsible]) | ||
|
||
return ( | ||
<div className={styles.Collapsible}> | ||
<div | ||
style={{ height: isCollapsed ? collapsedHeight : 'auto' }} | ||
className={styles.collapsibleWrapper} | ||
> | ||
<div ref={mainElement} className={styles.children}> | ||
{children} | ||
</div> | ||
</div> | ||
{isCollapsible && ( | ||
<Row className={styles.showMore}> | ||
<span onClick={handleChangeShowMore}> | ||
{isCollapsed | ||
? t('parcel_coordinates.show_more') | ||
: t('parcel_coordinates.show_less')} | ||
</span> | ||
</Row> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
export default React.memo(Collapsible) |
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,6 @@ | ||
import React from 'react' | ||
|
||
export type Props = { | ||
children: React.ReactNode | ||
collapsedHeight: number | ||
} |
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,2 @@ | ||
import Collapsible from './Collapsible' | ||
export { Collapsible } |
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,7 @@ | ||
.pin { | ||
background-image: url(../../images/pin-land.svg); | ||
width: 17px; | ||
height: 16px; | ||
background-size: 19px; | ||
background-position: -2px -1px; | ||
} |
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,17 @@ | ||
import React from 'react' | ||
import { Badge } from 'decentraland-ui' | ||
import { Props } from './Coordinate.types' | ||
import styles from './Coordinate.module.css' | ||
|
||
const Coordinate = (props: Props) => { | ||
const { x, y, className } = props | ||
|
||
return ( | ||
<Badge className={className} color="#37333D"> | ||
<i className={styles.pin} /> | ||
{`${x},${y}`} | ||
</Badge> | ||
) | ||
} | ||
|
||
export default React.memo(Coordinate) |
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,5 @@ | ||
export type Props = { | ||
x: number | ||
y: number | ||
className?: string | ||
} |
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,3 @@ | ||
import Coordinate from './Coordinate' | ||
|
||
export { Coordinate } |
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
43 changes: 43 additions & 0 deletions
43
webapp/src/components/NFTPage/EstateDetail/ParcelCoordinates/ParcelCoordinates.module.css
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,43 @@ | ||
.coordinates { | ||
display: grid; | ||
justify-content: space-between; | ||
grid-template-columns: repeat(auto-fill, 110px); | ||
margin-top: 13px; | ||
overflow: hidden; | ||
} | ||
|
||
.collapsed { | ||
height: 88px; | ||
} | ||
|
||
.expanded { | ||
height: auto; | ||
} | ||
|
||
.coordinates a .coordinate { | ||
color: var(--text); | ||
} | ||
|
||
.coordinates a .coordinate:hover { | ||
background-color: var(--primary) !important; | ||
} | ||
|
||
.coordinates a:visited .coordinate { | ||
background-color: #242129 !important; | ||
} | ||
|
||
.coordinate { | ||
margin: 6px; | ||
cursor: pointer !important; | ||
} | ||
|
||
.showMore { | ||
margin-top: 15px; | ||
justify-content: center; | ||
} | ||
|
||
.showMore span { | ||
font-size: 15px; | ||
color: var(--primary); | ||
cursor: pointer; | ||
} |
41 changes: 41 additions & 0 deletions
41
webapp/src/components/NFTPage/EstateDetail/ParcelCoordinates/ParcelCoordinates.tsx
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,41 @@ | ||
import React from 'react' | ||
import { Header } from 'decentraland-ui' | ||
import { Link } from 'react-router-dom' | ||
import { t } from 'decentraland-dapps/dist/modules/translation/utils' | ||
import classNames from 'classnames' | ||
|
||
import { locations } from '../../../../modules/routing/locations' | ||
import { Row } from '../../../Layout/Row' | ||
import Coordinate from '../../../Coordinate/Coordinate' | ||
import { Collapsible } from '../../../Collapsible' | ||
import { Props } from './ParcelCoordinates.types' | ||
import styles from './ParcelCoordinates.module.css' | ||
|
||
const ParcelCoordinates = (props: Props) => { | ||
const { estate } = props | ||
const coordinatesClasses = classNames(styles.coordinates) | ||
|
||
return ( | ||
<div className={styles.ParcelCoordinates}> | ||
<Header sub>{t('parcel_coordinates.title')}</Header> | ||
<Collapsible collapsedHeight={60}> | ||
<Row className={coordinatesClasses}> | ||
{estate.parcels.map((parcel, index) => ( | ||
<Link | ||
to={locations.parcel(parcel.x.toString(), parcel.y.toString())} | ||
> | ||
<Coordinate | ||
className={styles.coordinate} | ||
key={index} | ||
x={parcel.x} | ||
y={parcel.y} | ||
/> | ||
</Link> | ||
))} | ||
</Row> | ||
</Collapsible> | ||
</div> | ||
) | ||
} | ||
|
||
export default React.memo(ParcelCoordinates) |
5 changes: 5 additions & 0 deletions
5
webapp/src/components/NFTPage/EstateDetail/ParcelCoordinates/ParcelCoordinates.types.ts
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,5 @@ | ||
import { Estate } from '../../../../modules/nft/estate/types' | ||
|
||
export type Props = { | ||
estate: Estate | ||
} |
2 changes: 2 additions & 0 deletions
2
webapp/src/components/NFTPage/EstateDetail/ParcelCoordinates/index.ts
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,2 @@ | ||
import ParcelCoordinates from './ParcelCoordinates' | ||
export { ParcelCoordinates } |
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