Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Hook to allow mixin modifiers #4

Open
patric-eberle opened this issue Apr 27, 2018 · 0 comments
Open

Proposal: Hook to allow mixin modifiers #4

patric-eberle opened this issue Apr 27, 2018 · 0 comments

Comments

@patric-eberle
Copy link

We just had a case, where we move the state handling of form fields to a mixin. Based on the current state of an element we update the modifier classes on the root element of a component. Currently I don't see an option, how we could automatically inject modifier classes from the mixin into b(). We currently defined a computed property which merges component and mixin states into one object.

I couldn't find a solution for this problem in your documentation. Therefore I wanted to propose a hook for b() which would be triggered on the component when ever b() calculates classes which would allow to extend the properties of the initial call. The hook then could be added by a mixin.

e.g. modifying the modifiers on the block element (b())

/**
 * @param   {object}    config
 * @param   {string}    config.block
 * @param   {string}    config.element
 * @param   {object}    config.modifiers
 * @param   {string}    config.mixins
 */
myHookMethod(config) {
  if (!config.element) {
    config.modifiers.state = 'active';
  }

  return config;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant