typeup 0.1.0

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/typeup.rb ADDED
@@ -0,0 +1,30 @@
1
+ # All gems that are required for this extension to work should go here.
2
+ # These are the requires you would normally put in your config.rb file
3
+ # By default, you should always included Compass. Do not include your
4
+ # extension.
5
+ require 'compass'
6
+
7
+ # This tells Compass what your Compass extension is called, and where to find
8
+ # its files
9
+ # Replace 'extension' with the name of your extension. Spaces allowed.
10
+ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
11
+ Compass::Frameworks.register('typeup', :path => extension_path)
12
+
13
+ # Version and date of version for your Compass extension.
14
+ # Replace Extension with the name of your extension
15
+ # Letters, numbers, and underscores only
16
+ # Version is a number. If a version contains alphas, it will be created as
17
+ # a prerelease version
18
+ # Date is in the form of YYYY-MM-DD
19
+ module TypeUp
20
+ VERSION = "0.1.0"
21
+ DATE = "2013-02-26"
22
+ end
23
+
24
+ # This is where any custom SassScript should be placed. The functions will be
25
+ # available on require of your extension without the need for users to import
26
+ # any partials. Uncomment below.
27
+
28
+ # module Sass::Script::Functions
29
+ #
30
+ # end
@@ -0,0 +1,182 @@
1
+ @import "typeup/settings";
2
+ @import "typeup/functions";
3
+ @import "modular-scale";
4
+
5
+ //-----------------------
6
+ //
7
+ // MIXINS
8
+ //
9
+ //-----------------------
10
+
11
+ @mixin typeup-body(
12
+ $fontSize: $fontSize,
13
+ $lineLength: $lineLength,
14
+ $xHeight: $xHeight
15
+ ) {
16
+
17
+ // Convert everything to workable units.
18
+ // Input supports em and px for font size and line length,
19
+ // xHeight is unitless.
20
+ $fontSize: typeup-convertToEms($fontSize, $baseFontSize);
21
+
22
+ @if $pixelSnapBaseSize {
23
+ $fontSize: typeup-snapToPixel($fontSize);
24
+ }
25
+
26
+ // Note that when we're stripping units from $fontSize, it's been converted to ems
27
+ $lineLength: typeup-convertToEms($lineLength, $baseFontSize * strip-units($fontSize));
28
+ $xHeight: strip-units($xHeight);
29
+
30
+ $typeup-lineHeight: typeup-calcLineHeight($fontSize, $lineLength, $xHeight);
31
+
32
+ body {
33
+ line-height: $typeup-lineHeight;
34
+ font-size: $fontSize;
35
+ }
36
+
37
+ @include typeup($fontSize, $lineLength, $xHeight);
38
+
39
+ }
40
+
41
+ @mixin typeup-container(
42
+ $fontSize: $fontSize,
43
+ $lineLength: $lineLength,
44
+ $xHeight: $xHeight
45
+ ) {
46
+ // Convert everything to workable units.
47
+ // Input supports em and px for font size and line length,
48
+ // xHeight is unitless.
49
+ $fontSize: typeup-convertToEms($fontSize, $baseFontSize);
50
+
51
+ @if $pixelSnapBaseSize {
52
+ $fontSize: typeup-snapToPixel($fontSize);
53
+ }
54
+
55
+ // Note that when we're stripping units from $fontSize, it's been converted to ems
56
+ $lineLength: typeup-convertToEms($lineLength, $baseFontSize * strip-units($fontSize));
57
+ $xHeight: strip-units($xHeight);
58
+
59
+ $typeup-lineHeight: typeup-calcLineHeight($fontSize, $lineLength, $xHeight);
60
+
61
+ font-size:$fontSize;
62
+ line-height: $typeup-lineHeight;
63
+ width: $lineLength;
64
+
65
+ @include typeup($fontSize, $lineLength, $xHeight);
66
+
67
+ }
68
+
69
+ @mixin typeup(
70
+ $fontSize: $fontSize,
71
+ $lineLength: $lineLength,
72
+ $xHeight: $xHeight
73
+ ) {
74
+ $typeup-lineHeight: typeup-calcLineHeight($fontSize, $lineLength, $xHeight);
75
+ $base-size: $fontSize;
76
+
77
+ // Loop through heading tags
78
+
79
+ @for $i from 1 to 7 {
80
+ h#{$i} {
81
+
82
+ $modularNumber: $startModularScaleAt + 1 - $i;
83
+
84
+ @if $modularNumber < 0 {
85
+ $modularNumber: 0;
86
+ }
87
+
88
+ font-size: ms(#{$modularNumber});
89
+
90
+ @include typeup-spacer(
91
+ ms(#{$modularNumber}),
92
+
93
+ // These functions don't have any significant logic;
94
+ // they just fetch the correct variable.
95
+ $before: typeup-headingLinesBefore(h#{$i}),
96
+ $after: typeup-headingLinesAfter(h#{$i}),
97
+ $baselineShift: typeup-headingBaselineShift(h#{$i})
98
+ );
99
+ }
100
+
101
+ // Get the heading styles in a class,
102
+ // such as .heading1
103
+ @if $doubleStrandedHeadingClasses == true {
104
+ .heading#{$i} {
105
+ @extend h#{$i};
106
+ }
107
+ }
108
+ }
109
+
110
+ p, ul, ol, pre {
111
+ margin-top:0;
112
+ margin-bottom:$typeup-lineHeight;
113
+ }
114
+
115
+ ul, ol {
116
+ padding-left:$typeup-lineHeight;
117
+ }
118
+
119
+ pre {
120
+ padding:$typeup-lineHeight;
121
+
122
+ code {
123
+ line-height: $typeup-lineHeight;
124
+ }
125
+ }
126
+
127
+ blockquote {
128
+ padding: $typeup-lineHeight;
129
+ margin-top: $typeup-lineHeight;
130
+ margin-bottom:$typeup-lineHeight;
131
+
132
+ p:last-child {
133
+ margin-bottom:0;
134
+ }
135
+ }
136
+
137
+ }
138
+
139
+ @mixin typeup-spacer(
140
+ $size-in-ems,
141
+ $before: $headingLinesBefore,
142
+ $after: $headingLinesAfter,
143
+ $baselineShift: $headingBaselineShift,
144
+ $overrideSpacingWithBaseline: $overrideSpacingWithBaseline
145
+ ) {
146
+
147
+ @if $overrideSpacingWithBaseline == true {
148
+
149
+ // Here spacing is a multiple of the global typeup line-height
150
+
151
+ $adjust: 0em;
152
+
153
+ // If heading lineheight is not a full baseline height, adjust
154
+ @if (typeup-linesForFontSize($size-in-ems)/1em) % 1 == 0.5 {
155
+ $adjust: (($typeup-lineHeight/ $size-in-ems) / 2) * 1em;
156
+ }
157
+
158
+ margin-top:$before * ($typeup-lineHeight / $size-in-ems) * 1em + $adjust;
159
+ margin-bottom: $after * ($typeup-lineHeight / $size-in-ems) * 1em;
160
+
161
+ } @else {
162
+
163
+ // Here spacing is a multiple of the headings calculated line height.
164
+ // This is recommended.
165
+
166
+ // For example, a heading with an absolute line-height of 80px
167
+ // and a $before value of 2 will receive 160px of margin-top
168
+
169
+ margin-top: $before * typeup-linesForFontSize($size-in-ems) * ($typeup-lineHeight / $size-in-ems) * 1em;
170
+ margin-bottom: $after * typeup-linesForFontSize($size-in-ems) * ($typeup-lineHeight / $size-in-ems) * 1em;
171
+
172
+ }
173
+
174
+ @if $baselineShift > 0em {
175
+ position:relative;
176
+ top: 0em - $baselineShift;
177
+ }
178
+
179
+ line-height: ($typeup-lineHeight / $size-in-ems) * typeup-linesForFontSize($size-in-ems) * 1em;
180
+
181
+ }
182
+
@@ -0,0 +1,144 @@
1
+ @function strip-units($number) {
2
+ @return $number / ($number * 0 + 1);
3
+ }
4
+
5
+ // Check how many line-heights needed for font size. Can return half a baseline height.
6
+ @function typeup-linesForFontSize(
7
+ $font-size: $fontSize,
8
+ $lineHeight: $typeup-lineHeight
9
+ ) {
10
+
11
+ $lines: ceil(2 * $font-size / $lineHeight) / 2;
12
+ @return $lines;
13
+ }
14
+
15
+ @function typeup-convertToEms($variable, $base) {
16
+ @if unit($variable) == "px" {
17
+ $variable: ($variable/$base) * 1em;
18
+ }
19
+
20
+ @return $variable;
21
+ }
22
+
23
+ // Snap to pixel and return as ems.
24
+ @function typeup-snapToPixel(
25
+ $unitToSnap,
26
+ $baseFontSize: $baseFontSize
27
+ ) {
28
+ $snappedPxValue: false;
29
+
30
+ @if unit($unitToSnap) == "px" {
31
+ $snappedPxValue: round($unitToSnap);
32
+ } @else if unit($unitToSnap) == "em" {
33
+ $snappedPxValue: round(($unitToSnap / 1em) * $baseFontSize);
34
+ } @else if unitless($unitToSnap) == true {
35
+ $snappedPxValue: round($unitToSnap * $baseFontSize);
36
+ }
37
+
38
+ $returnPxValue: typeup-convertToEms($snappedPxValue, $baseFontSize);
39
+
40
+ @return $returnPxValue;
41
+ }
42
+
43
+ @function typeup-calcLineHeight(
44
+ $fontSize: $fontSize,
45
+ $lineLength: $lineLength,
46
+ $xHeight: $xHeight,
47
+ $calcPower: $calcExponent
48
+ ) {
49
+
50
+ @if unit($fontSize) == "px" {
51
+ $fontSize: ($fontSize / $baseFontSize) * 1em;
52
+ }
53
+
54
+ /*
55
+ * Making the variables unitless.
56
+ *
57
+ */
58
+
59
+ $fontSizeUnitless: strip-units($fontSize);
60
+ $lineLengthUnitless: strip-units($lineLength);
61
+
62
+ // Calculate the proper line height.
63
+ $lineHeightUnitless: pow(($lineLengthUnitless * 0.036), $calcPower) * $xHeight + 0.3;
64
+
65
+ @if $lineHeightUnitless < $minimumLineHeight {
66
+ $lineHeightUnitless: $minimumLineHeight;
67
+ }
68
+
69
+ /*
70
+ * Moving on to pixel snapping. We don't want a line-height of 24.334571px (for example),
71
+ * we want it nicely at 24px.
72
+ */
73
+
74
+ // Rounding the line height to nearest pixel
75
+ $snappedLineHeight: typeup-snapToPixel($lineHeightUnitless * $fontSizeUnitless) / $fontSizeUnitless;
76
+
77
+ @return $snappedLineHeight;
78
+ }
79
+
80
+
81
+ // Because Sass doesnt support interpolation
82
+ // inside variable names (only selectors),
83
+ // we're using some excellent code here.
84
+
85
+ @function typeup-headingLinesBefore($tag) {
86
+ @if $tag == h1 {
87
+ @return $h1LinesBefore;
88
+ }
89
+ @if $tag == h2 {
90
+ @return $h2LinesBefore;
91
+ }
92
+ @if $tag == h3 {
93
+ @return $h3LinesBefore;
94
+ }
95
+ @if $tag == h4 {
96
+ @return $h4LinesBefore;
97
+ }
98
+ @if $tag == h5 {
99
+ @return $h5LinesBefore;
100
+ }
101
+ @if $tag == h6 {
102
+ @return $h6LinesBefore;
103
+ }
104
+ }
105
+
106
+ @function typeup-headingLinesAfter($tag) {
107
+ @if $tag == h1 {
108
+ @return $h1LinesAfter;
109
+ }
110
+ @if $tag == h2 {
111
+ @return $h2LinesAfter;
112
+ }
113
+ @if $tag == h3 {
114
+ @return $h3LinesAfter;
115
+ }
116
+ @if $tag == h4 {
117
+ @return $h4LinesAfter;
118
+ }
119
+ @if $tag == h5 {
120
+ @return $h5LinesAfter;
121
+ }
122
+ @if $tag == h6 {
123
+ @return $h6LinesAfter; }
124
+ }
125
+
126
+ @function typeup-headingBaselineShift($tag) {
127
+ @if $tag == h1 {
128
+ @return $h1BaselineShift;
129
+ }
130
+ @if $tag == h2 {
131
+ @return $h2BaselineShift;
132
+ }
133
+ @if $tag == h3 {
134
+ @return $h3BaselineShift;
135
+ }
136
+ @if $tag == h4 {
137
+ @return $h4BaselineShift;
138
+ }
139
+ @if $tag == h5 {
140
+ @return $h5BaselineShift;
141
+ }
142
+ @if $tag == h6 {
143
+ @return $h6BaselineShift; }
144
+ }
@@ -0,0 +1,116 @@
1
+
2
+ //-----------------------
3
+ //
4
+ // MAIN SETTINGS
5
+ //
6
+ //-----------------------
7
+
8
+ // Base font size, in ems.
9
+ $fontSize: 1em !default;
10
+
11
+ // Container width. Final absolute width depends on font size.
12
+ $lineLength: 35em !default;
13
+
14
+ // This is a multiplier you can use to adjust line height,
15
+ // particularly for fonts with very high or low x-heights.
16
+ $xHeight:1 !default;
17
+
18
+ // The ratio scale that modular-scale will use.
19
+ $ratio: fourth() !default;
20
+
21
+ // This variable is for modular-scale, copied from fontSize.
22
+ $base-size: $fontSize;
23
+
24
+ // Unless you are overriding your browser base font size,
25
+ // there is no need to touch this.
26
+ $baseFontSize: 16px !default;
27
+
28
+ // If the base font size and font size dont result in
29
+ // a integer, snap it
30
+ $pixelSnapBaseSize: true !default;
31
+
32
+
33
+ $minimumLineHeight: 0.7 !default;
34
+
35
+
36
+
37
+ // Outputting this variable for use before applying
38
+ // typeup-container() or typeup-body() mixins
39
+ $typeup-lineHeight: typeup-calcLineHeight($fontSize, $lineLength, $xHeight) !default;
40
+
41
+ //-----------------------
42
+ //
43
+ // DETAILED SETTINGS
44
+ //
45
+ //-----------------------
46
+
47
+ // If true, will copy
48
+ // heading styles to a class
49
+ // like .heading1
50
+ $doubleStrandedHeadingClasses: false !default;
51
+
52
+ // H1 gets ms(4), h2 gets (ms3) and so on.
53
+ // Modular scale won't go below 0, though.
54
+ //
55
+ // So if you put in 2 here,
56
+ // h1 will get ms(2), h2 will get ms(1) and
57
+ // all the rest will get ms(0)
58
+ $startModularScaleAt: 4 !default;
59
+
60
+ // Using square root for line height calculation
61
+
62
+ $calcExponent: 1/2 !default;
63
+
64
+ //----------------------------------
65
+ // Heading spacing default settings
66
+ //----------------------------------
67
+
68
+ // This determines if headings have spacing relative to global
69
+ // (paragraph text) line height (=true), or the calculated line
70
+ // height of the heading (=false). False is recommended as it
71
+ // maintains a solid relative spacing when the headings line height
72
+ // is significantly larger or smaller than the global line height.
73
+ $overrideSpacingWithBaseline: false !default;
74
+
75
+ // How many line-heights of margin on top of heading
76
+ $headingLinesBefore: 1 !default;
77
+
78
+ // How many line-height of margin on bottom of heading
79
+ $headingLinesAfter: 0 !default;
80
+
81
+ // Amount of baseline-shift in em (relative to heading size)
82
+ $headingBaselineShift:0em !default;
83
+
84
+ //----------------------------------
85
+ // Heading spacing
86
+ //----------------------------------
87
+
88
+ // H1 Spacing settings
89
+ $h1LinesBefore: 1 !default;
90
+ $h1LinesAfter: $headingLinesAfter !default;
91
+ $h1BaselineShift: $headingBaselineShift !default;
92
+
93
+ // H2 Spacing settings
94
+ $h2LinesBefore: $headingLinesBefore !default;
95
+ $h2LinesAfter: $headingLinesAfter !default;
96
+ $h2BaselineShift: $headingBaselineShift !default;
97
+
98
+ // H3 Spacing settings
99
+ $h3LinesBefore: $headingLinesBefore !default;
100
+ $h3LinesAfter: $headingLinesAfter !default;
101
+ $h3BaselineShift: $headingBaselineShift !default;
102
+
103
+ // H4 Spacing settings
104
+ $h4LinesBefore: $headingLinesBefore !default;
105
+ $h4LinesAfter: $headingLinesAfter !default;
106
+ $h4BaselineShift: $headingBaselineShift !default;
107
+
108
+ // H5 Spacing settings
109
+ $h5LinesBefore: $headingLinesBefore !default;
110
+ $h5LinesAfter: $headingLinesAfter !default;
111
+ $h5BaselineShift: $headingBaselineShift !default;
112
+
113
+ // H6 Spacing settings
114
+ $h6LinesBefore: $headingLinesBefore !default;
115
+ $h6LinesAfter: $headingLinesAfter !default;
116
+ $h6BaselineShift: $headingBaselineShift !default;
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typeup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tommi Kaikkonen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sass
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: compass
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.12.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.12.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: modular-scale
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.6
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.6
62
+ description: A Compass extension for quick typesetting
63
+ email:
64
+ - tommi@kaikkonendesign.fi
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - lib/typeup.rb
70
+ - stylesheets/_typeup.scss
71
+ - stylesheets/typeup/_settings.scss
72
+ - stylesheets/typeup/_functions.scss
73
+ homepage: http://tommikaikkonen.github.com/type-up/
74
+ licenses: []
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: 1.3.6
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 1.8.24
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: A typesetting system with great versatility and ease of use
97
+ test_files: []