[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
`vendor/plugins/compass/extensions` to `vendor/plugins/compass_extensions`.
* Global reset no longer automatically resets the *:focus. This allows browsers to
use their default :focus styles which is considered a best practice. If you wish
to reset :focus styles simply include this in your stylesheets:
* [Compass Core] Global reset no longer automatically resets the *:focus.
This allows browsers to use their default :focus styles which is considered
a best practice. If you wish to reset :focus styles simply include this in
your stylesheets:
`*: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)
---------------------------

View File

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

View File

@ -1,12 +1,25 @@
// This technique, by [Justin Maxwell](http://code404.com/), was originally
// published at http://mattsnider.com/css/css-string-truncation-with-ellipsis/
// Firefox implementation by [Rikkert Koppes](http://www.rikkertkoppes.com/thoughts/2008/6/)
@import "compass/css3/shared";
// 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) {
@if $no-wrap {
white-space: nowrap; }
@if $no-wrap { white-space: nowrap; }
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
-ms-text-overflow: ellipsis;
-moz-binding: stylesheet-url(unquote("xml/ellipsis.xml#ellipsis")); }
@include experimental(text-overflow, ellipsis,
not -moz,
not -webkit,
-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.
// 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.
// @param img
// the relative path from the project image directory to the image.
// @param x
// the x position of the background image.
// @param y
// the y position of the background image.
//
// Parameters:
//
// * `img` -- the relative path from the project image directory to the image.
// * `x` -- the x position of the background image.
// * `y` -- the y position of the background image.
@mixin replace-text($img, $x: 50%, $y: 50%) {
@include hide-text;
background: {
image: image-url($img);
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.
@mixin hide-text {
text-indent: -9999em;
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
// You can delete this sass file if you want, it's just an example of how to use the ellipsis mixin.