diff --git a/docs/content/2.components/mark.md b/docs/content/2.components/mark.md new file mode 100644 index 0000000..fc63f48 --- /dev/null +++ b/docs/content/2.components/mark.md @@ -0,0 +1,83 @@ +--- +description: Display a indicator with or without counts on any component +--- + +## Usage + +Use the default slot to add any component you want to display the indicator on. + +::ComponentPreview +--- +slots: + default: | + +--- +#default +:RayButton{icon="tabler:message" label="messages" color="invert"} +:: + +### Styles + +You can change the color and size of the indicator by using the `color` and `size` props. + +::ComponentPreview +--- +props: + color: amber + size: sm +slots: + default: | + +--- +#default +:RayButton{icon="tabler:message" label="messages" color="invert"} +:: + +### Position + +Use the `position` prop to change the position of the indicator. + +::ComponentPreview +--- +props: + position: top-right +slots: + default: | + +--- +#default +:RayButton{icon="tabler:message" label="messages" color="invert"} +:: + +### Count + +Add a count to the indicator by using the `value` prop. + +::ComponentPreview +--- +props: + value: 5 +slots: + default: | + +--- +#default +:RayButton{icon="tabler:message" label="messages" color="invert"} +:: + +#### Overflow + +Set `max` prop to handle overflow situation. + +::ComponentPreview +--- +props: + value: 110 + max: 99 +slots: + default: | + +--- +#default +:RayButton{icon="tabler:message" label="messages" color="invert"} +:: diff --git a/src/runtime/components/elements/Mark.vue b/src/runtime/components/elements/Mark.vue new file mode 100644 index 0000000..64601e1 --- /dev/null +++ b/src/runtime/components/elements/Mark.vue @@ -0,0 +1,90 @@ + + + diff --git a/src/runtime/types/index.ts b/src/runtime/types/index.ts index caea2fd..532ee79 100644 --- a/src/runtime/types/index.ts +++ b/src/runtime/types/index.ts @@ -4,5 +4,6 @@ export * from './input' export * from './textarea' export * from './kbd' export * from './toggle' +export * from './mark' export * from './utils' diff --git a/src/runtime/types/mark.d.ts b/src/runtime/types/mark.d.ts new file mode 100644 index 0000000..b4473ad --- /dev/null +++ b/src/runtime/types/mark.d.ts @@ -0,0 +1,14 @@ +import type { AppConfig } from '@nuxt/schema' +import type { mark } from '../ui.config' +import type { ExtractDeepKey } from './utils' +import type colors from '#ray-colors' + +export type MarkSize = + | keyof typeof mark.size + | ExtractDeepKey +export type MarkColor = + | ExtractDeepKey + | (typeof colors)[number] +export type MarkPosition = + | keyof typeof mark.position + | ExtractDeepKey diff --git a/src/runtime/ui.config/elements/mark.ts b/src/runtime/ui.config/elements/mark.ts new file mode 100644 index 0000000..db6c691 --- /dev/null +++ b/src/runtime/ui.config/elements/mark.ts @@ -0,0 +1,51 @@ +export default { + wrapper: 'relative', + base: 'absolute text-white rounded-full inline-flex justify-center items-center', + ring: 'ring-2 ring-white dark:ring-gray-900', + rounded: 'rounded-full', + background: 'bg-{color}-500', + position: { + 'top-left': 'top-0 left-0', + 'top-right': 'top-0 right-0', + 'bottom-left': 'bottom-0 left-0', + 'bottom-right': 'bottom-0 right-0', + }, + translate: { + 'top-left': '-translate-x-0.5 -translate-y-0.5', + 'top-right': 'translate-x-0.5 -translate-y-0.5', + 'bottom-left': '-translate-x-0.5 translate-y-0.5', + 'bottom-right': 'translate-x-0.5 translate-y-0.5', + }, + size: { + xs: 'w-1.5 h-1.5', + sm: 'w-2 h-2', + md: 'w-2.5 h-2.5', + }, + value: { + size: { + xs: 'px-1 h-3 leading-none text-xs', + sm: 'px-1.5 h-4 leading-none text-xs', + md: 'px-2 h-5 leading-none text-sm', + }, + translate: { + 'top-left': '-translate-x-1/3 -translate-y-1/3', + 'top-right': 'translate-x-1/3 -translate-y-1/3', + 'bottom-left': '-translate-x-1/3 translate-y-1/3', + 'bottom-right': 'translate-x-1/3 translate-y-1/3', + }, + }, + transition: { + moveClass: 'transform ease-out duration-300 transition', + enterActiveClass: 'transform ease-out duration-300 transition', + leaveActiveClass: 'transform ease-out duration-300 transition absolute', + enterFromClass: 'translate-y-2 opacity-0', + enterToClass: 'translate-y-0 opacity-100', + leaveFromClass: 'translate-y-0 opacity-100', + leaveToClass: '-translate-y-2 opacity-0', + }, + default: { + size: 'sm', + color: 'primary', + position: 'top-right', + }, +} diff --git a/src/runtime/ui.config/index.ts b/src/runtime/ui.config/index.ts index 0ada6dc..dd9656e 100644 --- a/src/runtime/ui.config/index.ts +++ b/src/runtime/ui.config/index.ts @@ -4,6 +4,7 @@ export { default as standard } from './standard' // elements export { default as button } from './elements/button' export { default as kbd } from './elements/kbd' +export { default as mark } from './elements/mark' // forms export { default as input } from './forms/input'