mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-13 04:36:12 +01:00
feat: start of embeds
This commit is contained in:
1 parent
f666023bef
commit
6984794be1
23 files changed
+313
-30
No files matched your search
+25
-21
@@ -28,7 +28,7 @@ const robotoFlex = Roboto_Flex({
|
||||
|
||||
export default function RootLayout({ children }: RootLayoutProps) {
|
||||
const pathname = usePathname();
|
||||
const isEmbed = pathname.split('/')[1] === 'embeds';
|
||||
const isEmbed = pathname.startsWith('/tools/embed/host');
|
||||
const isRoot = pathname === '/';
|
||||
|
||||
return (
|
||||
@@ -56,30 +56,34 @@ export default function RootLayout({ children }: RootLayoutProps) {
|
||||
backgroundColor: isEmbed ? 'transparent' : undefined,
|
||||
}}
|
||||
>
|
||||
<Theme
|
||||
appearance="dark"
|
||||
panelBackground="solid"
|
||||
radius="full"
|
||||
accentColor="amber"
|
||||
suppressHydrationWarning
|
||||
suppressContentEditableWarning
|
||||
>
|
||||
<Flex
|
||||
direction="column"
|
||||
style={{
|
||||
minHeight: '100vh',
|
||||
paddingTop: isEmbed ? undefined : NAVBAR_HEIGHT,
|
||||
}}
|
||||
{!isEmbed && (
|
||||
<Theme
|
||||
appearance="dark"
|
||||
panelBackground="solid"
|
||||
radius="full"
|
||||
accentColor="amber"
|
||||
suppressHydrationWarning
|
||||
suppressContentEditableWarning
|
||||
>
|
||||
{!isEmbed && <Navbar />}
|
||||
<Flex
|
||||
direction="column"
|
||||
style={{
|
||||
minHeight: '100vh',
|
||||
paddingTop: isEmbed ? undefined : NAVBAR_HEIGHT,
|
||||
}}
|
||||
>
|
||||
{!isEmbed && <Navbar />}
|
||||
|
||||
<Checks />
|
||||
<Checks />
|
||||
|
||||
<Suspense fallback={<PageLoader />}>{children}</Suspense>
|
||||
<Suspense fallback={<PageLoader />}>{children}</Suspense>
|
||||
|
||||
{!isEmbed && <Footer />}
|
||||
</Flex>
|
||||
</Theme>
|
||||
{!isEmbed && <Footer />}
|
||||
</Flex>
|
||||
</Theme>
|
||||
)}
|
||||
|
||||
{isEmbed && children}
|
||||
</body>
|
||||
</html>
|
||||
</App.Provider>
|
||||
|
||||
+7
-5
@@ -1,10 +1,11 @@
|
||||
'use client';
|
||||
|
||||
import { Flex } from '@radix-ui/themes';
|
||||
import { Box, Flex } from '@radix-ui/themes';
|
||||
import { AdMidSectionResponsive } from '../components/AdMidSectionResponsive';
|
||||
import {
|
||||
compareTool,
|
||||
discordTool,
|
||||
embedTool,
|
||||
moreTool,
|
||||
ratingTool,
|
||||
sessionTool,
|
||||
@@ -43,7 +44,7 @@ export default function Page() {
|
||||
|
||||
<Flex gap="4" direction={{ initial: 'column', sm: 'row' }}>
|
||||
<ToolCard tool={sessionTool} />
|
||||
<ToolCard tool={ratingTool} />
|
||||
<ToolCard tool={embedTool} />
|
||||
</Flex>
|
||||
|
||||
{!exempt && (
|
||||
@@ -59,13 +60,14 @@ export default function Page() {
|
||||
)}
|
||||
|
||||
<Flex gap="4" direction={{ initial: 'column', sm: 'row' }}>
|
||||
<ToolCard tool={ratingTool} />
|
||||
<ToolCard tool={discordTool} />
|
||||
<ToolCard tool={moreTool} />
|
||||
</Flex>
|
||||
|
||||
{/* <Flex gap="4" direction={{ initial: 'column', sm: 'row' }}>
|
||||
<Flex gap="4" direction={{ initial: 'column', sm: 'row' }}>
|
||||
<ToolCard tool={moreTool} />
|
||||
<Box flexGrow="1" />
|
||||
</Flex> */}
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
'use client';
|
||||
|
||||
import { Flex } from '@radix-ui/themes';
|
||||
import { Dispatch, SetStateAction, use, useState } from 'react';
|
||||
import { EmbedConfigInputs } from '../../../../../components/EmbedConfigInputs';
|
||||
import PageWrapper from '../../../../../components/PageWrapper';
|
||||
import {
|
||||
TanksEmbedCard,
|
||||
TanksEmbedWrapper,
|
||||
} from '../../../../../components/TanksEmbed';
|
||||
import { tanksDefinitionsArray } from '../../../../../core/blitzkit/tankDefinitions';
|
||||
import {
|
||||
EmbedConfig,
|
||||
EmbedConfigType,
|
||||
ExtractEmbedConfigType,
|
||||
} from '../../types';
|
||||
import { extractEmbedConfigDefaults } from '../../utilities';
|
||||
|
||||
const tankEmbedConfig = {
|
||||
listWidth: { type: EmbedConfigType.Number, default: 320, unit: 'px' },
|
||||
listGap: { type: EmbedConfigType.Size, default: '2' },
|
||||
listMaxTanks: { type: EmbedConfigType.Number, default: 8 },
|
||||
|
||||
cardRadius: { type: EmbedConfigType.Radius, default: '2' },
|
||||
cardHeaderPadding: { type: EmbedConfigType.Size, default: '2' },
|
||||
} satisfies EmbedConfig;
|
||||
|
||||
export type TanksEmbedState = ExtractEmbedConfigType<typeof tankEmbedConfig>;
|
||||
|
||||
export default function Page() {
|
||||
const tanks = use(tanksDefinitionsArray);
|
||||
const [state, setState] = useState(
|
||||
extractEmbedConfigDefaults(tankEmbedConfig),
|
||||
);
|
||||
|
||||
return (
|
||||
<PageWrapper>
|
||||
<Flex align="start" justify="between" gap="4">
|
||||
<TanksEmbedWrapper state={state}>
|
||||
{tanks.slice(0, state.listMaxTanks).map((tank) => (
|
||||
<TanksEmbedCard key={tank.id} tank={tank} state={state} />
|
||||
))}
|
||||
</TanksEmbedWrapper>
|
||||
|
||||
<EmbedConfigInputs
|
||||
config={tankEmbedConfig}
|
||||
state={state}
|
||||
setState={
|
||||
setState as Dispatch<
|
||||
SetStateAction<ExtractEmbedConfigType<EmbedConfig>>
|
||||
>
|
||||
}
|
||||
/>
|
||||
</Flex>
|
||||
</PageWrapper>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import PageWrapper from '../../../components/PageWrapper';
|
||||
|
||||
export default function Page() {
|
||||
return <PageWrapper></PageWrapper>;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
export enum EmbedConfigType {
|
||||
Number,
|
||||
Radius,
|
||||
Size,
|
||||
}
|
||||
|
||||
export type EmbedConfig = Record<string, EmbedConfigItem>;
|
||||
|
||||
export type EmbedConfigItem =
|
||||
| {
|
||||
type: EmbedConfigType.Number;
|
||||
default: number;
|
||||
unit?: string;
|
||||
}
|
||||
| {
|
||||
type: EmbedConfigType.Radius;
|
||||
default: RadixRadius;
|
||||
}
|
||||
| {
|
||||
type: EmbedConfigType.Size;
|
||||
default: RadixSize;
|
||||
};
|
||||
|
||||
export type RadixRadius = `${1 | 2 | 3 | 4}` | 'full';
|
||||
export type RadixSize = `${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`;
|
||||
|
||||
export type ExtractEmbedConfigType<Config extends EmbedConfig> = {
|
||||
[Key in keyof Config]: ({
|
||||
type: Config[Key]['type'];
|
||||
} & EmbedConfigItem)['default'];
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { EmbedConfig, ExtractEmbedConfigType } from './types';
|
||||
|
||||
export function extractEmbedConfigDefaults<Config extends EmbedConfig>(
|
||||
config: Config,
|
||||
) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(config).map(([key, value]) => [key, value.default]),
|
||||
) as ExtractEmbedConfigType<Config>;
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user