mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: state passing
This commit is contained in:
1 parent
a0d6aecf7a
commit
fa489a665a
2 files changed
+28
-3
No files matched your search
@@ -30,5 +30,13 @@ export function BreakdownPreview() {
|
||||
export function BreakdownRenderer() {
|
||||
const { useState } = useEmbedStateCurry<typeof breakdownConfig>();
|
||||
|
||||
return useState('cardBodyBackgroundColor');
|
||||
return (
|
||||
<BreakdownEmbedWrapper>
|
||||
{useState('showTotal') && <BreakdownEmbedCard tank={null} />}
|
||||
|
||||
{tanks.slice(0, useState('listMaxTanks')).map((tank) => (
|
||||
<BreakdownEmbedCard key={tank.id} tank={tank} />
|
||||
))}
|
||||
</BreakdownEmbedWrapper>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Box } from '@radix-ui/themes';
|
||||
import { useMemo } from 'react';
|
||||
import { parse } from 'urlon';
|
||||
import { BlitzKitTheme } from '../../../../../components/BlitzKitTheme';
|
||||
import {
|
||||
embedConfigurations,
|
||||
embedRenderers,
|
||||
@@ -10,6 +12,7 @@ import {
|
||||
type EmbedConfig,
|
||||
type ExtractEmbedConfigTypes,
|
||||
} from '../../../../../stores/embedState';
|
||||
import { useEmbedStateCurry } from '../../../../../stores/embedState/utilities';
|
||||
|
||||
interface PageProps {
|
||||
embed: keyof typeof embedConfigurations;
|
||||
@@ -27,11 +30,25 @@ export function Page({ embed }: PageProps) {
|
||||
|
||||
return state;
|
||||
}, [embed]);
|
||||
const Renderer = embedRenderers[embed];
|
||||
|
||||
return (
|
||||
<EmbedState.Provider data={state}>
|
||||
<Renderer />
|
||||
<Content embed={embed} />
|
||||
</EmbedState.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
function Content({ embed }: PageProps) {
|
||||
const Renderer = embedRenderers[embed];
|
||||
const { useState } = useEmbedStateCurry();
|
||||
const width = useState('width');
|
||||
const height = useState('height');
|
||||
|
||||
return (
|
||||
<BlitzKitTheme style={{ background: 'transparent' }}>
|
||||
<Box width={`${width}px`} height={`${height}px`} overflow="hidden">
|
||||
<Renderer />
|
||||
</Box>
|
||||
</BlitzKitTheme>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user