|
| 1 | +<!-- |
| 2 | + - SPDX-FileCopyrightText: 2025 Nextcloud contributors |
| 3 | + - SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | +--> |
| 5 | + |
| 6 | +<script setup lang="ts"> |
| 7 | +import { computed } from 'vue' |
| 8 | +
|
| 9 | +interface Props { |
| 10 | + stickyTop?: boolean |
| 11 | + stickyLeft?: boolean |
| 12 | + activateBottomShadow?: boolean |
| 13 | + activateRightShadow?: boolean |
| 14 | +} |
| 15 | +
|
| 16 | +const { |
| 17 | + stickyTop = false, |
| 18 | + stickyLeft = false, |
| 19 | + activateBottomShadow = false, |
| 20 | + activateRightShadow = false, |
| 21 | +} = defineProps<Props>() |
| 22 | +
|
| 23 | +const stickyClass = computed(() => ({ |
| 24 | + container: true, |
| 25 | + 'sticky-top': stickyTop, |
| 26 | + 'sticky-left': stickyLeft, |
| 27 | + 'sticky-bottom-shadow': activateBottomShadow, |
| 28 | + 'sticky-right-shadow': activateRightShadow, |
| 29 | +})) |
| 30 | +</script> |
| 31 | + |
| 32 | +<template> |
| 33 | + <div :class="stickyClass"> |
| 34 | + <slot name="default"> |
| 35 | + <div class="inner"></div> |
| 36 | + </slot> |
| 37 | + </div> |
| 38 | +</template> |
| 39 | + |
| 40 | +<style lang="scss" scoped> |
| 41 | +.container { |
| 42 | + --shadow-height: 10px; |
| 43 | +} |
| 44 | +
|
| 45 | +.inner { |
| 46 | + width: 100%; |
| 47 | + height: 100%; |
| 48 | + background-color: var(--color-main-background); |
| 49 | +} |
| 50 | +
|
| 51 | +.sticky-left { |
| 52 | + position: sticky; |
| 53 | + left: 0; |
| 54 | + z-index: 5; |
| 55 | +} |
| 56 | +
|
| 57 | +.sticky-top { |
| 58 | + --shadow-height: 10px; |
| 59 | + position: sticky; |
| 60 | + top: 0; |
| 61 | + z-index: 4; |
| 62 | + padding-bottom: 0px; |
| 63 | + padding-bottom: var(--shadow-height); |
| 64 | +
|
| 65 | + &::after { |
| 66 | + content: ''; |
| 67 | + position: absolute; |
| 68 | + bottom: 0; |
| 69 | + left: -1px; |
| 70 | + right: 0; |
| 71 | + height: 0; |
| 72 | + background: linear-gradient( |
| 73 | + to bottom, |
| 74 | + rgba(var(--color-box-shadow-rgb), 0.3), |
| 75 | + rgba(var(--color-box-shadow-rgb), 0) |
| 76 | + ); |
| 77 | + transition: |
| 78 | + all var(--animation-slow) linear, |
| 79 | + border 1ms; |
| 80 | + } |
| 81 | +
|
| 82 | + &.sticky-bottom-shadow { |
| 83 | + border-top: 0; |
| 84 | + padding-bottom: var(--shadow-height); |
| 85 | + margin-bottom: 0; |
| 86 | + &::after { |
| 87 | + height: var(--shadow-height); |
| 88 | + } |
| 89 | + } |
| 90 | +} |
| 91 | +
|
| 92 | +.sticky-top.sticky-left { |
| 93 | + z-index: 7; |
| 94 | +} |
| 95 | +
|
| 96 | +/* TODO: Implement sticky right shadow |
| 97 | + An Alternative could be using a grid instead of ::after |
| 98 | + to be able to position multiple shadows in all directions */ |
| 99 | +
|
| 100 | +/* |
| 101 | + padding-right: var(--shadow-height); |
| 102 | +
|
| 103 | + &::after { |
| 104 | + content: ''; |
| 105 | + position: absolute; |
| 106 | + right: 0; |
| 107 | + top: -1px; |
| 108 | + bottom: 0; |
| 109 | + width: 0; |
| 110 | + background: linear-gradient( |
| 111 | + to right, |
| 112 | + rgba(var(--color-box-shadow-rgb), 0.3), |
| 113 | + rgba(var(--color-box-shadow-rgb), 0) |
| 114 | + ); |
| 115 | + transition: |
| 116 | + all var(--animation-slow) linear, |
| 117 | + border 1ms; |
| 118 | + } |
| 119 | +
|
| 120 | + &.sticky-right-shadow { |
| 121 | + border-right: 0; |
| 122 | + padding-right: var(--shadow-height); |
| 123 | + margin-right: 0; |
| 124 | + &::after { |
| 125 | + width: var(--shadow-height); |
| 126 | + } |
| 127 | + } */ |
| 128 | +</style> |
0 commit comments