GithubHelp home page GithubHelp logo

custom pseudo selectors? about jss HOT 3 CLOSED

cssinjs avatar cssinjs commented on April 27, 2024
custom pseudo selectors?

from jss.

Comments (3)

kof avatar kof commented on April 27, 2024

Now I got what you mean. In other words you want to use in jss some specific pseudo selectors and map them to corresponding classes when generating css. This is a good use case for a plugin.

from jss.

gavinengel avatar gavinengel commented on April 27, 2024

I also want the plugin to inject javascript to give to the browser, and not simply css. I could do that with a plugin?

Extending :click further, I can even imagine it taking parameters:

:click(
  btn: right, // mouse button used
  dur: 1.5s,  // time a pointer is held down on a click (perhaps min and max duration)
  drg: left, // the direction of movement after a click is begun
  off: #bar, // the id/class/tag element the point ends on when click-off
  dst: 100px, // distance the pointer movement travels before click-off
  cnt: 2 // number of clicks, 2 means double-click
)

By the way, here is some "dream code" that eventually I'd like to be able to use (or perhaps an extended jss syntax). It is a hybrid of js events/logic with css. I think with such a robust language, a developer could implement the vast majority of UI/UX stuff.

body {
  font-size: small;
  background: #fff;
  color: #222;
  [data-role="blah"] {
    [data-attr]: 132px; /* attribute string manipulation */
    div .foo color: #333;
  }
  #my-app {
    #foo:hover {
      [data-bazbar]++; /* attribute data arithmatic */
    }
    .bar {
      (.foo[data-bar] <= 500) { // basic if/then logic being used here
        [data-blah]: 12;
        [style border]: red;

        // the "^" character points to top (root) page element, 
        // so that child element events can modify any other element
        ^ #myapp > div [style color]: blue; 

      }
      &:active {
        .something [style border, background]: blue; // this is the same ...
        .something { border : blue; background: blue } // ... as this.
      }
      .someclass (height >= 2000) [style border, color]: green;
      &:parent {
        color: purple;
        font-size: 24px;
      }
      #baz:click {
        // new operators:
        #foo .someclass [data-foo]~: large; 
        .someclass [data-*]: 200;
       .foo [data-bar] -= 12;  
       .foo [data-bar] /= 12;  
       .foo [data-bar] *= 12;  
       .foo [data-bar] %= 12;  
       .foo class &= large; } // toggle on
       .foo class ^= large; } // toggle off
       .foo class ~= large; } // toggle opposite
    } 
  }
}

I'd love to see less need for writing javascript, and more use of a "CSS" style language that can deal with style, logic, events, attributes. Attribute manipulation is important to me, because it would allow Polymer-style elements to be controlled easily by manipulating HTML tag attributes as if they are simply variables. (BTW, I prefer the look of CSS to JSON, because it doesn't need so many brackets and braces--it looks better.)

from jss.

kof avatar kof commented on April 27, 2024

This is definitely out of jss scope. JSS core should stay really fast. Thats why I even moved plugins to separate repositories and removed them from core. What you are talking about is a task for a framework on top of jss.

from jss.

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.