feat: hosting tech

This commit is contained in:
TrèsAbhi committed 2024-10-27 22:29:28 -05:00
1 parent 94099412b0
commit a0d6aecf7a
8 files changed
+76 -23

No files matched your search

@@ -26,3 +26,9 @@ export function BreakdownPreview() {
</BreakdownEmbedWrapper> </BreakdownEmbedWrapper>
); );
} }
export function BreakdownRenderer() {
const { useState } = useEmbedStateCurry<typeof breakdownConfig>();
return useState('cardBodyBackgroundColor');
}
+5
View File
@@ -3,6 +3,7 @@ import { grayA, grayDark, grayDarkA } from '@radix-ui/colors';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { import {
BreakdownPreview, BreakdownPreview,
BreakdownRenderer,
compositeStatsKeysOptions, compositeStatsKeysOptions,
} from '../components/Embeds/breakdown'; } from '../components/Embeds/breakdown';
import type { import type {
@@ -99,3 +100,7 @@ export function extractEmbedConfigDefaults<Config extends EmbedConfig>(
Object.entries(config).map(([key, value]) => [key, value.default]), Object.entries(config).map(([key, value]) => [key, value.default]),
) as ExtractEmbedConfigTypes<Config>; ) as ExtractEmbedConfigTypes<Config>;
} }
export const embedRenderers = {
breakdown: BreakdownRenderer,
} satisfies Record<string, () => ReactNode>;
+1 -14
View File
@@ -5,25 +5,12 @@ import { Checks } from '../components/Checks';
import Footer from '../components/Footer.astro'; import Footer from '../components/Footer.astro';
import Navbar from '../components/Navbar.astro'; import Navbar from '../components/Navbar.astro';
import Party3 from '../components/Party3.astro'; import Party3 from '../components/Party3.astro';
import './base.css';
const { pathname } = Astro.url; const { pathname } = Astro.url;
const isRoot = pathname === '/'; const isRoot = pathname === '/';
--- ---
<style is:global>
@import '@radix-ui/themes/styles.css';
body {
margin: 0;
}
.ad-container {
display: flex;
align-items: center;
}
</style>
<!-- MIGRATION TODO: roboto flex font -->
<html lang="en"> <html lang="en">
<head> <head>
{ {
@@ -0,0 +1,13 @@
---
import './base.css';
---
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<slot />
</body>
</html>
+5
View File
@@ -0,0 +1,5 @@
@import '@radix-ui/themes/styles.css';
body {
margin: 0;
}
@@ -0,0 +1,37 @@
import { useMemo } from 'react';
import { parse } from 'urlon';
import {
embedConfigurations,
embedRenderers,
extractEmbedConfigDefaults,
} from '../../../../../constants/embeds';
import {
EmbedState,
type EmbedConfig,
type ExtractEmbedConfigTypes,
} from '../../../../../stores/embedState';
interface PageProps {
embed: keyof typeof embedConfigurations;
}
export function Page({ embed }: PageProps) {
const state = useMemo(() => {
const params = new URLSearchParams(window.location.search);
const stateRaw = params.get('state');
const partialState = stateRaw === null ? {} : parse(stateRaw);
const state = {
...extractEmbedConfigDefaults(embedConfigurations[embed]),
...partialState,
} as ExtractEmbedConfigTypes<EmbedConfig>;
return state;
}, [embed]);
const Renderer = embedRenderers[embed];
return (
<EmbedState.Provider data={state}>
<Renderer />
</EmbedState.Provider>
);
}
@@ -1,14 +1,13 @@
--- ---
import { embedPreviews } from '../../../../../constants/embeds'; import { capitalize } from 'lodash-es';
import { EmbedState } from '../../../../../stores/embedState'; import EmbedLayout from '../../../../../layouts/EmbedLayout.astro';
import { Page } from './_index';
export { getStaticPaths } from '../index.astro'; export { getStaticPaths } from '../index.astro';
const Test = embedPreviews.breakdown;
--- ---
sploinky sploinky splonk <title>BlitzKit - {capitalize(Astro.params.embed)} embed</title>
<EmbedState.Provider> <EmbedLayout>
<Test /> <Page client:only="react" embed={Astro.params.embed} />
</EmbedState.Provider> </EmbedLayout>
+2 -1
View File
@@ -1,4 +1,5 @@
declare module 'urlon' { declare module 'urlon' {
function stringify(value: any): string; function stringify(value: any): string;
export { stringify }; function parse(value: string): any;
export { parse, stringify };
} }