Last active
December 20, 2015 15:39
Print CSS - creating non-semantic print classes Useful for links which auto get expanded into 'text (url)' which you may not want ... especially for email or if the link text is the actual url.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_link(text, url) | |
link_to(text, url, class: 'no-print') << | |
content_tag('span', class: 'print-only') { text } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "#print_link" do | |
it "should render a link with text, url, and no-print class" do | |
helper.should_receive(:link_to). | |
with('yo', 'http://blah.com', class: 'no-print'). | |
and_return("") | |
helper.print_link('yo', 'http://blah.com') | |
end | |
it "should render a span with print-only class and text" do | |
helper.print_link('yo', 'http://blah.com').should =~ /span class=\"print-only\">yo/ | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@include print-utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://compass-style.org/reference/compass/utilities/print/ | |
@import "compass/utilities/print"; | |
@include print-utilities(screen); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.print_only { | |
display: block; | |
&span, &b, &i, &small, &strong, &em, &a, &img, &button, &input, &label, &select, &textarea { | |
display: inline; | |
} | |
} | |
.no_print { | |
display: none; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.print_only { | |
display: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment