mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: migrate embed and fix embed not rendering because of no context
This commit is contained in:
1 parent
e656b83719
commit
4dd1113b6d
18 files changed
+79
-65
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import { Switch } from '@radix-ui/themes';
|
import { Switch } from '@radix-ui/themes';
|
||||||
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/tools/embed/[embed]/_index';
|
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/embed/[embed]/_index';
|
||||||
import { EmbedState } from '../../stores/embedState';
|
import { EmbedState } from '../../stores/embedState';
|
||||||
|
|
||||||
export function Boolean({ configKey }: EmbedPreviewControllerProps) {
|
export function Boolean({ configKey }: EmbedPreviewControllerProps) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/tools/embed/[embed]/_index';
|
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/embed/[embed]/_index';
|
||||||
import { EmbedState } from '../../stores/embedState';
|
import { EmbedState } from '../../stores/embedState';
|
||||||
import { ColorControllerRaw } from './ColorControllerRaw';
|
import { ColorControllerRaw } from './ColorControllerRaw';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Select } from '@radix-ui/themes';
|
import { Select } from '@radix-ui/themes';
|
||||||
import { useLocale } from '../../hooks/useLocale';
|
import { useLocale } from '../../hooks/useLocale';
|
||||||
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/tools/embed/[embed]/_index';
|
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/embed/[embed]/_index';
|
||||||
import { EmbedState } from '../../stores/embedState';
|
import { EmbedState } from '../../stores/embedState';
|
||||||
import type {
|
import type {
|
||||||
EmbedConfigItemType,
|
EmbedConfigItemType,
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ export function GenerateURL({ embed }: GenerateURLProps) {
|
|||||||
setSearchDialogOpen(false);
|
setSearchDialogOpen(false);
|
||||||
setCopyDialogOpen(false);
|
setCopyDialogOpen(false);
|
||||||
|
|
||||||
return `${location.origin}/tools/embed/${embed}/host?${searchParams.toString()}`;
|
return `${location.origin}/embed/${embed}/host?${searchParams.toString()}`;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Link2Icon />{' '}
|
<Link2Icon />{' '}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Slider } from '@radix-ui/themes';
|
import { Slider } from '@radix-ui/themes';
|
||||||
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/tools/embed/[embed]/_index';
|
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/embed/[embed]/_index';
|
||||||
import { EmbedState, type RadixRadius } from '../../stores/embedState';
|
import { EmbedState, type RadixRadius } from '../../stores/embedState';
|
||||||
|
|
||||||
export function Radius({ configKey }: EmbedPreviewControllerProps) {
|
export function Radius({ configKey }: EmbedPreviewControllerProps) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { FontBoldIcon, FontSizeIcon } from '@radix-ui/react-icons';
|
import { FontBoldIcon, FontSizeIcon } from '@radix-ui/react-icons';
|
||||||
import { Flex, Slider, Text } from '@radix-ui/themes';
|
import { Flex, Slider, Text } from '@radix-ui/themes';
|
||||||
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/tools/embed/[embed]/_index';
|
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/embed/[embed]/_index';
|
||||||
import { EmbedState, type RadixSizeWithout0 } from '../../stores/embedState';
|
import { EmbedState, type RadixSizeWithout0 } from '../../stores/embedState';
|
||||||
import {
|
import {
|
||||||
radixTextWeights,
|
radixTextWeights,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Slider } from '@radix-ui/themes';
|
import { Slider } from '@radix-ui/themes';
|
||||||
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/tools/embed/[embed]/_index';
|
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/embed/[embed]/_index';
|
||||||
import { EmbedState, type RadixSize } from '../../stores/embedState';
|
import { EmbedState, type RadixSize } from '../../stores/embedState';
|
||||||
|
|
||||||
export function Size({ configKey }: EmbedPreviewControllerProps) {
|
export function Size({ configKey }: EmbedPreviewControllerProps) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Slider } from '@radix-ui/themes';
|
import { Slider } from '@radix-ui/themes';
|
||||||
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/tools/embed/[embed]/_index';
|
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/embed/[embed]/_index';
|
||||||
import { EmbedState, type RadixSizeWithout0 } from '../../stores/embedState';
|
import { EmbedState, type RadixSizeWithout0 } from '../../stores/embedState';
|
||||||
|
|
||||||
export function SizeWithout0({ configKey }: EmbedPreviewControllerProps) {
|
export function SizeWithout0({ configKey }: EmbedPreviewControllerProps) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Slider as RadixSlider } from '@radix-ui/themes';
|
import { Slider as RadixSlider } from '@radix-ui/themes';
|
||||||
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/tools/embed/[embed]/_index';
|
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/embed/[embed]/_index';
|
||||||
import { EmbedState, type RadixSize } from '../../stores/embedState';
|
import { EmbedState, type RadixSize } from '../../stores/embedState';
|
||||||
import type {
|
import type {
|
||||||
EmbedConfigItemType,
|
EmbedConfigItemType,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { TextField } from '@radix-ui/themes';
|
import { TextField } from '@radix-ui/themes';
|
||||||
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/tools/embed/[embed]/_index';
|
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/embed/[embed]/_index';
|
||||||
import { EmbedState } from '../../stores/embedState';
|
import { EmbedState } from '../../stores/embedState';
|
||||||
|
|
||||||
export function TextController({ configKey }: EmbedPreviewControllerProps) {
|
export function TextController({ configKey }: EmbedPreviewControllerProps) {
|
||||||
|
|||||||
+20
-20
@@ -8,33 +8,33 @@ import {
|
|||||||
} from '@radix-ui/react-icons';
|
} from '@radix-ui/react-icons';
|
||||||
import { Box, Button, Flex, Heading, ScrollArea, Text } from '@radix-ui/themes';
|
import { Box, Button, Flex, Heading, ScrollArea, Text } from '@radix-ui/themes';
|
||||||
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
||||||
import { CopyButton } from '../../../../../components/CopyButton';
|
import { CopyButton } from '../../../../components/CopyButton';
|
||||||
import { Boolean } from '../../../../../components/Embeds/Boolean';
|
import { Boolean } from '../../../../components/Embeds/Boolean';
|
||||||
import { Color } from '../../../../../components/Embeds/Color';
|
import { Color } from '../../../../components/Embeds/Color';
|
||||||
import { Enum } from '../../../../../components/Embeds/Enum';
|
import { Enum } from '../../../../components/Embeds/Enum';
|
||||||
import { GenerateURL } from '../../../../../components/Embeds/GenerateURL';
|
import { GenerateURL } from '../../../../components/Embeds/GenerateURL';
|
||||||
import { Import } from '../../../../../components/Embeds/Import';
|
import { Import } from '../../../../components/Embeds/Import';
|
||||||
import { PreviewWrapper } from '../../../../../components/Embeds/PreviewWrapper';
|
import { PreviewWrapper } from '../../../../components/Embeds/PreviewWrapper';
|
||||||
import { Radius } from '../../../../../components/Embeds/Radius';
|
import { Radius } from '../../../../components/Embeds/Radius';
|
||||||
import { RichText } from '../../../../../components/Embeds/RichText';
|
import { RichText } from '../../../../components/Embeds/RichText';
|
||||||
import { Size } from '../../../../../components/Embeds/Size';
|
import { Size } from '../../../../components/Embeds/Size';
|
||||||
import { SizeWithout0 } from '../../../../../components/Embeds/SizeWithout0';
|
import { SizeWithout0 } from '../../../../components/Embeds/SizeWithout0';
|
||||||
import { Slider } from '../../../../../components/Embeds/Slider';
|
import { Slider } from '../../../../components/Embeds/Slider';
|
||||||
import { TextController } from '../../../../../components/Embeds/TextController';
|
import { TextController } from '../../../../components/Embeds/TextController';
|
||||||
import { PageWrapper } from '../../../../../components/PageWrapper';
|
import { PageWrapper } from '../../../../components/PageWrapper';
|
||||||
import {
|
import {
|
||||||
embedConfigurations,
|
embedConfigurations,
|
||||||
extractEmbedConfigDefaults,
|
extractEmbedConfigDefaults,
|
||||||
} from '../../../../../constants/embeds';
|
} from '../../../../constants/embeds';
|
||||||
import { NAVBAR_HEIGHT } from '../../../../../constants/navbar';
|
import { NAVBAR_HEIGHT } from '../../../../constants/navbar';
|
||||||
import {
|
import {
|
||||||
LocaleProvider,
|
LocaleProvider,
|
||||||
useLocale,
|
useLocale,
|
||||||
type LocaleAcceptorProps,
|
type LocaleAcceptorProps,
|
||||||
} from '../../../../../hooks/useLocale';
|
} from '../../../../hooks/useLocale';
|
||||||
import { App } from '../../../../../stores/app';
|
import { App } from '../../../../stores/app';
|
||||||
import { EmbedState, type EmbedConfig } from '../../../../../stores/embedState';
|
import { EmbedState, type EmbedConfig } from '../../../../stores/embedState';
|
||||||
import { EmbedItemType } from '../../../../../stores/embedState/constants';
|
import { EmbedItemType } from '../../../../stores/embedState/constants';
|
||||||
|
|
||||||
export interface EmbedPreviewControllerProps {
|
export interface EmbedPreviewControllerProps {
|
||||||
configKey: string;
|
configKey: string;
|
||||||
+14
-8
@@ -1,24 +1,28 @@
|
|||||||
import { Box } from '@radix-ui/themes';
|
import { Box } from '@radix-ui/themes';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { parse } from 'urlon';
|
import { parse } from 'urlon';
|
||||||
import { BlitzKitTheme } from '../../../../../../components/BlitzKitTheme';
|
import { BlitzKitTheme } from '../../../../../components/BlitzKitTheme';
|
||||||
import {
|
import {
|
||||||
embedConfigurations,
|
embedConfigurations,
|
||||||
embedRenderers,
|
embedRenderers,
|
||||||
extractEmbedConfigDefaults,
|
extractEmbedConfigDefaults,
|
||||||
} from '../../../../../../constants/embeds';
|
} from '../../../../../constants/embeds';
|
||||||
|
import {
|
||||||
|
LocaleProvider,
|
||||||
|
type LocaleAcceptorProps,
|
||||||
|
} from '../../../../../hooks/useLocale';
|
||||||
import {
|
import {
|
||||||
EmbedState,
|
EmbedState,
|
||||||
type EmbedConfig,
|
type EmbedConfig,
|
||||||
type ExtractEmbedConfigTypes,
|
type ExtractEmbedConfigTypes,
|
||||||
} from '../../../../../../stores/embedState';
|
} from '../../../../../stores/embedState';
|
||||||
import { useEmbedStateCurry } from '../../../../../../stores/embedState/utilities';
|
import { useEmbedStateCurry } from '../../../../../stores/embedState/utilities';
|
||||||
|
|
||||||
interface PageProps {
|
interface PageProps {
|
||||||
embed: keyof typeof embedConfigurations;
|
embed: keyof typeof embedConfigurations;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Page({ embed }: PageProps) {
|
export function Page({ embed, locale }: PageProps & LocaleAcceptorProps) {
|
||||||
const state = useMemo(() => {
|
const state = useMemo(() => {
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const stateRaw = params.get('state');
|
const stateRaw = params.get('state');
|
||||||
@@ -32,9 +36,11 @@ export function Page({ embed }: PageProps) {
|
|||||||
}, [embed]);
|
}, [embed]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EmbedState.Provider data={state}>
|
<LocaleProvider locale={locale}>
|
||||||
<Content embed={embed} />
|
<EmbedState.Provider data={state}>
|
||||||
</EmbedState.Provider>
|
<Content embed={embed} />
|
||||||
|
</EmbedState.Provider>
|
||||||
|
</LocaleProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
+4
-2
@@ -1,11 +1,13 @@
|
|||||||
---
|
---
|
||||||
import EmbedLayout from '../../../../../../layouts/EmbedLayout.astro';
|
import EmbedLayout from '../../../../../layouts/EmbedLayout.astro';
|
||||||
import type { getStaticPaths } from '../index.astro';
|
import type { getStaticPaths } from '../index.astro';
|
||||||
import { Page } from './_index';
|
import { Page } from './_index';
|
||||||
|
|
||||||
export { getStaticPaths } from '../index.astro';
|
export { getStaticPaths } from '../index.astro';
|
||||||
|
|
||||||
|
const { locale } = Astro.params;
|
||||||
---
|
---
|
||||||
|
|
||||||
<EmbedLayout>
|
<EmbedLayout>
|
||||||
<Page client:only="react" embed={Astro.params.embed} />
|
<Page {locale} client:only="react" embed={Astro.params.embed} />
|
||||||
</EmbedLayout>
|
</EmbedLayout>
|
||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
import { AstroSeo } from '@astrolib/seo';
|
import { AstroSeo } from '@astrolib/seo';
|
||||||
import type { GetStaticPaths } from 'astro';
|
import type { GetStaticPaths } from 'astro';
|
||||||
import { capitalize } from 'lodash-es';
|
import { capitalize } from 'lodash-es';
|
||||||
import { embedConfigurations } from '../../../../../constants/embeds';
|
import { embedConfigurations } from '../../../../constants/embeds';
|
||||||
import BaseLayout from '../../../../../layouts/BaseLayout.astro';
|
import BaseLayout from '../../../../layouts/BaseLayout.astro';
|
||||||
import { getStaticPaths as parentGetStaticPaths } from '../index.astro';
|
import { getStaticPaths as parentGetStaticPaths } from '../index.astro';
|
||||||
import { Page } from './_index';
|
import { Page } from './_index';
|
||||||
|
|
||||||
+9
-10
@@ -1,19 +1,19 @@
|
|||||||
import { Box, Flex, Link, Text } from '@radix-ui/themes';
|
import { Box, Flex, Link, Text } from '@radix-ui/themes';
|
||||||
import { PreviewWrapper } from '../../../../components/Embeds/PreviewWrapper';
|
import { PreviewWrapper } from '../../../components/Embeds/PreviewWrapper';
|
||||||
import { LinkI18n } from '../../../../components/LinkI18n';
|
import { LinkI18n } from '../../../components/LinkI18n';
|
||||||
import { PageWrapper } from '../../../../components/PageWrapper';
|
import { PageWrapper } from '../../../components/PageWrapper';
|
||||||
import {
|
import {
|
||||||
embedConfigurations,
|
embedConfigurations,
|
||||||
extractEmbedConfigDefaults,
|
extractEmbedConfigDefaults,
|
||||||
} from '../../../../constants/embeds';
|
} from '../../../constants/embeds';
|
||||||
import { Var } from '../../../../core/radix/var';
|
import { Var } from '../../../core/radix/var';
|
||||||
import {
|
import {
|
||||||
|
type LocaleAcceptorProps,
|
||||||
LocaleProvider,
|
LocaleProvider,
|
||||||
useLocale,
|
useLocale,
|
||||||
type LocaleAcceptorProps,
|
} from '../../../hooks/useLocale';
|
||||||
} from '../../../../hooks/useLocale';
|
import { App } from '../../../stores/app';
|
||||||
import { App } from '../../../../stores/app';
|
import { EmbedState } from '../../../stores/embedState';
|
||||||
import { EmbedState } from '../../../../stores/embedState';
|
|
||||||
|
|
||||||
export function Page({ locale }: LocaleAcceptorProps) {
|
export function Page({ locale }: LocaleAcceptorProps) {
|
||||||
return (
|
return (
|
||||||
@@ -39,7 +39,6 @@ function Content() {
|
|||||||
>
|
>
|
||||||
{strings.website.tools.embed.suggest}
|
{strings.website.tools.embed.suggest}
|
||||||
</Link>
|
</Link>
|
||||||
.
|
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Flex justify="center">
|
<Flex justify="center">
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
import { embedTool } from '../../../constants/tools';
|
||||||
|
import ToolLayout from '../../../layouts/ToolLayout.astro';
|
||||||
|
import { Page } from './_index';
|
||||||
|
|
||||||
|
export { getStaticPaths } from '../index.astro';
|
||||||
|
|
||||||
|
const { locale } = Astro.params;
|
||||||
|
---
|
||||||
|
|
||||||
|
<ToolLayout tool={embedTool}>
|
||||||
|
<Page {locale} />
|
||||||
|
</ToolLayout>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
import ToolRedirect from '../../../components/ToolRedirect.astro';
|
||||||
|
|
||||||
|
export { getStaticPaths } from '../index.astro';
|
||||||
|
---
|
||||||
|
|
||||||
|
<ToolRedirect tool="embed" />
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
---
|
|
||||||
import { embedTool } from '../../../../constants/tools';
|
|
||||||
import ToolLayout from '../../../../layouts/ToolLayout.astro';
|
|
||||||
import { Page } from './_index';
|
|
||||||
|
|
||||||
export { getStaticPaths } from '../../index.astro';
|
|
||||||
|
|
||||||
const { locale } = Astro.params;
|
|
||||||
---
|
|
||||||
|
|
||||||
<ToolLayout tool={embedTool}>
|
|
||||||
<Page {locale} />
|
|
||||||
</ToolLayout>
|
|
||||||
Reference in new issue
Block a user