3d-ribbon 0.1.1

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.
@@ -0,0 +1,230 @@
1
+ #3D CSS Ribbons
2
+
3
+ A extension (for [Compass](http://compass-style.org/)) to create 3D ribbons using only CSS.
4
+ **[Live example](http://jsfiddle.net/dzignus/LXJ7X/)**.
5
+
6
+ ![some nice example](http://static.tumblr.com/djfsbl4/N1qllypq4/ribbon_example.png)
7
+
8
+ The extension is inspired in [3D Ribbon Generator](http://www.css3d.net/ribbon-generator/).
9
+
10
+
11
+
12
+
13
+ #Installation
14
+
15
+ From the command line:
16
+
17
+ sudo gem install 3d-ribbon
18
+
19
+ Installing into an existing project:
20
+
21
+ # edit the project configuration file and add:
22
+ require '3d-ribbon'
23
+
24
+ #from the command line
25
+ compass install 3d-ribbon
26
+
27
+ #import the extension into your scss/sass file
28
+ @import "3d-ribbon"
29
+
30
+ Or create a new project:
31
+
32
+ compass create <project_name> -r 3d-ribbon --using 3d-ribbon
33
+
34
+ #import the extension into your scss/sass file
35
+ @import "3d-ribbon"
36
+
37
+
38
+
39
+
40
+ #Intro
41
+
42
+ The extension offer a simple and flexible way to create 3D ribbons with CSS.
43
+
44
+ Browser support:
45
+
46
+ * IE7+
47
+ * Firefox 3.5+
48
+ * Google Chrome
49
+ * Safari / Safari iOS
50
+
51
+ Note: In IE7/8, box-shadows and border-radius only using [CSS3 Pie](http://compass-style.org/reference/compass/css3/pie/).
52
+
53
+ ## First, in your HTML document:
54
+
55
+ This is the basic structure to create a ribbon with two sides (left / right):
56
+
57
+ <div id="ribbon-example-foo">
58
+
59
+ <!--start ribbon-->
60
+ <div class="ribbon-wrapper">
61
+ <div class="ribbon-front">
62
+
63
+ Here you can put some content (like "Lorem ipsum dolor sit amet...") or HTML elements
64
+
65
+ </div>
66
+ <div class="ribbon-edge-left-top"></div>
67
+ <div class="ribbon-edge-right-top"></div>
68
+ <div class="ribbon-edge-left-bottom"></div>
69
+ <div class="ribbon-edge-right-bottom"></div>
70
+ <div class="ribbon-back-left"></div>
71
+ <div class="ribbon-back-right"></div>
72
+ </div>
73
+ <!--end ribbon -->
74
+
75
+ </div>
76
+
77
+
78
+ If you need only one side in the ribbon, you can remove some `<div />`. For example, if you need a ribbon with only the right side, you can remove `<div class="ribbon-edge-left-top"></div>`, `<div class="ribbon-edge-left-bottom"></div>` and `<div class="ribbon-back-left"></div>`.
79
+
80
+
81
+ ## Then, in your Sass document:
82
+
83
+ **The simple way**:
84
+
85
+ #ribbon-example-foo{
86
+ @include ribbon($front-width: 400px);
87
+ }
88
+
89
+ **The flexible way (with all options)**:
90
+
91
+ #ribbon-example-foo{
92
+ @include ribbon(
93
+ $front-width: 750px,
94
+ $sides: left-bottom,
95
+ $ribbon-height: 40px,
96
+ $front-color: #80B5AD,
97
+ $edges-color: darken(#8ABD9A, 30%),
98
+ $back-color: #8DBF96,
99
+ $back-width: 30px,
100
+ $overlap-width: 35px,
101
+ $overlap-height: 15px,
102
+ $border-radius: 7px,
103
+ $include-pie: true);
104
+ }
105
+
106
+
107
+
108
+ #Settings:
109
+
110
+ ## $front-width:
111
+
112
+ The width of the ribbon content, in px. This is the only mandatory argument.
113
+
114
+
115
+ ## $sides:
116
+
117
+ The sides of the ribbon (left / right) and position (top / bottom). Options availables:
118
+
119
+ * `left-top`
120
+ * `left-bottom`
121
+ * `right-top`
122
+ * `right-bottom`
123
+
124
+ For example, is you want a ribbon with only one side (right) and orientation top:
125
+
126
+ @include ribbon($front-width: 450px, $sides: right-top);
127
+
128
+
129
+ Default value: `left-bottom right-bottom`.
130
+
131
+
132
+ ## $ribbon-height:
133
+
134
+ The height of the ribbon, in px. Default value: `40px`.
135
+
136
+
137
+ ## $front-color:
138
+
139
+ The color of the front of the ribbon. Default value: `#3A89CE`.
140
+
141
+
142
+ ## $edges-color:
143
+
144
+ The color of the edges of the ribbon. Default value: `darken($front-color, 30%)`.
145
+
146
+
147
+ ## $back-color:
148
+
149
+ The color of the back part of the ribbon. Default value: `$front-color`.
150
+
151
+
152
+ ## $back-width:
153
+
154
+ The width of the back part of the ribbon, in px. Default value: `40px`.
155
+
156
+
157
+ ## $overlap-width:
158
+
159
+ The width of the overlap of the ribbon, in px. Default value: `30px`.
160
+
161
+
162
+ ## $overlap-height:
163
+
164
+ The height of the overlap of the ribbon, in px. Default value: `20px`.
165
+
166
+
167
+ ## $border-radius:
168
+
169
+ Border radius of the back part of the ribbon. Default value: `0`.
170
+
171
+
172
+ ## $include-pie:
173
+
174
+ Support for CSS3 PIE (AKA: border-radius, box-shadow and others CSS3 styles for IE8/7/6). [More info](http://compass-style.org/reference/compass/css3/pie/). Remember set `$pie-behavior` with the path of the `PIE.htc` and deliver the file with the mime-type `Content-Type: text/x-component`.
175
+
176
+ Default value: `false`.
177
+
178
+
179
+
180
+
181
+ #Examples
182
+
183
+ The examples in action can be found in `templates/project/3d-ribbon-examples.html`.
184
+
185
+ #ribbon-example-1{
186
+ @include ribbon($front-width: 400px);
187
+ }
188
+
189
+ #ribbon-example-2{
190
+ @include ribbon($front-width: 450px, $sides: left-top right-bottom); //Asimetric ribbon!
191
+ }
192
+
193
+ #ribbon-example-3{
194
+ @include ribbon($front-width: 550px, $ribbon-height: 40px, $front-color: #8C46C3);
195
+ }
196
+
197
+ #ribbon-example-4{
198
+ @include ribbon($front-width: 600px, $front-color: #8C46C3, $edges-color: darken(#9F4BBA, 10%), $back-color: #B952AE);
199
+ }
200
+
201
+ #ribbon-example-5{
202
+ @include ribbon($front-width: 650px, $back-width: 20px, $overlap-width: 25px, $overlap-height: 10px);
203
+ }
204
+
205
+ #ribbon-example-6{
206
+ @include ribbon($front-width: 650px, $back-width: 0);
207
+ }
208
+
209
+ #ribbon-example-7{
210
+ @include ribbon($front-width: 700px, $border-radius: 5px);
211
+ }
212
+
213
+ #ribbon-example-8{
214
+ @include ribbon(
215
+ $front-width: 750px,
216
+ $sides: left-bottom,
217
+ $ribbon-height: 40px,
218
+ $front-color: #80B5AD,
219
+ $edges-color: darken(#8ABD9A, 30%),
220
+ $back-color: #8DBF96,
221
+ $back-width: 30px,
222
+ $overlap-width: 35px,
223
+ $overlap-height: 15px,
224
+ $border-radius: 7px,
225
+ $include-pie: true);
226
+ }
227
+
228
+
229
+
230
+
@@ -0,0 +1,3 @@
1
+ require 'compass'
2
+ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
3
+ Compass::Frameworks.register('3d-ribbon', :path => extension_path)
@@ -0,0 +1,250 @@
1
+ // 3D CSS Ribbon ------------------------------------------------------------
2
+ // Plugin by Leandro D'onofrio - http://dzign.us/
3
+
4
+
5
+ // Imports --------------------------------------------------------------------
6
+
7
+ @import "compass/css3/images";
8
+ @import "compass/css3/box-shadow";
9
+ @import "compass/css3/border-radius";
10
+ @import "compass/css3/pie";
11
+
12
+ //** 3D CSS Ribbon **//
13
+
14
+ //The real name was "3d-ribbon" but mixins can't start with a number...
15
+ @mixin ribbon(
16
+
17
+ // Set the sides of the ribbon
18
+ $sides : left-bottom right-bottom,
19
+
20
+ // Set the color of the ribbon
21
+ $front-color : #3A89CE,
22
+
23
+ // Set the color of the edges
24
+ $edges-color : darken($front-color, 30%),
25
+
26
+ // Set the color of the back sides
27
+ $back-color : $front-color,
28
+
29
+ // Set the width of the front
30
+ $front-width : 0,
31
+
32
+ // Set the height of the ribbon
33
+ $ribbon-height : 40px,
34
+
35
+ // Set the width of the back sides
36
+ $back-width : 40px,
37
+
38
+ // Set the width of the overlaps
39
+ $overlap-width : 30px,
40
+
41
+ // Set the height of the overlaps
42
+ $overlap-height : 20px,
43
+
44
+ // Set the distance of the overlaps
45
+ $overlap-distance : 0,
46
+
47
+ // Set the border radius of the back sides
48
+ $border-radius : 0,
49
+
50
+ //Support for CSS3 PIE - More info: http://compass-style.org/reference/compass/css3/pie/
51
+ $include-pie : false
52
+
53
+ ) {
54
+
55
+ //If include CSS3 PIE, don't repeat position: relative
56
+ $pie-default-approach : none;
57
+
58
+ //ribbon-wrapper
59
+ div.ribbon-wrapper {
60
+ height: ($ribbon-height + $overlap-height);
61
+ width: $front-width;
62
+ position: relative;
63
+ z-index: 3;
64
+
65
+ //Shadow only for bottom sides
66
+ @if ($overlap-distance == 0) and ($sides == (left-bottom right-bottom)) or ($sides == (right-bottom left-bottom)) {
67
+
68
+ background-position: 0 $ribbon-height;
69
+ @include background-image(linear-gradient(#555 0px, rgba(255, 255, 255, 0) $overlap-height));
70
+
71
+ }
72
+
73
+ }
74
+
75
+ //ribbon-front
76
+ div.ribbon-front {
77
+ width: ($front-width + ($overlap-width*length($sides)) + ($overlap-distance*length($sides)));
78
+ height: $ribbon-height;
79
+ background-color: $front-color;
80
+ position: relative;
81
+ z-index: 2;
82
+ @include box-shadow(rgba(0, 0, 0, 0.5) 0px 0px 4px);
83
+
84
+ @if ($sides == right-top) or ($sides == right-bottom) {
85
+
86
+ left: 0;
87
+
88
+ } @else {
89
+
90
+ left: -($overlap-width + $overlap-distance);
91
+
92
+ }
93
+
94
+ @if $include-pie == true {
95
+
96
+ @include pie;
97
+
98
+ }
99
+
100
+ }
101
+
102
+ //for each side
103
+ @each $position in (left right) {
104
+
105
+ //left side
106
+ @if ($position == left) and (($sides == left-top) or ($sides == left-bottom)) {
107
+
108
+ div.ribbon-edge-left-top,
109
+ div.ribbon-edge-left-bottom {
110
+ @include _ribbon-edge(left, $overlap-width, $overlap-distance);
111
+ }
112
+
113
+ div.ribbon-back-left {
114
+ @include _ribbon-back($back-width, $ribbon-height, $back-color, $border-radius, left, $overlap-distance, $include-pie);
115
+ }
116
+
117
+ //right side
118
+ } @else if ($position == right) and (($sides == right-top) or ($sides == right-bottom)) {
119
+
120
+ div.ribbon-edge-right-top,
121
+ div.ribbon-edge-right-bottom {
122
+ @include _ribbon-edge(right, $overlap-width, $overlap-distance);
123
+ }
124
+
125
+ div.ribbon-back-right {
126
+ @include _ribbon-back($back-width, $ribbon-height, $back-color, $border-radius, right, $overlap-distance, $include-pie);
127
+ }
128
+
129
+ //both sides
130
+ } @else if ($sides == (left-top right-top)) or ($sides == (left-bottom right-bottom)) or ($sides == (left-top right-bottom)) or ($sides == (left-bottom right-top)) or ($sides == (right-top left-top)) or ($sides == (right-bottom left-bottom)) or ($sides == (right-top left-bottom)) or ($sides == (right-bottom left-top)) {
131
+
132
+ div.ribbon-edge-#{$position}-top,
133
+ div.ribbon-edge-#{$position}-bottom {
134
+ @include _ribbon-edge(#{$position}, $overlap-width, $overlap-distance);
135
+ }
136
+
137
+ div.ribbon-back-#{$position} {
138
+ @include _ribbon-back($back-width, $ribbon-height, $back-color, $border-radius, #{$position}, $overlap-distance, $include-pie);
139
+ }
140
+
141
+ }
142
+
143
+ }
144
+
145
+ //for each selected side
146
+ @each $side in $sides {
147
+
148
+ //left-top side
149
+ @if $side == left-top {
150
+
151
+ div.ribbon-edge-left-top {
152
+ bottom: ($ribbon-height + $overlap-height);
153
+ border-width: $overlap-height $overlap-width 0 0;
154
+ border-color: transparent $edges-color transparent transparent;
155
+ }
156
+
157
+ div.ribbon-back-left {
158
+ top: -$overlap-height;
159
+ }
160
+
161
+ //left-bottom side
162
+ } @else if $side == left-bottom {
163
+
164
+ div.ribbon-edge-left-bottom {
165
+ top: $ribbon-height;
166
+ border-width: 0 $overlap-width $overlap-height 0;
167
+ border-color: transparent $edges-color transparent transparent;
168
+ }
169
+
170
+ div.ribbon-back-left {
171
+ top: $overlap-height;
172
+ }
173
+
174
+ //right-top side
175
+ } @else if $side == right-top {
176
+
177
+ div.ribbon-edge-right-top {
178
+ bottom: ($ribbon-height + $overlap-height);
179
+ border-width: 0 $overlap-width $overlap-height 0;
180
+ border-color: transparent transparent $edges-color transparent;
181
+ }
182
+
183
+ div.ribbon-back-right {
184
+ top: -$overlap-height;
185
+ }
186
+
187
+ //right-bottom side
188
+ } @else if $side == right-bottom {
189
+
190
+ div.ribbon-edge-right-bottom {
191
+ top: $ribbon-height;
192
+ border-width: $overlap-height $overlap-width 0 0;
193
+ border-color: $edges-color transparent transparent transparent;
194
+ }
195
+
196
+ div.ribbon-back-right {
197
+ top: $overlap-height;
198
+ }
199
+
200
+ }
201
+
202
+ }
203
+
204
+ }
205
+
206
+ //private mixins
207
+ @mixin _ribbon-edge($position, $overlap-width, $overlap-distance) {
208
+
209
+ height:0;
210
+ width:0;
211
+ position: absolute;
212
+ z-index: 1;
213
+ #{$position}: -($overlap-width + $overlap-distance);
214
+ border-style:solid;
215
+
216
+ }
217
+
218
+ @mixin _ribbon-back($back-width, $ribbon-height, $back-color, $border-radius, $position, $overlap-distance, $include-pie) {
219
+
220
+ width: $back-width;
221
+ height: $ribbon-height;
222
+ position: absolute;
223
+ z-index: 0;
224
+ @include box-shadow(rgba(0, 0, 0, 0.5) 0px 0px 4px);
225
+
226
+ @if $border-radius != 0 {
227
+
228
+ @if $position == left {
229
+
230
+ @include border-left-radius($border-radius);
231
+
232
+ } @else if $position == right {
233
+
234
+ @include border-right-radius($border-radius);
235
+
236
+ }
237
+
238
+ }
239
+
240
+ background-color: $back-color;
241
+ #{$position}: -($back-width + $overlap-distance);
242
+
243
+ @if $include-pie == true {
244
+
245
+ @include pie;
246
+
247
+ }
248
+
249
+ }
250
+