Skip to content

Commit

Permalink
Refactor drop theme arrows into a helper (for use by Select/Tooltip/S…
Browse files Browse the repository at this point in the history
…hepherd etc.)
  • Loading branch information
adamschwartz committed Jan 6, 2014
1 parent 69c1898 commit 24104c9
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 134 deletions.
4 changes: 2 additions & 2 deletions css/drop-theme-arrows.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
position: relative;
font-family: inherit;
background: white;
color: inherit;
padding: 1em;
font-size: 1.1em;
line-height: 1.5em; }
line-height: 1.5em;
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2)); }
.drop.drop-theme-arrows .drop-content:before {
content: "";
display: block;
Expand Down
137 changes: 5 additions & 132 deletions sass/drop-theme-arrows.sass
Original file line number Diff line number Diff line change
@@ -1,137 +1,10 @@
@import compass/css3
@import compass/utilities/general/clearfix
@import helpers/drop-theme-arrows

$themePrefix: "drop"
$tetherThemePrefx: "tether" // TODO -- make $tetherThemePrefx the same as $themePrefix once Zack does the coffeescript prefixer thing
$arrowSize: 16px
$backgroundColor: #fff
$color: inherit
$useDropShadow: true

.drop.drop-theme-arrows
max-width: 100%
max-height: 100%

.drop-content
+border-radius(5px)
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .2))
position: relative
font-family: inherit
background: $backgroundColor
color: $color
padding: 1em
font-size: 1.1em
line-height: 1.5em

&:before
content: ""
display: block
position: absolute
width: 0
height: 0
border-color: transparent
border-width: $arrowSize
border-style: solid

// Centers and middles
&.tether-element-attached-bottom.tether-element-attached-center .drop-content
margin-bottom: $arrowSize

&:before
top: 100%
left: 50%
margin-left: - $arrowSize
border-top-color: $backgroundColor

&.tether-element-attached-top.tether-element-attached-center .drop-content
margin-top: $arrowSize

&:before
bottom: 100%
left: 50%
margin-left: - $arrowSize
border-bottom-color: $backgroundColor

&.tether-element-attached-right.tether-element-attached-middle .drop-content
margin-right: $arrowSize

&:before
left: 100%
top: 50%
margin-top: - $arrowSize
border-left-color: $backgroundColor

&.tether-element-attached-left.tether-element-attached-middle .drop-content
margin-left: $arrowSize

&:before
right: 100%
top: 50%
margin-top: - $arrowSize
border-right-color: $backgroundColor

// Top and bottom corners
&.tether-element-attached-top.tether-element-attached-left.tether-target-attached-bottom .drop-content
margin-top: $arrowSize

&:before
bottom: 100%
left: $arrowSize
border-bottom-color: $backgroundColor

&.tether-element-attached-top.tether-element-attached-right.tether-target-attached-bottom .drop-content
margin-top: $arrowSize

&:before
bottom: 100%
right: $arrowSize
border-bottom-color: $backgroundColor

&.tether-element-attached-bottom.tether-element-attached-left.tether-target-attached-top .drop-content
margin-bottom: $arrowSize

&:before
top: 100%
left: $arrowSize
border-top-color: $backgroundColor

&.tether-element-attached-bottom.tether-element-attached-right.tether-target-attached-top .drop-content
margin-bottom: $arrowSize

&:before
top: 100%
right: $arrowSize
border-top-color: $backgroundColor

// Side corners
&.tether-element-attached-top.tether-element-attached-right.tether-target-attached-left .drop-content
margin-right: $arrowSize

&:before
top: $arrowSize
left: 100%
border-left-color: $backgroundColor

&.tether-element-attached-top.tether-element-attached-left.tether-target-attached-right .drop-content
margin-left: $arrowSize

&:before
top: $arrowSize
right: 100%
border-right-color: $backgroundColor

&.tether-element-attached-bottom.tether-element-attached-right.tether-target-attached-left .drop-content
margin-right: $arrowSize

&:before
bottom: $arrowSize
left: 100%
border-left-color: $backgroundColor

&.tether-element-attached-bottom.tether-element-attached-left.tether-target-attached-right .drop-content
margin-left: $arrowSize

&:before
bottom: $arrowSize
right: 100%
border-right-color: $backgroundColor
+drop-theme-arrows($themePrefix: $themePrefix, $tetherThemePrefx: $tetherThemePrefx, $arrowSize: $arrowSize, $backgroundColor: $backgroundColor, $color: $color, $useDropShadow: $useDropShadow)
136 changes: 136 additions & 0 deletions sass/helpers/_drop-theme-arrows.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
@import compass/css3
@import compass/utilities/general/clearfix

=drop-theme-arrows($themePrefix: "drop", $tetherThemePrefx: "tether", $arrowSize: 16px, $backgroundColor: #fff, $color: inherit, $useDropShadow: false) // TODO -- make $tetherThemePrefx the same as $themePrefix once Zack does the coffeescript prefixer thing
.drop.#{ $themePrefix }-theme-arrows
max-width: 100%
max-height: 100%

.#{ $themePrefix }-content
+border-radius(5px)
position: relative
font-family: inherit
background: $backgroundColor
color: $color
padding: 1em
font-size: 1.1em
line-height: 1.5em

@if $useDropShadow
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .2))

&:before
content: ""
display: block
position: absolute
width: 0
height: 0
border-color: transparent
border-width: $arrowSize
border-style: solid

// Centers and middles
&.#{ $tetherThemePrefx }-element-attached-bottom.#{ $tetherThemePrefx }-element-attached-center .#{ $themePrefix }-content
margin-bottom: $arrowSize

&:before
top: 100%
left: 50%
margin-left: - $arrowSize
border-top-color: $backgroundColor

&.#{ $tetherThemePrefx }-element-attached-top.#{ $tetherThemePrefx }-element-attached-center .#{ $themePrefix }-content
margin-top: $arrowSize

&:before
bottom: 100%
left: 50%
margin-left: - $arrowSize
border-bottom-color: $backgroundColor

&.#{ $tetherThemePrefx }-element-attached-right.#{ $tetherThemePrefx }-element-attached-middle .#{ $themePrefix }-content
margin-right: $arrowSize

&:before
left: 100%
top: 50%
margin-top: - $arrowSize
border-left-color: $backgroundColor

&.#{ $tetherThemePrefx }-element-attached-left.#{ $tetherThemePrefx }-element-attached-middle .#{ $themePrefix }-content
margin-left: $arrowSize

&:before
right: 100%
top: 50%
margin-top: - $arrowSize
border-right-color: $backgroundColor

// Top and bottom corners
&.#{ $tetherThemePrefx }-element-attached-top.#{ $tetherThemePrefx }-element-attached-left.#{ $tetherThemePrefx }-target-attached-bottom .#{ $themePrefix }-content
margin-top: $arrowSize

&:before
bottom: 100%
left: $arrowSize
border-bottom-color: $backgroundColor

&.#{ $tetherThemePrefx }-element-attached-top.#{ $tetherThemePrefx }-element-attached-right.#{ $tetherThemePrefx }-target-attached-bottom .#{ $themePrefix }-content
margin-top: $arrowSize

&:before
bottom: 100%
right: $arrowSize
border-bottom-color: $backgroundColor

&.#{ $tetherThemePrefx }-element-attached-bottom.#{ $tetherThemePrefx }-element-attached-left.#{ $tetherThemePrefx }-target-attached-top .#{ $themePrefix }-content
margin-bottom: $arrowSize

&:before
top: 100%
left: $arrowSize
border-top-color: $backgroundColor

&.#{ $tetherThemePrefx }-element-attached-bottom.#{ $tetherThemePrefx }-element-attached-right.#{ $tetherThemePrefx }-target-attached-top .#{ $themePrefix }-content
margin-bottom: $arrowSize

&:before
top: 100%
right: $arrowSize
border-top-color: $backgroundColor

// Side corners
&.#{ $tetherThemePrefx }-element-attached-top.#{ $tetherThemePrefx }-element-attached-right.#{ $tetherThemePrefx }-target-attached-left .#{ $themePrefix }-content
margin-right: $arrowSize

&:before
top: $arrowSize
left: 100%
border-left-color: $backgroundColor

&.#{ $tetherThemePrefx }-element-attached-top.#{ $tetherThemePrefx }-element-attached-left.#{ $tetherThemePrefx }-target-attached-right .#{ $themePrefix }-content
margin-left: $arrowSize

&:before
top: $arrowSize
right: 100%
border-right-color: $backgroundColor

&.#{ $tetherThemePrefx }-element-attached-bottom.#{ $tetherThemePrefx }-element-attached-right.#{ $tetherThemePrefx }-target-attached-left .#{ $themePrefix }-content
margin-right: $arrowSize

&:before
bottom: $arrowSize
left: 100%
border-left-color: $backgroundColor

&.#{ $tetherThemePrefx }-element-attached-bottom.#{ $tetherThemePrefx }-element-attached-left.#{ $tetherThemePrefx }-target-attached-right .#{ $themePrefix }-content
margin-left: $arrowSize

&:before
bottom: $arrowSize
right: 100%
border-right-color: $backgroundColor

0 comments on commit 24104c9

Please sign in to comment.