-
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.
* ref: move cell renderers to own components * feat: add data type highlighting
- Loading branch information
1 parent
1269fea
commit bf51f13
Showing
13 changed files
with
251 additions
and
37 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
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,29 @@ | ||
<template> | ||
<div | ||
:class="[ | ||
twMerge( | ||
'vsc-relative vsc-inset-0 vsc-break-words vsc-py-2 vsc-px-2 vsc-text-[#2196f3]', | ||
truncate && 'vsc-whitespace-nowrap vsc-text-ellipsis vsc-overflow-hidden', | ||
props.class, | ||
), | ||
]" | ||
:title="text" | ||
> | ||
<slot> | ||
<span v-html="text" /> | ||
<div v-if="isSearchMatch" class="vsc-absolute vsc-inset-0 vsc-bg-yellow-400/5" /> | ||
</slot> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { defineProps, HTMLAttributes } from 'vue' | ||
import { twMerge } from '../../utils/tailwind-merge.utils' | ||
const props = defineProps<{ | ||
truncate?: boolean | ||
text?: string | ||
isSearchMatch?: boolean | ||
class?: HTMLAttributes['class'] | ||
}>() | ||
</script> |
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,29 @@ | ||
<template> | ||
<div | ||
:class="[ | ||
twMerge( | ||
'vsc-relative vsc-inset-0 vsc-break-words vsc-py-2 vsc-px-2', | ||
truncate && 'vsc-whitespace-nowrap vsc-text-ellipsis vsc-overflow-hidden', | ||
props.class, | ||
), | ||
]" | ||
:title="text" | ||
> | ||
<slot> | ||
<span v-html="text" /> | ||
<div v-if="isSearchMatch" class="vsc-absolute vsc-inset-0 vsc-bg-yellow-400/5" /> | ||
</slot> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { defineProps, HTMLAttributes } from 'vue' | ||
import { twMerge } from '../../utils/tailwind-merge.utils' | ||
const props = defineProps<{ | ||
truncate?: boolean | ||
text?: string | ||
isSearchMatch?: boolean | ||
class?: HTMLAttributes['class'] | ||
}>() | ||
</script> |
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,57 @@ | ||
<template> | ||
<div | ||
:class="[ | ||
twMerge( | ||
'vsc-inline-flex vsc-items-center vsc-font-bold vsc-whitespace-nowrap vsc-h-8 vsc-gap-2 vsc-text-xs vsc-py-2 vsc-px-2', | ||
props.class, | ||
), | ||
isSortable && twMerge('vsc-inline-flex vsc-items-center vsc-gap-2 vsc-cursor-pointer', props.sortableClass), | ||
Boolean(column.isSortable && getSortDirection(column.field)) && props.sortingClass, | ||
]" | ||
@click="handleClickColumnHeader(column)" | ||
> | ||
<SortIcon v-if="column.isSortable && getSortDirection(column.field)" :direction="getSortDirection(column.field)" /> | ||
<slot>{{ text }}</slot> | ||
<Icon v-if="column.info" icon="codicon:info" class="vsc-ml-auto vsc-min-w-3 vsc-min-h-3" v-tooltip="column.info" /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed, HTMLAttributes } from 'vue' | ||
import type { IVueScreener, Column } from '../../interfaces/vue-screener' | ||
import SortIcon from '../icons/SortIcon.vue' | ||
import { twMerge } from '../../utils/tailwind-merge.utils' | ||
import { Icon } from '@iconify/vue' | ||
import { vTooltip } from 'floating-vue' | ||
import 'floating-vue/dist/style.css' | ||
const props = defineProps<{ | ||
screener: IVueScreener | ||
column: Column | ||
sortableClass?: string | ||
sortingClass?: string | ||
text?: string | number | ||
class?: HTMLAttributes['class'] | ||
}>() | ||
const isSortable = computed(() => props.column.isSortable) | ||
const getSortDirection = (field: string | number): 'asc' | 'desc' | null => { | ||
if (props.screener.searchQuery.value.sortField === field) { | ||
return props.screener.searchQuery.value.sortDirection | ||
} | ||
return null | ||
} | ||
const handleClickColumnHeader = (column: Column) => { | ||
if (column.isSortable) { | ||
props.screener.actions.sort(column.field) | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
.v-popper__popper { | ||
@apply vsc-text-xs; | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<template> | ||
<div | ||
:class="[ | ||
twMerge( | ||
'vsc-relative vsc-inset-0 vsc-break-words vsc-py-2 vsc-px-2 vsc-text-[#d81b60]', | ||
truncate && 'vsc-whitespace-nowrap vsc-text-ellipsis vsc-overflow-hidden', | ||
props.class, | ||
), | ||
]" | ||
:title="text" | ||
> | ||
<slot> | ||
<span v-html="text" /> | ||
<div v-if="isSearchMatch" class="vsc-absolute vsc-inset-0 vsc-bg-yellow-400/5" /> | ||
</slot> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { defineProps, HTMLAttributes } from 'vue' | ||
import { twMerge } from '../../utils/tailwind-merge.utils' | ||
const props = defineProps<{ | ||
truncate?: boolean | ||
text?: string | ||
isSearchMatch?: boolean | ||
class?: HTMLAttributes['class'] | ||
}>() | ||
</script> |
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,31 @@ | ||
<template> | ||
<div | ||
:class="[ | ||
twMerge( | ||
'vsc-relative vsc-inset-0 vsc-break-words vsc-py-2 vsc-px-2 vsc-text-[#4caf50]', | ||
truncate && 'vsc-whitespace-nowrap vsc-text-ellipsis vsc-overflow-hidden', | ||
props.class, | ||
), | ||
]" | ||
:title="text" | ||
> | ||
<slot> | ||
<span v-html="parsedText" /> | ||
<div v-if="isSearchMatch" class="vsc-absolute vsc-inset-0 vsc-bg-yellow-400/5" /> | ||
</slot> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed, defineProps, HTMLAttributes } from 'vue' | ||
import { twMerge } from '../../utils/tailwind-merge.utils' | ||
const props = defineProps<{ | ||
truncate?: boolean | ||
text?: string | ||
isSearchMatch?: boolean | ||
class?: HTMLAttributes['class'] | ||
}>() | ||
const parsedText = computed(() => `"${props.text}"`) | ||
</script> |
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
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
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
32 changes: 32 additions & 0 deletions
32
src/stories/1-basic-usage/5-disable-data-type-highlighting.story.vue
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,32 @@ | ||
<template> | ||
<Story title="5. Disable data type highlighting" source="-"> | ||
<div class="vsc-p-4 vsc-bg-zinc-800"> | ||
<VueScreener | ||
title="Array of objects" | ||
:data="baseData" | ||
:columns="{ id: { width: 'minmax(50px, max-content)' } }" | ||
disable-data-type-highlight | ||
/> | ||
</div> | ||
<br /> | ||
<div class="vsc-p-4 vsc-bg-zinc-800"> | ||
<VueScreener | ||
title="Array of primitives" | ||
:data="primitivesData" | ||
:columns="{ 0: { width: 'minmax(50px, max-content)' } }" | ||
disable-data-type-highlight | ||
/> | ||
</div> | ||
<br /> | ||
<div class="vsc-p-4 vsc-bg-zinc-800"> | ||
<VueScreener title="Array of mixed objects" :data="mixedObjectsData" disable-data-type-highlight /> | ||
</div> | ||
</Story> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { VueScreener } from '../../index' | ||
import baseData from '../../fixtures/data.json' | ||
import primitivesData from '../../fixtures/primitives-data.json' | ||
import mixedObjectsData from '../../fixtures/mix-objects-data.json' | ||
</script> |
2 changes: 1 addition & 1 deletion
2
src/stories/1-basic-usage/5-slots.story.vue → src/stories/1-basic-usage/6-slots.story.vue
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