Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

How to develop a component having mutability by the Site Theme

http://dcsf-dev08.i-on.net/dxp/basecamp

Basic Structure

  1. One Component has One Directory end with .mc. ( Multi-Component, Mutable Component )
    ex) list component in list.mc/

  2. If Component is providing many themes, You can implement it to branch in each directory.

    list.mc/
      index.vue     // Implement to do branch
      impl.js       // Implement component business logic
      multikart.vue // multikart theme template
      unishop.vue   // unishop theme template
      default.vue   // default theme template
      .
      .
  3. Register your component to *.collection.js .

    {
      [componentId( 'list' )]: registerComponent( () =>
        import( './list.mc' )
      ),
    } 
  4. Finally, you can use list component as <reg-list/> .

How it works

Index Branch Component : **/*.mc/index.vue

That component has only a script block<script>...</script> and import theme components in there.

<script>
  import impl from './impl';
  import multikart from './multikart';
  import unishop from './unishop';
  import { MasqueradeRenderReplace } from '../../../_core/helper/builderComponent';

  export default {
    props: impl.props, // connect component properties.

    /**
     * Replace Render Function
     * Replace render function to apply support function implemented 
     * to connect component params between real theme component and itself.
     * It will pass events and props and slots to the theme component.
     */
    render: MasqueradeRenderReplace,  // Easy way to import: Enter "Masq" and use auto complete.

    methods: {
      /**
       * kernel()
       * The kernel provides a real theme component correctly depends on the condition.
       */
      kernel() { 
      
        // Branch method 
        // ./_core/helper/builderComponent.js:$$switchThemeComponent
        // This array parameter has composed as pair elements.
        return this.$$switchThemeComponent([
          // condition(theme string or boolean) ,component 
          // Meaning of these is if left condition is true will return right component entered.
          'multikart', multikart,
          'unishop', unishop,
          
          // if no one is true will return last left one.
          unishop,
        ]);
      },
    },
  };
</script>

  • No labels