<template>
  <div
    class="bms-side-panel"
    :class="{
      'bms-side-panel--left': align === 'left',
      'bms-side-panel--right': align === 'right',
      'bms-side-panel--collapsed': collapsed,
    }"
    :style="{ '--bms-side-panel-width': width }"
  >
    <slot />
  </div>
</template>

<script setup lang="ts">
withDefaults(
  defineProps<{
    align: 'left' | 'right';
    collapsed?: boolean;
    width?: string;
  }>(),
  { collapsed: false, width: '300px' },
);
</script>

<style lang="scss" scoped>
.bms-side-panel {
  background: var(--bms-white);
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;

  &--left {
    border-right: 1px solid var(--bms-border-color);
    height: 100%;
    width: var(--bms-side-panel-width);
    min-width: 0;
    opacity: 1;
    transition:
      width 500ms,
      opacity 500ms;

    &.bms-side-panel--collapsed {
      width: 0;
      opacity: 0;
    }
  }

  &--right {
    border-left: 1px solid var(--bms-border-color);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;

    > * {
      flex: 1 1 auto;
      min-height: 0;
    }
  }
}
</style>
