8000 feat!: remove html props -- use equivalent slots fixes #1930 by VividLemon · Pull Request #2311 · bootstrap-vue-next/bootstrap-vue-next · GitHub
[go: up one dir, main page]

Skip to content

feat!: remove html props -- use equivalent slots fixes #1930 #2311

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

Merged
merged 11 commits into from
Nov 15, 2024

Conversation

VividLemon
Copy link
Member
@VividLemon VividLemon commented Oct 28, 2024

refactor: useTemplateRef

@xvaara Please double check the changes to popover html usage

fixes #2333

@VividLemon VividLemon requested a review from xvaara October 28, 2024 17:40
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@VividLemon VividLemon mentioned this pull request Oct 28, 2024
3 tasks
Copy link
pkg-pr-new bot commented Oct 28, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/bootstrap-vue-next/bootstrap-vue-next@2311
pnpm add https://pkg.pr.new/bootstrap-vue-next/bootstrap-vue-next/@bootstrap-vue-next/nuxt@2311

commit: 5938eb9

@VividLemon VividLemon requested a review from dwgray October 28, 2024 17:47
Copy link
Contributor
@xvaara xvaara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add the slot for option in the group components

@VividLemon VividLemon requested a review from xvaara November 4, 2024 18:10
Copy link
Contributor
@xvaara xvaara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly ok.

<template v-else>
<BFormCheckbox v-for="(item, index) in normalizeOptions" :key="item.self" v-bind="item.props">
<slot
:name="slots[`option(${index})`] ? (`option(${index})` as 'option()') : 'option()'"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of the slots. Was wondering if we could have a slot for value also? option(${item.props.value}) so we could have <template #option(foo)>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, but then we have problem if the value is a number, does the index or the value take precedence...

Me myself, I don't see a case where I would use the index over the value in this. So I'd say use the value as option.foo and create a different for the index, ie option[1]... or something like that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all situations of any component, I am unsure if value is unique

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xvaara In some components value could also be a non-string representation. <option>'s value could be {} if desired

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I toyed with the idea of using the components id but index seemed easier than ids

Copy link
Contributor
@xvaara xvaara Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all situations of any component, I am unsure if value is unique

Does it need to? It's a problem for the end user. I find if I need to figure which index the element is in more bothersome. ie if a add an element to the array, I need to change the v-slot index value also... And if it's a dynamic list that I want to somehow change for some, it will be so hard. Or I'd need to have multiple v-if:s in there.

The more I think about this the more I think that this is wrong way of doing it.

We should have a prop for the optionSlotField (or something like that) which defaults to 'value' and name the slot with that, or index. And pass the whole option to the slot:

        <slot
          :name="
            slots[`option(${option[prop.optionSlotField]})`]
              ? (`option(${option[prop.optionSlotField]})` as 'option()')
              : slots[`option(${index})`]
                ? (`option(${index})` as 'option()')
                : 'option()'
          "
          :option="option"
        >
          {{ option.text }}
        </slot>

then we can have

<template #option={option}>
  <img :src="option.flag"> {{ option.name }} ({{ option.coutrycode }})
</template>
<template #option(us)={option}>
  <img :src="/images/us-flag.svg"> USA! USA! USA!
</template>

Limiting it to text and value kinda limits the functionality too much.

@xvaara In some components value could also be a non-string representation. <option>'s value could be {} if desired

Maybe have prop optionSlotName, default: (option) => option.value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I toyed with the idea of using the components id but index seemed easier than ids

What does the components id have to do with the options v-for?

Copy link
Contributor
@xvaara xvaara Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, do we need to have slots for other than basic? user can just have:

<template #option={option}>
  <template v-if="option.countrycode === 'us'">
    <img :src="/images/us-flag.svg"> USA! USA! USA!
  </template>
  <template v-else>
    <img :src="option.flag"> {{ option.name }} ({{ option.coutrycode }})
  </template>
</template>

Copy link
Member
@dwgray dwgray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general. Agree with @xvaara on wanting the slots for the other similar components.

@VividLemon VividLemon merged commit ce01648 into bootstrap-vue-next:main Nov 15, 2024
4 checks passed
@github-actions github-actions bot mentioned this pull request Nov 15, 2024
xvaara added a commit to xvaara/bootstrap-vue-next that referenced this pull request Nov 19, 2024
* upstream/main: (49 commits)
  fix: rename ref to avoid Vue warnings (Fix bootstrap-vue-next#2337) (bootstrap-vue-next#2353)
  Fix show/hide events and emits (bootstrap-vue-next#1821)
  add some classes and ids for components (bootstrap-vue-next#2344)
  feat: add __usedComponents __usedDirectives property to the BootstrapVueNextResolver function (bootstrap-vue-next#2351)
  doc(BNavbar): Parity pass (bootstrap-vue-next#2347)
  docs: fix lint error (bootstrap-vue-next#2349)
  fix(BNavbarToggle): toggle default slot doesnt have a scoped argument 'expanded' fixes bootstrap-vue-next#2348
  feat!: remove html props -- use equivalent slots fixes bootstrap-vue-next#1930 (bootstrap-vue-next#2311)
  chore: release main (bootstrap-vue-next#2343)
  fix(BDropdown): fix infinite loop on keyboard navigation (bootstrap-vue-next#2342)
  chore: release main (bootstrap-vue-next#2336)
  feat(BPagination): add keyboard shortcuts fixes bootstrap-vue-next#2153
  doc(BNav): Parity pass (bootstrap-vue-next#2332)
  chore: release main (bootstrap-vue-next#2327)
  fix(BTable): dynamic slots not rendering fixes bootstrap-vue-next#2328 (bootstrap-vue-next#2329)
  feat(BTable): make it possible to style custom footers (bootstrap-vue-next#2314)
  chore: release main (bootstrap-vue-next#2323)
  fix(BFormGroup): fix layout problem when label-for is not used (bootstrap-vue-next#2321)
  chore: release main (bootstrap-vue-next#2320)
  feat(BPagination): add small screen support (bootstrap-vue-next#2308)
  ...
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.

Add wrapper-class to BNavForm
3 participants
0