Skip to content

Commit

Permalink
feat: default to span
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-peteu committed Mar 21, 2024
1 parent dceb30c commit cedc3c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
15 changes: 7 additions & 8 deletions packages/analytics/metric-cards/sandbox/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,18 @@
</template>

<script setup lang="ts">
import { MetricCardContainer } from '../src'
import { MetricCardContainer, type MetricCardDef } from '../src'
import { DECIMAL_DISPLAY, metricChange } from '../src/utilities'
import type { MetricCardContainerOptions } from '../src/types'
import { MetricCardType } from '../src/enums'
import { MetricCardSize } from '../src/constants'
const cards = [
const cards: MetricCardDef[] = [
{
cardType: MetricCardType.TRAFFIC,
currentValue: 192895156,
previousValue: 236609609,
title: 'Requests',
titleTag: 'h4',
description: 'Requests proxied through all data plane nodes',
tooltip: 'This is a tooltip',
increaseIsBad: false,
Expand All @@ -99,7 +98,6 @@ const cards = [
formatChangeFn: val => `${metricChange(val * 100, true, 'N/A')}`,
formatValueFn: val => `${val.toFixed(DECIMAL_DISPLAY)}%`,
title: 'Error Rate',
titleTag: 'h4',
description: 'Rate of requests that ended up in a 5xx response',
increaseIsBad: true,
trendRange: 'vs last week',
Expand All @@ -110,7 +108,6 @@ const cards = [
previousValue: 511,
formatValueFn: val => `${val}ms`,
title: 'P99 Latency',
titleTag: 'h4',
description: 'Time taken to send a response back to the client',
increaseIsBad: true,
trendRange: 'vs last week',
Expand All @@ -120,7 +117,6 @@ const cards = [
currentValue: 5,
previousValue: 4,
title: 'Active Runtimes',
titleTag: 'h4',
increaseIsBad: true,
trendRange: 'vs last week',
},
Expand All @@ -130,13 +126,16 @@ const cards = [
previousValue: 23.2121,
formatValueFn: val => `${val.toFixed(0)}%`,
title: 'Saturation',
titleTag: 'h4',
tooltip: 'A secondary tooltip',
increaseIsBad: true,
trendRange: 'vs last week',
},
]
const cardsWithHeadings: MetricCardDef[] = cards.map((item) => {
return { titleTag: 'h2', ...item }
})
const cardsWithErrors = JSON.parse(JSON.stringify(cards))
cardsWithErrors[0].hasError = true
cardsWithErrors[1].hasError = true
Expand Down Expand Up @@ -167,7 +166,7 @@ const cardsRegularCompact: MetricCardContainerOptions = {
}
const cardsXL: MetricCardContainerOptions = {
cards: [...cards].slice(0, 3),
cards: [...cardsWithHeadings].slice(0, 3),
loading: false,
hasTrendAccess: true,
fallbackDisplayText: 'Not available',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
:color="KUI_COLOR_TEXT_NEUTRAL"
:size="KUI_ICON_SIZE_30"
/>
<span v-if="!titleTag">{{ title }}</span>
<component
:is="titleTag"
else
>
<component :is="titleTag">
{{ title }}
</component>
<KTooltip
Expand Down Expand Up @@ -192,7 +188,7 @@ const props = defineProps({
},
titleTag: {
type: String as PropType<HeaderTag>,
default: '',
default: 'span',
},
})
Expand Down

0 comments on commit cedc3c3

Please sign in to comment.