diff --git a/frontend/src/lib/components/UserMenu.svelte b/frontend/src/lib/components/UserMenu.svelte index 1817286..bf3e2d7 100644 --- a/frontend/src/lib/components/UserMenu.svelte +++ b/frontend/src/lib/components/UserMenu.svelte @@ -149,7 +149,7 @@ padding-inline: 1.5rem; padding-top: 0.75rem; padding-bottom: 0.25rem; - color: var(--colorBlue0); + color: var(--colorGreen0); font-weight: 600; } diff --git a/frontend/src/lib/css/navigationLink.module.css b/frontend/src/lib/css/navigationLink.module.css index 10e4707..b10dad2 100644 --- a/frontend/src/lib/css/navigationLink.module.css +++ b/frontend/src/lib/css/navigationLink.module.css @@ -2,6 +2,7 @@ transition-duration: 50ms; transition-property: text-decoration-color; transition-timing-function: ease-out; + cursor: pointer; padding-block: 0.75rem; color: var(--colorOrange0); font-weight: 600; @@ -24,8 +25,14 @@ } } -.withIcon { +.withIconLeft { display: inline-grid; grid-template-columns: max-content 1fr; column-gap: 0.5rem; } + +.withIconRight { + display: inline-grid; + grid-template-columns: 1fr max-content; + column-gap: 0.5rem; +} diff --git a/frontend/src/lib/swissGrid.ts b/frontend/src/lib/swissGrid.ts new file mode 100644 index 0000000..1f155a8 --- /dev/null +++ b/frontend/src/lib/swissGrid.ts @@ -0,0 +1,45 @@ +const getDecimalDegreesFromSeconds = (totalSeconds: number) => { + let totalSeconds_ = totalSeconds + const hours = Math.floor(totalSeconds_ / 3600) + totalSeconds_ = totalSeconds_ % 3600 + const minutes = Math.floor(totalSeconds_ / 60) + totalSeconds_ = totalSeconds_ % 60 + const seconds = totalSeconds_ + const decimal = hours + minutes / 60 + seconds / 3600 + + console.debug(hours, minutes, seconds) + + return decimal +} + +const { pow } = Math +/** + * converts swiss grid coordinates to decimal latitude and longitude that can be used with embedded maps + * + * based on the approximate formula of 3.4 in + * - https://backend.swisstopo.admin.ch/fileservice/sdweb-docs-prod-swisstopoch-files/files/2023/11/14/ea9cbbd6-9583-4a39-8bdf-15fc6a1c2fad.pdf + * - via https://www.swisstopo.admin.ch/de/schweizerische-kartenprojektionen + */ +export const getDecimalLatitudeLongitude = (swissGridCoordinates: { E: number; N: number }) => { + const X = swissGridCoordinates.N / 1_000_000 - 0.2 + const Y = swissGridCoordinates.E / 1_000_000 - 0.6 + + const a1 = + 4.72973056 + 0.7925714 * X + 0.132812 * pow(X, 2) + 0.0255 * pow(X, 3) + 0.0048 * pow(X, 4) + const a3 = -0.04427 - 0.0255 * X - 0.0096 * pow(X, 2) + const a5 = 0.00096 + const lambda = 2.67825 + a1 * Y + a3 * pow(Y, 3) + a5 * pow(Y, 5) + + const p0 = 3.23864877 * X - 0.0025486 * pow(X, 2) - 0.013245 * pow(X, 3) + 0.000048 * pow(X, 4) + const p2 = -0.27135379 - 0.0450442 * X - 0.007553 * pow(X, 2) - 0.00146 * pow(X, 3) + const p4 = 0.002442 + 0.00132 * X + const phi = 16.902866 + p0 + p2 * pow(Y, 2) + p4 * pow(Y, 4) + + const latitude = getDecimalDegreesFromSeconds(phi * 10000) + const longitude = getDecimalDegreesFromSeconds(lambda * 10000) + + return { + latitude, + longitude, + } +} diff --git a/frontend/src/app.css b/frontend/src/reset.css similarity index 95% rename from frontend/src/app.css rename to frontend/src/reset.css index 3bca1ec..33ceb12 100644 --- a/frontend/src/app.css +++ b/frontend/src/reset.css @@ -78,3 +78,9 @@ h6 { #__next { isolation: isolate; } + +ul, +ol { + padding: 0; + list-style-type: none; +} diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index d35440d..670384a 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -1,6 +1,6 @@ -
-
- -
-
- {#if !data.nfts.length} -

No NFTs have been minted yet.

- {:else} - {#each data.nfts as nft} - - - - {/each} - {/if} -
-
+
+

Missions

+ + {#if !data.nfts.length} +

No NFTs have been minted yet.

+ {:else} + + {/if}
diff --git a/frontend/src/routes/MissionTeaser.svelte b/frontend/src/routes/MissionTeaser.svelte new file mode 100644 index 0000000..c510e8c --- /dev/null +++ b/frontend/src/routes/MissionTeaser.svelte @@ -0,0 +1,31 @@ + + +
+

{typeOfNaturalObject}

+ + + +

{typeOfWork}

+ + + Details + +
diff --git a/frontend/src/routes/certificates/[serialNumber]/+page.svelte b/frontend/src/routes/certificates/[serialNumber]/+page.svelte index fe83167..f45691f 100644 --- a/frontend/src/routes/certificates/[serialNumber]/+page.svelte +++ b/frontend/src/routes/certificates/[serialNumber]/+page.svelte @@ -1,16 +1,77 @@
-

{data.nft.name} #{data.nft.serialNumber}

+

{data.nft.certificate.typeOfNaturalObject}

+ + +

{data.nft.certificate.typeOfWork}

+ +

Operations manager: {data.nft.certificate.operationsManager}

+ +

Effect on biodiversity

+

{data.nft.certificate.effectOnBiodiversity}

+ +

Location

+ +

+ Coordinates + + {data.nft.certificate.swissGridE?.toLocaleString()} / {data.nft.certificate.swissGridN?.toLocaleString()} +

+ +
+ + + + View on OpenStreetMap + + +
+

NFT

{#snippet withAccountInformation({ hashConnect })} {#if hashConnect.accountInformation.hasAssociatedWithToken} @@ -23,8 +84,11 @@ executeTransaction: hashConnect.session.executeTransaction, }) }} + class="{navigationLinkStyles.navigationLink} {navigationLinkStyles.withIconRight}" > - Claim + Claim this NFT + + Image of certificate #{data.nft.serialNumber} - -

{new Date(data.nft.certificate.dateOfWork).toLocaleDateString()}

-

{data.nft.certificate.swissGridE} / {data.nft.certificate.swissGridN}

-

{data.nft.certificate.operationsManager}

-

{data.nft.certificate.typeOfNaturalObject}

-

{data.nft.certificate.typeOfWork}

-

{data.nft.certificate.effectOnBiodiversity}

diff --git a/frontend/src/routes/certificates/[serialNumber]/+page.ts b/frontend/src/routes/certificates/[serialNumber]/+page.ts index 7444126..334957a 100644 --- a/frontend/src/routes/certificates/[serialNumber]/+page.ts +++ b/frontend/src/routes/certificates/[serialNumber]/+page.ts @@ -14,6 +14,6 @@ export const load = async ({ fetch, params }) => { return { nft, - metadataTitle: `${nft.name} #${nft.serialNumber} - BIDI`, + metadataTitle: `${nft.certificate.typeOfNaturalObject} - BIDI`, } } diff --git a/frontend/src/routes/dashboard/+layout.svelte b/frontend/src/routes/dashboard/+layout.svelte index 632de6b..1ab40c6 100644 --- a/frontend/src/routes/dashboard/+layout.svelte +++ b/frontend/src/routes/dashboard/+layout.svelte @@ -15,11 +15,11 @@ @@ -84,7 +84,7 @@ display: grid; grid-auto-flow: column; align-items: center; - color: var(--colorBlue0); + color: var(--colorGreen0); font-weight: 600; }