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

[FEATURE] select with icons or dropdown that changes handler #74

Closed
darkylmnx opened this issue May 25, 2017 · 10 comments
Closed

[FEATURE] select with icons or dropdown that changes handler #74

darkylmnx opened this issue May 25, 2017 · 10 comments

Comments

@darkylmnx
Copy link

darkylmnx commented May 25, 2017

i came accross a use case where neither the select component nor the dropdown component solves it.

If you are on facebook, you probably came accross the following image
image

It gives you the ability to change the privacy of a post but also explains them.

Currently, a dropdown would be the way to go (as there is html inside the options), but here's the problem now, when you make your choice, the dropdown handler / trigger does not change value, therefore the user doesn't have feedback on what he choosed.

In this sens, the behaviour seems more like a select, but because of the html issue (icons and stuff) i can't use the select component.

Api proposal

Could you add on the drop down component a prop replace which would be a boolean, and if set, would replace & show the selected dropdown option instead of the handler / trigger.

@rafaberaldo
Copy link
Member

rafaberaldo commented May 25, 2017

Well, I left the trigger opened for that purpose. You can change the trigger based on the v-model of the dropdown.

@darkylmnx
Copy link
Author

well i tried something like
image

and it doesn't seem to work, and btw, why don't you use a slot for html in option ? and use a label attr ? It makes code not really readable

@rafaberaldo
Copy link
Member

rafaberaldo commented May 26, 2017

Could you copy paste your code so I can test?

What you mean by html in option? Give more detailed stuff so I can help you better! Also are you using the last Buefy version? You didn't use the issue template...

@darkylmnx
Copy link
Author

darkylmnx commented May 26, 2017

sorry, i didn't as it wasn't an issue but a feature request.

i'm using latest vue version and latest buefy version

This is what i'd like to acheive :

    <b-dropdown v-model="is_public">
        <button class="button is-flat" type="button" slot="trigger">
            <b-icon icon="globe" v-if="is_public"></b-icon>
            <b-icon icon="users" v-if="!is_public"></b-icon>
            <span v-if="is_public">{{ $t('hit_form.public_title') }}</span>
            <span v-if="!is_public">{{ $t('hit_form.private_title') }}</span>
        </button>

        <b-dropdown-option class="columns" :value="true">
          <div class="column">
            <b-icon icon="globe"></b-icon>
          </div>
          <div class="column">
            <h3>{{ $t('hit_form.public_title') }}</h3>
            <p>{{ $t('hit_form.public_text') }}</p>
          </div>
        </b-dropdown-option>
        <b-dropdown-option class="columns" :value="false">
          <div class="column">
            <b-icon icon="users"></b-icon>
          </div>
          <div class="column">
            <h3>{{ $t('hit_form.private_title') }}</h3>
            <p>{{ $t('hit_form.private_text') }}</p>
          </div>
        </b-dropdown-option>
      </b-dropdown>

but because you do'nt allow html in your b-dropdown-option, i can't do that. Using your label prob will make the code messy, as there's lot of html here + the translation function

@rafaberaldo
Copy link
Member

rafaberaldo commented May 26, 2017

OK, I've understood now what you want. I didn't allow html in slot for security reasons, but I'll figure it out.

Edit: But that is not exactly your original issue right? I'll take a look at that afterwards.

@darkylmnx
Copy link
Author

darkylmnx commented May 26, 2017 via email

@rafaberaldo
Copy link
Member

rafaberaldo commented May 26, 2017

Like receiving the data of the dropdown from a user-generated content.

Actually that doesn't make sense, LMFT.

@rafaberaldo
Copy link
Member

rafaberaldo commented May 26, 2017

Available in next patch:

dropdown

Code is basically the same you provided:

<b-dropdown v-model="isPublic">
    <button class="button is-primary" type="button" slot="trigger">
        <template v-if="isPublic">
            <b-icon icon="public"></b-icon>
            <span>Public</span>
        </template>
        <template v-else>
            <b-icon icon="people"></b-icon>
            <span>Friends</span>
        </template>
        <b-icon icon="arrow_drop_down"></b-icon>
    </button>

    <b-dropdown-option :value="true">
        <div class="media">
            <b-icon class="media-left" icon="public"></b-icon>
            <div class="media-content">
                <h3>Public</h3>
                <small>Everyone can see</small>
            </div>
        </div>
    </b-dropdown-option>
    <b-dropdown-option :value="false">
        <div class="media">
            <b-icon class="media-left" icon="people"></b-icon>
            <div class="media-content">
                <h3>Friends</h3>
                <small>Only friends can see</small>
            </div>
        </div>
    </b-dropdown-option>
</b-dropdown>

@darkylmnx
Copy link
Author

that's nice :)

@smokiebacon
Copy link

smokiebacon commented Dec 4, 2019

Great, what I was looking for. However, I can't seem to figure out how to make all the underlying text to show up in a snuggly box. Overflowing texts gets cut off, like so.

Screen Shot 2019-12-03 at 4 23 15 PM

In mobile:
Screen Shot 2019-12-03 at 4 23 31 PM

Any way to make overflowing text get contained?

kikuomax added a commit to kikuomax/buefy that referenced this issue Sep 18, 2023
* test(lib): update Clockpicker spec

- Updates the unit tests (spec) of `Clockpicker` so that they can work
  with `@vue/test-utils` V2:
    - Awaits `wrapper.setProps` to make sure the subsequent tests verify
      the updated state.
    - Replaces direct data modification with `wrapper.setData` and
      awaits it to make sure the subsequent tests verify the updated
      state.
    - Replaces `wrapper.name()` with `wrapper.vm.$options.name` because
      `wrapper.name` no longer exists in `@vue/test-utils` V2.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Replaces `propsData` option for `shallowMount` with `props`
      because `propsData` might be deprecated in the future.
    - Refreshes the snapshot. Prevents `b-dropdown` from becoming a stub
      to reproduce a snapshot closer to the legacy one, because default
      slots in a stub are no longer rendered on `@vue/test-utils` V2. I
      did not find any problems in the updated snapshot.

issue ntohq#1

* test(lib): update ClockpickerFace spec

- Updates the unit tests of `ClockpickerFace` so that they can work with
  `@vue/test-utils` V2:
    - Awaits `wrapper.setProps` to make sure the subsequent tests verify
      the updated state.
    - Replaces direct data modification with `wrapper.setData` and
      awaits it to make sure the subsequent tests verify the updated
      state.
    - Replaces `wrapper.name()` with `wrapper.vm.$options.name` because
      `wrapper.name` no longer exists in `@vue/test-utils` V2.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Replaces `propsData` option for `shallowMount` with `props`
      because `propsData` might be deprecated in the future.
    - Refreshes the snapshot. I did not find any problems in the updated
      snapshot.

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

No branches or pull requests

3 participants