Closed Grotlo closed 4 years ago
probably not a good solution. Closing this.
Why not a good solution? Controlling the position would be great! 👍
Why not a good solution? Controlling the position would be great! 👍
It would be great and this solution does work somewhat! However, my solution was a very brute force way of doing it and not very elegant at all.
export let position;
switch (position) {
case "bottom-right":
positionTop = 100;
positionLeft = 0;
positionTranslateX = 0;
positionTranslateY = 0;
margin = "5px 0 0 0";
break;
case "bottom-left":
positionTop = 100;
positionLeft = -13;
positionTranslateX = 0;
positionTranslateY = 0;
margin = "5px 0 0 0";
break;
case "middle-bottom":
positionTop = 100;
positionTranslateY = 0;
margin = "5px 0 0 0";
break;
case "right":
positionLeft = 100;
positionTranslateX = 0;
margin = "0 0 0 5px";
break;
case "left":
positionRight = 100;
positionLeft = null;
positionTranslateX = 0;
margin = "0 5px 0 0";
default:
break;
}
If you know of a better way of doing it, feel free to make changes and make a new PR!
Ah I really want this :)
fixes #70
I've managed to place the datepicker on *five different positions: "middle-bottom", "bottom-left", "bottom-right", "left" and "right". Positioning is set as a prop, so you only need to put ´position="bottom-right"´ to set its position. When doing this, it made sense to make the button also close the datepicker, which is achieved as well. The calendar has the function to move based on viewport boundries, but since these will be set positions I've made it so that that won't happen if a position is set and defined.
I'm setting this as a draft because it might be a bit of brute forcing to get the component to line up correctly, but it seems to work with the default button and my custom one as well. Also, there's only *five positions, because I couldn't manage to do the top positions without putting in ridicously high numbers which made me believe that I did something wrong.
(I have some time now, so I can probably continue with #60 )