Skip to content

Commit

Permalink
Merge pull request #175 from vuejs-jp/feature/accordion
Browse files Browse the repository at this point in the history
[コアスタッフ内の管理画面内のみの利用を想定] Accordion
  • Loading branch information
jiyuujin authored Jul 3, 2024
2 parents 63a3605 + fc286d1 commit dbb15a4
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/ui/components/common/Accordion.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { StoryFn } from '@storybook/vue3'
import Accordion from './Accordion.vue'

export default {
title: 'common/Accordion',
component: Accordion,
args: {
default: '<strong>Go!</strong>',
title: '折りたたみ',
},
argTypes: {
default: {
description: 'The default Vue slot',
control: {
type: 'text',
},
table: {
category: 'Slots',
type: {
summary: 'html',
},
},
},
title: {
description: 'The title property',
control: {
type: 'text',
},
},
},
}

const Template: StoryFn<unknown> = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { Accordion },
setup() {
return { args }
},
template: '<Accordion v-bind="args">{{ args.default }}</Accordion>',
})

export const Default = Template.bind({})
41 changes: 41 additions & 0 deletions packages/ui/components/common/Accordion.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script setup lang="ts">
import { ref } from 'vue'
import CssResetButton from './CssResetButton.vue'
interface AccordionProps {
title: string;
}
const props = defineProps<AccordionProps>()
const showPanel = ref(false)
const togglePanel = (event) => showPanel.value = !showPanel.value
</script>

<template>
<div class="panel">
<CssResetButton class="parent-panel" @click.prevent="togglePanel">
{{ title }} >
</CssResetButton>
<div v-if="showPanel" class="panel-content">
<slot />
</div>
</div>
</template>

<style scoped>
.parent-panel {
padding: 22px 24px;
border-radius: 6px;
box-shadow: var(--box-shadow-button);
border: var(--border);
outline: none;
color: var(--color-vue-blue);
font-weight: normal;
width: 100%;
text-align: left;
}
.panel-content {
padding: 22px 24px;
}
</style>

0 comments on commit dbb15a4

Please sign in to comment.