|
| 1 | +@import "shared"; |
| 2 | + |
| 3 | +$default-border-radius: 5px !default; |
| 4 | + |
| 5 | +// Round all corners by a specific amount, defaults to value of `$default-border-radius`. |
| 6 | +// |
| 7 | +// When two values are passed, the first is the horizontal radius |
| 8 | +// and the second is the vertical radius. |
| 9 | +// |
| 10 | +// Note: webkit does not support shorthand syntax for several corners at once. |
| 11 | +// So in the case where you pass several values only the first will be passed to webkit. |
| 12 | +// |
| 13 | +// Examples: |
| 14 | +// |
| 15 | +// .simple { @include border-radius(4px, 4px); } |
| 16 | +// .compound { @include border-radius(2px 5px, 3px 6px); } |
| 17 | +// .crazy { @include border-radius(1px 3px 5px 7px, 2px 4px 6px 8px)} |
| 18 | +// |
| 19 | +// Which generates: |
| 20 | +// |
| 21 | +// .simple { |
| 22 | +// -webkit-border-radius: 4px 4px; |
| 23 | +// -moz-border-radius: 4px / 4px; |
| 24 | +// -khtml-border-radius: 4px / 4px; |
| 25 | +// border-radius: 4px / 4px; } |
| 26 | +// |
| 27 | +// .compound { |
| 28 | +// -webkit-border-radius: 2px 3px; |
| 29 | +// -moz-border-radius: 2px 5px / 3px 6px; |
| 30 | +// -khtml-border-radius: 2px 5px / 3px 6px; |
| 31 | +// border-radius: 2px 5px / 3px 6px; } |
| 32 | +// |
| 33 | +// .crazy { |
| 34 | +// -webkit-border-radius: 1px 2px; |
| 35 | +// -moz-border-radius: 1px 3px 5px 7px / 2px 4px 6px 8px; |
| 36 | +// -khtml-border-radius: 1px 3px 5px 7px / 2px 4px 6px 8px; |
| 37 | +// border-radius: 1px 3px 5px 7px / 2px 4px 6px 8px; } |
| 38 | + |
| 39 | +@mixin border-radius($radius: $default-border-radius, $vertical-radius: false) { |
| 40 | + |
| 41 | + @if $vertical-radius { |
| 42 | + // Webkit doesn't understand the official shorthand syntax for specifying |
| 43 | + // a vertical radius unless so in case there's several we only take the first. |
| 44 | + @include experimental(border-radius, first-value-of($radius) first-value-of($vertical-radius), |
| 45 | + not -moz, |
| 46 | + -webkit, |
| 47 | + not -o, |
| 48 | + not -ms, |
| 49 | + not -khtml, |
| 50 | + not official |
| 51 | + ); |
| 52 | + @include experimental("border-radius", $radius unquote("/") $vertical-radius, |
| 53 | + -moz, |
| 54 | + not -webkit, |
| 55 | + not -o, |
| 56 | + not -ms, |
| 57 | + -khtml, |
| 58 | + official |
| 59 | + ); |
| 60 | + } |
| 61 | + @else { |
| 62 | + @include experimental(border-radius, $radius); |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +// Round radius at position by amount. |
| 67 | +// |
| 68 | +// * legal values for `$vert`: `top`, `bottom` |
| 69 | +// * legal values for `$horz`: `left`, `right` |
| 70 | + |
| 71 | +@mixin border-corner-radius($vert, $horz, $radius: $default-border-radius) { |
| 72 | + // Support for mozilla's syntax for specifying a corner |
| 73 | + @include experimental("border-radius-#{$vert}#{$horz}", $radius, |
| 74 | + -moz, |
| 75 | + not -webkit, |
| 76 | + not -o, |
| 77 | + not -ms, |
| 78 | + not -khtml, |
| 79 | + not official |
| 80 | + ); |
| 81 | + @include experimental("border-#{$vert}-#{$horz}-radius", $radius, |
| 82 | + not -moz, |
| 83 | + -webkit, |
| 84 | + not -o, |
| 85 | + not -ms, |
| 86 | + -khtml, |
| 87 | + official |
| 88 | + ); |
| 89 | + |
| 90 | +} |
| 91 | + |
| 92 | +// Round top-left corner only |
| 93 | + |
| 94 | +@mixin border-top-left-radius($radius: $default-border-radius) { |
| 95 | + @include border-corner-radius(top, left, $radius); } |
| 96 | + |
| 97 | +// Round top-right corner only |
| 98 | + |
| 99 | +@mixin border-top-right-radius($radius: $default-border-radius) { |
| 100 | + @include border-corner-radius(top, right, $radius); } |
| 101 | + |
| 102 | +// Round bottom-left corner only |
| 103 | + |
| 104 | +@mixin border-bottom-left-radius($radius: $default-border-radius) { |
| 105 | + @include border-corner-radius(bottom, left, $radius); } |
| 106 | + |
| 107 | +// Round bottom-right corner only |
| 108 | + |
| 109 | +@mixin border-bottom-right-radius($radius: $default-border-radius) { |
| 110 | + @include border-corner-radius(bottom, right, $radius); } |
| 111 | + |
| 112 | +// Round both top corners by amount |
| 113 | +@mixin border-top-radius($radius: $default-border-radius) { |
| 114 | + @include border-top-left-radius($radius); |
| 115 | + @include border-top-right-radius($radius); } |
| 116 | + |
| 117 | +// Round both right corners by amount |
| 118 | +@mixin border-right-radius($radius: $default-border-radius) { |
| 119 | + @include border-top-right-radius($radius); |
| 120 | + @include border-bottom-right-radius($radius); } |
| 121 | + |
| 122 | +// Round both bottom corners by amount |
| 123 | +@mixin border-bottom-radius($radius: $default-border-radius) { |
| 124 | + @include border-bottom-left-radius($radius); |
| 125 | + @include border-bottom-right-radius($radius); } |
| 126 | + |
| 127 | +// Round both left corners by amount |
| 128 | +@mixin border-left-radius($radius: $default-border-radius) { |
| 129 | + @include border-top-left-radius($radius); |
| 130 | + @include border-bottom-left-radius($radius); } |
0 commit comments