Skip to content

Commit

Permalink
feat(apis): Adding api docs for media container - FRONT-4635 (#3651)
Browse files Browse the repository at this point in the history
  • Loading branch information
planctus committed Sep 26, 2024
1 parent 33574c1 commit f6efedf
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
},
"reactSnap": {
"exclude": [
"/apis/*",
"/component-library/**/cms-images/**",
"/component-library/cms-images/**",
"/playground/**",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: API
order: 3
---

import React from 'react';
import Iframe from '../../../../../../website-components/Showcase/Iframe';

## Setup

There are 2 ways to initialise the component.

### Automatic

Add `data-ecl-auto-init="MediaContainer"` attribute to component's markup:

```html
<div
class="ecl-media-container"
data-ecl-media-container
data-ecl-auto-init="MediaContainer"
>
...
</div>
```

Use the `ECL` library's `autoInit()` (`ECL.autoInit()`) when your page is ready or other custom event you want to hook onto.

### Manual

Get target element, create an instance and invoke `init()`.

Given you have 1 element with an attribute `data-ecl-media-container` on the page:

```js
var elt = document.querySelector('[data-ecl-media-container]');
var mediaContainer = new ECL.MediaContainer(elt);
mediaContainer.init();
```

### Retrieve an existing instance

If an existing instance needs to be updated, it can be retrieved this way:

```js
var elt = document.querySelector('[data-ecl-media-container]');
var instance = ECL.components.get(elt);
```

## API

<Iframe url="../../../../../apis/MediaContainer.html" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: API
order: 3
---

import React from 'react';
import Iframe from '../../../../../../website-components/Showcase/Iframe';

## Setup

There are 2 ways to initialise the component.

### Automatic

Add `data-ecl-auto-init="MediaContainer"` attribute to component's markup:

```html
<div
class="ecl-media-container"
data-ecl-media-container
data-ecl-auto-init="MediaContainer"
>
...
</div>
```

Use the `ECL` library's `autoInit()` (`ECL.autoInit()`) when your page is ready or other custom event you want to hook onto.

### Manual

Get target element, create an instance and invoke `init()`.

Given you have 1 element with an attribute `data-ecl-media-container` on the page:

```js
var elt = document.querySelector('[data-ecl-media-container]');
var mediaContainer = new ECL.MediaContainer(elt);
mediaContainer.init();
```

### Retrieve an existing instance

If an existing instance needs to be updated, it can be retrieved this way:

```js
var elt = document.querySelector('[data-ecl-media-container]');
var instance = ECL.components.get(elt);
```

## API

<Iframe url="../../../../../apis/MediaContainer.html" />

1 comment on commit f6efedf

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.