Debian Codegraph @

lib/compass/typography/text/_replacement.scss

raw
1 // Indicates the direction you prefer to move your text
2 // when hiding it.
3 //
4 // `left` is more robust, especially in older browsers.
5 // `right` seems have better runtime performance.
6 $hide-text-direction: left !default;
7
8 // Hides html text and replaces it with an image.
9 // If you use this on an inline element, you will need to change the display to block or inline-block.
10 // Also, if the size of the image differs significantly from the font size, you'll need to set the width and/or height.
11 //
12 // Parameters:
13 //
14 // * `img` -- the relative path from the project image directory to the image, or a url literal.
15 // * `x` -- the x position of the background image.
16 // * `y` -- the y position of the background image.
17 @mixin replace-text($img, $x: 50%, $y: 50%) {
18 @include hide-text;
19 background: {
20 @if is-url($img) {
21 image: url($img);
22 } @else {
23 image: image-url($img);
24 }
25 repeat: no-repeat;
26 position: $x $y;
27 };
28 }
29
30 // Like the `replace-text` mixin, but also sets the width
31 // and height of the element according the dimensions of the image.
32 //
33 // If you set `$inline` to true, then an inline image (data uri) will be used.
34 @mixin replace-text-with-dimensions($img, $x: 50%, $y: 50%, $inline: false) {
35 @include replace-text(if($inline, inline-image($img), $img), $x, $y);
36 width: image-width($img);
37 height: image-height($img);
38 }
39
40 // Hides text in an element so you can see the background.
41 //
42 // The direction indicates how the text should be moved out of view.
43 //
44 // See `$hide-text-direction` for more information and to set this globally
45 // for your application.
46 @mixin hide-text($direction: $hide-text-direction) {
47 @if $direction == left {
48 $approximate-em-value: 12px;
49 $wider-than-any-screen: -9999;
50 text-indent: $wider-than-any-screen * $approximate-em-value;
51 overflow: hidden;
52 text-align: left;
53 } @else {
54 // slightly wider than the box prevents issues with inline-block elements
55 text-indent: 110%;
56 white-space: nowrap;
57 overflow: hidden;
58 }
59 }
60
61 // Hides text in an element by squishing the text into oblivion.
62 // Use this if you need to hide text contained in an inline element
63 // but still have it read by a screen reader.
64 @mixin squish-text {
65 font: 0/0 serif;
66 text-shadow: none;
67 color: transparent;
68 }