datepicker.scss 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. //== foundational variables ==//
  2. $black: hsl(0, 0%, 4%) !default;
  3. $white: hsl(0, 0%, 100%) !default;
  4. $light: hsl(0, 0%, 96%) !default; // white-ter
  5. $dark: hsl(0, 0%, 21%) !default; // grey-darker
  6. $link: hsl(217, 71%, 53%) !default; // blue
  7. $grey-dark: lighten($black, 25%) !default;
  8. $grey-light: darken($light, 25%) !default;
  9. $grey-lighter: darken($light, 10%) !default;
  10. //== datepicker variables ==//
  11. $dp-background-color: $white !default;
  12. $dp-border-color: $grey-lighter !default;
  13. $dp-border-radius: 4px !default;
  14. $dp-border-radius-small: 2px !default;
  15. $dp-line-height-base: 1.5 !default;
  16. $dp-font-size-normal: 1rem !default;
  17. $dp-font-size-small: 0.75rem !default;
  18. $dp-font-weight-semibold: 600 !default;
  19. $dp-font-weight-bold: 700 !default;
  20. $dp-dropdown-offset: 4px !default;
  21. $dp-dropdown-shadow: 0 2px 3px rgba($black, 0.1), 0 0 0 1px rgba($black, 0.1) !default;
  22. $dp-dropdown-z: 20 !default;
  23. $dp-title-background-color: $light !default;
  24. $dp-cell-size-base: 2.25rem !default;
  25. $dp-cell-focus-background-color: darken($light, 5%) !default;
  26. $dp-cell-prevnext-color: hsl(0, 0%, 48%) !default; // grey
  27. $dp-cell-disabled-color: $grey-lighter !default;
  28. $dp-cell-selected-background-color: $link !default;
  29. $dp-cell-selected-color: #fff !default; // link(blue)-invert
  30. $dp-cell-selected-font-weight: 600 !default;
  31. $dp-cell-today-background-color: hsl(171, 100%, 41%) !default; // turquoise (primary)
  32. $dp-cell-today-color: #fff !default; // turquoise-invert
  33. $dp-cell-highlighted-background-color: $light !default;
  34. $dp-range-start-end-background-color: $grey-light !default;
  35. $dp-range-start-end-color: $dp-cell-selected-color !default;
  36. $dp-range-background-color: $grey-lighter !default;
  37. $dp-range-today-background-color: $dp-cell-today-background-color !default;
  38. $dp-week-color: $grey-light !default;
  39. $dp-footer-background-color: $light !default;
  40. $dp-input-in-edit-border-color: darken($link, 5%) !default;
  41. $dp-input-in-edit-focus-box-shadow-size: 0 0 0.25em 0.25em !default;
  42. //== non-configurable variables ==//
  43. $dp-cell-shrink-threshold: $dp-cell-size-base * 10; // = 8 * 1.25
  44. $dp-cell-shrinked-width: $dp-cell-size-base * 7 / 8;
  45. //== mixins ==//
  46. @import 'mixins';
  47. //== styles ==//
  48. .datepicker {
  49. display: none;
  50. &.active {
  51. display: block;
  52. }
  53. }
  54. .datepicker-dropdown {
  55. position: absolute;
  56. top: 0;
  57. left: 0;
  58. z-index: $dp-dropdown-z;
  59. padding-top: $dp-dropdown-offset;
  60. &.datepicker-orient-top {
  61. padding-top: 0;
  62. padding-bottom: $dp-dropdown-offset;
  63. }
  64. }
  65. .datepicker-picker {
  66. display: inline-block;
  67. border-radius: $dp-border-radius;
  68. background-color: $dp-background-color;
  69. .datepicker-dropdown & {
  70. box-shadow: $dp-dropdown-shadow;
  71. }
  72. span {
  73. display: block;
  74. flex: 1;
  75. border: 0;
  76. border-radius: $dp-border-radius;
  77. cursor: default;
  78. text-align: center;
  79. -webkit-touch-callout: none;
  80. user-select: none;
  81. }
  82. }
  83. .datepicker-main {
  84. padding: 2px;
  85. }
  86. .datepicker-footer {
  87. box-shadow: inset 0 1px 1px rgba($black, 0.1);
  88. background-color: $dp-footer-background-color;
  89. }
  90. %flex-container {
  91. display: flex;
  92. }
  93. %flex-wrap {
  94. flex-wrap: wrap;
  95. }
  96. %flex-basis-day {
  97. flex-basis: percentage(1 / 7);
  98. }
  99. %flex-basis-month-year {
  100. flex-basis: 25%;
  101. }
  102. %datepicker-cell-height {
  103. height: $dp-cell-size-base;
  104. line-height: $dp-cell-size-base;
  105. }
  106. .datepicker-title {
  107. box-shadow: inset 0 -1px 1px rgba($black, 0.1);
  108. background-color: $dp-title-background-color;
  109. padding: 0.375rem 0.75rem;
  110. text-align: center;
  111. font-weight: $dp-font-weight-bold;
  112. }
  113. .datepicker-controls {
  114. @extend %flex-container;
  115. .datepicker-header & {
  116. padding: 2px 2px 0;
  117. }
  118. @if mixin-exists(dp-button) {
  119. @include dp-button;
  120. } @else {
  121. .button {
  122. $button-color: $dark;
  123. $button-background-color: $white;
  124. $button-border-color: $grey-lighter;
  125. $button-border-width: 1px;
  126. $button-padding-vertical: calc(0.375em - #{$button-border-width});
  127. $button-padding-horizontal: 0.75em;
  128. $button-hover-color: $dark; // link-hover
  129. $button-hover-border-color: $grey-light; // link-hover-border
  130. $button-focus-color: $dark; // link-focus
  131. $button-focus-border-color: $link; // link-focus-border
  132. $button-focus-box-shadow-size: 0 0 0 0.125em;
  133. $button-focus-box-shadow-color: rgba($link, 0.25);
  134. $button-active-color: $dark; // link-active
  135. $button-active-border-color: $grey-dark; // link-active-border
  136. display: inline-flex;
  137. position: relative;
  138. align-items: center;
  139. justify-content: center;
  140. margin: 0;
  141. border: $button-border-width solid $button-border-color;
  142. border-radius: $dp-border-radius; // control-radius
  143. box-shadow: none;
  144. background-color: $button-background-color;
  145. cursor: pointer;
  146. padding: $button-padding-vertical $button-padding-horizontal;
  147. height: 2.25em; // control-height
  148. vertical-align: top;
  149. text-align: center;
  150. line-height: $dp-line-height-base; // control-line-height
  151. white-space: nowrap;
  152. color: $button-color;
  153. font-size: $dp-font-size-normal; // size-normal
  154. &:focus,
  155. &:active {
  156. outline: none;
  157. }
  158. &:hover {
  159. border-color: $button-hover-border-color;
  160. color: $button-hover-color;
  161. }
  162. &:focus {
  163. border-color: $button-focus-border-color;
  164. color: $button-focus-color;
  165. &:not(:active) {
  166. box-shadow: $button-focus-box-shadow-size $button-focus-box-shadow-color;
  167. }
  168. }
  169. &:active {
  170. border-color: $button-active-border-color;
  171. color: $button-active-color;
  172. }
  173. &[disabled] {
  174. cursor: not-allowed;
  175. }
  176. .datepicker-header & {
  177. @include dp-header-button-common;
  178. &:hover {
  179. background-color: darken($white, 2.5%);
  180. }
  181. &:focus {
  182. &:not(:active) {
  183. box-shadow: 0 0 0 0.125em rgba($white, 0.25);
  184. }
  185. }
  186. &:active {
  187. background-color: darken($white, 5%);
  188. }
  189. &[disabled] {
  190. box-shadow: none;
  191. }
  192. }
  193. .datepicker-footer & {
  194. @include dp-footer-button-common;
  195. }
  196. }
  197. }
  198. .view-switch {
  199. flex: auto;
  200. }
  201. .prev-btn,
  202. .next-btn {
  203. padding-right: 0.375rem;
  204. padding-left: 0.375rem;
  205. width: $dp-cell-size-base;
  206. &.disabled {
  207. visibility: hidden;
  208. }
  209. }
  210. }
  211. .datepicker-view {
  212. @extend %flex-container;
  213. .days-of-week {
  214. @extend %flex-container;
  215. }
  216. .dow {
  217. @extend %flex-basis-day;
  218. height: $dp-font-size-normal * $dp-line-height-base;
  219. line-height: $dp-font-size-normal * $dp-line-height-base;
  220. font-size: ($dp-font-size-small + $dp-font-size-normal) / 2;
  221. font-weight: $dp-font-weight-bold;
  222. }
  223. .week {
  224. @extend %datepicker-cell-height;
  225. width: $dp-cell-size-base;
  226. color: $dp-week-color;
  227. font-size: $dp-font-size-small;
  228. @media (max-width: $dp-cell-shrink-threshold) {
  229. width: $dp-cell-shrinked-width;
  230. }
  231. }
  232. }
  233. .datepicker-grid {
  234. @extend %flex-container;
  235. @extend %flex-wrap;
  236. width: $dp-cell-size-base * 7;
  237. @media (max-width: $dp-cell-shrink-threshold) {
  238. .calendar-weeks + .days & {
  239. width: $dp-cell-shrinked-width * 7;
  240. }
  241. }
  242. }
  243. .datepicker-cell {
  244. @extend %datepicker-cell-height;
  245. &:not(.disabled):hover {
  246. background-color: darken($dp-background-color, 2.5%);
  247. cursor: pointer;
  248. }
  249. &.focused:not(.selected) {
  250. background-color: $dp-cell-focus-background-color;
  251. }
  252. &.selected {
  253. &,
  254. &:hover {
  255. background-color: $dp-cell-selected-background-color;
  256. color: $dp-cell-selected-color;
  257. font-weight: $dp-cell-selected-font-weight;
  258. }
  259. }
  260. &.disabled {
  261. color: $dp-cell-disabled-color;
  262. }
  263. &.prev,
  264. &.next {
  265. &:not(.disabled) {
  266. color: $dp-cell-prevnext-color;
  267. }
  268. &.selected {
  269. color: darken($dp-cell-selected-color, 10%);
  270. }
  271. }
  272. &.highlighted:not(.selected):not(.range):not(.today) {
  273. border-radius: 0;
  274. background-color: $dp-cell-highlighted-background-color;
  275. &:not(.disabled):hover {
  276. background-color: darken($dp-cell-highlighted-background-color, 2.5%);
  277. }
  278. &.focused {
  279. background-color: $dp-cell-focus-background-color;
  280. }
  281. }
  282. &.today {
  283. &:not(.selected) {
  284. background-color: $dp-cell-today-background-color;
  285. &:not(.disabled) {
  286. color: $dp-cell-today-color;
  287. }
  288. }
  289. &.focused:not(.selected) {
  290. background-color: darken($dp-cell-today-background-color, 2.5%);
  291. }
  292. }
  293. &%range-start-end-common {
  294. background-color: $dp-range-start-end-background-color;
  295. color: $dp-range-start-end-color;
  296. }
  297. &%range-start-end-focused-common {
  298. background-color: darken($dp-range-start-end-background-color, 2.5%);
  299. }
  300. &.range-start {
  301. border-radius: $dp-border-radius 0 0 $dp-border-radius;
  302. &:not(.selected) {
  303. @extend %range-start-end-common;
  304. }
  305. &.focused:not(.selected) {
  306. @extend %range-start-end-focused-common;
  307. }
  308. }
  309. &.range-end {
  310. border-radius: 0 $dp-border-radius $dp-border-radius 0;
  311. &:not(.selected) {
  312. @extend %range-start-end-common;
  313. }
  314. &.focused:not(.selected) {
  315. @extend %range-start-end-focused-common;
  316. }
  317. }
  318. &.range {
  319. border-radius: 0;
  320. background-color: $dp-range-background-color;
  321. &:not(.disabled):not(.focused):not(.today):hover {
  322. background-color: darken($dp-range-background-color, 2.5%);
  323. }
  324. &.disabled {
  325. color: darken($dp-range-background-color, 10%);
  326. }
  327. &.focused {
  328. background-color: darken($dp-range-background-color, 5%);
  329. }
  330. @if $dp-range-today-background-color != $dp-cell-today-background-color {
  331. &.today {
  332. background-color: $dp-range-today-background-color;
  333. }
  334. }
  335. }
  336. .datepicker-view .days & {
  337. @extend %flex-basis-day;
  338. }
  339. .datepicker-view.datepicker-grid & {
  340. @extend %flex-basis-month-year;
  341. height: $dp-cell-size-base * 2;
  342. line-height: $dp-cell-size-base * 2;
  343. }
  344. }
  345. .datepicker-input.in-edit {
  346. border-color: $dp-input-in-edit-border-color;
  347. &:focus,
  348. &:active {
  349. box-shadow: $dp-input-in-edit-focus-box-shadow-size rgba($dp-input-in-edit-border-color, 0.2);
  350. }
  351. }