gem_2345 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/gem_2345/import-once.rb +28 -0
- data/lib/gem_2345/import-once/activate.rb +20 -0
- data/lib/gem_2345/import-once/engine.rb +36 -0
- data/lib/gem_2345/import-once/importer.rb +81 -0
- data/lib/gem_2345/import-once/version.rb +5 -0
- data/lib/gem_2345/version.rb +1 -1
- data/stylesheets/_compass.scss +3 -0
- data/stylesheets/_lemonade.scss +38 -0
- data/stylesheets/compass/_configuration.scss +54 -0
- data/stylesheets/compass/_css3.scss +21 -0
- data/stylesheets/compass/_layout.scss +3 -0
- data/stylesheets/compass/_reset-legacy.scss +3 -0
- data/stylesheets/compass/_reset.scss +3 -0
- data/stylesheets/compass/_support.scss +447 -0
- data/stylesheets/compass/_typography.scss +4 -0
- data/stylesheets/compass/_utilities.scss +9 -0
- data/stylesheets/compass/css3/_animation.scss +122 -0
- data/stylesheets/compass/css3/_appearance.scss +17 -0
- data/stylesheets/compass/css3/_background-clip.scss +35 -0
- data/stylesheets/compass/css3/_background-origin.scss +37 -0
- data/stylesheets/compass/css3/_background-size.scss +19 -0
- data/stylesheets/compass/css3/_border-radius.scss +107 -0
- data/stylesheets/compass/css3/_box-shadow.scss +88 -0
- data/stylesheets/compass/css3/_box-sizing.scss +21 -0
- data/stylesheets/compass/css3/_box.scss +85 -0
- data/stylesheets/compass/css3/_columns.scss +212 -0
- data/stylesheets/compass/css3/_deprecated-support.scss +272 -0
- data/stylesheets/compass/css3/_filter.scss +50 -0
- data/stylesheets/compass/css3/_flexbox.scss +156 -0
- data/stylesheets/compass/css3/_font-face.scss +48 -0
- data/stylesheets/compass/css3/_hyphenation.scss +71 -0
- data/stylesheets/compass/css3/_images.scss +152 -0
- data/stylesheets/compass/css3/_inline-block.scss +31 -0
- data/stylesheets/compass/css3/_opacity.scss +27 -0
- data/stylesheets/compass/css3/_pie.scss +1 -0
- data/stylesheets/compass/css3/_regions.scss +27 -0
- data/stylesheets/compass/css3/_selection.scss +59 -0
- data/stylesheets/compass/css3/_shared.scss +5 -0
- data/stylesheets/compass/css3/_text-shadow.scss +82 -0
- data/stylesheets/compass/css3/_transform.scss +590 -0
- data/stylesheets/compass/css3/_transition.scss +190 -0
- data/stylesheets/compass/css3/_user-interface.scss +71 -0
- data/stylesheets/compass/layout/_grid-background.scss +178 -0
- data/stylesheets/compass/layout/_sticky-footer.scss +23 -0
- data/stylesheets/compass/layout/_stretching.scss +24 -0
- data/stylesheets/compass/reset/_utilities-legacy.scss +135 -0
- data/stylesheets/compass/reset/_utilities.scss +142 -0
- data/stylesheets/compass/typography/_links.scss +3 -0
- data/stylesheets/compass/typography/_lists.scss +4 -0
- data/stylesheets/compass/typography/_text.scss +4 -0
- data/stylesheets/compass/typography/_units.scss +183 -0
- data/stylesheets/compass/typography/_vertical_rhythm.scss +300 -0
- data/stylesheets/compass/typography/links/_hover-link.scss +5 -0
- data/stylesheets/compass/typography/links/_link-colors.scss +28 -0
- data/stylesheets/compass/typography/links/_unstyled-link.scss +7 -0
- data/stylesheets/compass/typography/lists/_bullets.scss +34 -0
- data/stylesheets/compass/typography/lists/_horizontal-list.scss +63 -0
- data/stylesheets/compass/typography/lists/_inline-block-list.scss +50 -0
- data/stylesheets/compass/typography/lists/_inline-list.scss +47 -0
- data/stylesheets/compass/typography/text/_ellipsis.scss +25 -0
- data/stylesheets/compass/typography/text/_force-wrap.scss +12 -0
- data/stylesheets/compass/typography/text/_nowrap.scss +2 -0
- data/stylesheets/compass/typography/text/_replacement.scss +74 -0
- data/stylesheets/compass/utilities/_color.scss +1 -0
- data/stylesheets/compass/utilities/_general.scss +6 -0
- data/stylesheets/compass/utilities/_links.scss +5 -0
- data/stylesheets/compass/utilities/_lists.scss +6 -0
- data/stylesheets/compass/utilities/_print.scss +17 -0
- data/stylesheets/compass/utilities/_sass.scss +2 -0
- data/stylesheets/compass/utilities/_sprites.scss +2 -0
- data/stylesheets/compass/utilities/_tables.scss +3 -0
- data/stylesheets/compass/utilities/_text.scss +5 -0
- data/stylesheets/compass/utilities/color/_brightness.scss +20 -0
- data/stylesheets/compass/utilities/color/_contrast.scss +52 -0
- data/stylesheets/compass/utilities/general/_clearfix.scss +44 -0
- data/stylesheets/compass/utilities/general/_float.scss +38 -0
- data/stylesheets/compass/utilities/general/_hacks.scss +65 -0
- data/stylesheets/compass/utilities/general/_min.scss +16 -0
- data/stylesheets/compass/utilities/general/_reset.scss +2 -0
- data/stylesheets/compass/utilities/general/_tabs.scss +1 -0
- data/stylesheets/compass/utilities/general/_tag-cloud.scss +18 -0
- data/stylesheets/compass/utilities/links/_hover-link.scss +3 -0
- data/stylesheets/compass/utilities/links/_link-colors.scss +3 -0
- data/stylesheets/compass/utilities/links/_unstyled-link.scss +3 -0
- data/stylesheets/compass/utilities/lists/_bullets.scss +3 -0
- data/stylesheets/compass/utilities/lists/_horizontal-list.scss +3 -0
- data/stylesheets/compass/utilities/lists/_inline-block-list.scss +3 -0
- data/stylesheets/compass/utilities/lists/_inline-list.scss +3 -0
- data/stylesheets/compass/utilities/sass/_lists.scss +16 -0
- data/stylesheets/compass/utilities/sass/_maps.scss +19 -0
- data/stylesheets/compass/utilities/sprites/_base.scss +92 -0
- data/stylesheets/compass/utilities/sprites/_sprite-img.scss +81 -0
- data/stylesheets/compass/utilities/tables/_alternating-rows-and-columns.scss +22 -0
- data/stylesheets/compass/utilities/tables/_borders.scss +38 -0
- data/stylesheets/compass/utilities/tables/_scaffolding.scss +9 -0
- data/stylesheets/compass/utilities/text/_ellipsis.scss +3 -0
- data/stylesheets/compass/utilities/text/_nowrap.scss +3 -0
- data/stylesheets/compass/utilities/text/_replacement.scss +3 -0
- data/templates/ellipsis/ellipsis.sass +9 -0
- data/templates/ellipsis/manifest.rb +27 -0
- data/templates/ellipsis/xml/ellipsis.xml +14 -0
- data/templates/extension/manifest.rb +26 -0
- data/templates/extension/stylesheets/main.sass +1 -0
- data/templates/extension/templates/project/manifest.rb +2 -0
- data/templates/extension/templates/project/screen.sass +2 -0
- data/templates/project/USAGE.markdown +32 -0
- data/templates/project/ie.sass +6 -0
- data/templates/project/manifest.rb +4 -0
- data/templates/project/print.sass +6 -0
- data/templates/project/screen.sass +7 -0
- metadata +113 -10
- data/.gitignore +0 -14
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/README.md +0 -31
- data/Rakefile +0 -9
- data/gem_2345.gemspec +0 -25
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
// stretch element height to specified top and bottom position
|
|
3
|
+
|
|
4
|
+
@mixin stretch-y($offset-top:0, $offset-bottom:0) {
|
|
5
|
+
@include stretch($offset-top, false, $offset-bottom, false);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// stretch element width to specified left and right position
|
|
10
|
+
|
|
11
|
+
@mixin stretch-x($offset-left:0, $offset-right:0) {
|
|
12
|
+
@include stretch(false, $offset-right, false, $offset-left);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// shorthand to stretch element height and width
|
|
17
|
+
|
|
18
|
+
@mixin stretch($offset-top:0, $offset-right:0, $offset-bottom:0, $offset-left:0) {
|
|
19
|
+
position: absolute;
|
|
20
|
+
@if $offset-top { top: $offset-top; }
|
|
21
|
+
@if $offset-bottom { bottom: $offset-bottom; }
|
|
22
|
+
@if $offset-left { left: $offset-left; }
|
|
23
|
+
@if $offset-right { right: $offset-right; }
|
|
24
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Based on [Eric Meyer's reset](http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/)
|
|
2
|
+
// Global reset rules.
|
|
3
|
+
// For more specific resets, use the reset mixins provided below
|
|
4
|
+
//
|
|
5
|
+
// *Please Note*: tables still need `cellspacing="0"` in the markup.
|
|
6
|
+
@mixin global-reset {
|
|
7
|
+
html, body, div, span, applet, object, iframe,
|
|
8
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
|
9
|
+
a, abbr, acronym, address, big, cite, code,
|
|
10
|
+
del, dfn, em, font, img, ins, kbd, q, s, samp,
|
|
11
|
+
small, strike, strong, sub, sup, tt, var,
|
|
12
|
+
dl, dt, dd, ol, ul, li,
|
|
13
|
+
fieldset, form, label, legend,
|
|
14
|
+
table, caption, tbody, tfoot, thead, tr, th, td {
|
|
15
|
+
@include reset-box-model;
|
|
16
|
+
@include reset-font; }
|
|
17
|
+
body {
|
|
18
|
+
@include reset-body; }
|
|
19
|
+
ol, ul {
|
|
20
|
+
@include reset-list-style; }
|
|
21
|
+
table {
|
|
22
|
+
@include reset-table; }
|
|
23
|
+
caption, th, td {
|
|
24
|
+
@include reset-table-cell; }
|
|
25
|
+
q, blockquote {
|
|
26
|
+
@include reset-quotation; }
|
|
27
|
+
a img {
|
|
28
|
+
@include reset-image-anchor-border; } }
|
|
29
|
+
|
|
30
|
+
// Reset all elements within some selector scope. To reset the selector itself,
|
|
31
|
+
// mixin the appropriate reset mixin for that element type as well. This could be
|
|
32
|
+
// useful if you want to style a part of your page in a dramatically different way.
|
|
33
|
+
//
|
|
34
|
+
// *Please Note*: tables still need `cellspacing="0"` in the markup.
|
|
35
|
+
@mixin nested-reset {
|
|
36
|
+
div, span, object, iframe, h1, h2, h3, h4, h5, h6, p,
|
|
37
|
+
pre, a, abbr, acronym, address, code, del, dfn, em, img,
|
|
38
|
+
dl, dt, dd, ol, ul, li, fieldset, form, label, legend, caption, tbody, tfoot, thead, tr {
|
|
39
|
+
@include reset-box-model;
|
|
40
|
+
@include reset-font; }
|
|
41
|
+
table {
|
|
42
|
+
@include reset-table; }
|
|
43
|
+
caption, th, td {
|
|
44
|
+
@include reset-table-cell; }
|
|
45
|
+
q, blockquote {
|
|
46
|
+
@include reset-quotation; }
|
|
47
|
+
a img {
|
|
48
|
+
@include reset-image-anchor-border; } }
|
|
49
|
+
|
|
50
|
+
// Reset the box model measurements.
|
|
51
|
+
@mixin reset-box-model {
|
|
52
|
+
margin: 0;
|
|
53
|
+
padding: 0;
|
|
54
|
+
border: 0;
|
|
55
|
+
outline: 0; }
|
|
56
|
+
|
|
57
|
+
// Reset the font and vertical alignment.
|
|
58
|
+
@mixin reset-font {
|
|
59
|
+
font: {
|
|
60
|
+
weight: inherit;
|
|
61
|
+
style: inherit;
|
|
62
|
+
size: 100%;
|
|
63
|
+
family: inherit; };
|
|
64
|
+
vertical-align: baseline; }
|
|
65
|
+
|
|
66
|
+
// Resets the outline when focus.
|
|
67
|
+
// For accessibility you need to apply some styling in its place.
|
|
68
|
+
@mixin reset-focus {
|
|
69
|
+
outline: 0; }
|
|
70
|
+
|
|
71
|
+
// Reset a body element.
|
|
72
|
+
@mixin reset-body {
|
|
73
|
+
line-height: 1;
|
|
74
|
+
color: black;
|
|
75
|
+
background: white; }
|
|
76
|
+
|
|
77
|
+
// Reset the list style of an element.
|
|
78
|
+
@mixin reset-list-style {
|
|
79
|
+
list-style: none; }
|
|
80
|
+
|
|
81
|
+
// Reset a table
|
|
82
|
+
@mixin reset-table {
|
|
83
|
+
border-collapse: separate;
|
|
84
|
+
border-spacing: 0;
|
|
85
|
+
vertical-align: middle; }
|
|
86
|
+
|
|
87
|
+
// Reset a table cell (`th`, `td`)
|
|
88
|
+
@mixin reset-table-cell {
|
|
89
|
+
text-align: left;
|
|
90
|
+
font-weight: normal;
|
|
91
|
+
vertical-align: middle; }
|
|
92
|
+
|
|
93
|
+
// Reset a quotation (`q`, `blockquote`)
|
|
94
|
+
@mixin reset-quotation {
|
|
95
|
+
quotes: "" "";
|
|
96
|
+
&:before, &:after {
|
|
97
|
+
content: ""; } }
|
|
98
|
+
|
|
99
|
+
// Resets the border.
|
|
100
|
+
@mixin reset-image-anchor-border {
|
|
101
|
+
border: none; }
|
|
102
|
+
|
|
103
|
+
// Unrecognized elements are displayed inline.
|
|
104
|
+
// This reset provides a basic reset for html5 elements
|
|
105
|
+
// so they are rendered correctly in browsers that don't recognize them
|
|
106
|
+
// and reset in browsers that have default styles for them.
|
|
107
|
+
@mixin reset-html5 {
|
|
108
|
+
#{elements-of-type(html5-block)} {
|
|
109
|
+
@include reset-box-model;
|
|
110
|
+
display: block; } }
|
|
111
|
+
|
|
112
|
+
// Resets the display of inline and block elements to their default display
|
|
113
|
+
// according to their tag type. Elements that have a default display that varies across
|
|
114
|
+
// versions of html or browser are not handled here, but this covers the 90% use case.
|
|
115
|
+
// Usage Example:
|
|
116
|
+
//
|
|
117
|
+
// // Turn off the display for both of these classes
|
|
118
|
+
// .unregistered-only, .registered-only
|
|
119
|
+
// display: none
|
|
120
|
+
// // Now turn only one of them back on depending on some other context.
|
|
121
|
+
// body.registered
|
|
122
|
+
// +reset-display(".registered-only")
|
|
123
|
+
// body.unregistered
|
|
124
|
+
// +reset-display(".unregistered-only")
|
|
125
|
+
@mixin reset-display($selector: "", $important: false) {
|
|
126
|
+
#{append-selector(elements-of-type("inline"), $selector)} {
|
|
127
|
+
@if $important {
|
|
128
|
+
display: inline !important; }
|
|
129
|
+
@else {
|
|
130
|
+
display: inline; } }
|
|
131
|
+
#{append-selector(elements-of-type("block"), $selector)} {
|
|
132
|
+
@if $important {
|
|
133
|
+
display: block !important; }
|
|
134
|
+
@else {
|
|
135
|
+
display: block; } } }
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// Based on [Eric Meyer's reset 2.0](http://meyerweb.com/eric/tools/css/reset/index.html)
|
|
2
|
+
// Global reset rules.
|
|
3
|
+
// For more specific resets, use the reset mixins provided below
|
|
4
|
+
@mixin global-reset {
|
|
5
|
+
html, body, div, span, applet, object, iframe,
|
|
6
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
|
7
|
+
a, abbr, acronym, address, big, cite, code,
|
|
8
|
+
del, dfn, em, img, ins, kbd, q, s, samp,
|
|
9
|
+
small, strike, strong, sub, sup, tt, var,
|
|
10
|
+
b, u, i, center,
|
|
11
|
+
dl, dt, dd, ol, ul, li,
|
|
12
|
+
fieldset, form, label, legend,
|
|
13
|
+
table, caption, tbody, tfoot, thead, tr, th, td,
|
|
14
|
+
article, aside, canvas, details, embed,
|
|
15
|
+
figure, figcaption, footer, header, hgroup,
|
|
16
|
+
menu, nav, output, ruby, section, summary,
|
|
17
|
+
time, mark, audio, video {
|
|
18
|
+
@include reset-box-model;
|
|
19
|
+
@include reset-font; }
|
|
20
|
+
// Unlike Eric's original reset, we reset the html element to be compatible
|
|
21
|
+
// with the vertical rhythm mixins.
|
|
22
|
+
html {
|
|
23
|
+
@include reset-body; }
|
|
24
|
+
ol, ul {
|
|
25
|
+
@include reset-list-style; }
|
|
26
|
+
table {
|
|
27
|
+
@include reset-table; }
|
|
28
|
+
caption, th, td {
|
|
29
|
+
@include reset-table-cell; }
|
|
30
|
+
q, blockquote {
|
|
31
|
+
@include reset-quotation; }
|
|
32
|
+
a img {
|
|
33
|
+
@include reset-image-anchor-border; }
|
|
34
|
+
@include reset-html5; }
|
|
35
|
+
|
|
36
|
+
// Reset all elements within some selector scope. To reset the selector itself,
|
|
37
|
+
// mixin the appropriate reset mixin for that element type as well. This could be
|
|
38
|
+
// useful if you want to style a part of your page in a dramatically different way.
|
|
39
|
+
@mixin nested-reset {
|
|
40
|
+
div, span, applet, object, iframe,
|
|
41
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
|
42
|
+
a, abbr, acronym, address, big, cite, code,
|
|
43
|
+
del, dfn, em, img, ins, kbd, q, s, samp,
|
|
44
|
+
small, strike, strong, sub, sup, tt, var,
|
|
45
|
+
b, u, i, center,
|
|
46
|
+
dl, dt, dd, ol, ul, li,
|
|
47
|
+
fieldset, form, label, legend,
|
|
48
|
+
table, caption, tbody, tfoot, thead, tr, th, td,
|
|
49
|
+
article, aside, canvas, details, embed,
|
|
50
|
+
figure, figcaption, footer, header, hgroup,
|
|
51
|
+
menu, nav, output, ruby, section, summary,
|
|
52
|
+
time, mark, audio, video {
|
|
53
|
+
@include reset-box-model;
|
|
54
|
+
@include reset-font; }
|
|
55
|
+
table {
|
|
56
|
+
@include reset-table; }
|
|
57
|
+
caption, th, td {
|
|
58
|
+
@include reset-table-cell; }
|
|
59
|
+
q, blockquote {
|
|
60
|
+
@include reset-quotation; }
|
|
61
|
+
a img {
|
|
62
|
+
@include reset-image-anchor-border; } }
|
|
63
|
+
|
|
64
|
+
// Reset the box model measurements.
|
|
65
|
+
@mixin reset-box-model {
|
|
66
|
+
margin: 0;
|
|
67
|
+
padding: 0;
|
|
68
|
+
border: 0; }
|
|
69
|
+
|
|
70
|
+
// Reset the font and vertical alignment.
|
|
71
|
+
@mixin reset-font {
|
|
72
|
+
font: inherit;
|
|
73
|
+
font-size: 100%;
|
|
74
|
+
vertical-align: baseline; }
|
|
75
|
+
|
|
76
|
+
// Resets the outline when focus.
|
|
77
|
+
// For accessibility you need to apply some styling in its place.
|
|
78
|
+
@mixin reset-focus {
|
|
79
|
+
outline: 0; }
|
|
80
|
+
|
|
81
|
+
// Reset a body element.
|
|
82
|
+
@mixin reset-body {
|
|
83
|
+
line-height: 1; }
|
|
84
|
+
|
|
85
|
+
// Reset the list style of an element.
|
|
86
|
+
@mixin reset-list-style {
|
|
87
|
+
list-style: none; }
|
|
88
|
+
|
|
89
|
+
// Reset a table
|
|
90
|
+
@mixin reset-table {
|
|
91
|
+
border-collapse: collapse;
|
|
92
|
+
border-spacing: 0; }
|
|
93
|
+
|
|
94
|
+
// Reset a table cell (`th`, `td`)
|
|
95
|
+
@mixin reset-table-cell {
|
|
96
|
+
text-align: left;
|
|
97
|
+
font-weight: normal;
|
|
98
|
+
vertical-align: middle; }
|
|
99
|
+
|
|
100
|
+
// Reset a quotation (`q`, `blockquote`)
|
|
101
|
+
@mixin reset-quotation {
|
|
102
|
+
quotes: none;
|
|
103
|
+
&:before, &:after {
|
|
104
|
+
content: "";
|
|
105
|
+
content: none; } }
|
|
106
|
+
|
|
107
|
+
// Resets the border.
|
|
108
|
+
@mixin reset-image-anchor-border {
|
|
109
|
+
border: none; }
|
|
110
|
+
|
|
111
|
+
// Unrecognized elements are displayed inline.
|
|
112
|
+
// This reset provides a basic reset for block html5 elements
|
|
113
|
+
// so they are rendered correctly in browsers that don't recognize them
|
|
114
|
+
// and reset in browsers that have default styles for them.
|
|
115
|
+
@mixin reset-html5 {
|
|
116
|
+
#{elements-of-type(html5-block)} {
|
|
117
|
+
display: block; } }
|
|
118
|
+
|
|
119
|
+
// Resets the display of inline and block elements to their default display
|
|
120
|
+
// according to their tag type. Elements that have a default display that varies across
|
|
121
|
+
// versions of html or browser are not handled here, but this covers the 90% use case.
|
|
122
|
+
// Usage Example:
|
|
123
|
+
//
|
|
124
|
+
// // Turn off the display for both of these classes
|
|
125
|
+
// .unregistered-only, .registered-only
|
|
126
|
+
// display: none
|
|
127
|
+
// // Now turn only one of them back on depending on some other context.
|
|
128
|
+
// body.registered
|
|
129
|
+
// +reset-display(".registered-only")
|
|
130
|
+
// body.unregistered
|
|
131
|
+
// +reset-display(".unregistered-only")
|
|
132
|
+
@mixin reset-display($selector: "", $important: false) {
|
|
133
|
+
#{append-selector(elements-of-type("inline"), $selector)} {
|
|
134
|
+
@if $important {
|
|
135
|
+
display: inline !important; }
|
|
136
|
+
@else {
|
|
137
|
+
display: inline; } }
|
|
138
|
+
#{append-selector(elements-of-type("block"), $selector)} {
|
|
139
|
+
@if $important {
|
|
140
|
+
display: block !important; }
|
|
141
|
+
@else {
|
|
142
|
+
display: block; } } }
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// @private Default font-size for all browsers
|
|
2
|
+
$browser-default-font-size: 16px;
|
|
3
|
+
|
|
4
|
+
// Base font size in pixels, if not already defined.
|
|
5
|
+
// Should be the same as the font-size of the html element.
|
|
6
|
+
$base-font-size: 16px !default;
|
|
7
|
+
|
|
8
|
+
// Whether to output fallback values in px when outputting rems.
|
|
9
|
+
$rem-with-px-fallback: true !default;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// Convert any CSS <length> or <percentage> value to any another.
|
|
13
|
+
//
|
|
14
|
+
// @param $length
|
|
15
|
+
// A css <length> or <percentage> value
|
|
16
|
+
//
|
|
17
|
+
// @param $to-unit
|
|
18
|
+
// String matching a css unit keyword, e.g. 'em', '%', etc.
|
|
19
|
+
//
|
|
20
|
+
// @param $from-context
|
|
21
|
+
// When converting from relative units, the absolute length (in px) to
|
|
22
|
+
// which $length refers (e.g. for $lengths in em units, would normally be the
|
|
23
|
+
// font-size of the current element).
|
|
24
|
+
//
|
|
25
|
+
// @param $to-context
|
|
26
|
+
// For converting to relative units, the absolute length in px to which the
|
|
27
|
+
// output value will refer. Defaults to the same as $from-context, since it is
|
|
28
|
+
// rarely needed.
|
|
29
|
+
@function convert-length(
|
|
30
|
+
$length,
|
|
31
|
+
$to-unit,
|
|
32
|
+
$from-context: $base-font-size,
|
|
33
|
+
$to-context: $from-context
|
|
34
|
+
) {
|
|
35
|
+
|
|
36
|
+
$from-unit: unit($length);
|
|
37
|
+
|
|
38
|
+
// Optimize for cases where `from` and `to` units are accidentally the same.
|
|
39
|
+
@if $from-unit == $to-unit { @return $length; }
|
|
40
|
+
|
|
41
|
+
// Context values must be in px so we can determine a conversion ratio for
|
|
42
|
+
// relative units.
|
|
43
|
+
@if unit($from-context) != 'px' { @warn "Paremeter $from-context must resolve to a value in pixel units."; }
|
|
44
|
+
@if unit($to-context) != 'px' { @warn "Parameter $to-context must resolve to a value in pixel units."; }
|
|
45
|
+
|
|
46
|
+
// Convert input length to pixels
|
|
47
|
+
$px-length: $length;
|
|
48
|
+
|
|
49
|
+
@if $from-unit != 'px' {
|
|
50
|
+
// Convert relative units using the from-context parameter.
|
|
51
|
+
@if $from-unit == 'em' { $px-length: $length * $from-context / 1em }
|
|
52
|
+
@else if $from-unit == 'rem' { $px-length: $length * $base-font-size / 1rem }
|
|
53
|
+
@else if $from-unit == '%' { $px-length: $length * $from-context / 100% }
|
|
54
|
+
@else if $from-unit == 'ex' { $px-length: $length * $from-context / 2ex }
|
|
55
|
+
// Convert absolute units using Sass' conversion table.
|
|
56
|
+
@else if $from-unit == 'in' or
|
|
57
|
+
$from-unit == 'mm' or
|
|
58
|
+
$from-unit == 'cm' or
|
|
59
|
+
$from-unit == 'pt' or
|
|
60
|
+
$from-unit == 'pc' { $px-length: 0px + $length }
|
|
61
|
+
// Certain units can't be converted.
|
|
62
|
+
@else if $from-unit == 'ch' or
|
|
63
|
+
$from-unit == 'vw' or
|
|
64
|
+
$from-unit == 'vh' or
|
|
65
|
+
$from-unit == 'vmin' {
|
|
66
|
+
@warn "#{$from-unit} units can't be reliably converted; Returning original value.";
|
|
67
|
+
@return $length;
|
|
68
|
+
}
|
|
69
|
+
@else {
|
|
70
|
+
@warn "#{$from-unit} is an unknown length unit. Returning original value.";
|
|
71
|
+
@return $length;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Convert length in pixels to the output unit
|
|
76
|
+
$output-length: $px-length;
|
|
77
|
+
@if $to-unit != 'px' {
|
|
78
|
+
// Relative units
|
|
79
|
+
@if $to-unit == 'em' { $output-length: $px-length * 1em / $to-context }
|
|
80
|
+
@else if $to-unit == 'rem' { $output-length: $px-length * 1rem / $base-font-size }
|
|
81
|
+
@else if $to-unit == '%' { $output-length: $px-length * 100% / $to-context }
|
|
82
|
+
@else if $to-unit == 'ex' { $output-length: $px-length * 2ex / $to-context }
|
|
83
|
+
// Absolute units
|
|
84
|
+
@else if $to-unit == 'in' { $output-length: 0in + $px-length }
|
|
85
|
+
@else if $to-unit == 'mm' { $output-length: 0mm + $px-length }
|
|
86
|
+
@else if $to-unit == 'cm' { $output-length: 0cm + $px-length }
|
|
87
|
+
@else if $to-unit == 'pt' { $output-length: 0pt + $px-length }
|
|
88
|
+
@else if $to-unit == 'pc' { $output-length: 0pc + $px-length }
|
|
89
|
+
// Non-convertible units
|
|
90
|
+
@else if $to-unit == 'ch' or
|
|
91
|
+
$to-unit == 'vw' or
|
|
92
|
+
$to-unit == 'vh' or
|
|
93
|
+
$to-unit == 'vmin' {
|
|
94
|
+
@warn "#{$to-unit} units can't be reliably converted; Returning original value.";
|
|
95
|
+
@return $length;
|
|
96
|
+
}
|
|
97
|
+
@else {
|
|
98
|
+
@warn "#{$to-unit} is an unknown length unit. Returning original value.";
|
|
99
|
+
@return $length;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@return $output-length;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
// @private Get the px/rem versions of a value.
|
|
108
|
+
@function rem-fallback-values($value) {
|
|
109
|
+
$_return: (
|
|
110
|
+
px: $value,
|
|
111
|
+
rem: $value,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
@if type-of($value) == number and not unitless($value) {
|
|
115
|
+
@if unit($value) == rem {
|
|
116
|
+
$_return: map-merge($_return, (
|
|
117
|
+
px: round(convert-length($value, px)),
|
|
118
|
+
));
|
|
119
|
+
} @else if unit($value) == px {
|
|
120
|
+
$_return: map-merge($_return, (
|
|
121
|
+
px: round($value),
|
|
122
|
+
rem: convert-length($value, rem),
|
|
123
|
+
));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@return $_return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// @private Get the px/rem versions of a list (or nested lists).
|
|
131
|
+
@function list-convert-rems($value) {
|
|
132
|
+
$_empty: (
|
|
133
|
+
px: (),
|
|
134
|
+
rem: (),
|
|
135
|
+
);
|
|
136
|
+
$_return: $_empty;
|
|
137
|
+
$_sep: null;
|
|
138
|
+
|
|
139
|
+
@if type-of($value) == list {
|
|
140
|
+
$_sep: list-separator($value);
|
|
141
|
+
@each $sub in $value {
|
|
142
|
+
$_this: list-convert-rems($sub);
|
|
143
|
+
$_return: (
|
|
144
|
+
px: append(map-get($_return, px), map-get($_this, px), $_sep),
|
|
145
|
+
rem: append(map-get($_return, rem), map-get($_this, rem), $_sep),
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
} @else {
|
|
149
|
+
$_this: rem-fallback-values($value);
|
|
150
|
+
$_return: map-merge($_return, $_this);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@return $_return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
// Output a given style rule containing rem values along with an (optional)
|
|
158
|
+
// fallback rule for older browsers (with rem values converted to px).
|
|
159
|
+
//
|
|
160
|
+
// @param $property
|
|
161
|
+
// The css property name.
|
|
162
|
+
//
|
|
163
|
+
// @param $values
|
|
164
|
+
// The value or list of values for the property.
|
|
165
|
+
//
|
|
166
|
+
// @param $use-px-fallback
|
|
167
|
+
// [ true | false ]
|
|
168
|
+
//
|
|
169
|
+
@mixin rem($property, $values, $use-px-fallback: $rem-with-px-fallback) {
|
|
170
|
+
|
|
171
|
+
// get converted values.
|
|
172
|
+
$values: list-convert-rems($values);
|
|
173
|
+
$px-values: map-get($values, px);
|
|
174
|
+
$values: map-get($values, rem);
|
|
175
|
+
|
|
176
|
+
// Use pixel fallback for browsers that don't understand rem units.
|
|
177
|
+
@if $use-px-fallback and $px-values != $values {
|
|
178
|
+
#{$property}: $px-values;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Use rem values for everyone else (overrides pixel values).
|
|
182
|
+
#{$property}: $values;
|
|
183
|
+
}
|