-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vue): add component accordion on vue (#221)
- Loading branch information
Sebastián García
authored
May 4, 2024
1 parent
34c2ae6
commit cc57740
Showing
11 changed files
with
215 additions
and
4 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,24 @@ | ||
<script setup lang="ts"> | ||
import { type HTMLAttributes, computed } from 'vue' | ||
import { AccordionContent, type AccordionContentProps } from 'radix-vue' | ||
import { accordionContent, cn } from '@openui-org/theme' | ||
const props = defineProps<AccordionContentProps & { class?: HTMLAttributes['class'] }>() | ||
const delegatedProps = computed(() => { | ||
const { class: _, ...delegated } = props | ||
return delegated | ||
}) | ||
</script> | ||
|
||
<template> | ||
<AccordionContent | ||
v-bind="delegatedProps" | ||
:class="cn(accordionContent())" | ||
> | ||
<div :class="cn('pb-4 pt-0', props.class)"> | ||
<slot /> | ||
</div> | ||
</AccordionContent> | ||
</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,24 @@ | ||
<script setup lang="ts"> | ||
import { type HTMLAttributes, computed } from 'vue' | ||
import { AccordionItem, type AccordionItemProps, useForwardProps } from 'radix-vue' | ||
import { accordionItem, cn } from '@openui-org/theme' | ||
const props = defineProps<AccordionItemProps & { class?: HTMLAttributes['class'] }>() | ||
const delegatedProps = computed(() => { | ||
const { class: _, ...delegated } = props | ||
return delegated | ||
}) | ||
const forwardedProps = useForwardProps(delegatedProps) | ||
</script> | ||
|
||
<template> | ||
<AccordionItem | ||
v-bind="forwardedProps" | ||
:class="cn(accordionItem(), props.class)" | ||
> | ||
<slot /> | ||
</AccordionItem> | ||
</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,30 @@ | ||
<script setup lang="ts"> | ||
import type { HTMLAttributes } from 'vue' | ||
import type { AccordionTriggerProps } from 'radix-vue' | ||
import { computed } from 'vue' | ||
import { AccordionHeader, AccordionTrigger } from 'radix-vue' | ||
import { accordionTrigger, cn } from '@openui-org/theme' | ||
const props = defineProps<AccordionTriggerProps & { class?: HTMLAttributes['class'] }>() | ||
const delegatedProps = computed(() => { | ||
const { class: _, ...delegated } = props | ||
return delegated | ||
}) | ||
</script> | ||
|
||
<template> | ||
<AccordionHeader class="flex"> | ||
<AccordionTrigger | ||
v-bind="delegatedProps" | ||
:class="cn(accordionTrigger(), props.class)" | ||
> | ||
<slot /> | ||
<slot name="icon"> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down h-4 w-4 shrink-0 transition-transform duration-200"><path d="m6 9 6 6 6-6" /></svg> | ||
</slot> | ||
</AccordionTrigger> | ||
</AccordionHeader> | ||
</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,15 @@ | ||
<script setup lang="ts"> | ||
import type { AccordionRootEmits, AccordionRootProps } from 'radix-vue' | ||
import { AccordionRoot, useForwardPropsEmits } from 'radix-vue' | ||
const props = defineProps<AccordionRootProps>() | ||
const emits = defineEmits<AccordionRootEmits>() | ||
const forwarded = useForwardPropsEmits(props, emits) | ||
</script> | ||
|
||
<template> | ||
<AccordionRoot v-bind="forwarded"> | ||
<slot /> | ||
</AccordionRoot> | ||
</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,4 @@ | ||
export { default as Accordion } from './accordion.vue' | ||
export { default as AccordionContent } from './accordion-content.vue' | ||
export { default as AccordionItem } from './accordion-item.vue' | ||
export { default as AccordionTrigger } from './accordion-trigger.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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './accordion' | ||
export * from './button' |
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,7 @@ | ||
// shims-vue.d.ts | ||
declare module '*.vue' { | ||
import type { DefineComponent } from 'vue' | ||
|
||
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, any > | ||
export default component | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.