[Compass Core] Smooth out some rough edges in the text module.

This commit is contained in:
Chris Eppstein 2010-05-01 23:51:20 -07:00
parent cd6076d097
commit 3b3fcf26f1
5 changed files with 58 additions and 20 deletions

View File

@ -12,10 +12,20 @@ COMPASS CHANGELOG
* [Rails] The default location for compass extensions has moved from * [Rails] The default location for compass extensions has moved from
`vendor/plugins/compass/extensions` to `vendor/plugins/compass_extensions`. `vendor/plugins/compass/extensions` to `vendor/plugins/compass_extensions`.
* Global reset no longer automatically resets the *:focus. This allows browsers to * [Compass Core] Global reset no longer automatically resets the *:focus.
use their default :focus styles which is considered a best practice. If you wish This allows browsers to use their default :focus styles which is considered
to reset :focus styles simply include this in your stylesheets: a best practice. If you wish to reset :focus styles simply include this in
your stylesheets:
`*:focus { @include reset-focus; }` `*:focus { @include reset-focus; }`
* [Compass Core] A new mixin `replace-text-with-dimensions` has been added.
This is the same as the `replace-text` mixin except that it will read the
dimensions from the image and set them for you on the element.
* [Compass Core] If you want Firefox 2 Support (via -moz-binding) for the
`ellipsis` mixin, you must now set `$firefox2-ellipsis` to `true` before
importing the module.
* [Compass Core] The `compass/text/ellipsis` module is now imported
automatically by the `compass/text` module.
0.10.0.rc4 (April 27, 2010) 0.10.0.rc4 (April 27, 2010)
--------------------------- ---------------------------

View File

@ -1,2 +1,3 @@
@import "text/ellipsis";
@import "text/nowrap"; @import "text/nowrap";
@import "text/replacement"; @import "text/replacement";

View File

@ -1,12 +1,25 @@
// This technique, by [Justin Maxwell](http://code404.com/), was originally @import "compass/css3/shared";
// published at http://mattsnider.com/css/css-string-truncation-with-ellipsis/
// Firefox implementation by [Rikkert Koppes](http://www.rikkertkoppes.com/thoughts/2008/6/)
// To get firefox2 support, you must install the ellipsis pattern:
//
// compass install compass/ellipsis
$firefox2-ellipsis: false !default;
// This technique, by [Justin Maxwell](http://code404.com/), was originally
// published [here](http://mattsnider.com/css/css-string-truncation-with-ellipsis/).
// Firefox implementation by [Rikkert Koppes](http://www.rikkertkoppes.com/thoughts/2008/6/).
@mixin ellipsis($no-wrap: true) { @mixin ellipsis($no-wrap: true) {
@if $no-wrap { @if $no-wrap { white-space: nowrap; }
white-space: nowrap; }
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; @include experimental(text-overflow, ellipsis,
-o-text-overflow: ellipsis; not -moz,
-ms-text-overflow: ellipsis; not -webkit,
-moz-binding: stylesheet-url(unquote("xml/ellipsis.xml#ellipsis")); } -o,
-ms,
not -khtml,
official
);
@if $experimental-support-for-mozilla and $firefox2-ellipsis {
-moz-binding: stylesheet-url(unquote("xml/ellipsis.xml#ellipsis"));
}
}

View File

@ -1,21 +1,32 @@
// Hides html text and replaces it with an image. // Hides html text and replaces it with an image.
// If you use this on an inline element, you will need to change the display to block or inline-block. // If you use this on an inline element, you will need to change the display to block or inline-block.
// Also, if the size of the image differs significantly from the font size, you'll need to set the width and/or height. // Also, if the size of the image differs significantly from the font size, you'll need to set the width and/or height.
// @param img //
// the relative path from the project image directory to the image. // Parameters:
// @param x //
// the x position of the background image. // * `img` -- the relative path from the project image directory to the image.
// @param y // * `x` -- the x position of the background image.
// the y position of the background image. // * `y` -- the y position of the background image.
@mixin replace-text($img, $x: 50%, $y: 50%) { @mixin replace-text($img, $x: 50%, $y: 50%) {
@include hide-text; @include hide-text;
background: { background: {
image: image-url($img); image: image-url($img);
repeat: no-repeat; repeat: no-repeat;
position: $x $y; }; } position: $x $y;
};
}
// Like the `replace-text` mixin, but also sets the width
// and height of the element according the dimensions of the image.
@mixin replace-text-with-dimensions($img, $x: 50%, $y: 50%) {
@include replace-text($img, $x, $y);
width: image-width($img);
height: image-height($img);
}
// Hides text in an element so you can see the background. // Hides text in an element so you can see the background.
@mixin hide-text { @mixin hide-text {
text-indent: -9999em; text-indent: -9999em;
overflow: hidden; overflow: hidden;
text-align: left; } text-align: left;
}

View File

@ -1,3 +1,6 @@
// Since you've installed the xml file, you must set
// $firefox2-ellipsis to true before importing.
$firefox2-ellipsis: true
@import compass/utilities/text/ellipsis @import compass/utilities/text/ellipsis
// You can delete this sass file if you want, it's just an example of how to use the ellipsis mixin. // You can delete this sass file if you want, it's just an example of how to use the ellipsis mixin.