Skip to content

HealthConnectionCard

Reworks meal-tracker's ProfilTab Health Connect card (connection status + edit/toggle button, optional resync button, optional hint text, a danger-colored "delete my data" link) into a yemek component. No Health Connect API logic and no dialog logic here — enable/disable and delete-confirmation stay the consumer's own dialogs, same rule as MetricRing's editable/BodyMetricsCard's edit.

Least nutrition-specific of yemek's Domain components so far (closer to a generic connection/ consent status card than a nutrition concept) — built per explicit owner decision.

Playground

Health Connect

Verbunden

Verlauf siehe Statistik-Tab.

Click "Trennen"/"Verbinden" to toggle — the status dot and text update, and the button briefly shows a checkmark + "Gespeichert".

vue
<script setup>
import { HealthConnectionCard } from 'yemek'

const saved = ref(false)
const resyncLoading = ref(false)
const resyncSaved = ref(false)

function toggleHealthConnect() {
  healthDialogOpen.value = true // consumer's own enable/disable dialog
}

async function resyncHealthHistory() {
  resyncLoading.value = true
  await loadTodayHealthSnapshot()
  resyncLoading.value = false
  resyncSaved.value = true
  setTimeout(() => { resyncSaved.value = false }, 2000)
}
</script>

<template>
  <HealthConnectionCard
    title="Health Connect"
    :connected="healthEnabled"
    :status-label="healthEnabled ? t('profil.healthConnectStatusOn') : t('profil.healthConnectStatusOff')"
    :edit-label="t('profil.editHealthConnectBtn')"
    saved-label="Gespeichert"
    :saved="healthSavedFeedback"
    :manageable="canManageHealthConnect"
    :unavailable-hint="t('profil.healthConnectDesktopHint')"
    :resync-label="healthEnabled ? t('profil.healthHistoryResync') : undefined"
    :resync-saved-label="t('profil.healthHistoryResynced')"
    :resync-loading="healthHistoryLoading"
    :resync-saved="healthResyncedFeedback"
    :hint="healthEnabled ? t('profil.healthHistoryStatistikHint') : undefined"
    :delete-label="t('profil.healthHistoryDeleteBtn')"
    @edit="toggleHealthConnect"
    @resync="resyncHealthHistory"
    @delete="healthDeleteDialogOpen = true"
  />
</template>

Props

PropTypeDefaultDescription
titlestringCard heading.
connectedbooleanDrives the status dot's color (accent when connected, muted otherwise).
statusLabelstringAlready-formatted status text.
editLabelstringEdit/toggle button label.
savedLabelstringundefinedShown (with a checkmark) instead of editLabel while saved is true.
savedbooleanfalseSwaps the edit button for a checkmark + savedLabel.
manageablebooleantrueWhen false, hides the edit/resync/delete controls and shows unavailableHint instead (e.g. desktop, where the integration doesn't exist).
unavailableHintstringundefinedShown instead of the status/controls when manageable is false.
resyncLabelstringundefinedResync button label. Button only renders when set (and manageable).
resyncSavedLabelstringundefinedShown (with a checkmark) instead of resyncLabel while resyncSaved is true.
resyncSavedbooleanfalse
resyncLoadingbooleanfalseDisables the resync button and shows a spinner.
hintstringundefinedShown below the status row while manageable.
deleteLabelstringundefinedDanger-colored link at the bottom. Only renders when set.

Events

EventPayloadFired when
editThe edit/toggle button is clicked.
resyncThe resync button is clicked (not fired while resyncLoading is true, since the button is disabled).
deleteThe delete link is clicked.

Behavior notes

  • No Health Connect API logic or dialog logic lives here — the consumer's own enable/disable dialog and delete-confirmation dialog stay exactly as they are; this only renders the card and emits which action was requested.
  • The status dot picks up a small accent glow (box-shadow) when connected — not just a plain color swap.
  • prefers-reduced-motion: reduce keeps the spinner but slows its rotation, and drops the card's entrance transition.