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

Add slot for clear calendar icon #75

Merged
merged 4 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/guide/Props/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
| autofocus | String | | Sets html `autofocus` attribute on input |
| bootstrap-styling | Boolean | false | Use bootstrap v4 styling classes. |
| calendar-button | Boolean | false | Show an icon that that can be clicked |
| calendar-button-icon | String | | Use icon for button (ex: fa fa-calendar) |
| calendar-button-icon-content | String | | Use for material-icons (ex: event) |
| calendar-button-icon | String | | (Deprecated for slot) Use icon for button (ex: fa fa-calendar) |
| calendar-button-icon-content | String | | (Deprecated for slot) Use for material-icons (ex: event) |
| calendar-class | String|Object | | CSS class applied to the calendar el |
| clear-button | Boolean | false | Show an icon for clearing the date |
| clear-button-icon | String | | Use icon for button (ex: fa fa-times) |
| clear-button-icon | String | | (Deprecated for slot) Use icon for button (ex: fa fa-times) |
| day-cell-content | Function | | Use to render custom content in day cell |
| disabled | Boolean | false | If `true`, disable Datepicker on screen |
| disabled-dates | Object | | See below for configuration |
Expand Down
54 changes: 41 additions & 13 deletions docs/guide/Slots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ to show some custom text:

```html
<DatePicker :bootstrap-styling="true">
<div slot="beforeCalendarHeaderDay" class="calendar-header">
Choose a Date
</div>
<template #beforeCalendarHeaderDay>
<div class="calendar-header">Choose a Date</div>
</template>
</DatePicker>
```

Expand All @@ -26,9 +26,11 @@ to show some custom text:

```html
<DatePicker :bootstrap-styling="true">
<div slot="calendarFooterMonth">
<button>Select all Months</button>
</div>
<template #calendarFooterMonth>
<div>
<button>Select all Months</button>
</div>
</template>
</DatePicker>
```

Expand All @@ -39,7 +41,9 @@ To implement some custom styling (for instance to add an animated placeholder) o

```html
<DatePicker>
<span slot="afterDateInput" class="animated-placeholder">Choose a Date</span>
<template #afterDateInput>
<span class="animated-placeholder">Choose a Date</span>
</template>
</DatePicker>
```

Expand All @@ -50,9 +54,9 @@ allows you to do that:

```html
<DatePicker>
<span slot="beforeDateInput">
<template #beforeDateInput>
<CustomIcon />
</span>
</template>
</DatePicker>
```

Expand All @@ -62,11 +66,35 @@ To provide custom content for buttons that rotate intervals in calendar header `

```html
<DatePicker>
<span slot="prevIntervalBtn">
<template #prevIntervalBtn>
<CustomIcon />
</span>
<span slot="nextIntervalBtn">
</template>
<template #nextIntervalBtn>
<CustomIcon />
</span>
</template>
</DatePicker>
```

## calendarBtn

To provide custom content for the calendar button, the `calendarBtn` slot may be used:

```html
<DatePicker :calendar-button="true">
<template #calendarBtn>
<CustomIcon />
</template>
</DatePicker>
```

## clearBtn

To provide custom content for the clear button, the `clearBtn` slot may be used:

```html
<DatePicker :clear-button="true">
<template #clearBtn>
<CustomIcon />
</template>
</DatePicker>
```
10 changes: 5 additions & 5 deletions example/Demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export default {
</script>

<style>
@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
@import url('https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css');

body {
font-family: 'Helvetica Neue Light', Helvetica, sans-serif;
Expand All @@ -511,10 +511,6 @@ select {
width: 100%;
}

select {
height: 2.5em;
}

.example {
background: #f2f2f2;
border: 1px solid #ddd;
Expand Down Expand Up @@ -543,6 +539,10 @@ h5 {
padding: 0;
}

h3 {
margin-top: 20px;
}

.form-group {
margin-bottom: 1em;
}
Expand Down
18 changes: 11 additions & 7 deletions src/components/DateInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
@click="toggleCalendar"
>
<span :class="{ 'input-group-text': bootstrapStyling }">
<i :class="calendarButtonIcon">
{{ calendarButtonIconContent }}
<span v-if="!calendarButtonIcon">&hellip;</span>
</i>
<slot name="calendarBtn">
<i :class="calendarButtonIcon">
{{ calendarButtonIconContent }}
<span v-if="!calendarButtonIcon">&hellip;</span>
</i>
</slot>
</span>
</span>
<!-- Input -->
Expand Down Expand Up @@ -49,9 +51,11 @@
@click="clearDate()"
>
<span :class="{ 'input-group-text': bootstrapStyling }">
<i :class="clearButtonIcon">
<span v-if="!clearButtonIcon">&times;</span>
</i>
<slot name="clearBtn">
<i :class="clearButtonIcon">
<span v-if="!clearButtonIcon">&times;</span>
</i>
</slot>
</span>
</span>
<slot name="afterDateInput" />
Expand Down
2 changes: 2 additions & 0 deletions src/components/Datepicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
>
<slot slot="beforeDateInput" name="beforeDateInput" />
<slot slot="afterDateInput" name="afterDateInput" />
<slot slot="clearBtn" name="clearBtn" />
<slot slot="calendarBtn" name="calendarBtn" />
</DateInput>

<Popup
Expand Down