mengxiong10 / vue-datepicker-next

A datepicker / datetimepicker component for Vue3
https://mengxiong10.github.io/vue-datepicker-next/
MIT License
148 stars 33 forks source link

feat: add "is-start" and "is-end" to the first and last dates respectively #28

Open MrMohamedAbdallah opened 2 years ago

MrMohamedAbdallah commented 2 years ago

That feature allow users to style the first and last cell in the dates range and single date.

For example, adding a border radius to the first and last ones.

image

mengxiong10 commented 2 years ago

You can use getClasses prop.

<date-picker :get-classes="getClasses" />
{
  methods: {
    getClasses(cellDate, innerValue) {
        const length = innerValue.length
        const classes = []
        if (length) {
            if (cellDate.getTime() == innerValue[0].getTime()) classes.push('is-start');
            if (cellDate.getTime() == innerValue[length - 1].getTime()) classes.push('is-end');
        }
        return classes
     }
  }
}
MrMohamedAbdallah commented 2 years ago

Yeah, but that PR is to make it a feature in the library itself. It will make it easier for styling, no need to add the getClasses prop in each instance for such a simple classes.

MrMohamedAbdallah commented 1 year ago

@mengxiong10 will that be merged soon?