Skip to content

Commit

Permalink
WIP: saving progress on renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaun Lloyd committed Jan 15, 2024
1 parent 2c95d3b commit c0e78b1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
12 changes: 11 additions & 1 deletion code/addons/interactions/src/components/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,18 @@ const Divider = styled.div(({ theme }) => ({
backgroundColor: theme.appBorderColor,
}));

const sanitizeRendererForDocsUrl = (renderer: string) => {
const normalizedRenderer = renderer.toLowerCase();

if (normalizedRenderer.includes('vue')) {
return 'vue';
}

return normalizedRenderer;
};

const buildDocsUrl = (base: string, path: string, renderer: string) =>
`${base}${path}?renderer=${renderer}`;
`${base}${path}?renderer=${sanitizeRendererForDocsUrl(renderer)}`;

interface EmptyProps {
renderer: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const InteractionsPanel: React.FC<InteractionsPanelProps> = React.memo(
}) {
const api = useStorybookApi();

const renderer = 'react';
const renderer = globalThis.STORYBOOK_ENV;
const docsUrlBase = api.getVersionDocsBaseUrl();

return (
Expand Down
15 changes: 14 additions & 1 deletion code/ui/manager/src/container/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ export const Shortcut: FC<{ keys: string[] }> = ({ keys }) => (
</>
);

const sanitizeRendererForDocsUrl = (renderer: string) => {
const normalizedRenderer = renderer.toLowerCase();

if (normalizedRenderer.includes('vue')) {
return 'vue';
}

return normalizedRenderer;
};

export const useMenu = (
state: State,
api: API,
Expand All @@ -71,10 +81,13 @@ export const useMenu = (
);

const documentation = useMemo(() => {
const baseURL = api.getVersionDocsBaseUrl();
const renderer = sanitizeRendererForDocsUrl(globalThis.STORYBOOK_ENV);

return {
id: 'documentation',
title: 'Documentation',
href: api.getVersionDocsBaseUrl(),
href: `${baseURL}?renderer=${renderer}`,
icon: <ShareAltIcon />,
};
}, [api]);
Expand Down

0 comments on commit c0e78b1

Please sign in to comment.