@gravity-ui/page-constructor 8.3.0 → 8.4.0

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.
Files changed (140) hide show
  1. package/build/cjs/blocks/Header/Header.css +6 -0
  2. package/build/cjs/blocks/Header/schema.js +1 -25
  3. package/build/cjs/blocks/Header/schema.js.map +1 -1
  4. package/build/cjs/blocks/Hero/Hero.css +211 -0
  5. package/build/cjs/blocks/Hero/Hero.d.ts +3 -0
  6. package/build/cjs/blocks/Hero/Hero.js +50 -0
  7. package/build/cjs/blocks/Hero/Hero.js.map +1 -0
  8. package/build/cjs/blocks/Hero/hooks.d.ts +4 -0
  9. package/build/cjs/blocks/Hero/hooks.js +38 -0
  10. package/build/cjs/blocks/Hero/hooks.js.map +1 -0
  11. package/build/cjs/blocks/Hero/schema.d.ts +2076 -0
  12. package/build/cjs/blocks/Hero/schema.js +66 -0
  13. package/build/cjs/blocks/Hero/schema.js.map +1 -0
  14. package/build/cjs/blocks/index.d.ts +1 -0
  15. package/build/cjs/blocks/index.js +3 -1
  16. package/build/cjs/blocks/index.js.map +1 -1
  17. package/build/cjs/components/Buttons/Buttons.d.ts +2 -1
  18. package/build/cjs/components/Buttons/Buttons.js +6 -3
  19. package/build/cjs/components/Buttons/Buttons.js.map +1 -1
  20. package/build/cjs/components/DefaultVideo/DefaultVideo.d.ts +1 -0
  21. package/build/cjs/components/DefaultVideo/DefaultVideo.js +2 -2
  22. package/build/cjs/components/DefaultVideo/DefaultVideo.js.map +1 -1
  23. package/build/cjs/components/Image/Image.d.ts +5 -1
  24. package/build/cjs/components/Image/Image.js +4 -2
  25. package/build/cjs/components/Image/Image.js.map +1 -1
  26. package/build/cjs/components/ImageBase/ImageBase.d.ts +2 -2
  27. package/build/cjs/components/ImageBase/ImageBase.js +5 -5
  28. package/build/cjs/components/ImageBase/ImageBase.js.map +1 -1
  29. package/build/cjs/components/Media/Image/Image.d.ts +4 -0
  30. package/build/cjs/components/Media/Image/Image.js +3 -3
  31. package/build/cjs/components/Media/Image/Image.js.map +1 -1
  32. package/build/cjs/components/Media/Media.js +8 -4
  33. package/build/cjs/components/Media/Media.js.map +1 -1
  34. package/build/cjs/components/Media/Video/Video.d.ts +5 -0
  35. package/build/cjs/components/Media/Video/Video.js +30 -4
  36. package/build/cjs/components/Media/Video/Video.js.map +1 -1
  37. package/build/cjs/components/ReactPlayer/ReactPlayer.css +5 -0
  38. package/build/cjs/components/ReactPlayer/ReactPlayer.d.ts +5 -0
  39. package/build/cjs/components/ReactPlayer/ReactPlayer.js +12 -4
  40. package/build/cjs/components/ReactPlayer/ReactPlayer.js.map +1 -1
  41. package/build/cjs/components/Title/TitleItem.css +6 -0
  42. package/build/cjs/constructor-items.d.ts +1 -0
  43. package/build/cjs/constructor-items.js +1 -0
  44. package/build/cjs/constructor-items.js.map +1 -1
  45. package/build/cjs/context/imageContext/imageContext.d.ts +1 -1
  46. package/build/cjs/context/imageContext/imageContext.js.map +1 -1
  47. package/build/cjs/demo/ComponentsText.stories.js +3 -3
  48. package/build/cjs/demo/ComponentsText.stories.js.map +1 -1
  49. package/build/cjs/hooks/index.d.ts +1 -0
  50. package/build/cjs/hooks/index.js +1 -0
  51. package/build/cjs/hooks/index.js.map +1 -1
  52. package/build/cjs/hooks/useImageSize.d.ts +8 -0
  53. package/build/cjs/hooks/useImageSize.js +52 -0
  54. package/build/cjs/hooks/useImageSize.js.map +1 -0
  55. package/build/cjs/models/constructor-items/blocks.d.ts +22 -3
  56. package/build/cjs/models/constructor-items/blocks.js +6 -1
  57. package/build/cjs/models/constructor-items/blocks.js.map +1 -1
  58. package/build/cjs/schema/constants.js +1 -0
  59. package/build/cjs/schema/constants.js.map +1 -1
  60. package/build/cjs/schema/validators/blocks.d.ts +1 -0
  61. package/build/cjs/schema/validators/blocks.js +1 -0
  62. package/build/cjs/schema/validators/blocks.js.map +1 -1
  63. package/build/cjs/schema/validators/common.d.ts +28 -0
  64. package/build/cjs/schema/validators/common.js +26 -1
  65. package/build/cjs/schema/validators/common.js.map +1 -1
  66. package/build/cjs/text-transform/config.js +17 -0
  67. package/build/cjs/text-transform/config.js.map +1 -1
  68. package/build/esm/blocks/Header/Header.css +6 -0
  69. package/build/esm/blocks/Header/schema.js +2 -26
  70. package/build/esm/blocks/Header/schema.js.map +1 -1
  71. package/build/esm/blocks/Hero/Hero.css +211 -0
  72. package/build/esm/blocks/Hero/Hero.d.ts +4 -0
  73. package/build/esm/blocks/Hero/Hero.js +48 -0
  74. package/build/esm/blocks/Hero/Hero.js.map +1 -0
  75. package/build/esm/blocks/Hero/hooks.d.ts +4 -0
  76. package/build/esm/blocks/Hero/hooks.js +33 -0
  77. package/build/esm/blocks/Hero/hooks.js.map +1 -0
  78. package/build/esm/blocks/Hero/schema.d.ts +2076 -0
  79. package/build/esm/blocks/Hero/schema.js +62 -0
  80. package/build/esm/blocks/Hero/schema.js.map +1 -0
  81. package/build/esm/blocks/index.d.ts +1 -0
  82. package/build/esm/blocks/index.js +1 -0
  83. package/build/esm/blocks/index.js.map +1 -1
  84. package/build/esm/components/Buttons/Buttons.d.ts +2 -1
  85. package/build/esm/components/Buttons/Buttons.js +6 -3
  86. package/build/esm/components/Buttons/Buttons.js.map +1 -1
  87. package/build/esm/components/DefaultVideo/DefaultVideo.d.ts +1 -0
  88. package/build/esm/components/DefaultVideo/DefaultVideo.js +2 -2
  89. package/build/esm/components/DefaultVideo/DefaultVideo.js.map +1 -1
  90. package/build/esm/components/Image/Image.d.ts +5 -1
  91. package/build/esm/components/Image/Image.js +4 -2
  92. package/build/esm/components/Image/Image.js.map +1 -1
  93. package/build/esm/components/ImageBase/ImageBase.d.ts +2 -2
  94. package/build/esm/components/ImageBase/ImageBase.js +5 -4
  95. package/build/esm/components/ImageBase/ImageBase.js.map +1 -1
  96. package/build/esm/components/Media/Image/Image.d.ts +4 -0
  97. package/build/esm/components/Media/Image/Image.js +3 -3
  98. package/build/esm/components/Media/Image/Image.js.map +1 -1
  99. package/build/esm/components/Media/Media.js +8 -4
  100. package/build/esm/components/Media/Media.js.map +1 -1
  101. package/build/esm/components/Media/Video/Video.d.ts +5 -0
  102. package/build/esm/components/Media/Video/Video.js +30 -4
  103. package/build/esm/components/Media/Video/Video.js.map +1 -1
  104. package/build/esm/components/ReactPlayer/ReactPlayer.css +5 -0
  105. package/build/esm/components/ReactPlayer/ReactPlayer.d.ts +5 -0
  106. package/build/esm/components/ReactPlayer/ReactPlayer.js +13 -5
  107. package/build/esm/components/ReactPlayer/ReactPlayer.js.map +1 -1
  108. package/build/esm/components/Title/TitleItem.css +6 -0
  109. package/build/esm/constructor-items.d.ts +1 -0
  110. package/build/esm/constructor-items.js +2 -1
  111. package/build/esm/constructor-items.js.map +1 -1
  112. package/build/esm/context/imageContext/imageContext.d.ts +1 -1
  113. package/build/esm/context/imageContext/imageContext.js.map +1 -1
  114. package/build/esm/demo/ComponentsText.stories.js +3 -3
  115. package/build/esm/demo/ComponentsText.stories.js.map +1 -1
  116. package/build/esm/hooks/index.d.ts +1 -0
  117. package/build/esm/hooks/index.js +1 -0
  118. package/build/esm/hooks/index.js.map +1 -1
  119. package/build/esm/hooks/useImageSize.d.ts +8 -0
  120. package/build/esm/hooks/useImageSize.js +47 -0
  121. package/build/esm/hooks/useImageSize.js.map +1 -0
  122. package/build/esm/models/constructor-items/blocks.d.ts +22 -3
  123. package/build/esm/models/constructor-items/blocks.js +6 -1
  124. package/build/esm/models/constructor-items/blocks.js.map +1 -1
  125. package/build/esm/schema/constants.js +2 -1
  126. package/build/esm/schema/constants.js.map +1 -1
  127. package/build/esm/schema/validators/blocks.d.ts +1 -0
  128. package/build/esm/schema/validators/blocks.js +1 -0
  129. package/build/esm/schema/validators/blocks.js.map +1 -1
  130. package/build/esm/schema/validators/common.d.ts +28 -0
  131. package/build/esm/schema/validators/common.js +25 -0
  132. package/build/esm/schema/validators/common.js.map +1 -1
  133. package/build/esm/text-transform/config.js +17 -0
  134. package/build/esm/text-transform/config.js.map +1 -1
  135. package/package.json +1 -1
  136. package/schema/index.js +1 -1
  137. package/server/models/constructor-items/blocks.d.ts +22 -3
  138. package/server/models/constructor-items/blocks.js +6 -1
  139. package/server/text-transform/config.js +17 -0
  140. package/styles/mixins.scss +4 -0
@@ -67,6 +67,12 @@ unpredictable css rules order in build */
67
67
  font-weight: var(--g-text-accent-font-weight);
68
68
  position: relative;
69
69
  }
70
+ @media (max-width: 769px) {
71
+ .pc-header-block__title.pc-header-block__title {
72
+ font-size: var(--g-text-display-3-font-size);
73
+ line-height: var(--g-text-display-3-line-height);
74
+ }
75
+ }
70
76
  @media (max-width: 577px) {
71
77
  .pc-header-block__title.pc-header-block__title {
72
78
  font-size: var(--g-text-display-2-font-size);
@@ -86,31 +86,7 @@ exports.HeaderProperties = {
86
86
  type: 'string',
87
87
  enum: ['default', 'dark'],
88
88
  },
89
- breadcrumbs: {
90
- type: 'object',
91
- additionalProperties: false,
92
- required: ['items'],
93
- properties: {
94
- items: {
95
- type: 'array',
96
- items: {
97
- type: 'object',
98
- additionalProperties: false,
99
- required: ['url', 'text'],
100
- properties: {
101
- url: {
102
- type: 'string',
103
- },
104
- text: {
105
- type: 'string',
106
- contentType: 'text',
107
- },
108
- },
109
- },
110
- },
111
- theme: { type: 'string', enum: ['light', 'dark'] },
112
- },
113
- },
89
+ breadcrumbs: common_1.HeaderBreadcrumbsProps,
114
90
  status: {
115
91
  type: 'string',
116
92
  },
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"../../../../src","sources":["blocks/Header/schema.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AACzD,8DAOwC;AACxC,4DAA4D;AAE/C,QAAA,sBAAsB,GAAG;IAClC,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,UAAU,EAAE;QACR,GAAG,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QACrB,QAAQ,EAAE,EAAC,IAAI,EAAE,SAAS,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AI,EAAE,SAAS;KAClB;CACJ,CAAC;AAEW,QAAA,WAAW,GAAG;IACvB,cAAc,EAAE;QACZ,oBAAoB,EAAE,KAAK;QAC3B,QAAQ,EAAE,CAAC,OAAO,CAAC;QACnB,UAAU,EAAE;YACR,GAAG,uBAAc;YACjB,GAAG,wBAAgB;SACtB;KACJ;CACJ,CAAC","sourcesContent":["import {ImageProps} from '../../components/Image/schema';\nimport {\n BlockBaseProps,\n ButtonBlock,\n MediaProps,\n VideoProps,\n mediaView,\n withTheme,\n} from '../../schema/validators/common';\nimport {filteredArray} from '../../schema/validators/utils';\n\nexport const HeaderVideoIframeProps = {\n type: 'object',\n additionalProperties: false,\n required: ['src'],\n properties: {\n src: {type: 'string'},\n autoplay: {type: 'boolean'},\n previewImg: {type: 'string'},\n height: {type: 'number'},\n },\n};\n\nexport const HeaderBackgroundProps = {\n type: 'object',\n additionalProperties: false,\n required: [],\n properties: {\n ...MediaProps,\n fullWidth: {type: 'boolean'},\n fullWidthMedia: {type: 'boolean'},\n },\n};\n\nexport const HeaderProperties = {\n title: {\n type: 'string',\n contentType: 'text',\n },\n overtitle: {\n type: 'string',\n contentType: 'text',\n },\n description: {\n type: 'string',\n contentType: 'yfm',\n inputType: 'textarea',\n },\n additionalInfo: {\n type: 'string',\n contentType: 'yfm',\n inputType: 'textarea',\n },\n width: {\n type: 'string',\n enum: ['s', 'm', 'l'],\n },\n buttons: filteredArray(ButtonBlock),\n offset: {\n type: 'string',\n enum: ['default', 'large'],\n },\n image: withTheme(ImageProps),\n video: withTheme(VideoProps),\n videoIframe: withTheme(HeaderVideoIframeProps),\n mediaView: {\n type: 'string',\n enum: mediaView,\n },\n backLink: {\n type: 'object',\n required: ['url', 'title'],\n properties: {\n url: {\n type: 'string',\n },\n title: {\n type: 'string',\n contentType: 'text',\n },\n },\n },\n imageSize: {\n type: 'string',\n enum: ['s', 'm'],\n },\n verticalOffset: {\n type: 'string',\n enum: ['0', 's', 'm', 'l', 'xl'],\n },\n background: withTheme(HeaderBackgroundProps),\n theme: {\n type: 'string',\n enum: ['default', 'dark'],\n },\n breadcrumbs: {\n type: 'object',\n additionalProperties: false,\n required: ['items'],\n properties: {\n items: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['url', 'text'],\n properties: {\n url: {\n type: 'string',\n },\n text: {\n type: 'string',\n contentType: 'text',\n },\n },\n },\n },\n theme: {type: 'string', enum: ['light', 'dark']},\n },\n },\n status: {\n type: 'string',\n },\n centered: {\n type: 'boolean',\n },\n};\n\nexport const HeaderBlock = {\n 'header-block': {\n additionalProperties: false,\n required: ['title'],\n properties: {\n ...BlockBaseProps,\n ...HeaderProperties,\n },\n },\n};\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"../../../../src","sources":["blocks/Header/schema.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AACzD,8DAQwC;AACxC,4DAA4D;AAE/C,QAAA,sBAAsB,GAAG;IAClC,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,UAAU,EAAE;QACR,GAAG,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QACrB,QAAQ,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC;QAC3B,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC5B,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;KAC3B;CACJ,CAAC;AAEW,QAAA,qBAAqB,GAAG;IACjC,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE;QACR,GAAG,mBAAU;QACb,SAAS,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC;QAC5B,cAAc,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC;KACpC;CACJ,CAAC;AAEW,QAAA,gBAAgB,GAAG;IAC5B,KAAK,EAAE;QACH,IAAI,EAAE,QAAQ;QACd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ACD,UAAU,EAAE,IAAA,kBAAS,EAAC,6BAAqB,CAAC;IAC5C,KAAK,EAAE;QACH,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;KAC5B;IACD,WAAW,EAAE,+BAAsB;IACnC,MAAM,EAAE;QACJ,IAAI,EAAE,QAAQ;KACjB;IACD,QAAQ,EAAE;QACN,IAAI,EAAE,SAAS;KAClB;CACJ,CAAC;AAEW,QAAA,WAAW,GAAG;IACvB,cAAc,EAAE;QACZ,oBAAoB,EAAE,KAAK;QAC3B,QAAQ,EAAE,CAAC,OAAO,CAAC;QACnB,UAAU,EAAE;YACR,GAAG,uBAAc;YACjB,GAAG,wBAAgB;SACtB;KACJ;CACJ,CAAC","sourcesContent":["import {ImageProps} from '../../components/Image/schema';\nimport {\n BlockBaseProps,\n ButtonBlock,\n HeaderBreadcrumbsProps,\n MediaProps,\n VideoProps,\n mediaView,\n withTheme,\n} from '../../schema/validators/common';\nimport {filteredArray} from '../../schema/validators/utils';\n\nexport const HeaderVideoIframeProps = {\n type: 'object',\n additionalProperties: false,\n required: ['src'],\n properties: {\n src: {type: 'string'},\n autoplay: {type: 'boolean'},\n previewImg: {type: 'string'},\n height: {type: 'number'},\n },\n};\n\nexport const HeaderBackgroundProps = {\n type: 'object',\n additionalProperties: false,\n required: [],\n properties: {\n ...MediaProps,\n fullWidth: {type: 'boolean'},\n fullWidthMedia: {type: 'boolean'},\n },\n};\n\nexport const HeaderProperties = {\n title: {\n type: 'string',\n contentType: 'text',\n },\n overtitle: {\n type: 'string',\n contentType: 'text',\n },\n description: {\n type: 'string',\n contentType: 'yfm',\n inputType: 'textarea',\n },\n additionalInfo: {\n type: 'string',\n contentType: 'yfm',\n inputType: 'textarea',\n },\n width: {\n type: 'string',\n enum: ['s', 'm', 'l'],\n },\n buttons: filteredArray(ButtonBlock),\n offset: {\n type: 'string',\n enum: ['default', 'large'],\n },\n image: withTheme(ImageProps),\n video: withTheme(VideoProps),\n videoIframe: withTheme(HeaderVideoIframeProps),\n mediaView: {\n type: 'string',\n enum: mediaView,\n },\n backLink: {\n type: 'object',\n required: ['url', 'title'],\n properties: {\n url: {\n type: 'string',\n },\n title: {\n type: 'string',\n contentType: 'text',\n },\n },\n },\n imageSize: {\n type: 'string',\n enum: ['s', 'm'],\n },\n verticalOffset: {\n type: 'string',\n enum: ['0', 's', 'm', 'l', 'xl'],\n },\n background: withTheme(HeaderBackgroundProps),\n theme: {\n type: 'string',\n enum: ['default', 'dark'],\n },\n breadcrumbs: HeaderBreadcrumbsProps,\n status: {\n type: 'string',\n },\n centered: {\n type: 'boolean',\n },\n};\n\nexport const HeaderBlock = {\n 'header-block': {\n additionalProperties: false,\n required: ['title'],\n properties: {\n ...BlockBaseProps,\n ...HeaderProperties,\n },\n },\n};\n"]}
@@ -0,0 +1,211 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-hero-block {
4
+ position: relative;
5
+ }
6
+ .pc-hero-block__background {
7
+ position: absolute;
8
+ top: 0;
9
+ bottom: 0;
10
+ left: 50%;
11
+ width: min(1440px, 100%);
12
+ border-radius: var(--pc-border-radius);
13
+ transform: translateX(-50%);
14
+ }
15
+ .pc-hero-block__background_full-width {
16
+ display: flex;
17
+ justify-content: center;
18
+ width: 100%;
19
+ border-radius: initial;
20
+ }
21
+ .pc-hero-block__background > div {
22
+ width: 100%;
23
+ height: 100%;
24
+ }
25
+ .pc-hero-block__background-image {
26
+ width: 100%;
27
+ height: 100%;
28
+ }
29
+ .pc-hero-block__background-video {
30
+ width: 100%;
31
+ height: 100%;
32
+ }
33
+ .pc-hero-block__background-video > video {
34
+ width: 100%;
35
+ height: 100%;
36
+ object-fit: cover;
37
+ }
38
+ .pc-hero-block__wrapper {
39
+ position: relative;
40
+ display: grid;
41
+ grid-template-columns: repeat(12, 1fr);
42
+ grid-template-rows: 1fr;
43
+ gap: 16px;
44
+ padding-inline: 8px;
45
+ }
46
+ .pc-hero-block__breadcrumbs {
47
+ position: absolute;
48
+ top: 16px;
49
+ left: 8px;
50
+ max-width: 100%;
51
+ }
52
+ .pc-hero-block__content {
53
+ grid-column: span 6;
54
+ padding-inline-end: 48px;
55
+ }
56
+ .pc-hero-block__content_vertical-offset_s {
57
+ padding-block: 48px;
58
+ }
59
+ .pc-hero-block__content_vertical-offset_m {
60
+ padding-block: 96px;
61
+ }
62
+ .pc-hero-block__content_vertical-offset_l {
63
+ padding-block: 128px;
64
+ }
65
+ .pc-hero-block__content_vertical-offset_xl {
66
+ padding-block: 160px;
67
+ }
68
+ .pc-hero-block__content_no-media {
69
+ width: 100%;
70
+ }
71
+ .pc-hero-block__content-overtitle {
72
+ margin-bottom: 8px;
73
+ }
74
+ .pc-hero-block__content-overtitle_theme_light {
75
+ --_--overtitle-color: var(--g-color-text-dark-primary);
76
+ }
77
+ .pc-hero-block__content-overtitle_theme_dark {
78
+ --_--overtitle-color: var(--g-color-text-light-primary);
79
+ }
80
+ .pc-hero-block__content-overtitle,
81
+ .pc-hero-block__content-overtitle .yfm_constructor {
82
+ font-size: var(--g-text-body-3-font-size);
83
+ line-height: var(--g-text-body-3-line-height);
84
+ color: var(--_--overtitle-color);
85
+ }
86
+ .pc-hero-block__media {
87
+ position: relative;
88
+ grid-column: span 6;
89
+ padding-block: 16px;
90
+ }
91
+ .pc-hero-block__media-container {
92
+ position: absolute;
93
+ inset: 16px 0;
94
+ display: flex;
95
+ align-items: center;
96
+ justify-content: center;
97
+ }
98
+ .pc-hero-block__media-container-content,
99
+ .pc-hero-block__media-container-content .pc-media-component-image__item,
100
+ .pc-hero-block__media-container-content .pc-fullscreen-image,
101
+ .pc-hero-block__media-container-content .pc-fullscreen-image__image-wrapper,
102
+ .pc-hero-block__media-container-content .pc-media-component-video__wrap,
103
+ .pc-hero-block__media-container-content .pc-media-component-video__react-player,
104
+ .pc-hero-block__media-container-content .pc-default-video,
105
+ .pc-hero-block__media-container-content .pc-ReactPlayer__preview-img,
106
+ .pc-hero-block__media-container-content .pc-full-screen-media,
107
+ .pc-hero-block__media-container-content .pc-full-screen-media__media-wrapper {
108
+ width: 100%;
109
+ height: auto;
110
+ }
111
+ .pc-hero-block__media-container-content .pc-ReactPlayer__player,
112
+ .pc-hero-block__media-container-content .pc-ReactPlayer__player > video,
113
+ .pc-hero-block__media-container-content .react-player__preview {
114
+ /* stylelint-disable declaration-no-important */
115
+ width: 100% !important;
116
+ height: auto !important;
117
+ /* stylelint-enable declaration-no-important */
118
+ }
119
+ .pc-hero-block__media-container-content_vertical,
120
+ .pc-hero-block__media-container-content_vertical .pc-media-component-image__item,
121
+ .pc-hero-block__media-container-content_vertical .pc-fullscreen-image,
122
+ .pc-hero-block__media-container-content_vertical .pc-fullscreen-image__image-wrapper,
123
+ .pc-hero-block__media-container-content_vertical .pc-media-component-video__wrap,
124
+ .pc-hero-block__media-container-content_vertical .pc-media-component-video__react-player,
125
+ .pc-hero-block__media-container-content_vertical .pc-default-video,
126
+ .pc-hero-block__media-container-content_vertical .pc-ReactPlayer__preview-img,
127
+ .pc-hero-block__media-container-content_vertical .pc-full-screen-media,
128
+ .pc-hero-block__media-container-content_vertical .pc-full-screen-media__media-wrapper {
129
+ width: auto;
130
+ height: 100%;
131
+ }
132
+ .pc-hero-block__media-container-content_vertical .pc-ReactPlayer__player,
133
+ .pc-hero-block__media-container-content_vertical .pc-ReactPlayer__player > video,
134
+ .pc-hero-block__media-container-content_vertical .react-player__preview {
135
+ /* stylelint-disable declaration-no-important */
136
+ width: auto !important;
137
+ height: 100% !important;
138
+ /* stylelint-enable declaration-no-important */
139
+ }
140
+ .pc-hero-block__media-container-content_round-corners {
141
+ border-radius: var(--pc-border-radius);
142
+ }
143
+ .pc-hero-block__media-container-content .pc-ReactPlayer__player {
144
+ display: flex;
145
+ }
146
+ .pc-hero-block__media-container-content .pc-Media__youtube {
147
+ border-radius: initial;
148
+ }
149
+ .pc-hero-block__media-container-content .pc-media-component-data-lens__wrap,
150
+ .pc-hero-block__media-container-content .pc-media-component-iframe {
151
+ margin: 0;
152
+ }
153
+ @media (max-width: 993px) {
154
+ .pc-hero-block__content {
155
+ grid-column: span 7;
156
+ }
157
+ .pc-hero-block__content_no-media {
158
+ grid-column: span 12;
159
+ }
160
+ .pc-hero-block__media {
161
+ grid-column: span 5;
162
+ }
163
+ }
164
+ @media (max-width: 769px) {
165
+ .pc-hero-block__wrapper {
166
+ padding-block: 20px 24px;
167
+ }
168
+ .pc-hero-block__breadcrumbs {
169
+ grid-column: span 12;
170
+ order: 1;
171
+ position: initial;
172
+ }
173
+ .pc-hero-block__content {
174
+ grid-column: span 12;
175
+ order: 3;
176
+ width: 100%;
177
+ padding-block: 0 16px;
178
+ padding-inline: 0;
179
+ }
180
+ .pc-hero-block__media {
181
+ grid-column: span 12;
182
+ order: 2;
183
+ width: 100%;
184
+ padding-block: 0;
185
+ }
186
+ .pc-hero-block__media-container {
187
+ position: initial;
188
+ inset: 0;
189
+ }
190
+ .pc-hero-block__media-container-content_vertical,
191
+ .pc-hero-block__media-container-content_vertical .pc-media-component-image__item,
192
+ .pc-hero-block__media-container-content_vertical .pc-fullscreen-image,
193
+ .pc-hero-block__media-container-content_vertical .pc-fullscreen-image__image-wrapper,
194
+ .pc-hero-block__media-container-content_vertical .pc-media-component-video__wrap,
195
+ .pc-hero-block__media-container-content_vertical .pc-media-component-video__react-player,
196
+ .pc-hero-block__media-container-content_vertical .pc-default-video,
197
+ .pc-hero-block__media-container-content_vertical .pc-ReactPlayer__preview-img,
198
+ .pc-hero-block__media-container-content_vertical .pc-full-screen-media,
199
+ .pc-hero-block__media-container-content_vertical .pc-full-screen-media__media-wrapper {
200
+ width: 100%;
201
+ height: auto;
202
+ }
203
+ .pc-hero-block__media-container-content_vertical .pc-ReactPlayer__player,
204
+ .pc-hero-block__media-container-content_vertical .pc-ReactPlayer__player > video,
205
+ .pc-hero-block__media-container-content_vertical .react-player__preview {
206
+ /* stylelint-disable declaration-no-important */
207
+ width: 100% !important;
208
+ height: auto !important;
209
+ /* stylelint-enable declaration-no-important */
210
+ }
211
+ }
@@ -0,0 +1,3 @@
1
+ import { HeroBlockProps } from "../../models/index.js";
2
+ declare const Hero: (props: HeroBlockProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default Hero;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const React = tslib_1.__importStar(require("react"));
6
+ const components_1 = require("../../components/index.js");
7
+ const constants_1 = require("../../constants.js");
8
+ const theme_1 = require("../../context/theme/index.js");
9
+ const windowWidthContext_1 = require("../../context/windowWidthContext/index.js");
10
+ const grid_1 = require("../../grid/index.js");
11
+ const sub_blocks_1 = require("../../sub-blocks/index.js");
12
+ const utils_1 = require("../../utils/index.js");
13
+ const hooks_1 = require("./hooks.js");
14
+ const b = (0, utils_1.block)('hero-block');
15
+ const Hero = (props) => {
16
+ const { breadcrumbs, overtitle, buttons, media: themedMedia, fullWidth, verticalOffset = 'm', theme: contentTheme = 'default', background: themedBackground, ...contentProps } = props;
17
+ const [mediaAspectRatio, setMediaAspectRatio] = React.useState(Infinity);
18
+ const { aspectRatio: mediaContainerAspectRatio, ref: mediaContainerRef } = (0, hooks_1.useContainerAspectRatio)();
19
+ const isDesktop = (0, windowWidthContext_1.useWindowWidth)() > constants_1.BREAKPOINTS.md;
20
+ const isMediaVertical = mediaAspectRatio < mediaContainerAspectRatio;
21
+ const contextTheme = (0, theme_1.useTheme)();
22
+ const theme = contentTheme === 'default' ? contextTheme : contentTheme;
23
+ const background = (0, utils_1.getThemedValue)(themedBackground, theme);
24
+ const media = (0, utils_1.getThemedValue)(themedMedia, theme);
25
+ const buttonProps = React.useMemo(() => buttons?.map((buttonThemed) => {
26
+ if (React.isValidElement(buttonThemed)) {
27
+ return buttonThemed;
28
+ }
29
+ const button = (0, utils_1.getThemedValue)(buttonThemed, theme);
30
+ return {
31
+ size: 'xl',
32
+ ...button,
33
+ };
34
+ }), [buttons, theme]);
35
+ const onMediaIntrinsicSizeChange = React.useCallback(({ width, height }) => setMediaAspectRatio(width / height), []);
36
+ return ((0, jsx_runtime_1.jsxs)("header", { className: b(), children: [background && ((0, jsx_runtime_1.jsx)(components_1.Media, { className: b('background', {
37
+ ['full-width']: fullWidth,
38
+ }), imageClassName: b('background-image'), videoClassName: b('background-video'), ...background, isBackground: true })), (0, jsx_runtime_1.jsx)(grid_1.Grid, { children: (0, jsx_runtime_1.jsxs)("div", { className: b('wrapper'), children: [breadcrumbs && ((0, jsx_runtime_1.jsx)(components_1.HeaderBreadcrumbs, { className: b('breadcrumbs'), ...breadcrumbs, theme: theme })), (0, jsx_runtime_1.jsxs)("div", { className: b('content', {
39
+ ['vertical-offset']: verticalOffset,
40
+ ['no-media']: !media,
41
+ }), children: [overtitle && ((0, jsx_runtime_1.jsx)("div", { className: b('content-overtitle', { theme }), children: typeof overtitle === 'string' ? ((0, jsx_runtime_1.jsx)(components_1.YFMWrapper, { tagName: "span", content: overtitle, modifiers: {
42
+ constructor: true,
43
+ constructorTheme: theme,
44
+ } })) : (overtitle) })), (0, jsx_runtime_1.jsx)(sub_blocks_1.Content, { size: "xl", colSizes: { all: 12 }, ...contentProps, buttons: buttonProps, theme: contentTheme })] }), media && ((0, jsx_runtime_1.jsx)("div", { className: b('media'), children: (0, jsx_runtime_1.jsx)("div", { className: b('media-container'), ref: mediaContainerRef, children: (0, jsx_runtime_1.jsx)(components_1.Media, { className: b('media-container-content', {
45
+ ['round-corners']: media.roundCorners ?? true,
46
+ vertical: isDesktop && isMediaVertical,
47
+ }), ...media, disablePlayerAutoSizing: true, onIntrinsicSizeChange: onMediaIntrinsicSizeChange }) }) }))] }) })] }));
48
+ };
49
+ exports.default = Hero;
50
+ //# sourceMappingURL=Hero.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hero.js","sourceRoot":"../../../../src","sources":["blocks/Hero/Hero.tsx"],"names":[],"mappings":";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AU,IACP,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE;4CACP,WAAW,EAAE,IAAI;4CACjB,gBAAgB,EAAE,KAAK;yCAC1B,GACH,CACL,CAAC,CAAC,CAAC,CACA,SAAS,CACZ,GACC,CACT,EACD,uBAAC,oBAAO,IACJ,IAAI,EAAC,IAAI,EACT,QAAQ,EAAE,EAAC,GAAG,EAAE,EAAE,EAAC,KACf,YAAY,EAChB,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,YAAY,GACrB,IACA,EACL,KAAK,IAAI,CACN,gCAAK,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,YACtB,gCAAK,SAAS,EAAE,CAAC,CAAC,iBAAiB,CAAC,EAAE,GAAG,EAAE,iBAAiB,YACxD,uBAAC,kBAAK,IACF,SAAS,EAAE,CAAC,CAAC,yBAAyB,EAAE;wCACpC,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,YAAY,IAAI,IAAI;wCAC7C,QAAQ,EAAE,SAAS,IAAI,eAAe;qCACzC,CAAC,KACE,KAAK,EACT,uBAAuB,QACvB,qBAAqB,EAAE,0BAA0B,GACnD,GACA,GACJ,CACT,IACC,GACH,IACF,CACZ,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {HeaderBreadcrumbs, Media, YFMWrapper} from '../../components';\nimport {BREAKPOINTS} from '../../constants';\nimport {useTheme} from '../../context/theme';\nimport {useWindowWidth} from '../../context/windowWidthContext';\nimport {Grid} from '../../grid';\nimport {ButtonProps, HeroBlockProps, Theme} from '../../models';\nimport {Content} from '../../sub-blocks';\nimport {block, getThemedValue} from '../../utils';\n\nimport {useContainerAspectRatio} from './hooks';\n\nimport './Hero.scss';\n\nconst b = block('hero-block');\n\nconst Hero = (props: HeroBlockProps) => {\n const {\n breadcrumbs,\n overtitle,\n buttons,\n media: themedMedia,\n fullWidth,\n verticalOffset = 'm',\n theme: contentTheme = 'default',\n background: themedBackground,\n ...contentProps\n } = props;\n\n const [mediaAspectRatio, setMediaAspectRatio] = React.useState<number>(Infinity);\n\n const {aspectRatio: mediaContainerAspectRatio, ref: mediaContainerRef} =\n useContainerAspectRatio();\n\n const isDesktop = useWindowWidth() > BREAKPOINTS.md;\n const isMediaVertical = mediaAspectRatio < mediaContainerAspectRatio;\n\n const contextTheme = useTheme();\n const theme = contentTheme === 'default' ? contextTheme : (contentTheme as Theme);\n\n const background = getThemedValue(themedBackground, theme);\n const media = getThemedValue(themedMedia, theme);\n\n const buttonProps = React.useMemo<(ButtonProps | React.ReactNode)[] | undefined>(\n () =>\n buttons?.map((buttonThemed) => {\n if (React.isValidElement(buttonThemed)) {\n return buttonThemed;\n }\n\n const button = getThemedValue(buttonThemed, theme) as ButtonProps;\n\n return {\n size: 'xl',\n ...button,\n };\n }),\n [buttons, theme],\n );\n\n const onMediaIntrinsicSizeChange = React.useCallback(\n ({width, height}: {width: number; height: number}) => setMediaAspectRatio(width / height),\n [],\n );\n\n return (\n <header className={b()}>\n {background && (\n <Media\n className={b('background', {\n ['full-width']: fullWidth,\n })}\n imageClassName={b('background-image')}\n videoClassName={b('background-video')}\n {...background}\n isBackground\n />\n )}\n <Grid>\n <div className={b('wrapper')}>\n {breadcrumbs && (\n <HeaderBreadcrumbs\n className={b('breadcrumbs')}\n {...breadcrumbs}\n theme={theme}\n />\n )}\n <div\n className={b('content', {\n ['vertical-offset']: verticalOffset,\n ['no-media']: !media,\n })}\n >\n {overtitle && (\n <div className={b('content-overtitle', {theme})}>\n {typeof overtitle === 'string' ? (\n <YFMWrapper\n tagName=\"span\"\n content={overtitle}\n modifiers={{\n constructor: true,\n constructorTheme: theme,\n }}\n />\n ) : (\n overtitle\n )}\n </div>\n )}\n <Content\n size=\"xl\"\n colSizes={{all: 12}}\n {...contentProps}\n buttons={buttonProps}\n theme={contentTheme}\n />\n </div>\n {media && (\n <div className={b('media')}>\n <div className={b('media-container')} ref={mediaContainerRef}>\n <Media\n className={b('media-container-content', {\n ['round-corners']: media.roundCorners ?? true,\n vertical: isDesktop && isMediaVertical,\n })}\n {...media}\n disablePlayerAutoSizing\n onIntrinsicSizeChange={onMediaIntrinsicSizeChange}\n />\n </div>\n </div>\n )}\n </div>\n </Grid>\n </header>\n );\n};\n\nexport default Hero;\n"]}
@@ -0,0 +1,4 @@
1
+ export declare const useContainerAspectRatio: () => {
2
+ aspectRatio: number;
3
+ ref: (mediaContainer: HTMLDivElement | null) => void;
4
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useContainerAspectRatio = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const React = tslib_1.__importStar(require("react"));
6
+ const throttle_1 = tslib_1.__importDefault(require("lodash/throttle.js"));
7
+ const SIZE_UPDATE_FREQUENCY_MS = 100;
8
+ const useContainerAspectRatio = () => {
9
+ const containerRef = React.useRef(null);
10
+ const [containerAspectRatio, setContainerAspectRatio] = React.useState(1);
11
+ const updateAspectRatio = React.useCallback(() => {
12
+ const container = containerRef.current;
13
+ if (container) {
14
+ setContainerAspectRatio(container.clientWidth / container.clientHeight);
15
+ }
16
+ }, []);
17
+ React.useEffect(() => {
18
+ const container = containerRef.current;
19
+ const isResizeEventsSupported = 'ResizeObserver' in window;
20
+ if (!container || !isResizeEventsSupported) {
21
+ return () => { };
22
+ }
23
+ const observer = new ResizeObserver((0, throttle_1.default)(updateAspectRatio, SIZE_UPDATE_FREQUENCY_MS, { leading: true }));
24
+ observer.observe(container);
25
+ return () => observer.disconnect();
26
+ }, [updateAspectRatio]);
27
+ return {
28
+ aspectRatio: containerAspectRatio,
29
+ ref: (mediaContainer) => {
30
+ if (mediaContainer) {
31
+ containerRef.current = mediaContainer;
32
+ updateAspectRatio();
33
+ }
34
+ },
35
+ };
36
+ };
37
+ exports.useContainerAspectRatio = useContainerAspectRatio;
38
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"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C,cAAqC,EAAE,EAAE;YAC3C,IAAI,cAAc,EAAE,CAAC;gBACjB,YAAY,CAAC,OAAO,GAAG,cAAc,CAAC;gBACtC,iBAAiB,EAAE,CAAC;YACxB,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAtCW,QAAA,uBAAuB,2BAsClC","sourcesContent":["import * as React from 'react';\n\nimport throttle from 'lodash/throttle';\n\nconst SIZE_UPDATE_FREQUENCY_MS = 100;\n\nexport const useContainerAspectRatio = () => {\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n const [containerAspectRatio, setContainerAspectRatio] = React.useState<number>(1);\n\n const updateAspectRatio = React.useCallback(() => {\n const container = containerRef.current;\n\n if (container) {\n setContainerAspectRatio(container.clientWidth / container.clientHeight);\n }\n }, []);\n\n React.useEffect(() => {\n const container = containerRef.current;\n const isResizeEventsSupported = 'ResizeObserver' in window;\n\n if (!container || !isResizeEventsSupported) {\n return () => {};\n }\n\n const observer = new ResizeObserver(\n throttle(updateAspectRatio, SIZE_UPDATE_FREQUENCY_MS, {leading: true}),\n );\n\n observer.observe(container);\n\n return () => observer.disconnect();\n }, [updateAspectRatio]);\n\n return {\n aspectRatio: containerAspectRatio,\n ref: (mediaContainer: HTMLDivElement | null) => {\n if (mediaContainer) {\n containerRef.current = mediaContainer;\n updateAspectRatio();\n }\n },\n };\n};\n"]}