-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add badges * undo hard coded hex color * separate expiry badge * remove un-needed type
- Loading branch information
1 parent
15d3b9e
commit 729c3ee
Showing
18 changed files
with
295 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import type { Meta, StoryObj } from '@storybook/vue3'; | ||
|
||
import BaseBadge from "@/elements/BaseBadge.vue"; | ||
|
||
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories | ||
const meta: Meta<typeof BaseBadge> = { | ||
title: "Elements/Badge", | ||
component: BaseBadge, | ||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/writing-docs/autodocs | ||
tags: ["autodocs"], | ||
argTypes: { | ||
type: { control: "select", options: ["primary", "secondary", "warning"] }, | ||
icon: { control: "boolean" }, | ||
default: { control: "text" }, | ||
}, | ||
args: { | ||
default: "Recommended", | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
type: "primary", | ||
icon: false, | ||
}, | ||
}; | ||
|
||
export const Secondary: Story = { | ||
args: { | ||
type: "secondary", | ||
icon: false, | ||
default: "Updated", | ||
}, | ||
}; | ||
|
||
export const Warning: Story = { | ||
args: { | ||
type: "warning", | ||
icon: false, | ||
default: "Experimental" | ||
}, | ||
}; | ||
|
||
export const IconPrimary: Story = { | ||
args: { | ||
type: "primary", | ||
icon: true, | ||
}, | ||
}; | ||
|
||
export const IconSecondary: Story = { | ||
args: { | ||
type: "secondary", | ||
icon: true, | ||
default: "Updated", | ||
}, | ||
}; | ||
|
||
export const IconWarning: Story = { | ||
args: { | ||
type: "warning", | ||
icon: true, | ||
default: "Experimental", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<script setup lang="ts"> | ||
import StatusInfoIcon from '@/icons/StatusInfoIcon.vue'; | ||
import StatusWarningIcon from '@/icons/StatusWarningIcon.vue'; | ||
// component properties | ||
interface Props { | ||
type?: string; | ||
icon?: boolean; | ||
} | ||
withDefaults(defineProps<Props>(), { | ||
type: "primary", | ||
icon: false, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div :class="{ [type]: type }" class="badge"> | ||
<span class="icon" v-if="icon"> | ||
<slot name="icon"> | ||
<status-info-icon v-if="type == 'primary' || type == 'secondary'"/> | ||
<status-warning-icon v-if="type == 'warning'"/> | ||
</slot> | ||
</span> | ||
<span class="text"> | ||
<slot/> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
@import '@/assets/styles/custom-media.pcss'; | ||
.icon { | ||
margin-top: auto; | ||
margin-bottom: auto; | ||
} | ||
.text { | ||
margin: auto; | ||
font-size: 0.8125rem; | ||
font-weight: 700; | ||
line-height: 1.2; | ||
text-transform: uppercase; | ||
} | ||
.badge { | ||
position: relative; | ||
display: inline-flex; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 0.1875rem; | ||
gap: 0.3125rem; | ||
border: 0.0625rem solid; | ||
padding: 0.140625rem 0.28125rem; | ||
} | ||
.primary { | ||
background-color: var(--colour-primary-soft); | ||
border-color: var(--colour-service-primary-hover); | ||
color: var(--colour-service-primary-hover); | ||
} | ||
.secondary { | ||
background-color: var(--colour-neutral-subtle); | ||
border-color: var(--colour-ti-secondary); | ||
color: var(--colour-ti-secondary); | ||
} | ||
.warning { | ||
background-color: var(--colour-warning-soft); | ||
border-color: var(--colour-ti-warning); | ||
color: var(--colour-ti-warning); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script setup lang="ts"> | ||
import BaseBadge from "./BaseBadge.vue"; | ||
import StatusExpiryIcon from "@/icons/StatusExpiryIcon.vue"; | ||
import { computed, toRef } from "vue"; | ||
import { t } from '@/composable/i18n'; | ||
import { ExpiryUnitTypes } from "@/definitions"; | ||
// component properties | ||
interface Props { | ||
timeRemaining?: number; | ||
warningThreshold?: number; | ||
timeUnit?: ExpiryUnitTypes; | ||
} | ||
const props = withDefaults(defineProps<Props>(), { | ||
timeRemaining: 10, | ||
warningThreshold: 5, | ||
timeUnit: ExpiryUnitTypes.Days | ||
}) | ||
const timeRemaining = toRef(() => props.timeRemaining); | ||
const warningThreshold = toRef(() => props.warningThreshold); | ||
const timeRemainingLabel = computed(() => timeRemaining.value.toString()); | ||
const status = computed(() => { | ||
if (timeRemaining.value <= 0) { | ||
return "secondary"; | ||
} else if (timeRemaining.value < warningThreshold.value) { | ||
return "warning"; | ||
} else { | ||
return "primary"; | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<base-badge :class="status" icon> | ||
<template #icon> | ||
<status-expiry-icon/> | ||
</template> | ||
{{ t(`expiryIndicator.${timeUnit}`, { 'n': timeRemainingLabel }) }} | ||
</base-badge> | ||
</template> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup lang="ts"> | ||
import BaseBadge from '@/elements/BaseBadge.vue'; | ||
</script> | ||
|
||
<template> | ||
<base-badge type="primary"> | ||
<slot/> | ||
</base-badge> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup lang="ts"> | ||
import BaseBadge from '@/elements/BaseBadge.vue'; | ||
</script> | ||
|
||
<template> | ||
<base-badge type="secondary"> | ||
<slot/> | ||
</base-badge> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup lang="ts"> | ||
import BaseBadge from '@/elements/BaseBadge.vue'; | ||
</script> | ||
|
||
<template> | ||
<base-badge type="warning"> | ||
<slot/> | ||
</base-badge> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.