Git Product home page Git Product logo

Comments (5)

andrewdavey avatar andrewdavey commented on June 25, 2024

You will need to split your styles into separate modules (folders) for the two scenarios. Something like this in your project:

/styles/desktop
/styles/ipad

Are detecting the user agent (e.g. iPad Safari) server side? Or do you want to use a media query (based on screen width)?
For the former, something like this in the view could work:

@{
if (Request.IsIPad()) { // for example
    Assets.Styles.Reference("styles/ipad");
} else {
    Assets.Styles.Reference("styles/desktop");
}
}

For the media query (which I think is a better approach in general), please wait for the new version of Cassette which adds support for defining the stylesheet link media attribute. I'm hoping to get this released next week.

from cassette.

tommck avatar tommck commented on June 25, 2024

RIght, but this would require I put an if/then/else in every file instead of just in the Site.Master, right?

from cassette.

tommck avatar tommck commented on June 25, 2024

Media queries are nice if you're only detecting size and orientation, but the UI is different when we're on the iPad. Different stylings, different font sizes, etc. We don't want the font sizes to change based on the size of the person's browser window

from cassette.

andrewdavey avatar andrewdavey commented on June 25, 2024

If the styles are site-wide then put the if-else Reference calls in your master page.

Otherwise, you may want to look into adding a extension method to StylesheetAssetManager that does the if-else and calls Reference with the required path. (Assuming you have some predictable for desktop and iPad stylesheet names.)

@Assets.Stylesheets.ReferenceForRequestingDevice("styles/example")

from cassette.

andrewdavey avatar andrewdavey commented on June 25, 2024

I'm closing this issue as I don't think Cassette itself needs to handle this. It's possible to extend and customize Cassette in your application code.
Let me know if you need any more help with this.

from cassette.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.