### Start Development Server for Component Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/docs/contributing/quickstart.mdx This command starts the development server using pnpm, enabling you to develop and test your new component. Ensure you have pnpm installed and are in the project's root directory. ```shell pnpm start ``` -------------------------------- ### Documenting Svelte Component Props: FeaturePhoto Example Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/docs/guides/svelte-components.mdx This code snippet demonstrates how a Svelte component's props are typically documented, showing an example of the 'FeaturePhoto' component. It includes the import statement and a usage example with various props like src, altText, caption, and width, indicating the expected data types. ```svelte ``` -------------------------------- ### Install Graphics Components Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/docs/intro.mdx This command installs the @reuters-graphics/graphics-components package using pnpm. Ensure you have pnpm installed or use your preferred package manager. ```bash pnpm i @reuters-graphics/graphics-components ``` -------------------------------- ### ArchieML Document Structure for ProfileCard Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/docs/guides/archieml.mdx Shows an example of how data for a ProfileCard component would be structured within an ArchieML document. This highlights the key-value pairs that correspond to component props. ```yaml [blocks] # ... type: profile-card name: Tom age: 10 picture: images/tom-the-cat.jpg birthday: 2020-09-25 bio: A very frisky feline. ... and an avid mouser! :end isGood: true # ... [] ``` -------------------------------- ### Configurable Column Widths with SCSS Classes (Svelte/SCSS) Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/components/Article/Article.mdx Provides an example of creating a reusable Svelte component that dynamically applies column widths based on a `width` prop, utilizing SCSS for styling and CSS variables for width definitions. It includes styles for various predefined widths and a fluid option. ```svelte
``` -------------------------------- ### SEO Component Usage with ArchieML Data (Svelte) Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/components/SEO/SEO.mdx Shows how to integrate the SEO component with data sourced from an ArchieML document and SvelteKit's app stores. This example assumes content is loaded from '$locales/en/content.json' and package information from '$pkg'. It dynamically sets SEO and sharing metadata. ```svelte ``` -------------------------------- ### Conditional Analytics Loading in SvelteKit Environments Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/components/Analytics/Analytics.mdx This example shows how to conditionally load the Analytics component based on the environment. It uses SvelteKit's '$app/environment' and '$app/stores' to prevent analytics from being sent in development or on preview servers, ensuring data accuracy. ```svelte {#if !dev && $page.url?.hostname !== 'graphics.thomsonreuters.com'} {/if} ``` -------------------------------- ### Importing and Using a Custom Svelte Component Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/docs/guides/svelte-components.mdx This example demonstrates how to define a simple Svelte component named 'Button.svelte' and then import and use it within another Svelte component, 'App.svelte'. It shows how to pass data to the child component via props. ```svelte ``` ```svelte

Welcome to Svelte

``` -------------------------------- ### Advanced ScrollerVideo with ScrollerBase and Jump Control (Svelte) Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/components/ScrollerVideo/ScrollerVideo.mdx This Svelte example showcases advanced integration of ScrollerVideo with ScrollerBase, focusing on controlling video playback based on the scroller's index. The `jumpVideo` function uses `scrollerVideo.setVideoPercentage` to jump to the start (0%) or end (100%) of the video depending on the current `index` of the ScrollerBase. The `onReady` prop is used to call `jumpVideo` once the ScrollerVideo is ready, and `trackScroll` is set to `false` to prevent default scroll-based playback. ```svelte {#snippet backgroundSnippet()} {/snippet} {#snippet foregroundSnippet()}

Index {index}

Index {index}

{/snippet}
``` -------------------------------- ### FeaturePhoto Component with ArchieML Integration (Svelte) Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/components/FeaturePhoto/FeaturePhoto.mdx Illustrates how to integrate the FeaturePhoto component with content sourced from an ArchieML document. This example shows parsing an ArchieML block object to dynamically populate the `FeaturePhoto` component's props, including `width`, `src`, `altText`, and `caption`. ```svelte {#each content.blocks as block} {#if block.Type === 'text'} {:else if block.type === 'photo'} {/if} {/each} ``` -------------------------------- ### Optimizing Video with FFmpeg for ScrollerVideo Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/components/ScrollerVideo/ScrollerVideo.mdx Provides an example FFmpeg command to optimize video files for web use with the ScrollerVideo component. This includes converting to H.264, setting resolution, frame rate, and other encoding parameters to ensure broad browser compatibility and reduce file size. ```bash npx ffmpeg -y -i .mp4 -c:v libx264 -movflags +faststart -crf 24 -r 24 -g 72 -vf scale=720:-1 -profile:v high -preset veryslow -pix_fmt yuv420p -color_primaries 1 -color_trc 1 -colorspace 1 -an .mp4 ``` -------------------------------- ### Dynamic ProfileCard Rendering with ArchieML Data (Svelte) Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/docs/guides/archieml.mdx Demonstrates how to dynamically render the ProfileCard component in Svelte using data fetched from an ArchieML JSON file. This example includes type conversions for props like age, birthday, and isGood. ```svelte {#each content.blocks as block} {#if block.type === 'text'} {:else if block.type === 'profile-card'} {/if} {/each} ``` -------------------------------- ### Passing Data to a Svelte Component via Props Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/docs/guides/svelte-components.mdx This example shows how to pass data to a Svelte component using props. It specifically demonstrates passing the 'text' prop to a Button component, illustrating how the component renders the provided text. ```svelte ``` -------------------------------- ### Video Component Configuration from ArchieML Data Source: https://github.com/reuters-graphics/graphics-components/blob/main/src/components/Video/Video.mdx Shows how to dynamically configure the Video component using data parsed from an ArchieML document. This example iterates through blocks, identifies video types, and maps ArchieML properties to Video component props, including converting string booleans to actual booleans using a utility function. ```svelte {#each content.blocks as block} {#if block.type === 'video'}