mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-27 08:39:59 +08:00
7a6a843f79
- @sunmao-ui/arco-lib@0.3.0-alpha.2 - @sunmao-ui/chakra-ui-lib@0.5.0-alpha.2 - @sunmao-ui/editor-sdk@0.3.0-alpha.2 - @sunmao-ui/editor@0.7.0-alpha.2 - @sunmao-ui/runtime@0.7.0-alpha.2 - @sunmao-ui/shared@0.2.0-alpha.2
56 lines
1.7 KiB
HTML
56 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" style="overflow: hidden">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>sunmao-ui runtime examples</title>
|
|
</head>
|
|
<body>
|
|
<select></select>
|
|
<div id="root"></div>
|
|
<script type="module">
|
|
import React from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
import { initSunmaoUI } from './src';
|
|
import { ChakraProvider } from '@chakra-ui/react';
|
|
import { sunmaoChakraUILib } from '@sunmao-ui/chakra-ui-lib';
|
|
import examples from '@example.json';
|
|
|
|
const selectEl = document.querySelector('select');
|
|
for (const example of examples) {
|
|
const optionEl = document.createElement('option');
|
|
optionEl.innerText = example.name;
|
|
selectEl.appendChild(optionEl);
|
|
}
|
|
selectEl.addEventListener('change', () => {
|
|
render(examples.find(e => e.name === selectEl.value));
|
|
});
|
|
|
|
const rootEl = document.querySelector('#root');
|
|
const render = example => {
|
|
ReactDOM.unmountComponentAtNode(rootEl);
|
|
const { App, registry } = initSunmaoUI({ libs: [sunmaoChakraUILib] });
|
|
const { app, modules = [] } = example.value;
|
|
window.registry = registry;
|
|
modules.forEach(m => {
|
|
registry.registerModule(m);
|
|
});
|
|
ReactDOM.render(
|
|
React.createElement(
|
|
React.StrictMode,
|
|
null,
|
|
React.createElement(
|
|
ChakraProvider,
|
|
null,
|
|
React.createElement(App, { options: app }, null)
|
|
)
|
|
),
|
|
rootEl
|
|
);
|
|
};
|
|
|
|
render(examples[0]);
|
|
</script>
|
|
</body>
|
|
</html>
|