Matestack Ui VueJs
AboutMatestack Ui CoreMatestack Ui VueJsMatestack Ui Bootstrap
  • Welcome
  • Migrating to 3.0
  • Back to 2.1 (via Core)
  • Getting started
    • Installation & Update
      • Webpacker Install Steps
      • Importmap Install Steps
      • JSBundling-Rails Install
    • Hello World
  • Built-in Reactivity
    • Emit Client Side Events
      • Onclick Component API
    • Toggle UI States
      • Toggle Component API
    • Call Server Side Actions
      • Action Component API
    • Reactive Forms
      • Overview
      • Form Component API
      • Input Component API
      • Textarea Component API
      • Checkbox Component API
      • Select Component API
      • Radio Component API
      • Nested Forms
    • Partial UI Updates
      • Overview
      • Async Component API
      • Cable Component API
      • Isolated Component API
    • Page Transitions
      • Transition Component API
    • Reactive Collections
      • Overview & API
  • Custom Reactivity
    • Custom Vue.js Components
    • Matestack's Vue.js APIs
    • Third party Vue.js Components
    • Third Party JavaScript
  • Integrations
    • Action Cable
    • Devise
  • Contribute
Powered by GitBook
On this page
  • Ruby Component
  • Vue.js Component
  • Usage
  1. Custom Reactivity

Third party Vue.js Components

PreviousMatestack's Vue.js APIsNextThird Party JavaScript

Last updated 3 years ago

Using a third party Vue.js component based on an example integrating

Untested!

Ruby Component

class Components::MglMap < Matestack::Ui::VueJsComponent

  vue_name "mgl-map-component"

  optional :custom_map_style_hash

  def response
    plain tag.mglmap(":accessToken": "#{access_token}", "mapStyle": "#{map_style}")
  end

  private

    def access_token
      get_global_access_token_from_env
      #...
    end

    def map_style
      some_global_map_style_hash.merge!(context.custom_map_style_hash)
      #...
    end
end

Vue.js Component

import MatestackUiVueJs from "matestack-ui-vuejs";

import Mapbox from "mapbox-gl";
import { MglMap } from "vue-mapbox";

const mglMapComponent = {
  mixins: [MatestackUiVueJs.componentMixin],
  template: MatestackUiVueJs.componentHelpers.inlineTemplate,
  data() {
    return {
      mapbox: undefined
    };
  },
  created(){
    this.mapbox = Mapbox;
  }
}
export default mglMapComponent

// and register in your application js file like:
appInstance.component('mgl-map-component', mglMapComponent) // register at appInstance

Usage

class SomePage < Matestack::Ui::Page

  def response
    div class: "some-layout" do
      Components::MglMap.call(custom_map_style_hash: { ... })
    end
  end

end
https://soal.github.io/vue-mapbox/