diff --git a/.storybook/preview-head.html b/.storybook/preview-head.html index 78d5381..9e7b85a 100644 --- a/.storybook/preview-head.html +++ b/.storybook/preview-head.html @@ -11,4 +11,15 @@ .padding { /* padding: 10px; */ } +.card1 { + position: absolute; + width: 100%; + height: calc(100% - 10px); +} + +.deck { + width: 100%; + height: 100%; + perspective: 1300px; +} \ No newline at end of file diff --git a/src/CardsDeck.stories.js b/src/CardsDeck.stories.js new file mode 100644 index 0000000..b6abd1c --- /dev/null +++ b/src/CardsDeck.stories.js @@ -0,0 +1,54 @@ +import CardsDeck from './CardsDeck.vue' +import FlipCard from './FlipCard.vue' +import { action } from '@storybook/addon-actions' + +export default { + title: 'Deck/Cards Deck', + component: { CardsDeck, FlipCard }, +}; + +const flip = action("flip") + +const Template = (args) => ({ + components: { CardsDeck, FlipCard }, + methods: { + flip(data) { flip(data); data.card.flipped = !data.card.flipped }, + computeStyle(card) { + return `transform: translateX(${card.x}px)` + + ` translateY(${card.y}px)` + + ` translateZ(${card.z}px)` + + ` rotateX(${card.x}deg)` + + ` rotateY(${card.y}deg)` + + ` rotateZ(${card.z}deg);` + + `transition: .25s linear;`+ + `z-index: ${10 - card.index}` + } + }, + setup() { + const cardsToShow = [ + { id: "0", index: 0, px: 0, py: 0, rx: 0, ry: 0, rz: 0, flipped: false }, + { id: "1", index: 1, px: 0, py: 0, rx: 0, ry: 0, rz: 0, flipped: false }, + { id: "2", index: 2, px: 0, py: 0, rx: 0, ry: 0, rz: 0, flipped: false }, + ] + return { args, cardsToShow }; + }, + template: ` +