aboutsummaryrefslogtreecommitdiff
path: root/src/tools/user-agent-parser/user-agent-result-cards.vue
blob: 77502df07549dd2eab0e5e0c8d6b686f68066407 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<script setup lang="ts">
import type { UAParser } from 'ua-parser-js';
import type { UserAgentResultSection } from './user-agent-parser.types';

const props = defineProps<{
  userAgentInfo?: UAParser.IResult
  sections: UserAgentResultSection[]
}>();
const { userAgentInfo, sections } = toRefs(props);
</script>

<template>
  <div>
    <n-grid :x-gap="12" :y-gap="8" cols="1 s:2" responsive="screen">
      <n-gi v-for="{ heading, icon, content } in sections" :key="heading">
        <c-card h-full>
          <div flex items-center gap-3>
            <n-icon size="30" :component="icon" :depth="3" />
            <span text-lg>{{ heading }}</span>
          </div>

          <div mt-5 flex gap-2>
            <span v-for="{ label, getValue } in content" :key="label">
              <c-tooltip v-if="getValue(userAgentInfo)" :tooltip="label">
                <n-tag type="success" size="large" round :bordered="false">
                  {{ getValue(userAgentInfo) }}
                </n-tag>
              </c-tooltip>
            </span>
          </div>
          <div flex flex-col>
            <span v-for="{ label, getValue, undefinedFallback } in content" :key="label">
              <span v-if="getValue(userAgentInfo) === undefined" op-70>{{ undefinedFallback }}</span>
            </span>
          </div>
        </c-card>
      </n-gi>
    </n-grid>
  </div>
</template>