Skip to content

feat(PageSection): give links and features to slots #4810

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

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

Conversation

Barbapapazes
Copy link
Contributor

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Hello πŸ‘‹,

When creating a page with UI layout components, I often start simple like:

<template>
  <UPageSection
    orientation="horizontal"
    title="Engage Your Audience"
    description="Share a single QR code to give your audience seamless access to everything they need - your profile, interactive features, live Q&A, and instant feedback."
    :links="[
      {
        label: 'Create Your Own',
        href: register().url,
      },
      {
        label: 'The Presentation Card',
        href: 'https://docs.inalia.app/presentation',
        target: '_blank',
        color: 'neutral',
        variant: 'ghost',
      },
    ]"
  />
</template>

And then, I want to add animations to the links using Motion. So I have to refactor the component and to extract the links to a separate variable:

<script setup>
const links = [
  {
    label: 'Create Your Own',
    href: register().url,
  },
  {
    label: 'The Presentation Card',
    href: 'https://docs.inalia.app/presentation',
    target: '_blank',
    color: 'neutral',
    variant: 'ghost',
  },
]
</script>

<template>
  <UPageSection
    orientation="horizontal"
    title="Engage Your Audience"
    description="Share a single QR code to give your audience seamless access to everything they need - your profile, interactive features, live Q&A, and instant feedback."
  >
    <template #links>
      <Motion v-for="link in links" :key="link.label">
        <!-- ... -->
      </Motion>
    </template>
  </UPageSection>
</template>

This is annoying when building a page with multiple sections like this cause the script will be polluted with repetitive code that was, at first, collocated with the corresponding section.

By passing the links to the UPageSection component, we can keep the script clean and the template readable as follows:

<template>
  <UPageSection
    orientation="horizontal"
    title="Engage Your Audience"
    description="Share a single QR code to give your audience seamless access to everything they need - your profile, interactive features, live Q&A, and instant feedback."
    :links="[
      {
        label: 'Create Your Own',
        href: register().url,
      },
      {
        label: 'The Presentation Card',
        href: 'https://docs.inalia.app/presentation',
        target: '_blank',
        color: 'neutral',
        variant: 'ghost',
      },
    ]"
  >
    <template #links={ links }>
      <Motion v-for="link in links" :key="link.label">
        <!-- ... -->
      </Motion>
    </template>
  </UPageSection>
</template>

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant