Perspective base a style class on another style class

v8.0.15

Can I base a style class on another style class?
Instead of having to either define the same styles twice or assign two styles to a component, I want to be able to add the styles defined in one class into another class, where the same precedence logic would apply as normal: if a particular style has two definitions (one from the linked class and one from the current class), then the current class’ version would take precedence.

Or am I doing Perspective wrong? (really I’m just fumbling along at the moment…)

In CSS, you can add multiple selectors to a style definition by separating them with a comma.

But I indeed don’t see how that’s possible in perspective yet.

CSS selectors are a pretty complicated grammar when you want to implement complete support for it.

Currently, Perspective styles work as dedicated elements - they’re applied by a selector per ID (open a Perspective session in browser dev tools, and you can see the style class CSS) - something like .psc-{your style class name} and applied as a classname on each element.

Style class composition is something we’re interested in - a lot of the groundwork of Perspective was built on the assumption users wouldn’t want to learn to be web developers, but y’all have consistently proven us wrong :slight_smile:

2 Likes

Early adopters are a different breed. I lean towards y'all's initial assumption for the long term.

1 Like

No reason we can’t take steps to keep both happy by just gating more advanced features behind some level of effort (IE, themes).

Just FYI, this is another vote for css type selectors.

It’s just a better mousetrap IMO. But definitely understand where you guys are coming from.