-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #384 from LianaHarris360/k-date-components
KDateComponents
- Loading branch information
Showing
15 changed files
with
1,568 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<template> | ||
|
||
<DocsPageTemplate apiDocs> | ||
|
||
<DocsPageSection title="Overview" anchor="#overview"> | ||
The KDateRange is a modal component that contains two input components and a calendar component that | ||
allow for a start and end date selection. | ||
<div> | ||
<KButton text="open demo" :primary="true" appearance="flat-button" :style="{ marginTop: '5px' }" @click="modalShown = true" /> | ||
<ClientOnly> | ||
<KDateRange | ||
v-if="modalShown" | ||
class="demo" | ||
:firstAllowedDate="firstAllowedDate" | ||
:lastAllowedDate="lastAllowedDate" | ||
submitText="Generate" | ||
cancelText="Cancel" | ||
title="Select a date range" | ||
description="(Optional) Description of modal component" | ||
dateLocale="en-US" | ||
startDateLegendText="Start Date" | ||
endDateLegendText="End Date" | ||
previousMonthText="Previous Month" | ||
nextMonthText="Next Month" | ||
v-bind="errorMessages" | ||
@submit="modalShown = false" | ||
@cancel="modalShown = false" | ||
/> | ||
</ClientOnly> | ||
</div> | ||
</DocsPageSection> | ||
</DocsPageTemplate> | ||
|
||
</template> | ||
|
||
|
||
<script> | ||
import format from 'date-fns/format'; | ||
import validationConstants from '../../lib/KDateRange/validationConstants'; | ||
import KButton from '../../lib/buttons-and-links/KButton'; | ||
export default { | ||
components: { | ||
KButton, | ||
}, | ||
data() { | ||
return { | ||
firstAllowedDate: new Date(2022, 0, 1), | ||
lastAllowedDate: new Date(), | ||
modalShown: false, | ||
}; | ||
}, | ||
computed: { | ||
errorMessages() { | ||
return { | ||
[validationConstants.MALFORMED]: 'Please enter a valid date', | ||
[validationConstants.START_DATE_AFTER_END_DATE]: 'Start date cannot be after end date', | ||
[validationConstants.FUTURE_DATE]: 'Cannot select a future date', | ||
[validationConstants.DATE_BEFORE_FIRST_ALLOWED]: | ||
'Date must be after ' + format(this.firstAllowedDate, 'DD/MM/YYYY'), | ||
}; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
|
||
<style lang="css" scoped> | ||
.demo { | ||
height: 850px; | ||
} | ||
</style> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.