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

Hide year navigation from datepicker #219

Closed
antoniogiroz opened this issue Dec 29, 2018 · 13 comments
Closed

Hide year navigation from datepicker #219

antoniogiroz opened this issue Dec 29, 2018 · 13 comments
Milestone

Comments

@antoniogiroz
Copy link

Hi!
How can I hide the year navigation arrows from datepicker, but not in year and moth pickers?

Remove from here:

image

But not from here:

image

image

Thanks!

@mengxiong10
Copy link
Owner

You can use the panel-change prop to do it.

<date-picker @panel-change="handlePanelChange" v-model="value" lang="en" ></date-picker>
handlePanelChange (panel, oldPanel) {
  if (panel === 'DATE') {
    document.querySelector('.mx-icon-last-year').style.display = 'none'
    document.querySelector('.mx-icon-next-year').style.display = 'none'
  } else if (panel !== 'TIME') {
    document.querySelector('.mx-icon-last-year').style.display = 'block'
    document.querySelector('.mx-icon-next-year').style.display = 'block'
  }
}

@antoniogiroz
Copy link
Author

This solution doesn't work if there are various datepicker elements.

@doctorsirius
Copy link

doctorsirius commented Dec 29, 2018

Would be easier, even for CSS styling, if the component would add an attribute or class to the parent element mx-calendar indicating the different modes; date, year, month, time.

@mengxiong10
Copy link
Owner

Yes, add class will be better.
I'll do it later.
@algil Now it can work by adding different ids.

<date-picker id="datepicker" @panel-change="handlePanelChange" v-model="value" lang="en" ></date-picker>
handlePanelChange (panel, oldPanel) {
  const datepicker = document.getElementById('datepicker');
  if (panel === 'DATE') {
    datepicker.querySelector('.mx-icon-last-year').style.display = 'none'
    datepicker.querySelector('.mx-icon-next-year').style.display = 'none'
  } else if (panel !== 'TIME') {
    datepicker.querySelector('.mx-icon-last-year').style.display = 'block'
    datepicker.querySelector('.mx-icon-next-year').style.display = 'block'
  }
}

@doctorsirius
Copy link

Any hope we can see mode classes anytime soon? Btw, another good thing for styling would be allow to specify a class to the confirmation button, so you can take approach of your own button classes (very common; like btn-primary, and so) instead of repeat styles.

@mengxiong10
Copy link
Owner

v2.7.0
add the class .mx-calendar-panel-date, .mx-calendar-panel-year ...
@algil
You can use a css to do this.

.mx-calendar-panel-date .mx-icon-last-year,
.mx-calendar-panel-date .mx-icon-next-year {
  display: none;
}

@mengxiong10
Copy link
Owner

@doctorsirius
You can use the footer slot.

<date-picker>
   <template slot="footer" slot-scope="{ confirm }>
      <button type="button"
            class="btn-primary"
            @click="confirm">OK</button>
  </template>
</date-picker>

@doctorsirius
Copy link

Cool! Thanks!

@mhdyahiya
Copy link

Thanks, @mengxiong10

@mengxiong10 mengxiong10 added this to the 3.0.0 milestone Sep 12, 2019
@ghost
Copy link

ghost commented Jan 10, 2020

image
I want to install like this for the red circle - change it to the previous month and the next month, thanks to everyone for help

@mengxiong10
Copy link
Owner

@FPTSonPM3
use css.

.mx-calendar-panel-year .mx-icon-double-right::before,
.mx-calendar-panel-year .mx-icon-double-left::before {
  display: none;
}

@ghost
Copy link

ghost commented Jan 13, 2020

I'm trying css for the header, is there any way to customize the number for the switch to the previous month, the switch to the next month?

@yakovcohen4
Copy link

I'm trying css for the header, is there any way to customize the number for the switch to the previous month, the switch to the next month?

@ghost
Did you manage to turn the sides of the arrows?
And if yes, how ?

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

No branches or pull requests

5 participants