_dropdown.sass 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // *************************************
  2. //
  3. // Dropdown
  4. // -> Dropdown menus
  5. //
  6. // -------------------------------------
  7. // Template (Haml)
  8. // -------------------------------------
  9. //
  10. // .dropdown(.is-active)
  11. // %a.dropdown-btn.btn{href: '#'} Button
  12. // %ul.dropdown-menu.list
  13. // %li.dropdown-item.list-item(.is-active)
  14. // %a.dropdown-item-link.list-item-link{href: '#'} Item
  15. // %li.dropdown-item.list-item(.is-active)
  16. // %a.dropdown-item-link.list-item-link{href: '#'} Item
  17. //
  18. // *************************************
  19. // ----- Dropdown ----- //
  20. $dropdown-width: 150px
  21. $b-transitionSpeed: 0.3s
  22. .dropdown
  23. max-width: $dropdown-width
  24. position: relative
  25. width: auto
  26. z-index: 30
  27. // -------------------------------------
  28. // States
  29. // -------------------------------------
  30. // ----- Active ----- //
  31. .dropdown:hover
  32. .dropdown-btn
  33. color: $c-text-invert
  34. &::after
  35. color: $c-text-invert
  36. .dropdown-menu
  37. @extend %fauxShow
  38. +transition(opacity $b-transitionSpeed ease-in-out, top $b-transitionSpeed ease-in-out)
  39. top: 130%
  40. // -------------------------------------
  41. // Context
  42. // -------------------------------------
  43. .has-dropdown
  44. overflow: visible
  45. // -------------------------------------
  46. // Scaffolding
  47. // -------------------------------------
  48. // ----- Button ----- //
  49. .dropdown-btn
  50. $placement: 'after'
  51. // @extend %icn
  52. // @extend %icn--#{$placement}
  53. // @extend %icn--arrowDown--alt--#{$placement}
  54. display: block
  55. &:hover,
  56. &:focus
  57. &::#{$placement}
  58. color: $c-text-invert
  59. &::#{$placement}
  60. color: $c-highlight
  61. font-size: 7px // IE being a jerk.
  62. left: auto
  63. line-height: 30px // IE being a jerk.
  64. padding-left: (1.25 * $b-space)
  65. padding-right: (1.25 * $b-space)
  66. // ----- Item ----- //
  67. .dropdown-item
  68. border-bottom: $b-border
  69. margin: 0
  70. &:last-child
  71. border: 0
  72. &:hover
  73. background: darken(#fff, 15%)
  74. // Link
  75. .dropdown-item-link
  76. border: 0
  77. display: block
  78. padding: $b-space-s $b-space
  79. // ----- Menu ----- //
  80. .dropdown-menu
  81. @extend %boxSizing
  82. @extend %card
  83. @extend %fauxHide
  84. border-radius: 0
  85. font-size: $b-fontSize-m
  86. left: 50%
  87. margin-left: -($dropdown-width / 2)
  88. padding: 0
  89. position: absolute
  90. text-align: center
  91. top: 3.5 * $b-space
  92. width: $dropdown-width
  93. z-index: 10
  94. &::after
  95. +caret('top', 8px, $c-text-invert)