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

update mixins to allow composition API #288

Closed
indirectlylit opened this issue Dec 16, 2021 · 2 comments · Fixed by #377
Closed

update mixins to allow composition API #288

indirectlylit opened this issue Dec 16, 2021 · 2 comments · Fixed by #377

Comments

@indirectlylit
Copy link
Contributor

indirectlylit commented Dec 16, 2021

Product

All

Desired behavior

The Vue composition API makes it possible to explicitly add functionality from modules to components using standard import mechanisms. This is preferable to using mixins because it makes it explicit which elements are being added and where it's coming from.

Current behavior

KResponsiveWindowMixin for example currently provides the following reactive properties:

  • windowIsSmall: boolean
  • windowIsMedium: boolean
  • windowIsLarge: boolean
  • windowHeight: integer height in pixels
  • windowWidth: integer width in pixels
  • windowBreakpoint: integer breakpoint level

However the usual mechanism for adding the mixin doesn't provide any hint as to what's being added:

  import KResponsiveWindowMixin from 'kolibri-design-system/lib/KResponsiveWindowMixin';

  export default {
    name: 'SomeComponent',
    mixins: [KResponsiveWindowMixin],

(Optional) The Value Add

Easier discoverability and documentation

(Optional) Possible Tradeoffs

Might be more verbose in some cases, and lots of refactoring effort with not much user-facing benefit

@MisRob
Copy link
Member

MisRob commented Sep 13, 2022

Even though using Composition API has the potential to become the most commonly encouraged way of using KResponsiveWindowMixin (and possibly other mixins as well), we plan this to be backward compatible. Therefore, the composition API support would be rather an alternative way to mixins. That would allow us to use the KDS version with this update in products immediately without the need to suddenly refactor all places that are using mixins (there are many).

@MisRob
Copy link
Member

MisRob commented Sep 14, 2022

Some suggestions from @bjester:

it would be good to keep the global level handling of the resize events when transitioning to a composable structure. Adding multiple resize event handlers would be detrimental to performance. It may also be worth considering refactoring it to use matchMedia instead https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants