Skip to content

Commit ba5636d

Browse files
committed
feat: add plugin for button showcase
1 parent 81f1f8e commit ba5636d

File tree

6 files changed

+69
-6
lines changed

6 files changed

+69
-6
lines changed

eslint.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,16 @@ import ignoreFolders from './.config/ignores.js';
77
export default defineConfig([
88
xoConfig,
99
eslintConfigPrettier,
10-
globalIgnores([...ignoreFolders])
10+
globalIgnores([...ignoreFolders]),
11+
{
12+
files: ['**/*.ts', '**/*.tsx'],
13+
parser: '@typescript-eslint/parser',
14+
parserOptions: {
15+
ecmaVersion: 'latest',
16+
sourceType: 'module',
17+
ecmaFeatures: { jsx: true }
18+
},
19+
plugins: ['@typescript-eslint'],
20+
extends: ['plugin:@typescript-eslint/recommended']
21+
}
1122
]);

packages/components/configs/mitosis.showcase.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
api: 'signals'
1515
},
1616
vue: {
17-
api: 'composition'
17+
api: 'options'
1818
}
1919
},
2020
commonOptions: {

showcases/next-showcase/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"moduleResolution": "node",
1212
"resolveJsonModule": true,
1313
"isolatedModules": true,
14-
"jsx": "preserve",
14+
"jsx": "react-jsx",
1515
"strictNullChecks": true,
1616
"downlevelIteration": true,
1717
"target": "ES2017",

showcases/patternhub/data/routes.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import ButtonShowcase from '@components/components/button/showcase/button.showcase';
2-
import { type ReactElement } from 'react';
1+
import type { ReactElement } from 'react';
32
import AccordionComponent from '../../react-showcase/src/components/accordion';
43
import AccordionItemComponent from '../../react-showcase/src/components/accordion-item';
54
import BadgeComponent from '../../react-showcase/src/components/badge';
@@ -27,6 +26,7 @@ import TabsComponent from '../../react-showcase/src/components/tabs';
2726
import TagComponent from '../../react-showcase/src/components/tag';
2827
import TextareaComponent from '../../react-showcase/src/components/textarea';
2928
import TooltipComponent from '../../react-showcase/src/components/tooltip';
29+
import { getShowcasePlugin } from '../../shared/showcase-plugins';
3030
import Components from './components.json';
3131

3232
export type NavigationItem = {
@@ -41,7 +41,9 @@ export type NavigationItem = {
4141
const nameComponentMap = {
4242
'custom-select': <MutliSelectComponent />,
4343
stack: <StackComponent />,
44-
button: <ButtonShowcase isPatternhub />,
44+
button: getShowcasePlugin('button')!.getShowcaseComponent({
45+
host: 'patternhub'
46+
}),
4547
link: <LinkComponent />,
4648
brand: <BrandComponent />,
4749
// Icon: <IconComponent />,

showcases/patternhub/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"noUnusedParameters": false,
1919
"jsx": "react-jsx",
2020
"incremental": true,
21+
"baseUrl": ".",
2122
"paths": {
2223
"@components": ["../../output/react/src"],
2324
"@components/src/*": ["../../output/react/src/*"],
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import ButtonShowcase from '@components/components/button/showcase/button.showcase';
2+
import { type ReactElement } from 'react';
3+
4+
export type ShowcaseId = 'button'; // Add later 'button' | 'link' | 'input' | ...
5+
6+
export type ShowcaseHost = 'patternhub' | 'react-showcase' | 'storybook';
7+
8+
export type ShowcasePluginContext = {
9+
host: ShowcaseHost;
10+
};
11+
12+
/**
13+
* Basic interface for a showcase plugin.
14+
*/
15+
export type ShowcasePlugin = {
16+
id: ShowcaseId;
17+
label: string;
18+
getShowcaseComponent: (
19+
context: ShowcasePluginContext
20+
) => ReactElement | undefined;
21+
};
22+
23+
/**
24+
* Showcase plugin for the Button component.
25+
*/
26+
export const buttonShowcasePlugin: ShowcasePlugin = {
27+
id: 'button',
28+
label: 'Button',
29+
getShowcaseComponent({ host }) {
30+
if (host === 'patternhub') {
31+
return <ButtonShowcase isPatternhub />;
32+
}
33+
34+
return <ButtonShowcase />;
35+
}
36+
};
37+
38+
/**
39+
* Central registry of all showcase plugins.
40+
*/
41+
export const showcasePlugins: ShowcasePlugin[] = [buttonShowcasePlugin]; // Add more plugins here later
42+
43+
/**
44+
* Get a showcase plugin by its ID.
45+
* @param id - The ID of the showcase plugin.
46+
* @returns The showcase plugin if found, otherwise undefined.
47+
*/
48+
export const getShowcasePlugin = (id: ShowcaseId): ShowcasePlugin | undefined =>
49+
showcasePlugins.find((plugin) => plugin.id === id);

0 commit comments

Comments
 (0)