-
Notifications
You must be signed in to change notification settings - Fork 268
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 #592 from ensdomains/dev
Deploy to live
- Loading branch information
Showing
12 changed files
with
189 additions
and
42 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
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
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
131 changes: 131 additions & 0 deletions
131
src/components/SingleName/ResolverAndRecords/ArtRecords.js
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,131 @@ | ||
import React from 'react' | ||
import { Query } from 'react-apollo' | ||
import styled from '@emotion/styled' | ||
|
||
import Loader from '../../Loader' | ||
|
||
import { | ||
RecordsContent, | ||
RecordsItem, | ||
RecordsKey, | ||
RecordsValue | ||
} from './RecordsItem' | ||
|
||
const Records = styled('div')` | ||
border-radius: 6px; | ||
border: 1px solid #ededed; | ||
box-shadow: inset 0 0 10px 0 rgba(235, 235, 235, 0.5); | ||
padding-bottom: 10px; | ||
display: block; | ||
margin-bottom: 20px; | ||
` | ||
|
||
const RecordsHeader = styled('div')` | ||
background: #f0f6fa; | ||
` | ||
|
||
const RecordsTitle = styled('h3')` | ||
font-family: Overpass; | ||
font-weight: 700; | ||
font-size: 12px; | ||
color: #adbbcd; | ||
letter-spacing: 0.5px; | ||
text-transform: uppercase; | ||
margin: 0; | ||
padding: 10px 20px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
` | ||
|
||
function isArt(name) { | ||
return !!name.match(/\.art$/) | ||
} | ||
|
||
function getArtRecordLabel(key) { | ||
const recordLabels = { | ||
title: 'Title', | ||
maker: 'Maker', | ||
type: 'Type of Object', | ||
subject: 'Subject', | ||
period: 'Period', | ||
dimensions: 'Measurements', | ||
materials: 'Materials & Techniques', | ||
markings: 'Inscriptions & Markings', | ||
features: 'Features', | ||
reference: 'Reference' | ||
} | ||
|
||
return recordLabels[key] | ||
} | ||
|
||
function isEmpty(records) { | ||
if (!records.length) { | ||
return true | ||
} | ||
|
||
return records.filter(record => record.value).length === 0 | ||
} | ||
|
||
function decodeRecords(values) { | ||
let parsed = {} | ||
try { | ||
parsed = JSON.parse(values) | ||
} catch (e) {} | ||
|
||
return Object.keys(parsed).reduce( | ||
(decoded, key) => | ||
decoded.concat({ | ||
label: getArtRecordLabel(key), | ||
value: parsed[key] | ||
}), | ||
[] | ||
) | ||
} | ||
|
||
function ArtRecordItem({ value, label }) { | ||
if (!value) return null | ||
|
||
return ( | ||
<RecordsItem> | ||
<RecordsContent> | ||
<RecordsKey>{label}</RecordsKey> | ||
<RecordsValue> | ||
<div>{value}</div> | ||
</RecordsValue> | ||
</RecordsContent> | ||
</RecordsItem> | ||
) | ||
} | ||
|
||
export default function ArtRecords({ domain, query }) { | ||
if (!isArt(domain.name)) return null | ||
|
||
return ( | ||
<Query query={query} variables={{ name: domain.name, key: 'artrecords' }}> | ||
{({ loading, data }) => { | ||
if (loading) return <Loader center /> | ||
|
||
const { getText: encodedArtRecords } = data | ||
|
||
if (!encodedArtRecords) return null | ||
|
||
const records = decodeRecords(encodedArtRecords) | ||
|
||
if (isEmpty(records)) return null | ||
|
||
return ( | ||
<Records> | ||
<RecordsHeader> | ||
<RecordsTitle>Art records</RecordsTitle> | ||
</RecordsHeader> | ||
|
||
{records.map((r, i) => ( | ||
<ArtRecordItem key={i} value={r.value} label={r.label} /> | ||
))} | ||
</Records> | ||
) | ||
}} | ||
</Query> | ||
) | ||
} |
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 |
---|---|---|
|
@@ -13,5 +13,8 @@ | |
}, | ||
"luxe": { | ||
"supported": true | ||
}, | ||
"art": { | ||
"supported": true | ||
} | ||
} |
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