-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Indicator components #314
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<script setup> | ||
import FwbIndicatorExample from './indicator/examples/FwbIndicatorExample.vue' | ||
import FwbIndicatorPositionExample from './indicator/examples/FwbIndicatorPositionExample.vue' | ||
</script> | ||
|
||
# Vue Indicator - Flowbite | ||
|
||
#### Use the indicator component to show a number count, account status, or as a loading label positioned relative to the parent component coded with Tailwind CSS | ||
|
||
--- | ||
|
||
:::tip | ||
Original reference: [https://flowbite.com/docs/components/indicators/](https://flowbite.com/docs/components/indicators/) | ||
::: | ||
|
||
The indicator component can be used as a small element positioned absolutely relative to another component such as a button or card and show a number count, account status (red for offline, green for online) and other useful information. | ||
|
||
Check out the following examples for multiple sizes, colors, positionings, styles, and more all coded with Tailwind CSS and Flowbite. | ||
|
||
## Default Indicator | ||
|
||
Use this example to create a simple indicator with multiple colors and position it anywhere on the website. | ||
|
||
<fwb-indicator-example /> | ||
```vue | ||
<template> | ||
<fwb-indicator /> | ||
<fwb-indicator type="dark" /> | ||
<fwb-indicator type="blue" /> | ||
<fwb-indicator type="green" /> | ||
<fwb-indicator type="red" /> | ||
<fwb-indicator type="indigo" /> | ||
<fwb-indicator type="purple" /> | ||
<fwb-indicator type="yellow" /> | ||
<fwb-indicator type="teal" /> | ||
</template> | ||
``` | ||
|
||
## Indicator position | ||
|
||
Use these examples to position the indicator component anywhere relative to the parent element. | ||
|
||
<fwb-indicator-position-example /> | ||
<br /> | ||
|
||
```vue | ||
<template> | ||
<div class='relative'> | ||
<fwb-indicator class="absolute top-0 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">top-left</fwb-indicator> | ||
<fwb-indicator class="absolute top-0 left-1/2 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">top-center</fwb-indicator> | ||
<fwb-indicator class="absolute top-0 right-0 -translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">top-right</fwb-indicator> | ||
<fwb-indicator class="absolute top-1/2 left-0 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">middle-left</fwb-indicator> | ||
<fwb-indicator class="absolute top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">middle-center</fwb-indicator> | ||
<fwb-indicator class="absolute top-1/2 right-0 -translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">middle-right</fwb-indicator> | ||
<fwb-indicator class="absolute bottom-0 translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">bottom-left</fwb-indicator> | ||
<fwb-indicator class="absolute bottom-0 left-1/2 translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">bottom-center</fwb-indicator> | ||
<fwb-indicator class="absolute bottom-0 right-0 translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">bottom-right</fwb-indicator> | ||
</div> | ||
</template> | ||
``` |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,18 @@ | ||||||
<template> | ||||||
<div class="vp-raw flex gap-4"> | ||||||
<fwb-indicator /> | ||||||
<fwb-indicator type="dark" /> | ||||||
<fwb-indicator type="blue" /> | ||||||
<fwb-indicator type="green" /> | ||||||
<fwb-indicator type="red" /> | ||||||
<fwb-indicator type="indigo" /> | ||||||
<fwb-indicator type="purple" /> | ||||||
<fwb-indicator type="yellow" /> | ||||||
<fwb-indicator type="teal" /> | ||||||
</div> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix indentation issues. Expected indentation of 2 spaces but found 0 spaces. -</div>
+ </div> Committable suggestion
Suggested change
ToolsGitHub Check: lint (18.x)
|
||||||
</template> | ||||||
|
||||||
<script setup lang="ts"> | ||||||
import { FwbIndicator } from '../../../../src/index' | ||||||
|
||||||
</script> |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,18 @@ | ||||||||||||||||
<template> | ||||||||||||||||
<div class="relative w-56 h-56 bg-gray-100 border border-gray-200 rounded-lg dark:bg-gray-800 dark:border-gray-700"> | ||||||||||||||||
<fwb-indicator class="absolute top-0 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">top-left</fwb-indicator> | ||||||||||||||||
Check warning on line 3 in docs/components/indicator/examples/FwbIndicatorPositionExample.vue GitHub Actions / lint (18.x)
Check warning on line 3 in docs/components/indicator/examples/FwbIndicatorPositionExample.vue GitHub Actions / lint (18.x)
|
||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues. The - <fwb-indicator class="absolute top-0 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">top-left</fwb-indicator>
+ <fwb-indicator
+ class="absolute top-0 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white"
+ type="blue"
+ >
+ top-left
+ </fwb-indicator> Committable suggestion
Suggested change
ToolsGitHub Check: lint (18.x)
|
||||||||||||||||
<fwb-indicator class="absolute top-0 left-1/2 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">top-center</fwb-indicator> | ||||||||||||||||
Check warning on line 4 in docs/components/indicator/examples/FwbIndicatorPositionExample.vue GitHub Actions / lint (18.x)
Check warning on line 4 in docs/components/indicator/examples/FwbIndicatorPositionExample.vue GitHub Actions / lint (18.x)
|
||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues. The - <fwb-indicator class="absolute top-0 left-1/2 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">top-center</fwb-indicator>
+ <fwb-indicator
+ class="absolute top-0 left-1/2 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white"
+ type="blue"
+ >
+ top-center
+ </fwb-indicator> Committable suggestion
Suggested change
ToolsGitHub Check: lint (18.x)
|
||||||||||||||||
<fwb-indicator class="absolute top-0 right-0 -translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">top-right</fwb-indicator> | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues. The - <fwb-indicator class="absolute top-0 right-0 -translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">top-right</fwb-indicator>
+ <fwb-indicator
+ class="absolute top-0 right-0 -translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white"
+ type="blue"
+ >
+ top-right
+ </fwb-indicator> Committable suggestion
Suggested change
ToolsGitHub Check: lint (18.x)
|
||||||||||||||||
<fwb-indicator class="absolute top-1/2 left-0 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">middle-left</fwb-indicator> | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues. The - <fwb-indicator class="absolute top-1/2 left-0 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">middle-left</fwb-indicator>
+ <fwb-indicator
+ class="absolute top-1/2 left-0 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white"
+ type="blue"
+ >
+ middle-left
+ </fwb-indicator> Committable suggestion
Suggested change
|
||||||||||||||||
<fwb-indicator class="absolute top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">middle-center</fwb-indicator> | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues. The - <fwb-indicator class="absolute top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">middle-center</fwb-indicator>
+ <fwb-indicator
+ class="absolute top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white"
+ type="blue"
+ >
+ middle-center
+ </fwb-indicator> Committable suggestion
Suggested change
|
||||||||||||||||
<fwb-indicator class="absolute top-1/2 right-0 -translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">middle-right</fwb-indicator> | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues. The - <fwb-indicator class="absolute top-1/2 right-0 -translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">middle-right</fwb-indicator>
+ <fwb-indicator
+ class="absolute top-1/2 right-0 -translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white"
+ type="blue"
+ >
+ middle-right
+ </fwb-indicator> Committable suggestion
Suggested change
|
||||||||||||||||
<fwb-indicator class="absolute bottom-0 translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">bottom-left</fwb-indicator> | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues. The - <fwb-indicator class="absolute bottom-0 translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">bottom-left</fwb-indicator>
+ <fwb-indicator
+ class="absolute bottom-0 translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white"
+ type="blue"
+ >
+ bottom-left
+ </fwb-indicator> Committable suggestion
Suggested change
|
||||||||||||||||
<fwb-indicator class="absolute bottom-0 left-1/2 translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">bottom-center</fwb-indicator> | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues. The - <fwb-indicator class="absolute bottom-0 left-1/2 translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">bottom-center</fwb-indicator>
+ <fwb-indicator
+ class="absolute bottom-0 left-1/2 translate-y-1/2 -translate-x-1/2 text-xs w-auto px-2 h-4 text-white"
+ type="blue"
+ >
+ bottom-center
+ </fwb-indicator> Committable suggestion
Suggested change
|
||||||||||||||||
<fwb-indicator class="absolute bottom-0 right-0 translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">bottom-right</fwb-indicator> | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues. The - <fwb-indicator class="absolute bottom-0 right-0 translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white" type="blue">bottom-right</fwb-indicator>
+ <fwb-indicator
+ class="absolute bottom-0 right-0 translate-y-1/2 translate-x-1/2 text-xs w-auto px-2 h-4 text-white"
+ type="blue"
+ >
+ bottom-right
+ </fwb-indicator> Committable suggestion
Suggested change
|
||||||||||||||||
</div> | ||||||||||||||||
</template> | ||||||||||||||||
|
||||||||||||||||
<script setup lang="ts"> | ||||||||||||||||
import { FwbIndicator } from '../../../../src/index' | ||||||||||||||||
|
||||||||||||||||
</script> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||
<template> | ||||||
<span :class="indicatorClasses"> | ||||||
<slot></slot> | ||||||
</span> | ||||||
</template> | ||||||
|
||||||
<script setup lang="ts"> | ||||||
import { computed } from 'vue' | ||||||
import { useMergeClasses } from '@/composables/useMergeClasses' | ||||||
|
||||||
type IndıcatorType = 'default' | 'dark' | 'blue' | 'green' | 'red' | 'indigo' | 'purple' | 'yellow' | 'teal' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in type definition. The type definition -type IndıcatorType = 'default' | 'dark' | 'blue' | 'green' | 'red' | 'indigo' | 'purple' | 'yellow' | 'teal'
+type IndicatorType = 'default' | 'dark' | 'blue' | 'green' | 'red' | 'indigo' | 'purple' | 'yellow' | 'teal' Committable suggestion
Suggested change
|
||||||
|
||||||
interface IIndicatorProps { | ||||||
type?: IndıcatorType | ||||||
class?: string | ||||||
} | ||||||
|
||||||
const props = withDefaults(defineProps<IIndicatorProps>(), { | ||||||
type: 'default', | ||||||
class: '', | ||||||
}) | ||||||
|
||||||
const defaultIndicatorClasses = 'w-3 h-3 rounded-full' | ||||||
const indicatorTypeClasses = { | ||||||
default: 'bg-gray-200', | ||||||
dark: 'bg-gray-900 dark:bg-gray-700', | ||||||
blue: 'bg-blue-600', | ||||||
green: 'bg-green-500', | ||||||
red: 'bg-red-500', | ||||||
indigo: 'bg-indigo-500', | ||||||
purple: 'bg-purple-500', | ||||||
yellow: 'bg-yellow-300', | ||||||
teal: 'bg-teal-500', | ||||||
} | ||||||
|
||||||
const indicatorClasses = computed(() => useMergeClasses([ | ||||||
defaultIndicatorClasses, | ||||||
indicatorTypeClasses[props.type], | ||||||
props.class, | ||||||
])) | ||||||
|
||||||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation issues.
Expected indentation of 2 spaces but found 0 spaces.
Committable suggestion
Tools
GitHub Check: lint (18.x)