Skip to content

Commit

Permalink
feat: FlipCard margin
Browse files Browse the repository at this point in the history
  • Loading branch information
akdasa committed Mar 2, 2023
1 parent 8e6f917 commit d1cf3a3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@akdasa-studios/shlokas-uikit",
"version": "0.0.12",
"version": "0.0.14",
"files": [
"dist"
],
Expand Down
7 changes: 4 additions & 3 deletions src/FlipCard.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const Template = (args) => ({
return { args };
},
template: `
<div style="width:200px;height:400px">
<FlipCard v-bind="args" @click="flip" class="card">
<div style="width:200px;height:400px;background-color:gray">
<FlipCard v-bind="args" @click="flip">
<template #front><div style="background-color:lightblue;height:100%">FRONT</div></template>
<template #back><div style="background-color:lightgreen;height:100%">BACK</div></template>
</FlipCard>
Expand All @@ -32,5 +32,6 @@ const Template = (args) => ({

export const Default = Template.bind({});
Default.args = {
flipped: false
flipped: false,
margin: '10px'
};
23 changes: 15 additions & 8 deletions src/FlipCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,38 @@


<script lang="ts" setup>
import { computed, defineProps, toRefs, defineEmits } from 'vue'
import { computed, defineProps, toRefs, ref } from 'vue'
/* -------------------------------------------------------------------------- */
/* Interface */
/* -------------------------------------------------------------------------- */
const props = defineProps<{
flipped: boolean
}>()
export interface Props {
flipped: boolean,
margin?: string
}
const props = withDefaults(defineProps<Props>(), {
margin: '0px'
})
/* -------------------------------------------------------------------------- */
/* State */
/* -------------------------------------------------------------------------- */
const { flipped } = toRefs(props)
const { flipped, margin } = toRefs(props)
const flipAngle = computed(() => flipped.value ? 180 : 0)
</script>

<style scoped lang="scss">
$flipAngleFront: calc(v-bind(flipAngle) * 1deg);
$flipAngleBack: calc(v-bind(flipAngle) * 1deg - 180deg);
$flipAngleBack: calc(v-bind(flipAngle) * 1deg - 180deg);
$margin: v-bind(margin);
.card {
width: 100%;
height: 100%;
width: calc(100% - ($margin * 2));
height: calc(100% - ($margin * 2));
translate: $margin $margin;
perspective: 900px;
.face {
Expand Down

0 comments on commit d1cf3a3

Please sign in to comment.