_button.scss 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. @mixin button ($style: simple, $base-color: #4294f0, $text-size: inherit, $padding: 7px 18px) {
  2. @if type-of($style) == string and type-of($base-color) == color {
  3. @include buttonstyle($style, $base-color, $text-size, $padding);
  4. }
  5. @if type-of($style) == string and type-of($base-color) == number {
  6. $padding: $text-size;
  7. $text-size: $base-color;
  8. $base-color: #4294f0;
  9. @if $padding == inherit {
  10. $padding: 7px 18px;
  11. }
  12. @include buttonstyle($style, $base-color, $text-size, $padding);
  13. }
  14. @if type-of($style) == color and type-of($base-color) == color {
  15. $base-color: $style;
  16. $style: simple;
  17. @include buttonstyle($style, $base-color, $text-size, $padding);
  18. }
  19. @if type-of($style) == color and type-of($base-color) == number {
  20. $padding: $text-size;
  21. $text-size: $base-color;
  22. $base-color: $style;
  23. $style: simple;
  24. @if $padding == inherit {
  25. $padding: 7px 18px;
  26. }
  27. @include buttonstyle($style, $base-color, $text-size, $padding);
  28. }
  29. @if type-of($style) == number {
  30. $padding: $base-color;
  31. $text-size: $style;
  32. $base-color: #4294f0;
  33. $style: simple;
  34. @if $padding == #4294f0 {
  35. $padding: 7px 18px;
  36. }
  37. @include buttonstyle($style, $base-color, $text-size, $padding);
  38. }
  39. &:disabled {
  40. opacity: 0.5;
  41. cursor: not-allowed;
  42. }
  43. }
  44. // Selector Style Button
  45. //************************************************************************//
  46. @mixin buttonstyle($type, $b-color, $t-size, $pad) {
  47. // Grayscale button
  48. @if $type == simple and $b-color == grayscale($b-color) {
  49. @include simple($b-color, true, $t-size, $pad);
  50. }
  51. @if $type == shiny and $b-color == grayscale($b-color) {
  52. @include shiny($b-color, true, $t-size, $pad);
  53. }
  54. @if $type == pill and $b-color == grayscale($b-color) {
  55. @include pill($b-color, true, $t-size, $pad);
  56. }
  57. @if $type == flat and $b-color == grayscale($b-color) {
  58. @include flat($b-color, true, $t-size, $pad);
  59. }
  60. // Colored button
  61. @if $type == simple {
  62. @include simple($b-color, false, $t-size, $pad);
  63. }
  64. @else if $type == shiny {
  65. @include shiny($b-color, false, $t-size, $pad);
  66. }
  67. @else if $type == pill {
  68. @include pill($b-color, false, $t-size, $pad);
  69. }
  70. @else if $type == flat {
  71. @include flat($b-color, false, $t-size, $pad);
  72. }
  73. }
  74. // Simple Button
  75. //************************************************************************//
  76. @mixin simple($base-color, $grayscale: false, $textsize: inherit, $padding: 7px 18px) {
  77. $color: hsl(0, 0, 100%);
  78. $border: adjust-color($base-color, $saturation: 9%, $lightness: -14%);
  79. $inset-shadow: adjust-color($base-color, $saturation: -8%, $lightness: 15%);
  80. $stop-gradient: adjust-color($base-color, $saturation: 9%, $lightness: -11%);
  81. $text-shadow: adjust-color($base-color, $saturation: 15%, $lightness: -18%);
  82. @if is-light($base-color) {
  83. $color: hsl(0, 0, 20%);
  84. $text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
  85. }
  86. @if $grayscale == true {
  87. $border: grayscale($border);
  88. $inset-shadow: grayscale($inset-shadow);
  89. $stop-gradient: grayscale($stop-gradient);
  90. $text-shadow: grayscale($text-shadow);
  91. }
  92. border: 1px solid $border;
  93. border-radius: 3px;
  94. box-shadow: inset 0 1px 0 0 $inset-shadow;
  95. color: $color;
  96. display: inline-block;
  97. font-size: $textsize;
  98. font-weight: bold;
  99. @include linear-gradient ($base-color, $stop-gradient);
  100. padding: $padding;
  101. text-decoration: none;
  102. text-shadow: 0 1px 0 $text-shadow;
  103. background-clip: padding-box;
  104. &:hover:not(:disabled) {
  105. $base-color-hover: adjust-color($base-color, $saturation: -4%, $lightness: -5%);
  106. $inset-shadow-hover: adjust-color($base-color, $saturation: -7%, $lightness: 5%);
  107. $stop-gradient-hover: adjust-color($base-color, $saturation: 8%, $lightness: -14%);
  108. @if $grayscale == true {
  109. $base-color-hover: grayscale($base-color-hover);
  110. $inset-shadow-hover: grayscale($inset-shadow-hover);
  111. $stop-gradient-hover: grayscale($stop-gradient-hover);
  112. }
  113. box-shadow: inset 0 1px 0 0 $inset-shadow-hover;
  114. cursor: pointer;
  115. @include linear-gradient ($base-color-hover, $stop-gradient-hover);
  116. }
  117. &:active:not(:disabled),
  118. &:focus:not(:disabled) {
  119. $border-active: adjust-color($base-color, $saturation: 9%, $lightness: -14%);
  120. $inset-shadow-active: adjust-color($base-color, $saturation: 7%, $lightness: -17%);
  121. @if $grayscale == true {
  122. $border-active: grayscale($border-active);
  123. $inset-shadow-active: grayscale($inset-shadow-active);
  124. }
  125. border: 1px solid $border-active;
  126. box-shadow: inset 0 0 8px 4px $inset-shadow-active, inset 0 0 8px 4px $inset-shadow-active;
  127. }
  128. }
  129. // Shiny Button
  130. //************************************************************************//
  131. @mixin shiny($base-color, $grayscale: false, $textsize: inherit, $padding: 7px 18px) {
  132. $color: hsl(0, 0, 100%);
  133. $border: adjust-color($base-color, $red: -117, $green: -111, $blue: -81);
  134. $border-bottom: adjust-color($base-color, $red: -126, $green: -127, $blue: -122);
  135. $fourth-stop: adjust-color($base-color, $red: -79, $green: -70, $blue: -46);
  136. $inset-shadow: adjust-color($base-color, $red: 37, $green: 29, $blue: 12);
  137. $second-stop: adjust-color($base-color, $red: -56, $green: -50, $blue: -33);
  138. $text-shadow: adjust-color($base-color, $red: -140, $green: -141, $blue: -114);
  139. $third-stop: adjust-color($base-color, $red: -86, $green: -75, $blue: -48);
  140. @if is-light($base-color) {
  141. $color: hsl(0, 0, 20%);
  142. $text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
  143. }
  144. @if $grayscale == true {
  145. $border: grayscale($border);
  146. $border-bottom: grayscale($border-bottom);
  147. $fourth-stop: grayscale($fourth-stop);
  148. $inset-shadow: grayscale($inset-shadow);
  149. $second-stop: grayscale($second-stop);
  150. $text-shadow: grayscale($text-shadow);
  151. $third-stop: grayscale($third-stop);
  152. }
  153. border: 1px solid $border;
  154. border-bottom: 1px solid $border-bottom;
  155. border-radius: 5px;
  156. box-shadow: inset 0 1px 0 0 $inset-shadow;
  157. color: $color;
  158. display: inline-block;
  159. font-size: $textsize;
  160. font-weight: bold;
  161. @include linear-gradient(top, $base-color 0%, $second-stop 50%, $third-stop 50%, $fourth-stop 100%);
  162. padding: $padding;
  163. text-align: center;
  164. text-decoration: none;
  165. text-shadow: 0 -1px 1px $text-shadow;
  166. &:hover:not(:disabled) {
  167. $first-stop-hover: adjust-color($base-color, $red: -13, $green: -15, $blue: -18);
  168. $second-stop-hover: adjust-color($base-color, $red: -66, $green: -62, $blue: -51);
  169. $third-stop-hover: adjust-color($base-color, $red: -93, $green: -85, $blue: -66);
  170. $fourth-stop-hover: adjust-color($base-color, $red: -86, $green: -80, $blue: -63);
  171. @if $grayscale == true {
  172. $first-stop-hover: grayscale($first-stop-hover);
  173. $second-stop-hover: grayscale($second-stop-hover);
  174. $third-stop-hover: grayscale($third-stop-hover);
  175. $fourth-stop-hover: grayscale($fourth-stop-hover);
  176. }
  177. cursor: pointer;
  178. @include linear-gradient(top, $first-stop-hover 0%,
  179. $second-stop-hover 50%,
  180. $third-stop-hover 50%,
  181. $fourth-stop-hover 100%);
  182. }
  183. &:active:not(:disabled),
  184. &:focus:not(:disabled) {
  185. $inset-shadow-active: adjust-color($base-color, $red: -111, $green: -116, $blue: -122);
  186. @if $grayscale == true {
  187. $inset-shadow-active: grayscale($inset-shadow-active);
  188. }
  189. box-shadow: inset 0 0 20px 0 $inset-shadow-active;
  190. }
  191. }
  192. // Pill Button
  193. //************************************************************************//
  194. @mixin pill($base-color, $grayscale: false, $textsize: inherit, $padding: 7px 18px) {
  195. $color: hsl(0, 0, 100%);
  196. $border-bottom: adjust-color($base-color, $hue: 8, $saturation: -11%, $lightness: -26%);
  197. $border-sides: adjust-color($base-color, $hue: 4, $saturation: -21%, $lightness: -21%);
  198. $border-top: adjust-color($base-color, $hue: -1, $saturation: -30%, $lightness: -15%);
  199. $inset-shadow: adjust-color($base-color, $hue: -1, $saturation: -1%, $lightness: 7%);
  200. $stop-gradient: adjust-color($base-color, $hue: 8, $saturation: 14%, $lightness: -10%);
  201. $text-shadow: adjust-color($base-color, $hue: 5, $saturation: -19%, $lightness: -15%);
  202. @if is-light($base-color) {
  203. $color: hsl(0, 0, 20%);
  204. $text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
  205. }
  206. @if $grayscale == true {
  207. $border-bottom: grayscale($border-bottom);
  208. $border-sides: grayscale($border-sides);
  209. $border-top: grayscale($border-top);
  210. $inset-shadow: grayscale($inset-shadow);
  211. $stop-gradient: grayscale($stop-gradient);
  212. $text-shadow: grayscale($text-shadow);
  213. }
  214. border: 1px solid $border-top;
  215. border-color: $border-top $border-sides $border-bottom;
  216. border-radius: 16px;
  217. box-shadow: inset 0 1px 0 0 $inset-shadow;
  218. color: $color;
  219. display: inline-block;
  220. font-size: $textsize;
  221. font-weight: normal;
  222. line-height: 1;
  223. @include linear-gradient ($base-color, $stop-gradient);
  224. padding: $padding;
  225. text-align: center;
  226. text-decoration: none;
  227. text-shadow: 0 -1px 1px $text-shadow;
  228. background-clip: padding-box;
  229. &:hover:not(:disabled) {
  230. $base-color-hover: adjust-color($base-color, $lightness: -4.5%);
  231. $border-bottom: adjust-color($base-color, $hue: 8, $saturation: 13.5%, $lightness: -32%);
  232. $border-sides: adjust-color($base-color, $hue: 4, $saturation: -2%, $lightness: -27%);
  233. $border-top: adjust-color($base-color, $hue: -1, $saturation: -17%, $lightness: -21%);
  234. $inset-shadow-hover: adjust-color($base-color, $saturation: -1%, $lightness: 3%);
  235. $stop-gradient-hover: adjust-color($base-color, $hue: 8, $saturation: -4%, $lightness: -15.5%);
  236. $text-shadow-hover: adjust-color($base-color, $hue: 5, $saturation: -5%, $lightness: -22%);
  237. @if $grayscale == true {
  238. $base-color-hover: grayscale($base-color-hover);
  239. $border-bottom: grayscale($border-bottom);
  240. $border-sides: grayscale($border-sides);
  241. $border-top: grayscale($border-top);
  242. $inset-shadow-hover: grayscale($inset-shadow-hover);
  243. $stop-gradient-hover: grayscale($stop-gradient-hover);
  244. $text-shadow-hover: grayscale($text-shadow-hover);
  245. }
  246. border: 1px solid $border-top;
  247. border-color: $border-top $border-sides $border-bottom;
  248. box-shadow: inset 0 1px 0 0 $inset-shadow-hover;
  249. cursor: pointer;
  250. @include linear-gradient ($base-color-hover, $stop-gradient-hover);
  251. text-shadow: 0 -1px 1px $text-shadow-hover;
  252. background-clip: padding-box;
  253. }
  254. &:active:not(:disabled),
  255. &:focus:not(:disabled) {
  256. $active-color: adjust-color($base-color, $hue: 4, $saturation: -12%, $lightness: -10%);
  257. $border-active: adjust-color($base-color, $hue: 6, $saturation: -2.5%, $lightness: -30%);
  258. $border-bottom-active: adjust-color($base-color, $hue: 11, $saturation: 6%, $lightness: -31%);
  259. $inset-shadow-active: adjust-color($base-color, $hue: 9, $saturation: 2%, $lightness: -21.5%);
  260. $text-shadow-active: adjust-color($base-color, $hue: 5, $saturation: -12%, $lightness: -21.5%);
  261. @if $grayscale == true {
  262. $active-color: grayscale($active-color);
  263. $border-active: grayscale($border-active);
  264. $border-bottom-active: grayscale($border-bottom-active);
  265. $inset-shadow-active: grayscale($inset-shadow-active);
  266. $text-shadow-active: grayscale($text-shadow-active);
  267. }
  268. background: $active-color;
  269. border: 1px solid $border-active;
  270. border-bottom: 1px solid $border-bottom-active;
  271. box-shadow: inset 0 0 6px 3px $inset-shadow-active;
  272. text-shadow: 0 -1px 1px $text-shadow-active;
  273. }
  274. }
  275. // Flat Button
  276. //************************************************************************//
  277. @mixin flat($base-color, $grayscale: false, $textsize: inherit, $padding: 7px 18px) {
  278. $color: hsl(0, 0, 100%);
  279. @if is-light($base-color) {
  280. $color: hsl(0, 0, 20%);
  281. }
  282. background-color: $base-color;
  283. border-radius: 3px;
  284. border: none;
  285. color: $color;
  286. display: inline-block;
  287. font-size: inherit;
  288. font-weight: bold;
  289. padding: 7px 18px;
  290. text-decoration: none;
  291. background-clip: padding-box;
  292. &:hover:not(:disabled){
  293. $base-color-hover: adjust-color($base-color, $saturation: 4%, $lightness: 5%);
  294. @if $grayscale == true {
  295. $base-color-hover: grayscale($base-color-hover);
  296. }
  297. background-color: $base-color-hover;
  298. cursor: pointer;
  299. }
  300. &:active:not(:disabled),
  301. &:focus:not(:disabled) {
  302. $base-color-active: adjust-color($base-color, $saturation: -4%, $lightness: -5%);
  303. @if $grayscale == true {
  304. $base-color-active: grayscale($base-color-active);
  305. }
  306. background-color: $base-color-active;
  307. cursor: pointer;
  308. }
  309. }