-
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.
- Loading branch information
Thomas O'Neill
committed
Feb 1, 2024
1 parent
2a120eb
commit d5f0a8e
Showing
109 changed files
with
8,719 additions
and
24,014 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"extends": "next/core-web-vitals", | ||
"rules": { | ||
"react/display-name": "off" | ||
"react/jsx-key": "off" | ||
} | ||
} |
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,54 @@ | ||
import { | ||
getFormattedTenureTypes, | ||
getFormattedEntryDates, | ||
} from "@/app/utils/sanity/entry" | ||
import { Entry } from "@/app/utils/sanity/types" | ||
import { Tag } from "@carbon/icons-react" | ||
import EntryItem from "./EntryItem" | ||
import EntryReferences from "./EntryReferences" | ||
import EntryPortableText from "./EntryPortableText" | ||
|
||
const EntryDetails = (entry?: Entry) => ( | ||
<div className="bg-white text-black grid grid-cols-4 grid-rows-auto gap-x-4 gap-y-1 sm:gap-y-6 p-8"> | ||
<EntryItem | ||
className="col-span-4 sm:col-span-2" | ||
heading={getFormattedTenureTypes(entry?.tenureType)} | ||
/> | ||
<EntryItem | ||
className="col-span-2 sm:col-span-1" | ||
heading={entry?.location?.region || "Unknown location"} | ||
/> | ||
<EntryItem | ||
className="col-span-2 sm:col-span-1 text-right sm:text-left" | ||
heading={getFormattedEntryDates(entry?.dates)} | ||
/> | ||
<EntryItem heading="" className="col-span-4"> | ||
<EntryPortableText value={entry?.content ?? []} /> | ||
</EntryItem> | ||
{entry?.references?.length && ( | ||
<EntryItem heading="More information" className="col-span-2"> | ||
<EntryReferences {...entry} /> | ||
</EntryItem> | ||
)} | ||
<EntryItem heading="Rating" className="col-span-2"> | ||
<> | ||
<p className="text-sm"> | ||
This entry is{" "} | ||
<span className="text-gray-400 text-sm lowercase"> | ||
{entry?.entryRating?.grade || "a draft"} | ||
</span> | ||
</p> | ||
<div className=""> | ||
{entry?.tags && | ||
entry.tags.map((entryTag) => ( | ||
<Tag key={entryTag.value} className={"bg-gray-200 mt-2"}> | ||
{entryTag.label} | ||
</Tag> | ||
))} | ||
</div> | ||
</> | ||
</EntryItem> | ||
</div> | ||
) | ||
|
||
export default EntryDetails |
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 { Tag } from "@/app/ui/Tag" | ||
import { Entry } from "@/app/utils/sanity/types" | ||
import { Close } from "@carbon/icons-react" | ||
import Link from "next/link" | ||
|
||
const EntryHeader = (entry?: Entry) => ( | ||
<div | ||
// TODO: The sanity image pipeline could get us an optimized image here | ||
// https://www.sanity.io/docs/presenting-images | ||
style={{ backgroundImage: `url(${entry?.mainImage?.file?.asset?.url})` }} | ||
className="h-80 p-8 pt-2 flex flex-col justify-between bg-center bg-cover" | ||
> | ||
<nav className="flex justify-between"> | ||
<Link href="/">Back to map</Link> | ||
<Link href="/"> | ||
<Close size={32} className="cursor-pointer" /> | ||
</Link> | ||
</nav> | ||
<div className="flex flex-row justify-between items-center"> | ||
<h1 className="text-3xl sm:text-5xl w-2/3 sm:w-1/2">{entry?.name}</h1> | ||
<Tag className="bg-white">{entry?.type}</Tag> | ||
</div> | ||
</div> | ||
) | ||
|
||
export default EntryHeader |
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,19 @@ | ||
import { HTMLProps, PropsWithChildren } from "react" | ||
|
||
type Props = HTMLProps<HTMLDivElement> & { | ||
heading: string | ||
} | ||
|
||
const EntryItem = ({ heading, children, ...rest }: Props) => ( | ||
<section {...rest}> | ||
<div | ||
role="doc-subtitle" | ||
className={`mb-1 ${children ? "text-sm" : "text-base sm:text-2xl"}`} | ||
> | ||
{heading} | ||
</div> | ||
{children} | ||
</section> | ||
) | ||
|
||
export default EntryItem |
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,113 @@ | ||
import { A } from "@/app/utils/fp" | ||
import { | ||
getPatternClasses, | ||
getPatterns, | ||
getRelatedEntriesByPattern, | ||
getRelatedEntriesByTenureQuery, | ||
} from "@/app/utils/sanity/queries" | ||
import { Entry, Term } from "@/app/utils/sanity/types" | ||
import { pipe } from "fp-ts/lib/function" | ||
import _ from "lodash" | ||
import EntryPageChartImpl from "./EntryPageChartImpl" | ||
|
||
type Props = { | ||
entry: Entry | ||
} | ||
|
||
const EntryPageChart = async (props: Props) => { | ||
const { entry } = props | ||
|
||
const terms: Term[] = entry.terms ?? [] | ||
|
||
const patterns = await getPatterns() | ||
const patternClasses = await getPatternClasses() | ||
|
||
const relatedEntriesByTenure = await getRelatedEntriesByTenureQuery( | ||
entry.tenureType, | ||
entry._id | ||
) | ||
|
||
const augmentedTerms = await Promise.all( | ||
pipe( | ||
terms, | ||
A.map(async (term) => { | ||
const patternId = term.pattern._ref | ||
const entryId = entry._id | ||
|
||
const relatedEntriesByPattern = await getRelatedEntriesByPattern( | ||
patternId, | ||
entryId | ||
) | ||
|
||
const pattern = _.find(patterns, ["_id", term.pattern?._ref]) | ||
|
||
const patternName = _.find(patterns, ["_id", term.pattern?._ref])?.name | ||
|
||
const type = _.capitalize( | ||
_.find(patterns, ["_id", term.pattern?._ref])?.type | ||
) | ||
|
||
// strength: term.strength, // 1-5 | ||
// description: term.description, | ||
const legalMechanisms = term.termLegalMechanisms?.map( | ||
(mechanism: Record<string, any>): string => mechanism.name | ||
) | ||
|
||
return { | ||
meta: pattern, | ||
name: patternName, | ||
patternClassName: _.find(patternClasses, [ | ||
"_id", | ||
pattern?.class?._ref, | ||
])?.name, | ||
patternClassOrder: _.find(patternClasses, [ | ||
"_id", | ||
pattern?.class?._ref, | ||
])?.order, | ||
patternIconUrl: pattern?.iconUrl, | ||
type: type === "Limitation" ? "Obligation" : type, | ||
strength: term.strength, | ||
description: term.description, | ||
legalMechanisms, | ||
relatedEntriesByPattern, | ||
} | ||
}) | ||
) | ||
) | ||
|
||
// Format the list of individual terms that apply to this entry | ||
// let formattedTerms = _(entry.terms) | ||
// .map((term: any) => ({ | ||
// pattern: _.find(patterns, ["_id", term.pattern?._ref]), | ||
// patternName: _.find(patterns, ["_id", term.pattern?._ref])?.name, | ||
// type: _.capitalize(_.find(patterns, ["_id", term.pattern?._ref])?.type), | ||
// strength: term.strength, // 1-5 | ||
// description: term.description, | ||
// legalMechanisms: term.termLegalMechanisms?.map( | ||
// (mechanism: Record<string, any>) => mechanism.name | ||
// ), | ||
// })) | ||
// .map((term: any) => ({ | ||
// meta: term.pattern, | ||
// name: term.patternName, | ||
// patternClassName: _.find(patternClasses, [ | ||
// "_id", | ||
// term.pattern?.class?._ref, | ||
// ])?.name, | ||
// patternClassOrder: _.find(patternClasses, [ | ||
// "_id", | ||
// term.pattern?.class?._ref, | ||
// ])?.order, | ||
// patternIconUrl: term.pattern?.iconUrl, | ||
// type: term.type === "Limitation" ? "Obligation" : term.type, | ||
// strength: term.strength, | ||
// description: term.description, | ||
// legalMechanisms: term.legalMechanisms, | ||
// })) | ||
// .sortBy("patternClassOrder", "name") | ||
// .value() | ||
|
||
return <EntryPageChartImpl augmentedTerms={augmentedTerms} /> | ||
} | ||
|
||
export default EntryPageChart |
Oops, something went wrong.