mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
admin: show the TREK API as its three services
The card names place search, address search and routing with what each answers and what is left of today's allowance. Each service is a tile with what is left as its figure, the day's use as a bar and used and limit as badges; the state, the kind of installation, a key from the environment and the time the count starts again sit as badges in the header. The sources add the terrain tiles the routes take their heights from.
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
import React from 'react'
|
||||
import { Check, Library, X } from 'lucide-react'
|
||||
import { Library, MapPin, Route, Search, X } from 'lucide-react'
|
||||
import TrekMark from '../../components/shared/TrekMark'
|
||||
import { fs } from '../../components/shared/DialogShell'
|
||||
import { StatusPill } from '../../components/Settings/settingsKit'
|
||||
import FoldSummary from './FoldSummary'
|
||||
import ServiceIdentityPanel from '../../components/Admin/ServiceIdentityPanel'
|
||||
import type { TranslationFn } from '../../types'
|
||||
import { TREK_API_SOURCES as SOURCES, trekApiFacts, trekApiFields } from '../../components/Admin/trekApiModel'
|
||||
import {
|
||||
TREK_API_SOURCES as SOURCES,
|
||||
trekApiAddressFeatures,
|
||||
trekApiFacts,
|
||||
trekApiFields,
|
||||
trekApiRoutingFeatures,
|
||||
} from '../../components/Admin/trekApiModel'
|
||||
|
||||
interface TrekApiCardProps {
|
||||
t: TranslationFn
|
||||
@@ -14,7 +20,9 @@ interface TrekApiCardProps {
|
||||
}
|
||||
|
||||
/**
|
||||
* The TREK Places API, above the Google key because it is the alternative to it.
|
||||
* The TREK API, above the Google key because it is the alternative to it: the
|
||||
* place index, the address search and the routing an installation gets from
|
||||
* the TREK services, each listed with what it answers.
|
||||
*
|
||||
* Given real weight on the page on purpose: it is what makes a key optional
|
||||
* instead of expected. The weight comes from the mark, one line of type and an
|
||||
@@ -28,7 +36,7 @@ interface TrekApiCardProps {
|
||||
*/
|
||||
const CHIP = 'rounded-full border px-2.5 py-[3px] font-medium'
|
||||
|
||||
/** One of the three lists under "more": an icon and a name, chips, a note. */
|
||||
/** One of the lists under "more": an icon and a name, chips, a note. */
|
||||
function FactGroup({ icon, title, note, children }: { icon: React.ReactNode; title: string; note: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="flex flex-col gap-2 px-3.5 py-3">
|
||||
@@ -55,7 +63,7 @@ export default function TrekApiCard({ t, managed = false }: TrekApiCardProps): R
|
||||
A pill beside the mark rather than a banner, so it does not shout
|
||||
over the settings around it. */}
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<TrekMark className="h-7 w-auto text-content" aria-label="TREK Places API" />
|
||||
<TrekMark className="h-7 w-auto text-content" aria-label="TREK API" />
|
||||
<StatusPill tone="accent">{t('admin.trekApi.badgeDefault')}</StatusPill>
|
||||
</div>
|
||||
|
||||
@@ -85,10 +93,10 @@ export default function TrekApiCard({ t, managed = false }: TrekApiCardProps): R
|
||||
{/* The fields as chips rather than a paragraph. A list of what you
|
||||
get is something you scan, not something you read, and a sentence
|
||||
forces the reader to parse commas to answer "is the phone number
|
||||
in there". */}
|
||||
in there". One list per service, under the service's own name. */}
|
||||
<FactGroup
|
||||
icon={<Check size={14} strokeWidth={2.4} className="text-success" aria-hidden="true" />}
|
||||
title={t('admin.trekApi.included')}
|
||||
icon={<MapPin size={14} strokeWidth={2.2} className="text-content-muted" aria-hidden="true" />}
|
||||
title={t('admin.trekApi.quota.service.places')}
|
||||
note={t('admin.trekApi.includedNote')}
|
||||
>
|
||||
{fields.map(field => (
|
||||
@@ -109,6 +117,26 @@ export default function TrekApiCard({ t, managed = false }: TrekApiCardProps): R
|
||||
))}
|
||||
</FactGroup>
|
||||
|
||||
<FactGroup
|
||||
icon={<Search size={14} strokeWidth={2.2} className="text-content-muted" aria-hidden="true" />}
|
||||
title={t('admin.trekApi.quota.service.photon')}
|
||||
note={t('admin.trekApi.addressNote')}
|
||||
>
|
||||
{trekApiAddressFeatures(t).map(item => (
|
||||
<li key={item} className={`${CHIP} border-edge-faint bg-surface-card text-content-secondary`}>{item}</li>
|
||||
))}
|
||||
</FactGroup>
|
||||
|
||||
<FactGroup
|
||||
icon={<Route size={14} strokeWidth={2.2} className="text-content-muted" aria-hidden="true" />}
|
||||
title={t('admin.trekApi.quota.service.valhalla')}
|
||||
note={t('admin.trekApi.routingNote')}
|
||||
>
|
||||
{trekApiRoutingFeatures(t).map(item => (
|
||||
<li key={item} className={`${CHIP} border-edge-faint bg-surface-card text-content-secondary`}>{item}</li>
|
||||
))}
|
||||
</FactGroup>
|
||||
|
||||
{/* Attribution, and not in the small print: the licences require the
|
||||
sources to be named, and naming them is also the answer to "where
|
||||
does this actually come from". */}
|
||||
|
||||
Reference in New Issue
Block a user