Skip to content
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

How to set MEDIA attribute for stylesheet? #9

Closed
sfmskywalker opened this issue Jul 25, 2011 · 6 comments
Closed

How to set MEDIA attribute for stylesheet? #9

sfmskywalker opened this issue Jul 25, 2011 · 6 comments

Comments

@sfmskywalker
Copy link

For mobile devices I want to include certain stylesheets and set the "media" attribute.
Currently I don't see how to do that using Cassette and am forced to usedirectly the element.

@andrewdavey
Copy link
Owner

This is a missing feature. I would think this needs to be configurable at the module level.

In web.config, something like this perhaps:

<cassette>
  <styles>
    <add path="styles/mobile" media="only screen and (max-device-width: 480px)" />
  </styles>
</cassette>

?

@sfmskywalker
Copy link
Author

That would work out great for me, and is consistent with how everything else is configured in Cassette.

@andrewdavey
Copy link
Owner

I'll leave this open, until the feature is implemented.

@sfmskywalker
Copy link
Author

Great :)

@andrewdavey
Copy link
Owner

In Cassette 0.6, the StylesheetModule class has a Media property. So it's now a matter of assigning the property in the configuration. A simple example is:

moduleSource.Add(new DirectorySource<StylesheetModule>("styles/mobile")
{
    FilePattern = "*.css",
    CustomizeModule = m => m.Media = "your-media-query-here"
});

However, I assume you'd rather use on PerSubDirectorySource<StylesheetModule> for all stylesheets and then set the media of a select few modules? So maybe we need to add something like:

/// after adding the module source...
moduleSource.Customize<StylesheetModule>("styles/mobile", m =>m.Media = "etc");

@sfmskywalker
Copy link
Author

Great enhancements with 0.6!

I currently just use the DirectorySource class, but you you're right that I'd rather use the PerSubDirectorySource to save me from explicitly specifying each subfolder under /css.
I didn't realize I could then customize a module afterwards. Now I do :)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants