<template>
  <div :class="containerClass">
    <slot />
  </div>
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'

@Component({
  name: 'stack-layout'
})
export default class StackLayout extends Vue {
  @Prop({ default: false }) readonly spaced!: boolean

  get containerClass () {
    return {
      'is-stack': true,
      'has-top-margin': true,
      'has-space-between': this.spaced !== false
    }
  }
}
</script>

<style lang="scss" scoped>
.is-stack {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.has-top-margin {
  margin-top: 0.5em;
}

.has-space-between {
  justify-content: space-between;
}

.is-stack > *:not(:first-child) {
  margin-left: 1em;
}
</style>
