Vue-js-modal: Top-right slot position

Created on 14 Jun 2017  路  8Comments  路  Source: euvl/vue-js-modal

Currently the top-right slot doesn't get any CSS applied to it. It'd be nice by default if it was positioned at the top right of the modal instead of the top right of the page.

screen shot 2017-06-14 at 4 58 59 pm

help wanted

Most helpful comment

I must be missing something.. it seems the top-right slot is not at the right dom level. It should be relative to the modal window not the modal overlay?

If it's relative to the overlay then I don't know how we can tie it to the top-right corner of the modal without using some javascript

I think the "default top right" for most use-cases is having it attached to the window.. not the absolute top right of the page as it is now..

could you please comment on what I might be missing here @euvl ? I want the X button to be attached to the top right corner of the modal window.. how do I achieve this?

All 8 comments

Yes, because everyone wants a different thing to be there, so you will have to implement your close button yourself.

I think the default is already good enough.

The corresponding class name is .v--modal-top-right. As the simplest solution, you can overwrite position in your code like this:

.v--modal-top-right {
    right: where_i_want_it_to_be px !important;
    top: where_i_want_it_to_be px !important;
}

What I was thinking instead is to just add another slot called "close button" that way for people that want to add a close button it's already positioned correctly in relations to the box. You shouldn't really have to override CSS to add an expected feature for a modal.

I will be happy to review a PR

I must be missing something.. it seems the top-right slot is not at the right dom level. It should be relative to the modal window not the modal overlay?

If it's relative to the overlay then I don't know how we can tie it to the top-right corner of the modal without using some javascript

I think the "default top right" for most use-cases is having it attached to the window.. not the absolute top right of the page as it is now..

could you please comment on what I might be missing here @euvl ? I want the X button to be attached to the top right corner of the modal window.. how do I achieve this?

Hey @vesper8, sure i can comment:

I must be missing something.. it seems the top-right slot is not at the right dom level. It should be relative to the modal window not the modal overlay?

Nope, I think that it is in the right spot. Positioning elements relatively to modal is easy (you can use css relative parent/absolute child}.

If it's relative to the overlay then I don't know how we can tie it to the top-right corner of the modal without using some javascript

See no problem in here. Writing a couple of lines of javascript ( < 5 ) should not be a problem.

I think the "default top right" for most use-cases is having it attached to the window.. not the absolute top right of the page as it is now..

Which use-cases though? If you will look at facebook and twitter, they have the same layout (my projects also required same positioning).

I want the X button to be attached to the top right corner of the modal window.. how do I achieve this?

Position <button/> absolutely to right:-50px, top:-50px and set it's size to 50x50, make parent relative.

Thanks 馃憤

the solution to fit the close button to modal window is:

<modal
        adaptive
        :name="modalSettings.name"
        :width="modalSettings.width"
        :height="modalSettings.height"
        :scrollable="modalSettings.scrollable"
      >
        <div class="quotation-container">  // this is the important a div container to slot and  content
          <div slot="top-right">
            <button @click="$modal.hide('quotation-modal')">
              x
            </button>
          </div>
          <the-quotation :ad-data="adData" />
        </div>
 </modal>

and this is the result:
captura de pantalla 2018-01-29 a la s 16 17 26

greetings!

@felipeegasneris you don't need the reference to slot in this case.

the solution to fit the close button to modal window is:

<modal
        adaptive
        :name="modalSettings.name"
        :width="modalSettings.width"
        :height="modalSettings.height"
        :scrollable="modalSettings.scrollable"
      >
        <div class="quotation-container">  // this is the important a div container to slot and  content
          <div slot="top-right">
            <button @click="$modal.hide('quotation-modal')">
              x
            </button>
          </div>
          <the-quotation :ad-data="adData" />
        </div>
 </modal>

and this is the result:
captura de pantalla 2018-01-29 a la s 16 17 26

greetings!

Just wrap the button within a '\' works, but the position is top-left, how to make it top-right as defined in the code?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

a3020 picture a3020  路  5Comments

ishetnogferre picture ishetnogferre  路  4Comments

vesper8 picture vesper8  路  3Comments

whaoran picture whaoran  路  3Comments

chris-rowe picture chris-rowe  路  4Comments