Giter Site home page Giter Site logo

Comments (4)

srowley avatar srowley commented on August 18, 2024

In GGity I approach this by just inserting an embedded stylesheet by default. The user can specify no stylesheet if they want to use an external one. Here that could be something like Plot.default_style(plot, false) or Plot.attributes(plot, default_style: false), in which case nothing gets inserted.

This isn't in GGity master yet. I made it more complicated than it probably needs to be in order to support constructing styles via the API (a la ggplot2 themes), and that part is not yet ready. Implementing the simple "default or nothing" approach above is a lot more straightforward, and I can probably repackage what I have already done into a PR if you are interested.

from contex.

mindok avatar mindok commented on August 18, 2024

Thanks @srowley - makes sense. I'm thinking of the following:

  1. Just enough default styling that things don't disappear if no CSS added
  2. Option to switch off default style
  3. Try to organise default styles so that they are overridden if CSS is provided but default styles aren't switched off. I'm sure there are some specificity gotchas when combining embedded css with external, and I'm sure there different depending on browser...

from contex.

srowley avatar srowley commented on August 18, 2024

With that in mind, the key constraint is that a given selector in the embedded style is always going to override the same selector in an external sheet. If the goal is to minimize the defaults and make it easy for them to be overridden even if the default is still on, I would think you can literally just insert:

    <style type="text/css">
      <![CDATA[
      text {
        fill: black
      }

      line {
        stroke: black
      }
      ]]>
    </style>

and all of the labels and tick-marks would show up. Any selector that uses a class (e.g. exc-tick text) in an external sheet would override that, so you don't have to make your external styles any more specific for them to override the default.

If that makes sense I'll send a PR; that's an easy one.

from contex.

mindok avatar mindok commented on August 18, 2024

Perfect. That’s pretty well what I had in mind...

from contex.

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.