Skip to content

Commit ca8d021

Browse files
authored
feat(datepicker): Add prop to append calendar to body (sumcumo#37)
* feat(datepicker): add popup to append calendar to body * test(project): resolve test config * chore(styles): adjust coding style * refactor(project): order props alphabetic Breaking-change: This will change the overall html structure of the datepicker
1 parent fe5d305 commit ca8d021

File tree

14 files changed

+467
-193
lines changed

14 files changed

+467
-193
lines changed

docs/.vuepress/components/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@
3838
.error {
3939
color: red;
4040
}
41+
42+
.overflow-scroll {
43+
overflow: scroll
44+
}

docs/guide/Props/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
| Prop | Type | Default | Description |
55
| ----------------------------- | -----------------| ----------- | ----------------------------------------------- |
6+
| append-to-body | Boolean | false | Append datepicker calendar to body |
67
| autofocus | String | | Sets html `autofocus` attribute on input |
78
| bootstrap-styling | Boolean | false | Use bootstrap v4 styling classes. |
89
| calendar-button | Boolean | false | Show an icon that that can be clicked |

docs/guide/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ If you use [SASS](https://sass-lang.com/) you can directly import the src file.
5555

5656
```vue
5757
<style lang="scss">
58-
@import '~@sumcumo/vue-datepicker/src/styles/style.scss';
58+
@import '~@sum.cumo/vue-datepicker/src/styles/style.scss';
5959
</style>
6060
```

example/Demo.vue

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<h1>Datepicker Examples</h1>
44
<div class="example">
55
<h3>Default datepicker...</h3>
6-
<Datepicker placeholder="Select Date" />
6+
<Datepicker
7+
placeholder="Select Date"
8+
:append-to-body="true"
9+
/>
710
<code>
811
&lt;datepicker placeholder="Select Date"&gt;&lt;/datepicker&gt;
912
</code>
@@ -37,6 +40,7 @@
3740
<Datepicker
3841
v-model="vModelExample"
3942
placeholder="Select Date"
43+
:append-to-body="true"
4044
/>
4145
<code>
4246
&lt;datepicker placeholder="Select Date" v-model="vmodelexample"&gt;&lt;/datepicker&gt;
@@ -45,6 +49,18 @@
4549
<p>{{ vModelExample }}</p>
4650
</div>
4751

52+
<div class="example overflow-scroll">
53+
<h3>Append datepicker to body</h3>
54+
<Datepicker
55+
:append-to-body="true"
56+
/>
57+
<h3>Don't append datepicker to body</h3>
58+
<Datepicker />
59+
<code>
60+
&lt;datepicker :append-to-body="true"&gt;&lt;/datepicker&gt;
61+
</code>
62+
</div>
63+
4864
<div class="example">
4965
<h3>Format datepicker</h3>
5066
<Datepicker :format="format" />
@@ -315,6 +331,29 @@
315331
<pre>yearPickerRange: {{ yearPickerRange }}</pre>
316332
</div>
317333
</div>
334+
335+
<div class="example">
336+
<h3>Fixed positions</h3>
337+
<Datepicker
338+
:fixed-position="fixedPosition"
339+
:append-to-body="true"
340+
/>
341+
<code>
342+
&lt;datepicker :fixed-position="fixedPosition"&gt;&lt;/datepicker&gt;
343+
</code>
344+
<div class="settings">
345+
<h5>Settings</h5>
346+
<select v-model="fixedPosition">
347+
<option
348+
v-for="(position) in fixedPositions"
349+
:key="position"
350+
:value="position"
351+
>
352+
{{ position }}
353+
</option>
354+
</select>
355+
</div>
356+
</div>
318357
</div>
319358
</template>
320359

@@ -392,6 +431,15 @@ export default {
392431
languages: lang,
393432
language: 'en',
394433
yearPickerRange: 10,
434+
fixedPositions: [
435+
'bottom',
436+
'bottom-left',
437+
'bottom-right',
438+
'top',
439+
'top-left',
440+
'top-right',
441+
],
442+
fixedPosition: 'bottom',
395443
}
396444
},
397445
computed: {
@@ -522,4 +570,8 @@ h5 {
522570
font-size: 80%;
523571
display: block;
524572
}
573+
574+
.overflow-scroll {
575+
overflow: scroll
576+
}
525577
</style>

jest.conf.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

jest.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
rootDir: './',
3+
moduleFileExtensions: [
4+
'js',
5+
'json',
6+
'vue',
7+
],
8+
moduleNameMapper: {
9+
'^~(.*)$': '<rootDir>/src/$1',
10+
},
11+
transform: {
12+
'^.+.js$': 'babel-jest',
13+
'^.+.vue': 'vue-jest',
14+
},
15+
setupFiles: ['<rootDir>/test/unit/setup.js'],
16+
coverageDirectory: '<rootDir>/test/unit/coverage',
17+
collectCoverageFrom: [
18+
'./src/**/*.{js,vue}',
19+
'!./src/locale/translations/**/*.js',
20+
],
21+
verbose: false,
22+
testURL: 'http://localhost',
23+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"audit": "npm audit --registry=https://registry.npmjs.org",
3434
"serve": "rollup -c scripts/serve.js --watch",
3535
"lint": "eslint --ext .js,.vue src test/unit/specs",
36-
"test": "jest --config test/unit/jest.conf.js --coverage",
37-
"test:watch": "jest --config test/unit/jest.conf.js --watch",
36+
"test": "jest --coverage",
37+
"test:watch": "jest --watch",
3838
"release": "standard-version",
3939
"prerelease": "standard-version --dry-run",
4040
"docs:dev": "vuepress dev docs",

0 commit comments

Comments
 (0)