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

doc: add plugin usage example #1556

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/dummy/app/templates/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,32 @@ Once you have stored the instance, you can then do things like `this.flatpickrRe

All options available to Flatpickr are available here with the exception of wrap.

## Plugins
Usage of plugins like [monthSelect](https://flatpickr.js.org/plugins/#monthselectplugin) can be accomplished via the `@plugins` property on the component.

Keep in mind to import the plugin and its styles, so you can instantiate it in your component and pass it to the `@plugins` array. *This utilizes the included flatpickr package as a dependency of ember-flatpickr.*

```js
// ember-cli-build.js
app.import("node_modules/flatpickr/dist/plugins/monthSelect/style.css");
Copy link
Owner

Choose a reason for hiding this comment

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

@derrabauke do these need to be imported globally or could they be imported where used?

app.import("node_modules/flatpickr/dist/plugins/monthSelect/index.js");
```

```js
// my-date-component.js
export default class MyDateComponent extends Component {
plugins = [new monthSelectPlugin({})];
}
```

```handlebars
{{! my-date-component.hbs }}
<EmberFlatpickr
@date={{this.date}}
@plugins={{this.plugins}}
/>
```

## ember-flatpickr and external elements

The wrap option for flatpickr causes flatpickr to search its child elements for elements annotated with certain attributes. With ember-flatpickr this can be accomplished with the following
Expand Down