Skip to content

Commit

Permalink
Merge pull request #384 from LianaHarris360/k-date-components
Browse files Browse the repository at this point in the history
KDateComponents
  • Loading branch information
marcellamaki authored Jan 5, 2023
2 parents 9d2a946 + 9fe98f6 commit d4226b5
Show file tree
Hide file tree
Showing 15 changed files with 1,568 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Releases are recorded as git tags in the [Github releases](https://github.com/le
- [#361] - Fixes 'Property or method "disabled" is not defined on the instance but referenced during render.' raised by `KDropdownMenu`
- [#377] - Implement `useKResponsiveWindow` composable.
- [#380] - Wrap `KRadioButton` text.
- [#384] - Add `KDateRange` to KDS

<!-- Referenced PRs -->
[#351]: https://github.com/learningequality/kolibri-design-system/pull/351
Expand All @@ -21,6 +22,7 @@ Releases are recorded as git tags in the [Github releases](https://github.com/le
[#361]: https://github.com/learningequality/kolibri-design-system/pull/361
[#377]: https://github.com/learningequality/kolibri-design-system/pull/377
[#380]: https://github.com/learningequality/kolibri-design-system/pull/380
[#384]: https://github.com/learningequality/kolibri-design-system/pull/384

## Version 1.4.x

Expand Down
77 changes: 77 additions & 0 deletions docs/pages/kdaterange.vue
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>

5 changes: 5 additions & 0 deletions docs/tableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ export default [
title: 'KLinearLoader',
isCode: true,
}),
new Page({
path: '/kdaterange',
title: 'KDateRange',
isCode: true,
}),
new Page({
path: '/kdropdownmenu',
title: 'KDropdownMenu',
Expand Down
Loading

0 comments on commit d4226b5

Please sign in to comment.