diff --git a/packages/docs/src/components/code-rotator.tsx b/packages/docs/src/components/code-rotator.tsx index 1da2eda97c..26ed461708 100644 --- a/packages/docs/src/components/code-rotator.tsx +++ b/packages/docs/src/components/code-rotator.tsx @@ -245,7 +245,11 @@ export const CodeRotator = component$((props: { class: ClassList }) => { const compileAll = $(async (code: string) => { await Promise.allSettled( frameworkExamples.map(async (framework) => { - const output = await compile(code, framework as OutputFramework, 'jsx'); + const output = await compile({ + code, + output: framework as OutputFramework, + inputSyntax: 'jsx' + }); (outputs as any)[framework] = output.replace( /\n?\n?import { useStore } from "..";\n?/g, '', diff --git a/packages/docs/src/components/header.tsx b/packages/docs/src/components/header.tsx index 10d20057ed..d28ebbcb01 100644 --- a/packages/docs/src/components/header.tsx +++ b/packages/docs/src/components/header.tsx @@ -40,7 +40,7 @@ export default component$(() => { alt="Mitosis logo" class="object-contain max-md:max-w-[110px]" width={160} - height={80} + height={40} src="https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F0fdb9aabd10f4205b3b3b56d7b950239" /> diff --git a/packages/docs/src/components/options-modal.tsx b/packages/docs/src/components/options-modal.tsx new file mode 100644 index 0000000000..d7394e9b1a --- /dev/null +++ b/packages/docs/src/components/options-modal.tsx @@ -0,0 +1,113 @@ +import { ToReactOptions, ToVueOptions } from '@builder.io/mitosis'; +import { $, Signal, component$, useSignal } from '@builder.io/qwik'; +import { OutputFramework } from '~/services/compile'; +import Select from './select'; + +type Option = {name: keyof O} & ({ + type: 'boolean'; + default: boolean +} | { + type: 'enum'; + enum: Array; + default: string; +}); + +const DEFAULT_OPTIONS: Option[] = [{ + name: 'typescript', + type: 'boolean', + default: true +}] + +type Dictionary = { + [index: string]: T +} +type Options = Dictionary + +export const getDefaultOptions = (target: OutputFramework) => { + const opts = getOptions(target) + const opt: Options = {} + + for (const o of opts) { + opt[o.name] = o.default + } + + return opt +} + + +const _getOptions = (target:OutputFramework) => { + switch (target) { + case 'vue':{ + const o: Array> = [{ + name: 'casing', + type: 'enum', + enum: ['pascal', 'kebab'], + default: 'pascal' + }, + { + name: 'api', + type: 'enum', + enum: ['options', 'composition'], + default: 'composition' + }] + + return o} + + case 'react': { + + const o: Array> = [{ + name: 'stylesType', + type: 'enum', + enum: [ + 'emotion', 'styled-components', 'styled-jsx', 'react-native', 'style-tag' + ], + default: 'style-tag' + }] + return o } + default: + return [] + } +} +const getOptions = (target:OutputFramework) => { + return [ + ...DEFAULT_OPTIONS, + ..._getOptions(target) + ] +} + +export default component$( + ({options, target}: { options: Options, target:Signal }) => { + const showModal = useSignal(false); + + + return ( +
+ + + {showModal.value &&
+

{target.value} settings.

+ +
+ {getOptions(target.value).map(option => { + console.log('consuming option: ', {option, options}); + + return
+
{option.name}
+
{option.type === 'boolean' ?
{ + console.log('before: ', options.value); + + options[option.name] = !options[option.name] + + console.log('after: ', options.value); + })} >
: (outputOneFramework.value = framework)} + onChange$={(framework: any) => { + outputOneFramework.value = framework; + Object.assign(optionsOne, getDefaultOptions(framework)) + }} options={outputs} - /> + />
)}
@@ -284,20 +303,27 @@ export default component$(() => {
)}
-
+
{visible.value && ( // Workaround weird bug where this doesn't render correctly // server side +
+ +