Skip to content

Commit

Permalink
use fetched SVGs for country paths
Browse files Browse the repository at this point in the history
  • Loading branch information
UmungoBungo committed Oct 14, 2024
1 parent 5266bc4 commit 085efe3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2,110 deletions.
1 change: 0 additions & 1 deletion packages/docs/src/components/Demo/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export const Demo: React.FC = () => {
};

const updateAudioMute = (isMuted: boolean) => {
console.log(audioState);
setAudioState((v) => ({
volume: v.volume === 0 ? 0.5 : v.volume, // if volume was previously 0, set it to 0.75
isMuted,
Expand Down
8 changes: 7 additions & 1 deletion packages/docs/src/remotion/HomepageVideo/Comp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export type Trending = {
repos: string[];
date: string;
temperatureInCelsius: number;
countryLabel: string;
countryPaths: {
d: string;
class: string;
}[];
};

export type LocationAndTrending = {
Expand All @@ -33,11 +38,12 @@ export const getDataAndProps = async () => {
)
.then((res) => res.json())
.then((data) => {
console.log('trending data', data);
return {
repos: data.trending.repos.slice(0, 3),
date: data.trending.dateFetched,
temperatureInCelsius: Math.round(data.temperature),
countryLabel: data.countryLabel,
countryPaths: data.countryPaths,
};
});

Expand Down
15 changes: 8 additions & 7 deletions packages/docs/src/remotion/HomepageVideo/CurrentCountry.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import {getBoundingBox, resetPath} from '@remotion/paths';
import React from 'react';
import {AbsoluteFill, spring, useCurrentFrame, useVideoConfig} from 'remotion';
import {ISO_3166_ALPHA_2_MAPPINGS, countriesPaths} from './paths';
import type {Location} from './types';

export const CurrentCountry: React.FC<{
readonly theme: 'dark' | 'light';
readonly location: Location;
}> = ({theme, location}) => {
const paths = countriesPaths.filter((c) => c.class === location.country);
const joined = paths.map((p) => p.d).join(' ');
readonly countryPaths: {
d: string;
class: string;
}[];
readonly countryLabel: string;
}> = ({theme, countryPaths, countryLabel}) => {
const joined = countryPaths.map((p) => p.d).join(' ');
const reset = resetPath(joined);
const boundingBox = getBoundingBox(reset);

Expand Down Expand Up @@ -75,7 +76,7 @@ export const CurrentCountry: React.FC<{
color: theme === 'dark' ? 'white' : 'black',
}}
>
{ISO_3166_ALPHA_2_MAPPINGS[location.country]}
{countryLabel}
</div>
</AbsoluteFill>
</AbsoluteFill>
Expand Down
6 changes: 5 additions & 1 deletion packages/docs/src/remotion/HomepageVideo/cards/Cards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ export const Cards: React.FC<{
temperatureInCelsius={temperatureInCelsius}
/>
) : index === 2 ? (
<CurrentCountry location={location} theme={theme} />
<CurrentCountry
countryPaths={trending.countryPaths}
countryLabel={trending.countryLabel}
theme={theme}
/>
) : (
<EmojiCard emojiPositions={emojiPositions} />
);
Expand Down
Loading

0 comments on commit 085efe3

Please sign in to comment.