Skip to content

Figure out difference between mixins and selector builders #39

Description

@janis-me

The use method is defined in a new WithUsables mixin. For mixin builders, it creates a new selector using the current context and the mixin context. It combines these into a single selector and applies the styles. It then returns the original builder. Thus, when a mixin is applied using use it cannot be changed anymore. Also, what I still have to figure out

  • Should a mixin be nested, or extend a selector? We can either do
const context = usable.getMixinContext();
_selectByContext([...this.context, ...context], this.postcssContainer, this.postcssRoot).style(styles);

or

const context = usable.getMixinContext();
_selectByContext(this.context, this.postcssContainer, this.postcssRoot).select(context).style(styles);

So the first would combine selectors, the second one would nest them. Issue with nesting is that something like

export const surimiIconAfter = mixin(':after').style({
  content: "'🍣'",
  position: 'absolute',
});

Would not select the after pseudo element of the current context, but of all descendants.
We would need something like

mixin('&:after')

which is, I think, not valid?

The mixin builder is a bit odd currently, as it would allow to put multiple .style calls in between some selections. That does nothing though, as the 'style' method just updates an object. That is also related to the question of how is a mixin different from a selector builder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreRelated to the core `surimi` package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions