@liquidcommercedev/rmn-sdk 1.5.0-beta.43 → 1.5.0-beta.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -19785,6 +19785,7 @@ class RbSmallDiscoverToutSE extends BaseSpotComponent {
19785
19785
  class RbVideoPlayerSE extends BaseSpotComponent {
19786
19786
  constructor() {
19787
19787
  super();
19788
+ this.reRenderOnDeviceChange = true;
19788
19789
  this.videoSelector = () => `.${this._config.prefix}__video-element`;
19789
19790
  this.muteButtonSelector = () => `.${this._config.prefix}__mute-button`;
19790
19791
  this.video = null;
@@ -19850,54 +19851,98 @@ class RbVideoPlayerSE extends BaseSpotComponent {
19850
19851
  const muteButton = this._container.querySelector(this.muteButtonSelector());
19851
19852
  muteButton === null || muteButton === undefined ? undefined : muteButton.removeEventListener('click', this.handleMuteToggle);
19852
19853
  }
19854
+ getGradientDirection(position) {
19855
+ switch (position) {
19856
+ case ENUM_TEXT_BLOCK_POSITION.TOP_LEFT:
19857
+ case ENUM_TEXT_BLOCK_POSITION.TOP_RIGHT:
19858
+ return 'to bottom';
19859
+ case ENUM_TEXT_BLOCK_POSITION.MIDDLE_LEFT:
19860
+ return 'to right';
19861
+ case ENUM_TEXT_BLOCK_POSITION.MIDDLE_RIGHT:
19862
+ return 'to left';
19863
+ case ENUM_TEXT_BLOCK_POSITION.BOTTOM_LEFT:
19864
+ case ENUM_TEXT_BLOCK_POSITION.BOTTOM_RIGHT:
19865
+ return 'to top';
19866
+ default:
19867
+ return 'to top';
19868
+ }
19869
+ }
19870
+ get hasContent() {
19871
+ const { header, mobileHeader, description, mobileDescription,
19872
+ // eslint-disable-next-line @typescript-eslint/naming-convention
19873
+ enableMobileTexts = false, } = this._data;
19874
+ const content = this._isMobileDevice && enableMobileTexts
19875
+ ? {
19876
+ header: mobileHeader,
19877
+ description: mobileDescription,
19878
+ }
19879
+ : { header, description };
19880
+ return Object.values(content).some(Boolean);
19881
+ }
19853
19882
  template() {
19854
19883
  const prefix = this._config.prefix;
19855
- const { url, posterTitle, posterDescription } = this._data.video;
19884
+ const { header, mobileHeader, description, mobileDescription, textBlockPosition = ENUM_TEXT_BLOCK_POSITION.BOTTOM_LEFT, mobileTextBlockPosition = textBlockPosition,
19885
+ // eslint-disable-next-line @typescript-eslint/naming-convention
19886
+ enableMobileTexts = false, } = this._data;
19887
+ // eslint-disable-next-line @typescript-eslint/naming-convention
19888
+ const { url, mobileUrl = url, mute = true, showMute = true } = this._data.video;
19856
19889
  if (!url) {
19857
19890
  return '<p>Please provide a video source</p>';
19858
19891
  }
19859
19892
  const renderOverlay = () => {
19860
- if (!posterTitle && !posterDescription)
19893
+ if (!this.hasContent)
19861
19894
  return '';
19895
+ const content = this._isMobileDevice && enableMobileTexts
19896
+ ? {
19897
+ header: mobileHeader,
19898
+ description: mobileDescription,
19899
+ }
19900
+ : { header, description };
19901
+ const elements = [
19902
+ renderElement('h2', `${prefix}__header`, content.header),
19903
+ renderElement('p', `${prefix}__description`, content.description),
19904
+ ];
19862
19905
  return `
19863
- <div class="${prefix}__overlay">
19864
- <div class="${prefix}__overlay-text">
19865
- ${posterTitle ? `<h2 class="${prefix}__title">${posterTitle}</h2>` : ''}
19866
- ${posterDescription ? `<p class="${prefix}__description">${posterDescription}</p>` : ''}
19867
- </div>
19906
+ <div class="${prefix}__text ${prefix}__text-block--${textBlockPosition} ${prefix}__text-block-mobile--${mobileTextBlockPosition}">
19907
+ ${elements.join('')}
19868
19908
  </div>
19869
19909
  `;
19870
19910
  };
19871
19911
  const renderVideo = () => `
19872
- <div class="${prefix}__video-container">
19873
- <video
19874
- class="${prefix}__video-element"
19875
- src="${url}"
19876
- autoplay
19877
- muted
19878
- loop
19879
- preload="metadata"
19880
- >
19881
- Your browser doesn't support HTML5 video playback.
19882
- </video>
19883
- </div>
19884
- `;
19885
- const renderMuteButton = () => `
19886
- <button type="button" class="${prefix}__mute-button">
19887
- <span class="${prefix}__mute-icon">
19888
- ${this.getMuteIcon()}
19889
- </span>
19890
- </button>
19891
- `;
19892
- const renderControls = () => `
19893
- <div class="${prefix}__controls">
19894
- ${renderMuteButton()}
19912
+ <div class="${prefix}__video-wrapper">
19913
+ <div class="${prefix}__video-container">
19914
+ <video
19915
+ class="${prefix}__video-element"
19916
+ src="${this._isMobileDevice ? mobileUrl : url}"
19917
+ autoplay
19918
+ ${mute ? 'muted' : ''}
19919
+ loop
19920
+ preload="metadata"
19921
+ playsinline
19922
+ >
19923
+ Your browser doesn't support HTML5 video playback.
19924
+ </video>
19925
+ </div>
19895
19926
  </div>
19896
19927
  `;
19928
+ const renderMuteButton = () => showMute
19929
+ ? `
19930
+ <button type="button" class="${prefix}__mute-button">
19931
+ <span class="${prefix}__mute-icon">
19932
+ ${this.getMuteIcon()}
19933
+ </span>
19934
+ </button>
19935
+ `
19936
+ : '';
19937
+ const renderControls = () => showMute
19938
+ ? `
19939
+ <div class="${prefix}__controls">
19940
+ ${renderMuteButton()}
19941
+ </div>
19942
+ `
19943
+ : '';
19897
19944
  return `
19898
- ${GFONT_PRECONNECT}
19899
- ${GFONT_SOURCE_SANS_3}
19900
- ${GFONT_CORMORANT}
19945
+ ${importFonts()}
19901
19946
  <div class="${prefix}">
19902
19947
  ${renderOverlay()}
19903
19948
  ${renderVideo()}
@@ -19907,67 +19952,217 @@ class RbVideoPlayerSE extends BaseSpotComponent {
19907
19952
  }
19908
19953
  styles() {
19909
19954
  const prefix = this._config.prefix;
19955
+ const { width, height, textBlockPosition = ENUM_TEXT_BLOCK_POSITION.BOTTOM_LEFT, mobileTextBlockPosition = textBlockPosition, textColor = '#ffffff', } = this._data;
19956
+ const { aspectRatio = '16:9' } = this._data.video;
19957
+ const desktopGradientDirection = this.getGradientDirection(textBlockPosition);
19958
+ const mobileGradientDirection = this.getGradientDirection(mobileTextBlockPosition);
19959
+ const linearGradient = generateGradientColor(this._config.overlay, 'rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 40%');
19960
+ const hostSelector = this._config.useShadowDom ? ':host' : this.tagName.toLowerCase();
19910
19961
  return `
19962
+ ${hostSelector} {
19963
+ width: 100%;
19964
+ height: 100%;
19965
+ max-width: ${width}px;
19966
+ max-height: ${height}px};
19967
+ }
19968
+
19911
19969
  .${prefix} {
19912
19970
  width: 100%;
19913
19971
  height: 100%;
19914
- background: #000;
19972
+ background: #fff;
19915
19973
  overflow: hidden;
19916
19974
  position: relative;
19917
19975
  }
19918
19976
 
19919
- .${prefix}__overlay {
19977
+ .${prefix}::before {
19978
+ content: '';
19920
19979
  position: absolute;
19921
19980
  top: 0;
19922
19981
  left: 0;
19923
19982
  right: 0;
19924
- z-index: 2;
19983
+ bottom: 0;
19984
+ z-index: 1;
19985
+ pointer-events: none;
19986
+ }
19987
+
19988
+ .${prefix}__video-wrapper {
19989
+ width: 100%;
19990
+ height: 100%;
19991
+ position: relative;
19992
+ overflow: hidden;
19993
+ }
19994
+
19995
+ .${prefix}__video-container {
19996
+ position: relative;
19925
19997
  width: 100%;
19926
19998
  height: 100%;
19927
19999
  display: flex;
19928
- flex-direction: column;
19929
- justify-content: flex-end;
19930
- background-image: linear-gradient(to top, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 40%);
20000
+ justify-content: center;
20001
+ align-items: center;
20002
+ aspect-ratio: ${aspectRatio.replace(':', '/')};
20003
+ }
20004
+
20005
+ .${prefix}__video-element {
20006
+ position: absolute;
20007
+ top: 50%;
20008
+ left: 50%;
20009
+ transform: translate(-50%, -50%);
20010
+ width: 100%;
20011
+ height: 100%;
20012
+ object-fit: contain;
19931
20013
  }
19932
20014
 
19933
- .${prefix}__overlay-text {
19934
- padding: 3rem;
20015
+ @media (max-aspect-ratio: 16/9) {
20016
+ .${prefix}__video-element {
20017
+ width: 100%;
20018
+ height: auto;
20019
+ }
20020
+ }
20021
+
20022
+ @media (min-aspect-ratio: 16/9) {
20023
+ .${prefix}__video-element {
20024
+ width: auto;
20025
+ height: 100%;
20026
+ }
20027
+ }
20028
+
20029
+ .${prefix}__text {
19935
20030
  display: flex;
19936
20031
  flex-direction: column;
20032
+ justify-content: flex-start;
20033
+ align-items: flex-start;
20034
+ width: 100%;
20035
+ height: fit-content;
19937
20036
  gap: 8px;
20037
+ position: absolute;
20038
+ color: ${textColor};
20039
+ z-index: 10;
19938
20040
  }
19939
20041
 
19940
- .${prefix}__title {
19941
- color: #fff;
19942
- font-size: 26px;
19943
- margin: 0;
19944
- font-family: "Cormorant", system-ui;
19945
- font-style: normal;
19946
- font-weight: 300;
19947
- line-height: normal;
20042
+ @container (max-width: 639px) {
20043
+ .${prefix}::before {
20044
+ ${this.hasContent
20045
+ ? `background: linear-gradient(${mobileGradientDirection}, ${linearGradient});`
20046
+ : ``}
20047
+ }
20048
+
20049
+ .${prefix}__text-block-mobile--${ENUM_TEXT_BLOCK_POSITION.TOP_LEFT} {
20050
+ top: 3%;
20051
+ left: 3%;
20052
+ align-items: flex-start;
20053
+ text-align: left;
20054
+ }
20055
+
20056
+ .${prefix}__text-block-mobile--${ENUM_TEXT_BLOCK_POSITION.TOP_RIGHT} {
20057
+ top: 3%;
20058
+ right: 3%;
20059
+ align-items: flex-end;
20060
+ text-align: right;
20061
+ }
20062
+
20063
+ .${prefix}__text-block-mobile--${ENUM_TEXT_BLOCK_POSITION.MIDDLE_LEFT} {
20064
+ top: 50%;
20065
+ left: 3%;
20066
+ transform: translateY(-50%);
20067
+ align-items: flex-start;
20068
+ text-align: left;
20069
+ }
20070
+
20071
+ .${prefix}__text-block-mobile--${ENUM_TEXT_BLOCK_POSITION.MIDDLE_RIGHT} {
20072
+ top: 50%;
20073
+ right: 3%;
20074
+ transform: translateY(-50%);
20075
+ align-items: flex-end;
20076
+ text-align: right;
20077
+ }
20078
+
20079
+ .${prefix}__text-block-mobile--${ENUM_TEXT_BLOCK_POSITION.BOTTOM_LEFT} {
20080
+ bottom: 3%;
20081
+ left: 3%;
20082
+ align-items: flex-start;
20083
+ text-align: left;
20084
+ }
20085
+
20086
+ .${prefix}__text-block-mobile--${ENUM_TEXT_BLOCK_POSITION.BOTTOM_RIGHT} {
20087
+ bottom: 3%;
20088
+ right: 3%;
20089
+ align-items: flex-end;
20090
+ text-align: right;
20091
+ }
19948
20092
  }
19949
20093
 
19950
- .${prefix}__description {
19951
- color: #ccc;
19952
- margin: 0;
19953
- font-size: 13px;
19954
- font-family: "Source Sans 3", system-ui;
19955
- font-style: normal;
19956
- font-weight: 400;
19957
- line-height: 20px;
20094
+ @container (min-width: 640px) {
20095
+ .${prefix}::before {
20096
+ ${this.hasContent
20097
+ ? `background: linear-gradient(${desktopGradientDirection}, ${linearGradient});`
20098
+ : ``}
20099
+ }
20100
+
20101
+ .${prefix}__text {
20102
+ width: 70%;
20103
+ }
20104
+
20105
+ .${prefix}__text-block--${ENUM_TEXT_BLOCK_POSITION.TOP_LEFT} {
20106
+ top: 3%;
20107
+ left: 3%;
20108
+ align-items: flex-start;
20109
+ text-align: left;
20110
+ }
20111
+
20112
+ .${prefix}__text-block--${ENUM_TEXT_BLOCK_POSITION.TOP_RIGHT} {
20113
+ top: 3%;
20114
+ right: 3%;
20115
+ align-items: flex-end;
20116
+ text-align: right;
20117
+ }
20118
+
20119
+ .${prefix}__text-block--${ENUM_TEXT_BLOCK_POSITION.MIDDLE_LEFT} {
20120
+ top: 50%;
20121
+ left: 3%;
20122
+ transform: translateY(-50%);
20123
+ align-items: flex-start;
20124
+ text-align: left;
20125
+ }
20126
+
20127
+ .${prefix}__text-block--${ENUM_TEXT_BLOCK_POSITION.MIDDLE_RIGHT} {
20128
+ top: 50%;
20129
+ right: 3%;
20130
+ transform: translateY(-50%);
20131
+ align-items: flex-end;
20132
+ text-align: right;
20133
+ }
20134
+
20135
+ .${prefix}__text-block--${ENUM_TEXT_BLOCK_POSITION.BOTTOM_LEFT} {
20136
+ bottom: 3%;
20137
+ left: 3%;
20138
+ align-items: flex-start;
20139
+ text-align: left;
20140
+ }
20141
+
20142
+ .${prefix}__text-block--${ENUM_TEXT_BLOCK_POSITION.BOTTOM_RIGHT} {
20143
+ bottom: 3%;
20144
+ right: 3%;
20145
+ align-items: flex-end;
20146
+ text-align: right;
20147
+ }
19958
20148
  }
19959
20149
 
19960
- .${prefix}__video-container {
19961
- position: relative;
19962
- width: 100%;
19963
- height: 100%;
20150
+ .${prefix}__header {
20151
+ font-size: 24px;
20152
+ margin: 0;
20153
+ font-family: "Cormorant", system-ui;
20154
+ font-style: normal;
20155
+ font-weight: 300;
20156
+ line-height: normal;
19964
20157
  }
19965
20158
 
19966
- .${prefix}__video-element {
19967
- width: 100%;
19968
- height: 100%;
19969
- object-fit: cover;
19970
- display: block;
20159
+ .${prefix}__description {
20160
+ font-size: 10px;
20161
+ font-family: "Source Sans 3", system-ui;
20162
+ font-style: normal;
20163
+ font-weight: 400;
20164
+ line-height: 20px;
20165
+ margin: 0;
19971
20166
  }
19972
20167
 
19973
20168
  .${prefix}__controls {
@@ -19980,7 +20175,7 @@ class RbVideoPlayerSE extends BaseSpotComponent {
19980
20175
  align-items: center;
19981
20176
  opacity: 0;
19982
20177
  transition: opacity 0.3s;
19983
- z-index: 3;
20178
+ z-index: 100;
19984
20179
  width: fit-content;
19985
20180
  border-radius: 50%;
19986
20181
  }
@@ -19989,7 +20184,7 @@ class RbVideoPlayerSE extends BaseSpotComponent {
19989
20184
  opacity: 1;
19990
20185
  }
19991
20186
 
19992
- .${prefix}__mute-button {
20187
+ .${prefix}__mute-button {
19993
20188
  background: none;
19994
20189
  border: none;
19995
20190
  color: white;
@@ -20010,6 +20205,38 @@ class RbVideoPlayerSE extends BaseSpotComponent {
20010
20205
  .${prefix}__mute-button:hover {
20011
20206
  opacity: 0.8;
20012
20207
  }
20208
+
20209
+ @container (min-width: 640px) {
20210
+ .${prefix}__text {
20211
+ width: 70%;
20212
+ }
20213
+ }
20214
+
20215
+ @container (min-width: 768px) {
20216
+ .${prefix}__description {
20217
+ font-size: 12px;
20218
+ }
20219
+ }
20220
+
20221
+ @container (min-width: 1024px) {
20222
+ .${prefix}__header {
20223
+ font-size: 26px;
20224
+ }
20225
+
20226
+ .${prefix}__description {
20227
+ font-size: 13px;
20228
+ }
20229
+ }
20230
+
20231
+ @container (min-width: 1280px) {
20232
+ .${prefix}__header {
20233
+ font-size: 28px;
20234
+ }
20235
+
20236
+ .${prefix}__description {
20237
+ font-size: 14px;
20238
+ }
20239
+ }
20013
20240
  `;
20014
20241
  }
20015
20242
  }
@@ -54,6 +54,7 @@ export interface ISpot {
54
54
  mute?: boolean;
55
55
  loop?: boolean;
56
56
  showControls?: boolean;
57
+ showMute?: boolean;
57
58
  showPlay?: boolean;
58
59
  showTimeline?: boolean;
59
60
  showVolume?: boolean;
@@ -128,20 +128,27 @@ export interface ILongToutTallRbSpot extends ISpotTemplateBaseData {
128
128
  mobileTextBlockPosition?: ENUM_TEXT_BLOCK_POSITION.TOP_LEFT | ENUM_TEXT_BLOCK_POSITION.TOP_RIGHT | ENUM_TEXT_BLOCK_POSITION.BOTTOM_LEFT | ENUM_TEXT_BLOCK_POSITION.BOTTOM_RIGHT | ENUM_TEXT_BLOCK_POSITION.MIDDLE_LEFT | ENUM_TEXT_BLOCK_POSITION.MIDDLE_RIGHT;
129
129
  }
130
130
  export interface IVideoPlayerRbSpot extends ISpotTemplateBaseData {
131
+ header?: string;
132
+ description?: string;
133
+ mobileHeader?: string;
134
+ mobileDescription?: string;
135
+ textColor?: string;
136
+ textBlockPosition?: ENUM_TEXT_BLOCK_POSITION.TOP_LEFT | ENUM_TEXT_BLOCK_POSITION.TOP_RIGHT | ENUM_TEXT_BLOCK_POSITION.BOTTOM_LEFT | ENUM_TEXT_BLOCK_POSITION.BOTTOM_RIGHT | ENUM_TEXT_BLOCK_POSITION.MIDDLE_LEFT | ENUM_TEXT_BLOCK_POSITION.MIDDLE_RIGHT;
137
+ mobileTextBlockPosition?: ENUM_TEXT_BLOCK_POSITION.TOP_LEFT | ENUM_TEXT_BLOCK_POSITION.TOP_RIGHT | ENUM_TEXT_BLOCK_POSITION.BOTTOM_LEFT | ENUM_TEXT_BLOCK_POSITION.BOTTOM_RIGHT | ENUM_TEXT_BLOCK_POSITION.MIDDLE_LEFT | ENUM_TEXT_BLOCK_POSITION.MIDDLE_RIGHT;
131
138
  video: {
132
139
  url?: string;
140
+ mobileUrl?: string;
133
141
  poster?: string;
134
- posterTitle?: string;
135
- posterDescription?: string;
136
- mobilePosterTitle?: string;
137
- mobilePosterDescription?: string;
142
+ mobilePoster?: string;
138
143
  autoplay?: boolean;
139
144
  mute?: boolean;
140
145
  loop?: boolean;
141
146
  showControls?: boolean;
147
+ showMute?: boolean;
142
148
  showPlay?: boolean;
143
149
  showTimeline?: boolean;
144
150
  showVolume?: boolean;
145
151
  showTime?: boolean;
152
+ aspectRatio?: '16:9' | '4:3' | '1:1' | '3:4' | '9:16';
146
153
  };
147
154
  }
@@ -1,6 +1,7 @@
1
1
  import { BaseSpotComponent } from 'modules/element/component/spot';
2
2
  import type { IVideoPlayerRbSpot } from '../rb-template.interface';
3
3
  export declare class RbVideoPlayerSE extends BaseSpotComponent<IVideoPlayerRbSpot> {
4
+ protected reRenderOnDeviceChange: boolean;
4
5
  private readonly videoSelector;
5
6
  private readonly muteButtonSelector;
6
7
  private video;
@@ -15,6 +16,8 @@ export declare class RbVideoPlayerSE extends BaseSpotComponent<IVideoPlayerRbSpo
15
16
  private initializeElements;
16
17
  private attachEventListeners;
17
18
  private removeEventListeners;
19
+ private getGradientDirection;
20
+ private get hasContent();
18
21
  protected template(): string;
19
22
  protected styles(): string;
20
23
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@liquidcommercedev/rmn-sdk",
3
3
  "description": "LiquidCommerce RMN SDK",
4
4
  "author": "LiquidCommerce Tech",
5
- "version": "1.5.0-beta.43",
5
+ "version": "1.5.0-beta.44",
6
6
  "homepage": "https://docs.liquidcommerce.co/rmn-sdk",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.esm.js",