-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add css option - fixes #24 #25
Conversation
Type: `string` | ||
|
||
Apply CSS styles to the webpage. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this block here, not sure if it should be added at the bottom of the options list? Not sure about the description either.
Apply custom CSS styles to the webpage.
Apply custom CSS styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply custom CSS to the webpage.
Oh, great! I was working in this some time ago and I was using |
|
||
if (css) { | ||
var style = document.createElement('style'); | ||
style.type = 'text/css'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moot as it's the default.
Sure. |
Added support for a css file but it's not working. Commented out the test. Anyone has an idea? Doesn't phantom support loading local files? Should I read the content of the file and just add it in the style tag? |
Didn't seem to work with a local file in phantomjs. So now I read the file and inject the content in the page. |
@@ -49,6 +49,10 @@ module.exports = function (url, size, opts) { | |||
es5shim = fs.readFileSync(es5Shim, 'utf8'); | |||
} | |||
|
|||
if (/\.css$/.test(opts.css)) { | |||
opts.css = fs.readFileSync(opts.css, 'utf8'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ok? Or should I use path.join(process.cwd(), opts.css)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok. fs
does that internally already.
Fixed description and merge conflict. Will do a PR in |
ping @kevva @sindresorhus :) |
Added support for a
css
option and it seems to work well. Feedback is more then welcome.I am not sure if
pageres
should support a css file, but I think it would be a nice addition. Shouldscreenshot-stream
support a css file as well then? Or shouldpageres
detect if it's a file, read the css file and pass the content of that file directly toscreenshot-stream
?// @sindresorhus