cssinjs / istf-spec

Interoperable Style Transfer Format [DRAFT]
247 stars 8 forks source link

Classnames #14

Closed kof closed 7 years ago

kof commented 7 years ago

As we def. need to support both scoped (generated) and regular class names, there is a question how to do that in a way that doesn't introduces much troubles to the runtimes.

I think class name generation algorithm should be out of scope for the standard, instead runtime should decide. There are too many hashing algorithms and counter based solutions. If we would try to generate the class name within the standard, we would need to make sure it will work across the entire world. If we let runtimes decide on the algorithm, it just has to work within a specific project.

kof commented 7 years ago

One idea I have to solve this is a class name template: .my-button-{id}, where {id} can be replaced by the runtime. If a class name has no id, it automatically makes it "global".

kof commented 7 years ago

Another idea which is based on #13

[
  [ SELECTOR_OPEN ],
  [ SELECTOR, '.foo', SCOPED ],
  [ PROPERTY, 'prop' ],
  [ VALUE, 'value' ],
  [ SELECTOR_OPEN ],
  [ SELECTOR, '&:psuedo' ],
  [ PROPERTY, 'foo' ],
  [ VALUE, 'bar' ],
  [ SELECTOR_CLOSE ],
  [ SELECTOR_CLOSE ],
]
.foo-123456 {
  prop: value;
  &:pseudo {
    foo: bar;
  }
}

Instead of [ SELECTOR, '.foo', SCOPED ], it could be also [ SCOPED_SELECTOR, '.foo'],

kof commented 7 years ago

I think we got this in #17