@streamscloud/embeddable 16.0.7-1772096232639 → 16.0.7-1772105016226

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.
@@ -1,14 +1,14 @@
1
1
  <script lang="ts">import { default as ArticleField } from './fields/article-field.svelte';
2
2
  import { fieldIsFilled } from './helpers';
3
- import { generatePaddingsCssVar } from './styles-transformer';
3
+ import { ArticleStylesHelper } from './styles-transformer';
4
4
  let { layout, metadata } = $props();
5
5
  const filledFields = $derived(layout.fields.filter(fieldIsFilled));
6
6
  const styles = $derived.by(() => {
7
7
  if (!layout.styles) {
8
8
  return '';
9
9
  }
10
- const mobileStyles = generatePaddingsCssVar({ styles: layout.styles, mobileView: true });
11
- const desktopStyles = generatePaddingsCssVar({ styles: layout.styles, mobileView: false });
10
+ const mobileStyles = ArticleStylesHelper.generatePaddingsCssVar({ styles: layout.styles, mobileView: true });
11
+ const desktopStyles = ArticleStylesHelper.generatePaddingsCssVar({ styles: layout.styles, mobileView: false });
12
12
  return `--_article-layout--padding--desktop:${desktopStyles};--_article-layout--padding--mobile:${mobileStyles};`;
13
13
  });
14
14
  </script>
@@ -0,0 +1,8 @@
1
+ <script lang="ts">import { ShadowRoot } from '../../ui/shadow-dom';
2
+ import { default as ArticleView } from './article-view.svelte';
3
+ let { sections, metadata, theme, locale } = $props();
4
+ </script>
5
+
6
+ <ShadowRoot locale={locale} theme={theme} backgroundDisabled={true} backgroundImageUrl="not-applicable">
7
+ <ArticleView sections={sections} metadata={metadata} />
8
+ </ShadowRoot>
@@ -0,0 +1,12 @@
1
+ import type { ThemeValue } from '../../core/theme';
2
+ import type { ArticleMetadata, ArticleSectionModel } from './types';
3
+ import type { AppLocaleValue } from '@streamscloud/kit/core/locale';
4
+ type Props = {
5
+ sections: ArticleSectionModel[];
6
+ metadata: ArticleMetadata;
7
+ theme: ThemeValue;
8
+ locale: AppLocaleValue | undefined;
9
+ };
10
+ declare const ArticleProxy: import("svelte").Component<Props, {}, "">;
11
+ type ArticleProxy = ReturnType<typeof ArticleProxy>;
12
+ export default ArticleProxy;
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">import { default as ArticleLayout } from './article-layout.svelte';
2
2
  import { default as FactsContainer } from './cmp.facts-container.svelte';
3
3
  import { layoutIsFilled } from './helpers';
4
- import { generatePaddingsCssVar } from './styles-transformer';
4
+ import { ArticleStylesHelper } from './styles-transformer';
5
5
  import { HtmlHelper } from '@streamscloud/kit/core/utils';
6
6
  import { HtmlBlock } from '@streamscloud/kit/ui/html-block';
7
7
  let { section, metadata } = $props();
@@ -10,8 +10,8 @@ const styles = $derived.by(() => {
10
10
  if (!section.styles) {
11
11
  return '';
12
12
  }
13
- const mobileStyles = generatePaddingsCssVar({ styles: section.styles, mobileView: true });
14
- const desktopStyles = generatePaddingsCssVar({ styles: section.styles, mobileView: false });
13
+ const mobileStyles = ArticleStylesHelper.generatePaddingsCssVar({ styles: section.styles, mobileView: true });
14
+ const desktopStyles = ArticleStylesHelper.generatePaddingsCssVar({ styles: section.styles, mobileView: false });
15
15
  return `--_article-section--padding--desktop:${desktopStyles};--_article-section--padding--mobile:${mobileStyles};`;
16
16
  });
17
17
  const sectionFactsText = $derived(section.facts ? HtmlHelper.sanitizeHtml(section.facts) : null);
@@ -0,0 +1,31 @@
1
+ <script lang="ts">import { default as ArticleSection } from './article-section.svelte';
2
+ import { sectionIsFilled } from './helpers';
3
+ let { sections, metadata } = $props();
4
+ const filledSections = $derived(sections.filter(sectionIsFilled));
5
+ const fieldMetadata = $derived({ displayDate: metadata.displayDate });
6
+ </script>
7
+
8
+ <div class="article-container">
9
+ <div class="article">
10
+ {#each filledSections as section (section.id)}
11
+ <ArticleSection section={section} metadata={fieldMetadata} />
12
+ {/each}
13
+ </div>
14
+ </div>
15
+
16
+ <style>.article-container {
17
+ --_article--min-height: var(--article--min-height, 0);
18
+ --_article--background: var(--article--background, light-dark(#ffffff, #1e1e1e));
19
+ --_article--text-color: var(--article--text-color, light-dark(#000000, #ffffff));
20
+ container-type: inline-size;
21
+ min-height: var(--_article--min-height);
22
+ }
23
+
24
+ .article {
25
+ --article-field--text-color: var(--_article--text-color);
26
+ min-height: var(--_article--min-height);
27
+ background: var(--_article--background);
28
+ padding-bottom: 6.25rem;
29
+ display: flex;
30
+ flex-direction: column;
31
+ }</style>
@@ -0,0 +1,8 @@
1
+ import type { ArticleMetadata, ArticleSectionModel } from './types';
2
+ type Props = {
3
+ sections: ArticleSectionModel[];
4
+ metadata: ArticleMetadata;
5
+ };
6
+ declare const ArticleView: import("svelte").Component<Props, {}, "">;
7
+ type ArticleView = ReturnType<typeof ArticleView>;
8
+ export default ArticleView;
@@ -1,31 +1,36 @@
1
- <script lang="ts">import { default as ArticleSection } from './article-section.svelte';
2
- import { sectionIsFilled } from './helpers';
3
- let { sections, metadata } = $props();
4
- const filledSections = $derived(sections.filter(sectionIsFilled));
5
- const fieldMetadata = $derived({ displayDate: metadata.displayDate });
1
+ <script lang="ts">import { createShadowRoot } from '../../ui/shadow-dom';
2
+ import { default as ArticleProxy } from './article-proxy.svelte';
3
+ import { mount, unmount } from 'svelte';
4
+ let { sections, metadata, theme = 'dark', locale } = $props();
5
+ const initHost = (node) => {
6
+ const shadowRoot = createShadowRoot(node);
7
+ const mounted = mount(ArticleProxy, {
8
+ target: shadowRoot,
9
+ props: {
10
+ get sections() {
11
+ return sections;
12
+ },
13
+ get metadata() {
14
+ return metadata;
15
+ },
16
+ get theme() {
17
+ return theme;
18
+ },
19
+ get locale() {
20
+ return locale;
21
+ }
22
+ }
23
+ });
24
+ return {
25
+ destroy: () => {
26
+ unmount(mounted);
27
+ }
28
+ };
29
+ };
6
30
  </script>
7
31
 
8
- <div class="article-container">
9
- <div class="article">
10
- {#each filledSections as section (section.id)}
11
- <ArticleSection section={section} metadata={fieldMetadata} />
12
- {/each}
13
- </div>
14
- </div>
32
+ <div class="article-host" use:initHost></div>
15
33
 
16
- <style>.article-container {
17
- --_article--min-height: var(--article--min-height, 0);
18
- --_article--background: var(--article--background, light-dark(#ffffff, #1e1e1e));
19
- --_article--text-color: var(--article--text-color, light-dark(#000000, #ffffff));
20
- container-type: inline-size;
21
- min-height: var(--_article--min-height);
22
- }
23
-
24
- .article {
25
- --article-field--text-color: var(--_article--text-color);
26
- min-height: var(--_article--min-height);
27
- background: var(--_article--background);
28
- padding-bottom: 6.25rem;
29
- display: flex;
30
- flex-direction: column;
34
+ <style>.article-host {
35
+ display: contents;
31
36
  }</style>
@@ -1,7 +1,11 @@
1
+ import type { ThemeValue } from '../../core/theme';
1
2
  import type { ArticleMetadata, ArticleSectionModel } from './types';
3
+ import type { AppLocaleValue } from '@streamscloud/kit/core/locale';
2
4
  type Props = {
3
5
  sections: ArticleSectionModel[];
4
6
  metadata: ArticleMetadata;
7
+ theme?: ThemeValue;
8
+ locale?: AppLocaleValue;
5
9
  };
6
10
  declare const Cmp: import("svelte").Component<Props, {}, "">;
7
11
  type Cmp = ReturnType<typeof Cmp>;
@@ -1,4 +1,4 @@
1
- <script lang="ts">import { generateMarginsCssVar } from '../styles-transformer';
1
+ <script lang="ts">import { ArticleStylesHelper } from '../styles-transformer';
2
2
  import { default as BylineField } from './byline-field.svelte';
3
3
  import { default as ImageField } from './image-field.svelte';
4
4
  import { default as MediaField } from './media-field.svelte';
@@ -8,8 +8,8 @@ import { default as TextField } from './text-field.svelte';
8
8
  import { default as VideoField } from './video-field.svelte';
9
9
  let { field, metadata } = $props();
10
10
  const styles = $derived.by(() => {
11
- const mobileStyles = generateMarginsCssVar({ styles: field.styles, mobileView: true });
12
- const desktopStyles = generateMarginsCssVar({ styles: field.styles, mobileView: false });
11
+ const mobileStyles = ArticleStylesHelper.generateMarginsCssVar({ styles: field.styles, mobileView: true });
12
+ const desktopStyles = ArticleStylesHelper.generateMarginsCssVar({ styles: field.styles, mobileView: false });
13
13
  return `--_article-field--margin--desktop:${desktopStyles};--_article-field--margin--mobile:${mobileStyles};`;
14
14
  });
15
15
  </script>
@@ -1,5 +1,7 @@
1
1
  export { default as Article } from './cmp.article.svelte';
2
+ export { default as ArticleView } from './article-view.svelte';
2
3
  export { default as FactsContainer } from './cmp.facts-container.svelte';
3
4
  export { fieldIsFilled, layoutIsFilled, sectionIsFilled } from './helpers';
5
+ export { ArticleStylesHelper } from './styles-transformer';
4
6
  export type { ArticleLayoutModel, ArticleLayoutStylesModel, ArticleMetadata, ArticleSectionModel, ArticleSectionStylesModel } from './types';
5
7
  export type { ArticleFieldDataModel, ArticleFieldModel, ArticleFieldStylesModel, BylineFieldDataModel, FieldMetadata, ImageFieldDataModel, MediaFieldDataModel, MediaGalleryFieldDataModel, RichTextFieldDataModel, TextFieldDataModel, VideoFieldDataModel } from './fields/types';
@@ -1,3 +1,5 @@
1
1
  export { default as Article } from './cmp.article.svelte';
2
+ export { default as ArticleView } from './article-view.svelte';
2
3
  export { default as FactsContainer } from './cmp.facts-container.svelte';
3
4
  export { fieldIsFilled, layoutIsFilled, sectionIsFilled } from './helpers';
5
+ export { ArticleStylesHelper } from './styles-transformer';
@@ -1,19 +1,47 @@
1
- export declare const generatePaddingsCssVar: (data: {
2
- styles: {
3
- paddingTop?: number | null;
4
- paddingBottom?: number | null;
5
- paddingLeft?: number | null;
6
- paddingRight?: number | null;
7
- };
8
- mobileView: boolean;
9
- }) => string;
10
- export declare const generateMarginsCssVar: (data: {
11
- styles: {
12
- marginTop?: number | null;
13
- marginBottom?: number | null;
14
- marginLeft?: number | null;
15
- marginRight?: number | null;
16
- } | null;
17
- mobileView: boolean;
18
- useFallbackIfMissing?: boolean;
19
- }) => string;
1
+ type IndentValues = {
2
+ top: number;
3
+ right: number;
4
+ bottom: number;
5
+ left: number;
6
+ };
7
+ export declare class ArticleStylesHelper {
8
+ static generatePaddingsCssVar: (data: {
9
+ styles: {
10
+ paddingTop?: number | null;
11
+ paddingBottom?: number | null;
12
+ paddingLeft?: number | null;
13
+ paddingRight?: number | null;
14
+ };
15
+ mobileView: boolean;
16
+ }) => string;
17
+ static parsePaddingValues: (data: {
18
+ styles: {
19
+ paddingTop?: number | null;
20
+ paddingBottom?: number | null;
21
+ paddingLeft?: number | null;
22
+ paddingRight?: number | null;
23
+ };
24
+ mobileView: boolean;
25
+ }) => IndentValues;
26
+ static generateMarginsCssVar: (data: {
27
+ styles: {
28
+ marginTop?: number | null;
29
+ marginBottom?: number | null;
30
+ marginLeft?: number | null;
31
+ marginRight?: number | null;
32
+ } | null;
33
+ mobileView: boolean;
34
+ useFallbackIfMissing?: boolean;
35
+ }) => string;
36
+ static parseMarginValues: (data: {
37
+ styles: {
38
+ marginTop?: number | null;
39
+ marginBottom?: number | null;
40
+ marginLeft?: number | null;
41
+ marginRight?: number | null;
42
+ } | null;
43
+ mobileView: boolean;
44
+ useFallbackIfMissing?: boolean;
45
+ }) => IndentValues;
46
+ }
47
+ export {};
@@ -1,36 +1,38 @@
1
- export const generatePaddingsCssVar = (data) => {
2
- const indents = parsePaddingValues(data);
3
- const paddings = [indents.top, indents.right, indents.bottom, indents.left];
4
- return paddings.map((p) => p + 'rem').join(' ');
5
- };
6
- const parsePaddingValues = (data) => {
7
- const { styles, mobileView } = data;
8
- const verticalScaleFactor = mobileView ? 0.7 : 1;
9
- const horizontalScaleFactor = mobileView ? 0.3 : 1;
10
- return {
11
- top: styles.paddingTop ? styles.paddingTop * verticalScaleFactor : 0,
12
- right: styles.paddingRight ? styles.paddingRight * horizontalScaleFactor : 0,
13
- bottom: styles.paddingBottom ? styles.paddingBottom * verticalScaleFactor : 0,
14
- left: styles.paddingLeft ? styles.paddingLeft * horizontalScaleFactor : 0
1
+ export class ArticleStylesHelper {
2
+ static generatePaddingsCssVar = (data) => {
3
+ const indents = ArticleStylesHelper.parsePaddingValues(data);
4
+ const paddings = [indents.top, indents.right, indents.bottom, indents.left];
5
+ return paddings.map((p) => p + 'rem').join(' ');
15
6
  };
16
- };
17
- export const generateMarginsCssVar = (data) => {
18
- const indents = parseMarginValues(data);
19
- const margins = [indents.top, indents.right, indents.bottom, indents.left];
20
- return margins.map((p) => p + 'rem').join(' ');
21
- };
22
- const parseMarginValues = (data) => {
23
- const { styles, useFallbackIfMissing = true, mobileView } = data;
24
- if (!styles && !useFallbackIfMissing) {
25
- return { top: 0, right: 0, bottom: 0, left: 0 };
26
- }
27
- const parsedStyles = styles || { marginBottom: 0.875 };
28
- const verticalScaleFactor = mobileView ? 0.7 : 1;
29
- const horizontalScaleFactor = mobileView ? 0.3 : 1;
30
- return {
31
- top: 'marginTop' in parsedStyles && parsedStyles.marginTop ? parsedStyles.marginTop * verticalScaleFactor : 0,
32
- right: 'marginRight' in parsedStyles && parsedStyles.marginRight ? parsedStyles.marginRight * horizontalScaleFactor : 0,
33
- bottom: 'marginBottom' in parsedStyles && parsedStyles.marginBottom ? parsedStyles.marginBottom * verticalScaleFactor : 0,
34
- left: 'marginLeft' in parsedStyles && parsedStyles.marginLeft ? parsedStyles.marginLeft * horizontalScaleFactor : 0
7
+ static parsePaddingValues = (data) => {
8
+ const { styles, mobileView } = data;
9
+ const verticalScaleFactor = mobileView ? 0.7 : 1;
10
+ const horizontalScaleFactor = mobileView ? 0.3 : 1;
11
+ return {
12
+ top: styles.paddingTop ? styles.paddingTop * verticalScaleFactor : 0,
13
+ right: styles.paddingRight ? styles.paddingRight * horizontalScaleFactor : 0,
14
+ bottom: styles.paddingBottom ? styles.paddingBottom * verticalScaleFactor : 0,
15
+ left: styles.paddingLeft ? styles.paddingLeft * horizontalScaleFactor : 0
16
+ };
35
17
  };
36
- };
18
+ static generateMarginsCssVar = (data) => {
19
+ const indents = ArticleStylesHelper.parseMarginValues(data);
20
+ const margins = [indents.top, indents.right, indents.bottom, indents.left];
21
+ return margins.map((p) => p + 'rem').join(' ');
22
+ };
23
+ static parseMarginValues = (data) => {
24
+ const { styles, useFallbackIfMissing = true, mobileView } = data;
25
+ if (!styles && !useFallbackIfMissing) {
26
+ return { top: 0, right: 0, bottom: 0, left: 0 };
27
+ }
28
+ const parsedStyles = styles || { marginBottom: 0.875 };
29
+ const verticalScaleFactor = mobileView ? 0.7 : 1;
30
+ const horizontalScaleFactor = mobileView ? 0.3 : 1;
31
+ return {
32
+ top: 'marginTop' in parsedStyles && parsedStyles.marginTop ? parsedStyles.marginTop * verticalScaleFactor : 0,
33
+ right: 'marginRight' in parsedStyles && parsedStyles.marginRight ? parsedStyles.marginRight * horizontalScaleFactor : 0,
34
+ bottom: 'marginBottom' in parsedStyles && parsedStyles.marginBottom ? parsedStyles.marginBottom * verticalScaleFactor : 0,
35
+ left: 'marginLeft' in parsedStyles && parsedStyles.marginLeft ? parsedStyles.marginLeft * horizontalScaleFactor : 0
36
+ };
37
+ };
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/embeddable",
3
- "version": "16.0.7-1772096232639",
3
+ "version": "16.0.7-1772105016226",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",