diff --git a/packages/cxl-ui/scss/cxl-jw-player/cxl-jw-player-feedback-shadow.scss b/packages/cxl-ui/scss/cxl-jw-player/cxl-jw-player-feedback-shadow.scss new file mode 100644 index 000000000..769714c22 --- /dev/null +++ b/packages/cxl-ui/scss/cxl-jw-player/cxl-jw-player-feedback-shadow.scss @@ -0,0 +1,3 @@ +:host(:not([hidden])) { + display: block; +} diff --git a/packages/cxl-ui/scss/cxl-jw-player/cxl-jw-player-feedback.scss b/packages/cxl-ui/scss/cxl-jw-player/cxl-jw-player-feedback.scss new file mode 100644 index 000000000..769714c22 --- /dev/null +++ b/packages/cxl-ui/scss/cxl-jw-player/cxl-jw-player-feedback.scss @@ -0,0 +1,3 @@ +:host(:not([hidden])) { + display: block; +} diff --git a/packages/cxl-ui/src/components/cxl-jw-player/README.md b/packages/cxl-ui/src/components/cxl-jw-player/README.md index 33202d041..d6fdbcbf1 100644 --- a/packages/cxl-ui/src/components/cxl-jw-player/README.md +++ b/packages/cxl-ui/src/components/cxl-jw-player/README.md @@ -9,7 +9,9 @@ minimum-search-length="3" player-id="5CFJNXKb" plugin-path="https://cxl.com/institute/wp-content/plugins/cxl-jwplayer/" - > + > + ...PHP + ``` ## Features: @@ -22,6 +24,7 @@ - [x] Captions search and highlight - [x] Save position - [ ] Theater mode +- [X] Feedback form ## Dependencies: diff --git a/packages/cxl-ui/src/components/cxl-jw-player/cxl-jw-player-feedback/index.js b/packages/cxl-ui/src/components/cxl-jw-player/cxl-jw-player-feedback/index.js new file mode 100644 index 000000000..6ea439bb1 --- /dev/null +++ b/packages/cxl-ui/src/components/cxl-jw-player/cxl-jw-player-feedback/index.js @@ -0,0 +1,23 @@ +import { html, LitElement } from 'lit'; +import { customElement, property } from 'lit/decorators.js'; +import style from '../../../styles/cxl-jw-player/cxl-jw-player-feedback-css'; +import shadowStyle from '../../../styles/cxl-jw-player/cxl-jw-player-feedback-shadow-css'; + +@customElement('cxl-jw-player-feedback') +export class CXLJWPlayerFeedbackElement extends LitElement { + @property({ reflect: true, type: Boolean }) hidden = true; + + static get styles() { + return [shadowStyle]; + } + + render() { + return html``; + } + + async __setup() { + await super.__setup(); + + this.__addStyle(style); + } +} diff --git a/packages/cxl-ui/src/components/cxl-jw-player/index.js b/packages/cxl-ui/src/components/cxl-jw-player/index.js index 9d245c651..d10aa910d 100644 --- a/packages/cxl-ui/src/components/cxl-jw-player/index.js +++ b/packages/cxl-ui/src/components/cxl-jw-player/index.js @@ -1,6 +1,6 @@ import { LitElement } from 'lit'; import { customElement } from 'lit/decorators.js'; -import { BaseMixin, TranscriptMixin, ChapterNavigationMixin, SavePositionMixin } from './mixins'; +import { BaseMixin, TranscriptMixin, ChapterNavigationMixin, FeedbackMixin, SavePositionMixin } from './mixins'; import style from '../../styles/cxl-jw-player/cxl-jw-player-css'; import shadowStyle from '../../styles/cxl-jw-player/cxl-jw-player-shadow-css'; import { mixin } from './utility'; @@ -11,6 +11,7 @@ export class CXLJWPlayerElement extends mixin(LitElement, [ BaseMixin, TranscriptMixin, ChapterNavigationMixin, + FeedbackMixin, SavePositionMixin, ]) { config = { diff --git a/packages/cxl-ui/src/components/cxl-jw-player/mixins/feedback/index.html.js b/packages/cxl-ui/src/components/cxl-jw-player/mixins/feedback/index.html.js new file mode 100644 index 000000000..9fe591bcb --- /dev/null +++ b/packages/cxl-ui/src/components/cxl-jw-player/mixins/feedback/index.html.js @@ -0,0 +1,8 @@ +import { html } from 'lit'; +import '@vaadin/button'; +import '@vaadin/icon'; + +// eslint-disable-next-line func-names +export const feedbackTemplate = function () { + return html`This is a sample feedback form.`; +}; diff --git a/packages/cxl-ui/src/components/cxl-jw-player/mixins/feedback/index.js b/packages/cxl-ui/src/components/cxl-jw-player/mixins/feedback/index.js new file mode 100644 index 000000000..00f64227b --- /dev/null +++ b/packages/cxl-ui/src/components/cxl-jw-player/mixins/feedback/index.js @@ -0,0 +1,69 @@ +import { html, render } from 'lit'; +import { property } from 'lit/decorators.js'; +import '../../../cxl-dialog/cxl-dialog'; + +export function FeedbackMixin(BaseClass) { + class Mixin extends BaseClass { + @property({ attribute: 'plugin-path', type: String }) pluginPath; + + __feedbackContent; + + __feedbackDialog; + + async __setupFeedback() { + this.__feedbackContent = this.querySelector('cxl-jw-player-feedback'); + + /* eslint-disable no-param-reassign */ + const headerRenderer = (root, dialog) => + render( + html` + + + + `, + root + ); + /* eslint-enable no-param-reassign */ + + const renderer = function (root) { + root.appendChild(this.__feedbackContent); + this.__feedbackContent.hidden = false; + }.bind(this); + + render( + html``, + this.__jwPlayerContainer + ); + + this.__jwPlayer.addButton( + ``, + 'Feedback', + this.__toggleFeedback.bind(this), + 'toggle-feedback' + ); + } + + async __setup() { + await super.__setup(); + + this.__setupFeedback(); + } + + __toggleFeedback() { + const el = this.querySelector('.jwplayer').querySelector('cxl-dialog'); + el.opened = !el.opened; + } + } + + return Mixin; +} diff --git a/packages/cxl-ui/src/components/cxl-jw-player/mixins/index.js b/packages/cxl-ui/src/components/cxl-jw-player/mixins/index.js index 280a40e71..384a2e0e6 100644 --- a/packages/cxl-ui/src/components/cxl-jw-player/mixins/index.js +++ b/packages/cxl-ui/src/components/cxl-jw-player/mixins/index.js @@ -1,4 +1,5 @@ export { BaseMixin } from './BaseMixin'; export { TranscriptMixin } from './TranscriptMixin'; export { ChapterNavigationMixin } from './chapter-navigation'; +export { FeedbackMixin } from './feedback'; export { SavePositionMixin } from './SavePositionMixin'; diff --git a/packages/storybook/cxl-ui/cxl-jw-player/feedback.stories.js b/packages/storybook/cxl-ui/cxl-jw-player/feedback.stories.js new file mode 100644 index 000000000..15156524f --- /dev/null +++ b/packages/storybook/cxl-ui/cxl-jw-player/feedback.stories.js @@ -0,0 +1,21 @@ +import { html } from 'lit'; +import '@conversionxl/cxl-ui/src/components/cxl-jw-player/index.js'; +import '@conversionxl/cxl-ui/src/components/cxl-jw-player/cxl-jw-player-feedback/index.js'; + +export default { + title: 'CXL UI/cxl-jw-player', +}; + +// eslint-disable-next-line no-empty-pattern +const Template = ({}) => + html` + + + This is a feedback form + `; + +export const Feedback = Template.bind({}); diff --git a/packages/storybook/cxl-ui/cxl-jw-player/index.stories.js b/packages/storybook/cxl-ui/cxl-jw-player/index.stories.js index a87cd4ad1..59142a3c1 100644 --- a/packages/storybook/cxl-ui/cxl-jw-player/index.stories.js +++ b/packages/storybook/cxl-ui/cxl-jw-player/index.stories.js @@ -1,5 +1,6 @@ import { html } from 'lit'; import '@conversionxl/cxl-ui/src/components/cxl-jw-player/index.js'; +import '@conversionxl/cxl-ui/src/components/cxl-jw-player/cxl-jw-player-feedback/index.js'; export default { title: 'CXL UI/cxl-jw-player', @@ -28,7 +29,9 @@ const Template = ({ captions, mediaId, minimumSearchLength, playerId, playlistId player-id=${playerId} playlist-id=${playlistId} plugin-path="${pluginPath}" - > + > + This is a feedback form + `; export const Default = Template.bind({}); diff --git a/packages/storybook/cxl-ui/cxl-jw-player/playlist.stories.js b/packages/storybook/cxl-ui/cxl-jw-player/playlist.stories.js index 3a55354aa..fad79c6ef 100644 --- a/packages/storybook/cxl-ui/cxl-jw-player/playlist.stories.js +++ b/packages/storybook/cxl-ui/cxl-jw-player/playlist.stories.js @@ -1,5 +1,6 @@ import { html } from 'lit'; import '@conversionxl/cxl-ui/src/components/cxl-jw-player/index.js'; +import '@conversionxl/cxl-ui/src/components/cxl-jw-player/cxl-jw-player-feedback/index.js'; export default { title: 'CXL UI/cxl-jw-player', @@ -29,7 +30,9 @@ const Template = ({ captions, mediaId, playerId, playlistId, pluginPath }) => playlist-id=${playlistId} plugin-path="${pluginPath}" type="playlist" - > + > + This is a feedback form + `; export const Playlist = Template.bind({});