-
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.
fix(core): add collapsible-container
- Loading branch information
1 parent
405030e
commit 18cee7d
Showing
29 changed files
with
9,060 additions
and
7,132 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,20 @@ | ||
<template> | ||
<base-button>Label</base-button> | ||
</template> | ||
|
||
<script> | ||
import BaseButton from '@foundation/core/Button'; | ||
export default { | ||
components: { | ||
BaseButton | ||
} | ||
}; | ||
</script> | ||
|
||
<style lang="postcss" scoped> | ||
>>> .button { | ||
color: #333; | ||
background: #eee; | ||
border: solid #ccc 1px; | ||
} | ||
</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
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 @@ | ||
export default class Dataset { | ||
#options = null; | ||
#model = null; | ||
|
||
constructor (options, model) { | ||
this.#options = options; | ||
this.#model = model; | ||
} | ||
|
||
get options () { | ||
return this.#options; | ||
} | ||
|
||
get model () { | ||
return this.#model; | ||
} | ||
|
||
toJSON () { | ||
return { | ||
options: this.#options, | ||
model: this.#model.toJSON() | ||
}; | ||
} | ||
} |
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,19 @@ | ||
export default class Model { | ||
#name = null; | ||
|
||
constructor (name, value) { | ||
this.#name = name; | ||
this.value = value; | ||
} | ||
|
||
get name () { | ||
return this.#name; | ||
} | ||
|
||
toJSON () { | ||
return { | ||
name: this.#name, | ||
value: this.value | ||
}; | ||
} | ||
} |
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,37 @@ | ||
import { cyrb53 } from '../../utils/hash'; | ||
|
||
export default class Option { | ||
#label = null; | ||
#value = null; | ||
#content = null; | ||
|
||
constructor (label, value, content) { | ||
this.#label = label; | ||
this.#value = value; | ||
this.#content = content; | ||
} | ||
|
||
get key () { | ||
return `${cyrb53(JSON.stringify(this.toJSON()))}`; | ||
} | ||
|
||
get label () { | ||
return this.#label; | ||
} | ||
|
||
get value () { | ||
return this.#value; | ||
} | ||
|
||
get content () { | ||
return this.#content; | ||
} | ||
|
||
toJSON () { | ||
return { | ||
label: this.#label, | ||
value: this.#value, | ||
content: this.#content | ||
}; | ||
} | ||
} |
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,81 @@ | ||
<template> | ||
<section class="collapsible-container"> | ||
<base-select | ||
v-for="(option) in options" | ||
:id="`${model.name}-${option.key}`" | ||
:key="`${model.name}-${option.key}`" | ||
v-model="model.value" | ||
v-bind="$attrs" | ||
:name="model.name" | ||
:option="option.value" | ||
:unselectable="collapsible" | ||
> | ||
<template #label> | ||
<slot name="label" :option="option"> | ||
{{ option.label }} | ||
</slot> | ||
</template> | ||
<template #extend> | ||
<slot name="content" :option="option" :show="show(option, model)"> | ||
<div v-if="show(option, model)"> | ||
{{ option.content }} | ||
</div> | ||
</slot> | ||
</template> | ||
</base-select> | ||
</section> | ||
</template> | ||
|
||
<script> | ||
import BaseSelect from '../Select'; | ||
import Dataset from './classes/Dataset'; | ||
export default { | ||
components: { | ||
BaseSelect | ||
}, | ||
inheritAttrs: false, | ||
props: { | ||
dataset: { | ||
type: Dataset, | ||
required: true | ||
}, | ||
collapsible: { | ||
type: Boolean, | ||
required: true | ||
} | ||
}, | ||
data () { | ||
return { | ||
name: this.dataset.name, | ||
model: this.dataset.model, | ||
options: this.dataset.options | ||
}; | ||
}, | ||
methods: { | ||
show (option, model) { | ||
return option.value === model.value || process.server; | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style lang="postcss" scoped> | ||
.collapsible-container { | ||
& >>> input { | ||
& + label + section { | ||
height: 0; | ||
overflow: hidden; | ||
} | ||
&:checked + label + section { | ||
height: auto; | ||
} | ||
} | ||
} | ||
</style> |
102 changes: 102 additions & 0 deletions
102
packages/core/CollapsibleContainer/mutation/Accordeon/default.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,102 @@ | ||
<template> | ||
<accordeon | ||
class="design-default" | ||
v-bind="$attrs" | ||
:dataset="dataset" | ||
v-on="$listeners" | ||
> | ||
<template #label="{option}"> | ||
{{ option.label }} | ||
<icon size="small"> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /> | ||
</svg> | ||
</icon> | ||
</template> | ||
<template #content="{show, option}"> | ||
<accordeon-transition-expand> | ||
<section v-show="show"> | ||
<slot name="content" :option="option"> | ||
{{ option.content }} | ||
</slot> | ||
</section> | ||
</accordeon-transition-expand> | ||
</template> | ||
</accordeon> | ||
</template> | ||
|
||
<script> | ||
import Icon from '../../../Icon'; | ||
import AccordeonTransitionExpand from '../../transition/expand'; | ||
import Dataset from '../../classes/Dataset'; | ||
import Model from '../../classes/Model'; | ||
import Option from '../../classes/Option'; | ||
import Accordeon from './index'; | ||
export default { | ||
components: { | ||
Accordeon, | ||
AccordeonTransitionExpand, | ||
Icon | ||
}, | ||
inheritAttrs: false, | ||
props: { | ||
dataset: { | ||
type: Dataset, | ||
default () { | ||
const model = new Model(`default-${Math.random()}`, 'b'); | ||
const options = [ | ||
{ label: 'LABEL A', value: 'a', content: 'CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A CONTENT A ' }, | ||
{ label: 'LABEL B', value: 'b', content: 'CONTENT B' }, | ||
{ label: 'LABEL C', value: 'c', content: 'CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C CONTENT C ' } | ||
].map(({ label, value, content }) => { | ||
return new Option(label, value, content); | ||
}); | ||
return new Dataset(options, model); | ||
} | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style lang="postcss" scoped> | ||
.accordeon.design-default { | ||
display: flex; | ||
flex-wrap: wrap; | ||
& >>> { | ||
& label { | ||
display: block; | ||
width: 100%; | ||
& .icon svg { | ||
width: 48px; | ||
} | ||
} | ||
} | ||
& > section { | ||
/* display: block !important; */ | ||
width: 100%; | ||
} | ||
} | ||
</style> | ||
|
||
<style lang="postcss" type="design" scoped> | ||
.design-default { | ||
& >>> { | ||
& input { | ||
&:focus + label { | ||
box-shadow: 0 0 5px #2196f3; | ||
} | ||
&:checked + label > .icon svg { | ||
transform: rotate(180deg); | ||
} | ||
} | ||
} | ||
} | ||
</style> |
Oops, something went wrong.