1.1.23 • Published 4 months ago

@martan-app/widgets-js v1.1.23

Weekly downloads
-
License
-
Repository
github
Last release
4 months ago

@martan-app/widgets-js

JavaScript client for using Martan widgets.

Usage

You can use the library as a normal dependency by installing it via npm i @martan-app/widgets-js --save.

Add CSS import "/node_modules/@martan-app/widgets-js/dist/style.css"

Examples

import Martan from '@martan-app/widgets-js'

import "/node_modules/@martan-app/widgets-js/dist/style.css"

// ID of the div that will receive the reviews widget
const $targetId = 'reviews_widget'

// Create widget instance
const martan = new Martan({
  storeId: 124089,
  widgetKey: 'WK_MY_WIDGET_KEY_UNIQUELY_GENERATED_IN_MARTAN_APP_ADMIN'
})

// Initialize reviews widget
const review = martan.reviews($targetId)

// start
review.start()

/*
  // if you need to destroy the widget, like in react

  useEffect(() => {
    review.start()

    // destroy after unmouting
    return () => {
      review.destroy()
    }
  }, [])
*/
reviews.destroy()

// Create widget instance for rating
const rating = martan.average({
  color: '#4caf50',
  fontSize: 20
})

// Initialize widget
rating.start()

// Destroy widget
rating.destroy()

Via CDN: <script src="https://unpkg.com/@martan-app/widgets-js@1.1.1/dist/martan.umd.js">

Styles: <link href="https://unpkg.com/@martan-app/widgets-js@1.1.1/dist/style.css">

<script type="module">
    // ID of the div that will receive the reviews widget
    const $targetId = 'reviews_widget'

    // Create widget instance
    const martan = new window.Martan({
        storeId: 124089,
        widgetKey: 'WK_MY_WIDGET_KEY_UNIQUELY_GENERATED_IN_MARTAN_APP_ADMIN',
    })

    // Initialize reviews widget
    const reviews = martan.reviews($targetId)
    reviews.start()

    // Create widget instance for rating
    const rating = martan.average({
        color: '#4caf50',
        fontSize: 20
    })

    // Initialize widget
    rating.start()

    // Destroy widget
    rating.destroy()
</script>
1.1.23

4 months ago

1.1.22

4 months ago

1.1.21

4 months ago

1.1.9

5 months ago

1.1.20

5 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.1.8

8 months ago

1.1.7

8 months ago

1.1.6

8 months ago

1.1.5

8 months ago

1.1.4

8 months ago

1.1.3

9 months ago

1.1.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago