archetype-utilities 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Progressive Enhancement
3
+ *
4
+ * https://github.com/Snugug/toolkit/blob/master/compass/stylesheets/toolkit/_pe.scss
5
+ * http://snugug.com/musings/progressive-enhancement-code-pattern-using-sass-and-modernizr
6
+ */
7
+
8
+ /**
9
+ * Enhance With
10
+ *
11
+ * $feature: Modernizr feature (base CSS class name)
12
+ */
13
+ @mixin enhance-with($feature) {
14
+ .#{$feature} & {
15
+ @content;
16
+ }
17
+ }
18
+
19
+ /**
20
+ * Degrade From
21
+ *
22
+ * $feature: Modernizr feature (base CSS class name)
23
+ */
24
+ @mixin degrade-from($feature, $no-js: true) {
25
+ @if $feature == 'js' or not $no-js {
26
+ .no-#{$feature} & {
27
+ @content;
28
+ }
29
+ }
30
+ @else {
31
+ .no-#{$feature} &,
32
+ .no-js & {
33
+ @content;
34
+ }
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Progressive Enhancement Text Replace Mixin
40
+ *
41
+ * $png-path: The path to the pngs for the image sprite, including the *.png (just like normal image sprites)
42
+ * $sprite: The name of the sprite you want to use (this is the file name without extension)
43
+ * $inline-svg: Switches between a Base64 encoded SVG or a normal url() for the SVG. Default to true
44
+ * $with-dimensions: Switches between including dimensions (height/width for all and background-size for SVG) or not -
45
+ * defaults to true.
46
+ * $inline: Whether or not the containing selector is an inline element. Defaults to false.
47
+ */
48
+
49
+ @mixin replace-text-pe($img-path, $sprite, $inline-svg: true, $with-dimensions: true, $inline-element: false) {
50
+ // Map Out the Sprite
51
+ $png-path: $img-path + '/*.png';
52
+ $sprite-map: sprite-map($png-path);
53
+
54
+ // Build SVG file name
55
+ // $svg-file: str-replace('*.png', '#{$sprite}.svg', $png-path);
56
+ $svg-file: $img-path + '/#{$sprite}.svg';
57
+
58
+ // Default Sprite File
59
+ $sprite-file: '' !default;
60
+
61
+ @if $with-dimensions {
62
+ // Get Sprite File for Height/Width
63
+ $sprite-file: sprite-file($sprite-map, $sprite);
64
+
65
+ // Put the height/width of the image in
66
+ width: image-width($sprite-file);
67
+ height: image-height($sprite-file);
68
+ }
69
+
70
+ // Hide text. Use squish-text() if the element is inline
71
+ @if $inline-element {
72
+ @extend %replace-text-pe-squish;
73
+ }
74
+ @else {
75
+ @extend %replace-text-pe-hide;
76
+ }
77
+
78
+ // Enhance with SVG
79
+ @include enhance-with('svg') {
80
+ // Inline the SVG so that advanced browsers and future tech doesn't need the extra HTTP requests for the SVG
81
+ @if $inline-svg {
82
+ background-image: inline-image($svg-file);
83
+ }
84
+ @else {
85
+ background-image: image-url($svg-file);
86
+ }
87
+ // No repeating backgrounds, please
88
+ background-repeat: no-repeat;
89
+ // Set background size to ensure that our SVG is the right size.
90
+ @if $with-dimensions {
91
+ background-size: image-width($sprite-file) image-height($sprite-file);
92
+ }
93
+ }
94
+
95
+ // Degrade from SVG
96
+ @include degrade-from('svg') {
97
+ // Extend the Sprite Background
98
+ @extend %#{sprite-map-name($sprite-map)}-image-map;
99
+ // Call the Sprite'd image's position.
100
+ @include sprite($sprite-map, $sprite);
101
+ }
102
+ }
103
+
104
+ //////////////////////////////
105
+ /**
106
+ * Sprite Map Generator
107
+ *
108
+ * Need a custom mixin to create extendable classes classes for background image for sprites because dynamic mixin names don't work.
109
+ * $png-path: The path to the pngs for the image sprite, including the *.png (just like normal image sprites)
110
+ */
111
+ @mixin sprite-map-generator($img-path) {
112
+ $png-path: $img-path + '/*.png';
113
+ $png-path: sprite-map($png-path);
114
+ %#{sprite-map-name($png-path)}-image-map {
115
+ background: {
116
+ image: $png-path;
117
+ repeat: no-repeat;
118
+ }
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Extendable Class for Squish Text mixin
124
+ */
125
+ %replace-text-pe-squish {
126
+ @include squish-text();
127
+ }
128
+
129
+ /**
130
+ * Extendable Class for Hide Text mixin
131
+ */
132
+ %replace-text-pe-hide {
133
+ @include hide-text();
134
+ }
135
+
@@ -0,0 +1,12 @@
1
+ //compass stitch
2
+ //
3
+ // Adds URLs and abbreviations to the end of links in printed documents
4
+ //
5
+ @mixin append-content {
6
+ a:after {
7
+ content:" (" attr(href) ")";
8
+ }
9
+ abbr:after {
10
+ content: " (" attr(title) ")";
11
+ }
12
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Pseudo Elements
3
+ *
4
+ * https://github.com/ericam/accoutrement/blob/master/stylesheets/accoutrement/_pseudo-elements.scss
5
+ */
6
+
7
+ /**
8
+ * Before
9
+ *
10
+ * Add content before an element
11
+ *
12
+ * @include before($content)
13
+ * $content: The string to add before
14
+ */
15
+ @mixin before($content) {
16
+ &:before {
17
+ content: $content;
18
+ @content;
19
+ }
20
+ }
21
+
22
+ /**
23
+ * After
24
+ *
25
+ * Add content after an element
26
+ * @include after($content)
27
+ * $content: The string to add after
28
+ */
29
+ @mixin after($content) {
30
+ &:after {
31
+ content: $content;
32
+ @content;
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Wrap
38
+ *
39
+ * Wrap content before and after an element
40
+ *
41
+ * @include wrap($content)
42
+ * $content: The strings to add before and after
43
+ */
44
+ @mixin wrap-content($content: "“" "”") {
45
+ $content: if(length($content) < 2, $content $content, $content);
46
+ @include before(nth($content,1)) { @content; };
47
+ @include after(nth($content,2)) { @content; };
48
+ }
49
+
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Sass List Utilities
3
+ *
4
+ * https://github.com/ericam/accoutrement/blob/master/stylesheets/accoutrement/_sass-lists.scss
5
+ */
6
+
7
+
8
+ /**
9
+ * Return a list with items in reverse order
10
+ *
11
+ * reverse($list)
12
+ * $list: The list to reverse.
13
+ */
14
+ @function reverse($list) {
15
+ $l: length($list);
16
+ $reverse: compact();
17
+ @for $i from 0 to $l { $reverse: append($reverse,nth($list,$l - $i)); }
18
+ @return $reverse;
19
+ }
20
+
21
+ /**
22
+ * Return a list with all duplicates removed
23
+ *
24
+ * remove-duplicates($list)
25
+ * $list: The list to clean up
26
+ */
27
+ @function remove-duplicates($list) {
28
+ $clean: compact();
29
+ @each $item in $list {
30
+ @if not index($clean, $item) { $clean: append($clean, $item) }
31
+ }
32
+ @return $clean;
33
+ }
34
+
35
+ /**
36
+ * Return a list with specific items removed
37
+ *
38
+ * filter($list, $target)
39
+ * $list: The list to filter
40
+ * $target: An item to be removed from the list
41
+ */
42
+ @function filter($list, $target) {
43
+ $clean: compact();
44
+ @if index($list, $target) {
45
+ @each $item in $list {
46
+ $clean: if($item == $target, $clean, append($clean, $item));
47
+ }
48
+ } @else { $clean: $list; }
49
+ @return $clean;
50
+ }
51
+
@@ -0,0 +1,83 @@
1
+ /**
2
+ * CSS Triangles
3
+ *
4
+ */
5
+
6
+ /**
7
+ * Simple Triangle
8
+ *
9
+ * .example { @include simple-triangle(5px, #fff, bottom); }
10
+ */
11
+ @mixin simple-triangle($size, $color, $direction) {
12
+ content: "";
13
+ display: block;
14
+ width: 0;
15
+ height: 0;
16
+ border: solid $size;
17
+ @if ($direction == down) {
18
+ border-color: $color transparent transparent transparent;
19
+ }
20
+ @if ($direction == up) {
21
+ border-color: transparent transparent $color transparent;
22
+ }
23
+ @if ($direction == right) {
24
+ border-color: transparent transparent transparent $color;
25
+ }
26
+ @if ($direction == left) {
27
+ border-color: transparent $color transparent transparent;
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Triangles
33
+ *
34
+ * https://github.com/Snugug/toolkit/blob/master/compass/stylesheets/toolkit/_triangle.scss
35
+ */
36
+ @mixin triangle($color: #000, $height: 1em, $width: 1em, $angle: 0) {
37
+ @if unit($height) == "" or unit($height) == "%" {
38
+ @debug "in triangle #{$height} is not a compatable unit for height."
39
+ }
40
+ @if unit($width) == "" or unit($width) == "%" {
41
+ @debug "in triangle #{$width} is not a compatable unit for width."
42
+ }
43
+
44
+ // offset 45deg to make each side start at 0
45
+ $deg: $angle + 45;
46
+ // if units, remove units
47
+ @if unit($deg) == deg {
48
+ $deg: $deg / 1deg;
49
+ }
50
+ // shift to be on a scale from 0 to 90.
51
+ @while $deg > 90 {
52
+ $deg: $deg - 90;
53
+ }
54
+ @while $deg < 0 {
55
+ $deg: $deg + 90;
56
+ }
57
+ // Get a ratio of 90 to multiply by.
58
+ $deg: $deg / 90;
59
+
60
+ // make sure metrics are reset
61
+ display: block;
62
+ width: 0;
63
+ height: 0;
64
+ border: 0 solid transparent;
65
+
66
+ // run through sides
67
+ @if $angle <= 45 or $angle > 315 {
68
+ border-bottom-color: $color;
69
+ border-width: 0 ($width * abs($deg - 1)) $height ($width * $deg);
70
+ }
71
+ @if $angle > 45 and $angle <= 135 {
72
+ border-left-color: $color;
73
+ border-width: ($height * $deg) 0 ($height * abs($deg - 1)) $width;
74
+ }
75
+ @if $angle > 135 and $angle <= 225 {
76
+ border-top-color: $color;
77
+ border-width: $height ($width * $deg) 0 ($width * abs($deg - 1));
78
+ }
79
+ @if $angle > 225 and $angle <= 315 {
80
+ border-right-color: $color;
81
+ border-width: ($height * abs($deg - 1)) $width ($height * $deg) 0;
82
+ }
83
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Font-Face
3
+ *
4
+ * base on:
5
+ * https://github.com/thoughtbot/bourbon/blob/master/app/assets/stylesheets/css3/_font-face.scss
6
+ */
7
+ @mixin font-face($font-stack, $file-path, $weight: normal, $style: normal ) {
8
+ @font-face {
9
+ font-family: $font-stack;
10
+ src: url('#{$file-path}.eot');
11
+ src: url('#{$file-path}.eot?#iefix') format('embedded-opentype'),
12
+ url('#{$file-path}.woff') format('woff'),
13
+ url('#{$file-path}.ttf') format('truetype'),
14
+ url('#{$file-path}.svg##{$font-family}') format('svg');
15
+ font-weight: $font-weight;
16
+ font-style: $font-style;
17
+ }
18
+ }
19
+
20
+ /**
21
+ * Box Emboss
22
+ *
23
+ * example: .box{ @include box-emboss(0.8, 0.05); }
24
+ */
25
+ @mixin box-emboss($opacity, $opacity2){
26
+ box-shadow:white($opacity) 0 1px 0, inset black($opacity2) 0 1px 0;
27
+ }
28
+
29
+ /**
30
+ * Text Emboss (letterpress)
31
+ *
32
+ * makes the text more readable by providing a sharper separation between letters and background
33
+ * example: .letterpress { @include text-emboss(0.7); }
34
+ */
35
+ @mixin text-emboss($opacity){
36
+ text-shadow:white($opacity) 0 1px 0;
37
+ }
38
+
39
+ /**
40
+ * CSS Hyphens
41
+ *
42
+ * word wrapping for skinny boxes:
43
+ * http://trentwalton.com/2011/09/07/css-hyphenation
44
+ *
45
+ * $value: none | manual | auto
46
+ */
47
+ @mixin hyphen($value) {
48
+ -moz-hyphens: auto;
49
+ -ms-hyphens: auto;
50
+ -webkit-hyphens: auto;
51
+ hyphens: auto;
52
+ }
53
+
54
+ // Compass Stich
55
+ // Nicer text rendering in webkit and gecko
56
+ // @see http://www.aestheticallyloyal.com/public/optimize-legibility/
57
+ // @see http://files.christophzillgens.com/webkit-font-smoothing.html
58
+ //
59
+ @mixin improve-text-rendering {
60
+ text-rendering:optimizeLegibility;
61
+ -webkit-font-smoothing:antialiased;
62
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Units
3
+ *
4
+ */
5
+
6
+
7
+ /**
8
+ * Percentage
9
+ *
10
+ * calculate a percentage based on values independant of Susy
11
+ */
12
+ @function calc-percent($target, $container) {
13
+ @return $target / $container * 100%;
14
+ }
15
+
16
+ /**
17
+ * Ems
18
+ *
19
+ * calculate an em value based on values independant of Susy
20
+ */
21
+ @function calc-em($target, $container) {
22
+ @return $target / $container * 1em;
23
+ }
24
+
25
+ /**
26
+ * Convert to Ems
27
+ *
28
+ * convert given value to em units
29
+ */
30
+ @function convert-to-em($value) {
31
+ $unit: unit($value);
32
+
33
+ @if $unit == 'px' {
34
+ @return $value / $base-font-size * 1em;
35
+ }
36
+ @else if $unit == '%' {
37
+ @return $value / 100% * 1em;
38
+ }
39
+ @else if $unit == 'em' {
40
+ @return $value;
41
+ }
42
+ @else {
43
+ @return $value;
44
+ }
45
+ }
46
+
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: archetype-utilities
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sam Ashley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sass
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: compass
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.12.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.12.1
41
+ description: A collection of Sass mixins for Archetype
42
+ email:
43
+ - sam@kwaledesign.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/archetype-utilities.rb
49
+ - stylesheets/_archetype-utilities.scss
50
+ - stylesheets/archetype-utilities/_accessibility.scss
51
+ - stylesheets/archetype-utilities/_align.scss
52
+ - stylesheets/archetype-utilities/_clearfix.scss
53
+ - stylesheets/archetype-utilities/_helpers.scss
54
+ - stylesheets/archetype-utilities/_ie.scss
55
+ - stylesheets/archetype-utilities/_links.scss
56
+ - stylesheets/archetype-utilities/_lists.scss
57
+ - stylesheets/archetype-utilities/_media.scss
58
+ - stylesheets/archetype-utilities/_normalize.scss
59
+ - stylesheets/archetype-utilities/_pe.scss
60
+ - stylesheets/archetype-utilities/_print.scss
61
+ - stylesheets/archetype-utilities/_pseudo.scss
62
+ - stylesheets/archetype-utilities/_sass-lists.scss
63
+ - stylesheets/archetype-utilities/_triangles.scss
64
+ - stylesheets/archetype-utilities/_typography.scss
65
+ - stylesheets/archetype-utilities/_units.scss
66
+ homepage: https://github.com/kwaledesign/archetype-utilities
67
+ licenses: []
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.6
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.0.3
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: A collection of Sass mixins for Archetype
89
+ test_files: []