mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-01-06 16:34:25 +08:00
172 lines
4.8 KiB
HTML
172 lines
4.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>meta-ui runtime example: box</title>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="root"></div>
|
|
<script type="module">
|
|
import renderApp from "../../src/main.tsx";
|
|
renderApp({
|
|
version: "example/v1",
|
|
metadata: {
|
|
name: "box",
|
|
description: "box",
|
|
},
|
|
spec: {
|
|
components: [
|
|
{
|
|
id: "test_btn",
|
|
type: "plain/v1/button",
|
|
properties: {
|
|
text: {
|
|
raw: "Click",
|
|
format: "plain",
|
|
},
|
|
},
|
|
traits: [
|
|
{
|
|
type: "core/v1/state",
|
|
properties: {
|
|
key: "count",
|
|
initialValue: 0,
|
|
},
|
|
},
|
|
{
|
|
type: "core/v1/event",
|
|
properties: {
|
|
events: [
|
|
{
|
|
event: "click",
|
|
componentId: "test_btn",
|
|
method: {
|
|
name: "setValue",
|
|
parameters:
|
|
"{{ test_btn.count > 0 ? 0 : test_btn.count + 1 }}",
|
|
},
|
|
wait: {},
|
|
disabled: false,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: "box_container",
|
|
type: "chakra_ui/v1/box",
|
|
properties: {
|
|
my: 8,
|
|
p: 8,
|
|
display: "flex",
|
|
bg: "{{ test_btn.count % 2 ? 'teal' : 'white' }}",
|
|
border: "1px solid",
|
|
borderColor: "{{ test_btn.count % 2 ? 'white' : 'teal' }}",
|
|
borderRadius: 8,
|
|
h: 200,
|
|
},
|
|
traits: [],
|
|
},
|
|
{
|
|
id: "box_child_1",
|
|
type: "chakra_ui/v1/box",
|
|
properties: {
|
|
mr: 4,
|
|
flex: 1,
|
|
bg: "teal",
|
|
color: "{{ test_btn.count % 2 ? 'teal' : 'white' }}",
|
|
bg: "{{ test_btn.count % 2 ? 'white' : 'teal' }}",
|
|
display: "flex",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
borderRadius: 4,
|
|
},
|
|
traits: [
|
|
{
|
|
type: "core/v1/slot",
|
|
properties: {
|
|
container: {
|
|
id: "box_container",
|
|
slot: "box_content",
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: "text",
|
|
type: "core/v1/text",
|
|
properties: {
|
|
value: {
|
|
raw: "in box child 1",
|
|
format: "plain",
|
|
},
|
|
},
|
|
traits: [
|
|
{
|
|
type: "core/v1/slot",
|
|
properties: {
|
|
container: {
|
|
id: "box_child_1",
|
|
slot: "box_content",
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: "box_child_2",
|
|
type: "chakra_ui/v1/box",
|
|
properties: {
|
|
flex: 1,
|
|
bg: "teal",
|
|
color: "{{ test_btn.count % 2 ? 'teal' : 'white' }}",
|
|
bg: "{{ test_btn.count % 2 ? 'white' : 'teal' }}",
|
|
display: "flex",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
borderRadius: 4,
|
|
},
|
|
traits: [
|
|
{
|
|
type: "core/v1/slot",
|
|
properties: {
|
|
container: {
|
|
id: "box_container",
|
|
slot: "box_content",
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: "text",
|
|
type: "core/v1/text",
|
|
properties: {
|
|
value: {
|
|
raw: "in box child 2",
|
|
format: "plain",
|
|
},
|
|
},
|
|
traits: [
|
|
{
|
|
type: "core/v1/slot",
|
|
properties: {
|
|
container: {
|
|
id: "box_child_2",
|
|
slot: "box_content",
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|