Skip to content

Commit

Permalink
added: auto detect placement
Browse files Browse the repository at this point in the history
  • Loading branch information
adenvt committed Aug 29, 2019
1 parent de0fc75 commit 9c4ec25
Show file tree
Hide file tree
Showing 11 changed files with 313 additions and 76 deletions.
13 changes: 13 additions & 0 deletions __mocks__/popper.js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import PopperJs from 'popper.js'

export default class Popper {
static placements = PopperJs.placements;

constructor () {
return {
destroy: () => {},
update: () => {},
scheduleUpdate: () => {}
}
}
}
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
],
'env': {
'test': {
'plugins': ['@babel/plugin-transform-modules-commonjs']
'plugins': ['@babel/plugin-transform-modules-commonjs', '@babel/plugin-proposal-class-properties']
}
}
}
20 changes: 18 additions & 2 deletions example/Demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,22 @@
</code>
</div>

<div class="example">
<h3>Placement</h3>
<datepicker :placement="placement"></datepicker>
<code>
&lt;datepicker :placement="{{ placement }}"&gt;&lt;/datepicker&gt;
</code>
<div class="settings">
<h5>Settings</h5>
<select v-model="placement">
<option value="auto">Auto</option>
<option value="top">Top</option>
<option value="bottom">Bottom</option>
</select>
</div>
</div>

<div class="example">
<h3>Day view only</h3>
<datepicker :minimumView="'day'" :maximumView="'day'"></datepicker>
Expand Down Expand Up @@ -245,7 +261,6 @@
&lt;datepicker :minimumView="'month'" :maximumView="'year'" :initialView="'year'"&gt;&lt;/datepicker&gt;
</code>
</div>

</div>
</template>

Expand Down Expand Up @@ -287,7 +302,8 @@ export default {
state: state,
vModelExample: null,
languages: lang,
language: 'en'
language: 'en',
placement: 'auto',
}
},
computed: {
Expand Down
2 changes: 1 addition & 1 deletion example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Demo from './Demo.vue'
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
window.app = new Vue({
el: '#app',
render: h => h(Demo)
})
153 changes: 153 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"lint",
"test"
],
"dependencies": {},
"dependencies": {
"popper.js": "^1.15.0"
},
"peerDependencies": {
"vue": "^2.6.10"
},
Expand All @@ -45,6 +47,7 @@
"@babel/core": "^7.4.5",
"@babel/node": "^7.4.5",
"@babel/plugin-external-helpers": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
Expand Down
Loading

0 comments on commit 9c4ec25

Please sign in to comment.