Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VTimeline): alignment consistency #20876

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

J-Sek
Copy link
Contributor

@J-Sek J-Sek commented Jan 17, 2025

Description

The alignment of timeline items is not consistent across various usage types:

  • when using default alignment
  • when using side on VTimeline
  • when using side on VTimelineItems

I aimed to keep all items (body and opposite) close to the center line. It then behaves the same as in v2.

Users that wish to restore previous behavior can do it with [align|justify]-self: stretch !important. For example:

/* justify-self for vertical / align-self for horizontal */
.v-timeline-item__body { justify-self: stretch !important; }
.v-timeline-item__opposite { justify-self: stretch !important; } 

Markup:

<template>
  <v-toolbar theme="dark">
    <v-btn-toggle class="my-2 mx-auto" v-model="direction">
      <v-btn value="vertical">vertical</v-btn>
      <v-btn value="horizontal">horizontal</v-btn>
    </v-btn-toggle>
  </v-toolbar>
  <v-app theme="dark">
    <v-container>
      <h4 class="text-overline text-center bg-primary">Default</h4>
      <v-timeline :direction="direction">
        <v-timeline-item v-for="(item, i) in items" :key="i" size="x-small">
          <div class="d-flex ga-2">
            <v-avatar icon="mdi-check" />
            <div class="align-self-center">
              <h4>Item {{ i + 1 }}</h4>
              <div v-for="s in i" :key="s" class="text-body-2">Subtitle</div>
            </div>
          </div>
          <template #opposite>
            <div class="d-flex ga-2">
              <v-avatar icon="mdi-clock" />
              <div class="align-self-center">
                <h4>Opposite</h4>
                <div v-for="s in (3 - i)" :key="s" class="text-body-2">Subtitle</div>
              </div>
            </div>
          </template>
        </v-timeline-item>
      </v-timeline>
    </v-container>

    <v-container>
      <h4 class="text-overline text-center bg-primary">Side on items</h4>
      <v-timeline :direction="direction">
        <v-timeline-item
          v-for="(item, i) in items"
          :key="i"
          :side="item.side"
          size="x-small"
        >
          <div class="d-flex ga-2">
            <v-avatar icon="mdi-check" />
            <div class="align-self-center">
              <h4>Item {{ i + 1 }}</h4>
              <div v-for="s in i" :key="s" class="text-body-2">Subtitle</div>
            </div>
          </div>
          <template #opposite>
            <div class="d-flex ga-2">
              <v-avatar icon="mdi-clock" />
              <div class="align-self-center">
                <h4>Opposite</h4>
                <div v-for="s in (3 - i)" :key="s" class="text-body-2">Subtitle</div>
              </div>
            </div>
          </template>
        </v-timeline-item>
      </v-timeline>
    </v-container>

    <v-container>
      <h4 class="text-overline text-center bg-primary">timeline side=start</h4>
      <v-timeline :direction="direction" side="start">
        <v-timeline-item v-for="(item, i) in items" :key="i" size="x-small">
          <div class="d-flex ga-2">
            <v-avatar icon="mdi-check" />
            <div class="align-self-center">
              <h4>Item {{ i + 1 }}</h4>
              <div v-for="s in i" :key="s" class="text-body-2">Subtitle</div>
            </div>
          </div>
          <template #opposite>
            <div class="d-flex ga-2">
              <v-avatar icon="mdi-clock" />
              <div class="align-self-center">
                <h4>Opposite</h4>
                <div v-for="s in (3 - i)" :key="s" class="text-body-2">Subtitle</div>
              </div>
            </div>
          </template>
        </v-timeline-item>
      </v-timeline>
    </v-container>

    <v-container>
      <h4 class="text-overline text-center bg-primary">timeline side=end</h4>
      <v-timeline :direction="direction" side="end">
        <v-timeline-item v-for="(item, i) in items" :key="i" size="x-small">
          <div class="d-flex ga-2">
            <v-avatar icon="mdi-check" />
            <div class="align-self-center">
              <h4>Item {{ i + 1 }}</h4>
              <div v-for="s in i" :key="s" class="text-body-2">Subtitle</div>
            </div>
          </div>
          <template #opposite>
            <div class="d-flex ga-2">
              <v-avatar icon="mdi-clock" />
              <div class="align-self-center">
                <h4>Opposite</h4>
                <div v-for="s in (3 - i)" :key="s" class="text-body-2">Subtitle</div>
              </div>
            </div>
          </template>
        </v-timeline-item>
      </v-timeline>
    </v-container>
    <v-container>
      <h4 class="text-overline text-center bg-primary">
        Side on timeline overrides side on items (start)
      </h4>
      <v-timeline :direction="direction" side="start">
        <v-timeline-item
          v-for="(item, i) in items"
          :key="i"
          :side="item.side"
          size="x-small"
        >
          <div class="d-flex ga-2">
            <v-avatar icon="mdi-check" />
            <div class="align-self-center">
              <h4>Item {{ i + 1 }}</h4>
              <div v-for="s in i" :key="s" class="text-body-2">Subtitle</div>
            </div>
          </div>
          <template #opposite>
            <div class="d-flex ga-2">
              <v-avatar icon="mdi-clock" />
              <div class="align-self-center">
                <h4>Opposite</h4>
                <div v-for="s in (3 - i)" :key="s" class="text-body-2">Subtitle</div>
              </div>
            </div>
          </template>
        </v-timeline-item>
      </v-timeline>
    </v-container>

    <v-container>
      <h4 class="text-overline text-center bg-primary">
        Side on timeline overrides side on items (end)
      </h4>
      <v-timeline :direction="direction" side="end">
        <v-timeline-item
          v-for="(item, i) in items"
          :key="i"
          :side="item.side"
          size="x-small"
        >
          <div class="d-flex ga-2">
            <v-avatar icon="mdi-check" />
            <div class="align-self-center">
              <h4>Item {{ i + 1 }}</h4>
              <div v-for="s in i" :key="s" class="text-body-2">Subtitle</div>
            </div>
          </div>
          <template #opposite>
            <div class="d-flex ga-2">
              <v-avatar icon="mdi-clock" />
              <div class="align-self-center">
                <h4>Opposite</h4>
                <div v-for="s in (3 - i)" :key="s" class="text-body-2">Subtitle</div>
              </div>
            </div>
          </template>
        </v-timeline-item>
      </v-timeline>
    </v-container>
  </v-app>
</template>

<script setup lang="ts">
  import { ref } from 'vue'
  const items = [
    { side: 'start' },
    { side: 'start' },
    { side: 'end' },
    { side: 'end' },
  ]
  const direction = ref<'horizontal' | 'vertical'>('vertical')
</script>

<style>
  .v-application__wrap {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
  .v-timeline-item__body {
    border: 1px dashed teal !important;
    .d-flex.ga-2 {
      border: 1px dashed orange !important;
    }
  }
  .v-timeline-item__opposite {
    border: 1px dashed lime !important;
    .d-flex.ga-2 {
      border: 1px dashed orange !important;
    }
  }
</style>

@J-Sek J-Sek added T: bug Functionality that does not work as intended/expected C: VTimeline VTimeline labels Jan 17, 2025
@J-Sek J-Sek self-assigned this Jan 17, 2025
@J-Sek J-Sek requested a review from KaelWD January 17, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VTimeline VTimeline T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant