Skip to content
Snippets Groups Projects
Select Git revision
  • f0e36f69ad474e3c327fc3e6863a90b6d3fd18e4
  • main default protected
  • dev
  • sidecar-to-clean-uploaded-files
  • supabase
  • serve-django-static
  • FastAPI
  • v0.1.0
8 results

Main.vue

Blame
  • Main.vue 1.29 KiB
    <script lang="ts" setup>
    import { useDisplay } from 'vuetify'
    
    const { smAndDown, width } = useDisplay()
    export interface Props {
      fluid?: boolean
    }
    const props = withDefaults(defineProps<Props>(), {
      fluid: true
    });
    const maxWidth = ref(1300)
    const minWidth = ref(900)
    const computedMinWidth = computed(() => {
      if (toValue(smAndDown)) return undefined
      if (toValue(width) - 450 > toValue(maxWidth)) return toValue(maxWidth)
      if (toValue(width) - 300 > toValue(minWidth)) return toValue(minWidth)
      return undefined
    })
    
    
    const scrollThreshold = ref(200)
    const density = ref<'compact' | 'prominent'>("prominent")
    
    function onScroll() {
      if (window.scrollY > scrollThreshold.value) {
        density.value = "compact"
      }
      else { density.value = "prominent" }
    }
    
    </script>
    
    <template>
      <v-card>
        <VApp>
          <Navbar :density="density" />
          <v-main style="min-height: 300px">
    
            <v-container v-scroll="onScroll" :fluid="props.fluid">
              <v-row justify="center">
                <v-col cols="auto">
                  <v-card flat color="transparent" :min-width="computedMinWidth"
                    :max-width="props.fluid ? undefined : maxWidth">
                    <slot />
                  </v-card>
                </v-col>
              </v-row>
            </v-container>
          </v-main>
        </VApp>
      </v-card>
    </template>