Skip to content
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

refactor: use class as prop to prevent class duplication with cn function #241

Merged
merged 28 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
66254fa
refactor: use `class` as prop to prevent class duplication
sadeghbarati Jan 3, 2024
a10731b
refactor: update
sadeghbarati Jan 6, 2024
470ed45
refactor: default style finish
sadeghbarati Jan 8, 2024
f387165
Merge branch 'dev' into refactor/use-class-prop
sadeghbarati Jan 8, 2024
71e6b9c
refactor: update
sadeghbarati Jan 11, 2024
039ede6
refactor: update
sadeghbarati Jan 18, 2024
8f3f52b
Merge branch 'refactor/use-class-prop' into refactor/use-class-prop
sadeghbarati Jan 18, 2024
e994656
refactor: update default
sadeghbarati Jan 18, 2024
3889d63
refactor: update
sadeghbarati Jan 19, 2024
d2bd2ce
refactor: update
sadeghbarati Jan 19, 2024
ec233cb
Merge branch 'dev' of into refactor/use-class-prop
sadeghbarati Jan 19, 2024
2a7c911
fix: separator background color (#295)
Jan 20, 2024
d9cbf36
refactor: update new-york classes
sadeghbarati Jan 20, 2024
ae7144f
Merge branch 'dev' into refactor/use-class-prop
sadeghbarati Jan 20, 2024
30abfe2
refactor: update
sadeghbarati Jan 20, 2024
5d85fff
Merge branch 'refactor/use-class-prop' of https://github.com/sadeghba…
sadeghbarati Jan 20, 2024
5567b06
chore: build registry
sadeghbarati Jan 20, 2024
b15f602
Merge branch 'dev' into refactor/use-class-prop
sadeghbarati Jan 23, 2024
57306c2
Merge branch 'dev' into refactor/use-class-prop
sadeghbarati Jan 29, 2024
9ae8641
chore: fix can't resolved component in md and demo files
sadeghbarati Jan 30, 2024
51a858d
refactor: update
sadeghbarati Jan 30, 2024
62c4109
refactor: remove unnecessary avoid-collisions
sadeghbarati Jan 30, 2024
010a3bd
Merge branch 'dev' into refactor/use-class-prop
sadeghbarati Jan 31, 2024
d7fdeb1
chore: build registry
sadeghbarati Jan 31, 2024
ad759e3
chore: fix the icons in registry demos
sadeghbarati Feb 1, 2024
c3d99cd
chore: change docs nav label background-color
sadeghbarati Feb 1, 2024
c15299a
chore: update deps
sadeghbarati Feb 2, 2024
a97b406
chore: make `sonner` ClientOnly for now
sadeghbarati Feb 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 3 additions & 5 deletions apps/www/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { defineConfig } from 'vitepress'
import Icons from 'unplugin-icons/vite'
import tailwind from 'tailwindcss'
import autoprefixer from 'autoprefixer'
import { createCssVariablesTheme } from 'shikiji'
import { createCssVariablesTheme } from 'shiki'

// import { transformerMetaWordHighlight } from 'shikiji-transformers'
// import { transformerMetaWordHighlight, transformerNotationWordHighlight } from '@shikijs/transformers'
import { siteConfig } from './theme/config/site'
import ComponentPreviewPlugin from './theme/plugins/previewer'

Expand Down Expand Up @@ -61,6 +61,7 @@ export default defineConfig({
theme: cssVariables,
codeTransformers: [
// transformerMetaWordHighlight(),
// transformerNotationWordHighlight(),
],
config(md) {
md.use(ComponentPreviewPlugin)
Expand All @@ -86,8 +87,5 @@ export default defineConfig({
'@': path.resolve(__dirname, '../src'),
},
},
ssr: {
noExternal: ['vue-sonner'],
},
},
})
4 changes: 2 additions & 2 deletions apps/www/.vitepress/theme/layout/DocsLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const sourceLink = 'https://github.com/radix-vue/shadcn-vue/tree/dev/'
>
{{ doc.title }}

<Badge v-if="doc.label" class="ml-2" :variant="'secondary'">
<span v-if="doc.label" class="ml-2 rounded-md bg-[#adfa1d] px-1.5 py-0.5 text-xs leading-none text-[#000000] no-underline group-hover:no-underline">
{{ doc.label }}
</Badge>
</span>
</a>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion apps/www/.vitepress/theme/layout/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ watch(() => $route.path, (n) => {
</DialogContent>
</Dialog>
<DefaultToaster />
<NewYorkSonner :theme="isDark ? 'dark' : 'light'" />
<ClientOnly>
<NewYorkSonner :theme="isDark ? 'dark' : 'light'" />
</ClientOnly>
<NewYorkToaster />
</div>
</template>
7 changes: 7 additions & 0 deletions apps/www/.vitepress/theme/styles/shiki.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@
--shiki-token-string-expression: #ebebeb;
--shiki-token-punctuation: #ffffff;
--shiki-token-link: #EE0000;
}

.shiki .highlighted-word {
border-radius: calc(var(--radius) - 2px);
border-color: rgba(63,63,70,.7);
background-color: rgba(63,63,70,.5);
padding: 0.25rem;
}
36 changes: 18 additions & 18 deletions apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@
"@morev/vue-transitions": "^2.3.6",
"@radix-icons/vue": "^1.0.0",
"@stackblitz/sdk": "^1.9.0",
"@tanstack/vue-table": "^8.11.7",
"@unovis/ts": "^1.3.1",
"@unovis/vue": "^1.3.1",
"@vee-validate/zod": "^4.12.4",
"@tanstack/vue-table": "^8.11.8",
"@unovis/ts": "^1.3.3",
"@unovis/vue": "^1.3.3",
"@vee-validate/zod": "^4.12.5",
"@vueuse/core": "^10.7.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"codesandbox": "^2.2.3",
"date-fns": "^2.30.0",
"embla-carousel": "8.0.0-rc19",
"embla-carousel-autoplay": "8.0.0-rc19",
"embla-carousel-vue": "8.0.0-rc19",
"embla-carousel": "^8.0.0-rc22",
"embla-carousel-autoplay": "^8.0.0-rc22",
"embla-carousel-vue": "^8.0.0-rc22",
"lucide-vue-next": "^0.276.0",
"radix-vue": "^1.3.2",
"radix-vue": "^1.4.0",
"tailwindcss-animate": "^1.0.7",
"v-calendar": "^3.1.2",
"vee-validate": "4.12.4",
"vee-validate": "4.12.5",
"vue": "^3.4.15",
"vue-sonner": "^1.0.2",
"vue-sonner": "^1.0.3",
"vue-wrap-balancer": "^1.1.3",
"zod": "^3.22.4"
},
Expand All @@ -46,26 +46,26 @@
"@iconify-json/tabler": "^1.1.89",
"@iconify/json": "^2.2.108",
"@iconify/vue": "^4.1.1",
"@shikijs/transformers": "^1.0.0-beta.3",
"@types/lodash.template": "^4.5.2",
"@types/node": "^20.8.10",
"@vitejs/plugin-vue": "^5.0.3",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vue/compiler-core": "^3.4.14",
"@vue/compiler-dom": "^3.4.14",
"@vue/compiler-core": "^3.4.15",
"@vue/compiler-dom": "^3.4.15",
"@vue/tsconfig": "^0.5.1",
"autoprefixer": "^10.4.16",
"autoprefixer": "^10.4.17",
"lodash.template": "^4.5.0",
"pathe": "^1.1.2",
"rimraf": "^5.0.5",
"shikiji": "^0.10.0-beta.9",
"shikiji-transformers": "^0.10.0-beta.9",
"tailwind-merge": "^2.2.0",
"shiki": "^1.0.0-beta.3",
"tailwind-merge": "^2.2.1",
"tailwindcss": "^3.4.1",
"tsx": "^4.7.0",
"typescript": "^5.3.3",
"unplugin-icons": "^0.17.1",
"unplugin-icons": "^0.18.3",
"vite": "^5.0.12",
"vitepress": "^1.0.0-rc.39",
"vitepress": "^1.0.0-rc.41",
"vue-tsc": "^1.8.27"
}
}
60 changes: 25 additions & 35 deletions apps/www/src/content/docs/components/data-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ We'll start with the basic `<Table />` component and build a complex data table

## Table of Contents

This guide will show you how to use [TanStack Table](https://tanstack.com/table/v8) and the <Table /> component to build your own custom data table. We'll cover the following topics:
This guide will show you how to use [TanStack Table](https://tanstack.com/table/v8) and the `<Table />` component to build your own custom data table. We'll cover the following topics:

- [Basic Table](#basic-table)
- [Row Actions](#row-actions)
Expand Down Expand Up @@ -109,31 +109,23 @@ Let's start by building a basic table.

First, we'll define our columns in the `columns.ts` file.

```ts:line-numbers title="components/payments/columns.ts" {1,12-27}
import type { ColumnDef } from '@tanstack/vue-table'

// This type is used to define the shape of our data.
// You can use a Zod schema here if you want.
export interface Payment {
id: string
amount: number
status: 'pending' | 'processing' | 'success' | 'failed'
email: string
}
```ts:line-numbers {1,12-27}
import { h } from 'vue'

export const columns: ColumnDef<Payment>[] = [
{
accessorKey: 'status',
header: 'Status',
},
{
accessorKey: 'email',
header: 'Email',
},
{
accessorKey: 'amount',
header: 'Amount',
},
header: () => h('div', { class: 'text-right' }, 'Amount'),
cell: ({ row }) => {
const amount = Number.parseFloat(row.getValue('amount'))
const formatted = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
}).format(amount)

return h('div', { class: 'text-right font-medium' }, formatted)
},
}
]
```

Expand All @@ -149,7 +141,7 @@ formatted, sorted and filtered.

Next, we'll create a `<DataTable />` component to render our table.

```ts:line-numbers
```vue:line-numbers
<script setup lang="ts" generic="TData, TValue">
import type { ColumnDef } from '@tanstack/vue-table'
import {
Expand Down Expand Up @@ -225,7 +217,7 @@ const table = useVueTable({

Finally, we'll render our table in our index component.

```ts:line-numbers {28}
```vue:line-numbers {28}
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { columns } from "./components/columns"
Expand Down Expand Up @@ -302,7 +294,7 @@ Let's add row actions to our table. We'll use a `<Dropdown />` component for thi

### Add the following into your `DataTableDropDown.vue` component:

```ts:line-numbers
```vue:line-numbers
// DataTableDropDown.vue
<script setup lang="ts">
import { MoreHorizontal } from 'lucide-vue-next'
Expand Down Expand Up @@ -402,8 +394,7 @@ This will automatically paginate your rows into pages of 10. See the [pagination

We can add pagination controls to our table using the `<Button />` component and the `table.previousPage()`, `table.nextPage()` API methods.

```ts:line-numbers {3,15,21-39}
// components/payments/DataTable.vue
```vue:line-numbers {3,15,21-39}
<script lang="ts" generic="TData, TValue">
import { Button } from "@/components/ui/button"

Expand Down Expand Up @@ -482,7 +473,7 @@ The `valueUpdater` function updates a Vue `ref` object's value. It handles both

### Update `<DataTable>`

```ts:line-numbers {4,7,16,34,41-44}
```vue:line-numbers {4,7,16,34,41-44}
<script setup lang="ts" generic="TData, TValue">
import type {
ColumnDef,
Expand Down Expand Up @@ -579,7 +570,7 @@ Let's add a search input to filter emails in our table.

### Update `<DataTable>`

```ts:line-numbers {4,11,19,39,48-49,52,60-64}
```vue:line-numbers {4,11,19,39,48-49,52,60-64}
<script setup lang="ts" generic="TData, TValue">
import type {
ColumnDef,
Expand Down Expand Up @@ -664,7 +655,7 @@ Adding column visibility is fairly simple using `@tanstack/vue-table` visibility

### Update `<DataTable>`

```ts:line-numbers {6,9-14,48,59,63,75-91}
```vue:line-numbers {6,9-14,48,59,63,75-91}
<script setup lang="ts" generic="TData, TValue">
import type {
ColumnDef,
Expand Down Expand Up @@ -829,7 +820,7 @@ export const columns: ColumnDef<Payment>[] = [

### Update `<DataTable>`

```ts:line-numbers {10,22,27}
```vue:line-numbers {10,22,27}
<script setup lang="ts" generic="TData, TValue">
const props = defineProps<{
columns: ColumnDef<TData, TValue>[]
Expand Down Expand Up @@ -895,7 +886,7 @@ Here are some components you can use to build your data tables. This is from the

Make any column header sortable and hideable.

```ts:line-numbers
```vue:line-numbers
<script setup lang="ts">
import type { Column } from '@tanstack/vue-table'
import { type Task } from '../data/schema'
Expand Down Expand Up @@ -988,7 +979,7 @@ export const columns = [

Add pagination controls to your table including page size and selection count.

```ts:line-numbers
```vue:line-numbers
<script setup lang="ts">
import { type Table } from '@tanstack/vue-table'
import { type Task } from '../data/schema'
Expand Down Expand Up @@ -1093,8 +1084,7 @@ defineProps<DataTablePaginationProps>()

A component to toggle column visibility.

```ts:line-numbers

```vue:line-numbers
<script setup lang="ts">
import type { Table } from '@tanstack/vue-table'
import { computed } from 'vue'
Expand Down
2 changes: 1 addition & 1 deletion apps/www/src/content/docs/components/navigation-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {

### Link Component

When using the Nuxt.js <NuxtLink /> component, you can use `navigationMenuTriggerStyle()` to apply the correct styles to the trigger.
When using the Nuxt.js `<NuxtLink />` component, you can use `navigationMenuTriggerStyle()` to apply the correct styles to the trigger.

```ts
import { navigationMenuTriggerStyle } from '@/components/ui/navigation-menu'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const date = ref({
</span>
</Button>
</PopoverTrigger>
<PopoverContent class="w-auto p-0" :align="'end'" :avoid-collisions="true">
<PopoverContent class="w-auto p-0" :align="'end'">
<Calendar
v-model.range="date"
:columns="2"
Expand Down
4 changes: 2 additions & 2 deletions apps/www/src/examples/forms/components/AccountForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async function onSubmit(values: any) {
</FormField>

<FormField v-slot="{ componentField, value }" name="dob">
<FormItem>
<FormItem class="flex flex-col">
<FormLabel>Date of birth</FormLabel>
<Popover>
<PopoverTrigger as-child>
Expand Down Expand Up @@ -123,7 +123,7 @@ async function onSubmit(values: any) {
</FormField>

<FormField v-slot="{ value }" name="language">
<FormItem>
<FormItem class="flex flex-col">
<FormLabel>Language</FormLabel>

<Popover v-model:open="open">
Expand Down
9 changes: 8 additions & 1 deletion apps/www/src/lib/registry/default/example/CardFormDemo.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<script setup lang='ts'>
import { Card, CardContent, CardHeader, CardTitle } from '@/lib/registry/default/ui/card'
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from '@/lib/registry/default/ui/card'
import {
Select,
SelectContent,
Expand Down
6 changes: 3 additions & 3 deletions apps/www/src/lib/registry/default/example/Cards/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
useVueTable,
} from '@tanstack/vue-table'
import { h, ref } from 'vue'
import { CaretSortIcon, ChevronDownIcon } from '@radix-icons/vue'
import { ChevronDown, ChevronsUpDown } from 'lucide-vue-next'
import DropdownAction from '../DataTableDemoColumn.vue'

import { Button } from '@/lib/registry/default/ui/button'
Expand Down Expand Up @@ -104,7 +104,7 @@ const columns: ColumnDef<Payment>[] = [
return h(Button, {
variant: 'ghost',
onClick: () => column.toggleSorting(column.getIsSorted() === 'asc'),
}, ['Email', h(CaretSortIcon, { class: 'ml-2 h-4 w-4' })])
}, ['Email', h(ChevronsUpDown, { class: 'ml-2 h-4 w-4' })])
},
cell: ({ row }) => h('div', { class: 'lowercase' }, row.getValue('email')),
},
Expand Down Expand Up @@ -179,7 +179,7 @@ const table = useVueTable({
<DropdownMenu>
<DropdownMenuTrigger as-child>
<Button variant="outline" class="ml-auto">
Columns <ChevronDownIcon class="ml-2 h-4 w-4" />
Columns <ChevronDown class="ml-2 h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
Expand Down
6 changes: 3 additions & 3 deletions apps/www/src/lib/registry/default/example/ComboboxDemo.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref } from 'vue'
import { CaretSortIcon, CheckIcon } from '@radix-icons/vue'
import { Check, ChevronsUpDown } from 'lucide-vue-next'

import { cn } from '@/lib/utils'
import { Button } from '@/lib/registry/default/ui/button'
Expand Down Expand Up @@ -44,7 +44,7 @@ const value = ref<string>('')
{{ value
? frameworks.find((framework) => framework.value === value)?.label
: "Select framework..." }}
<CaretSortIcon class="ml-2 h-4 w-4 shrink-0 opacity-50" />
<ChevronsUpDown class="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent class="w-[200px] p-0">
Expand All @@ -65,7 +65,7 @@ const value = ref<string>('')
}"
>
{{ framework.label }}
<CheckIcon
<Check
:class="cn(
'ml-auto h-4 w-4',
value === framework.value ? 'opacity-100' : 'opacity-0',
Expand Down
Loading