diff --git a/src/components/Lottie/Lottie.mdx b/src/components/Lottie/Lottie.mdx index f8e194df..c15630b6 100644 --- a/src/components/Lottie/Lottie.mdx +++ b/src/components/Lottie/Lottie.mdx @@ -47,6 +47,8 @@ If importing the Lottie file directly into a Svelte component, make sure to appe ## Using with ArchieML +If you are using `Lottie` with ArchieML, store your Lottie zip file in the `src/statics/lottie/` folder. + With the graphics kit, you'll likely get your text and prop values from an ArchieML doc... ```yaml @@ -98,12 +100,18 @@ With the graphics kit, you'll likely get your text and prop values from an Archi # ArchieML doc [blocks] type: lottie - src: LottieFile.zip + showDebugInfo: true + loop: true + + # Optionally, set playback speed + speed: 0.5 + + # Lottie file stored in `src/statics/lottie/` folder + src: lottie/LottieFile.zip [.segment] start: 0 end: 20 [] - :end [] ``` @@ -112,18 +120,21 @@ With the graphics kit, you'll likely get your text and prop values from an Archi ```svelte {#each content.blocks as block} {#if block.type == 'lottie'} {/if} {/each} @@ -155,60 +166,25 @@ When setting markers in AfterEffects, ensure that the **Comment** section of the ## Switching themes -[Lottie Creator](https://lottiefiles.com/theming) allows you to define multiple color themes for your animation. You can switch between these themes using the `theme` prop. +[Lottie Creator](https://lottiefiles.com/theming) allows you to define multiple colour themes for your animation. You can switch between these themes using the `theme` prop. -Available themes can be found in the debug info when `showDebugInfo` prop is enabled. +Available themes can be found in the debug info when the `showDebugInfo` prop is set to `true`. -With the graphics kit, you'll likely get your text and prop values from an ArchieML doc... - -```yaml -# ArchieML doc -[blocks] - type: lottie - src: LottieFile.zip - theme: myTheme - :end -[] -``` - -... which you'll parse out of a ArchieML block object before passing to the `Lottie` component. - -```svelte - - -{#each content.blocks as block} - - {#if block.type == 'lottie'} - - {/if} -{/each} -``` - -It is also possible to switch themes dynamically based on the `progress` prop by binding a variable to it. +You can set multiple themes and switch between them dynamically -- for example, based on the `progress` of the animation. [Demo](?path=/story/components-graphics-scrollerlottie--themes) ```svelte ``` -## With ScrollerBase +## Using with `ScrollerBase` -The `Lottie` component can be used in conjunction with the `ScrollerBase` component to create a more complex scrolling experience. The `ScrollerBase` component provides a scrollable container that can hold the `Lottie` component as a background. +The `Lottie` component can be used with the `ScrollerBase` component to create a more complex scrolling experience. `ScrollerBase` provides a scrollable container sets the `Lottie` component as a background. ```svelte + + + + + +
+ + + +
+
+ + + +
+``` +### Using with ArchieML With the graphics kit, you'll likely get your text and prop values from an ArchieML doc... ```yaml # ArchieML doc [blocks] type: lottie - src: LottieFile.zip + + # Lottie file stored in `src/statics/lottie/` folder + src: lottie/LottieFile.zip # Array of foregrounds [.foregrounds] + + # Foreground 1: Headline component startFrame: 0 # When in the animation to start showing the foreground endFrame: 50 # When to stop showing the foreground - type: text - {.foregroundProps} - text: Some text for the foreground - {} - startFrame: 50 # When in the animation to start showing the foreground - endFrame: 100 # When to stop showing the foreground - type: component - {.foregroundProps} - componentType: Headline - hed: Some headline text - dek: Some deck text - [.authors] - * Jane Doe - * John Smith - [] - {} - [] - :end + # Set foreground type + type: component + + # Set props to pass into `LottieForeground` + {.foregroundProps} + componentName: Headline + hed: Headline + dek: Some deck text + [.authors] + * Jane Doe + * John Smith + [] + {} + + # Foreground 2: Text only + startFrame: 50 + endFrame: 100 + + # Set foreground type + type: text + + # If the foreground type is `text`, set text prop here + {.foregroundProps} + text: Some text for the foreground + {} [] ``` @@ -328,35 +339,29 @@ With the graphics kit, you'll likely get your text and prop values from an Archi } from '@reuters-graphics/graphics-components'; import { assets } from '$app/paths'; + // Make an object of components to use as foregrounds const Components = $state({ Headline, - Video, }); {#each content.blocks as block} {#if block.type == 'lottie'} - + {#each block.foregrounds as foreground} {#if foreground.type == 'text'} {:else if foreground.type == 'component'} {@const Component = - Components[foreground.foregroundProps.componentType]} + Components[foreground.foregroundProps.componentName]} diff --git a/src/components/Lottie/Lottie.stories.svelte b/src/components/Lottie/Lottie.stories.svelte index 4af36fdf..a8a318a4 100644 --- a/src/components/Lottie/Lottie.stories.svelte +++ b/src/components/Lottie/Lottie.stories.svelte @@ -1,5 +1,7 @@