-
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.
Merge pull request #175 from vuejs-jp/feature/accordion
[コアスタッフ内の管理画面内のみの利用を想定] Accordion
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 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
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({}) |
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,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> |