Skip to content

Commit

Permalink
Merge pull request #3958 from gengjiawen/feat/vite_demo
Browse files Browse the repository at this point in the history
feat: migrate demo to vite
  • Loading branch information
marvinhagemeister committed May 8, 2023
2 parents 8b943f9 + e4f3522 commit b114dcc
Show file tree
Hide file tree
Showing 40 changed files with 1,393 additions and 15,968 deletions.
1 change: 0 additions & 1 deletion demo/contenteditable.js → demo/contenteditable.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createElement } from 'preact';
import { useState } from 'preact/hooks';

export default function Contenteditable() {
Expand Down
2 changes: 1 addition & 1 deletion demo/context.js → demo/context.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line no-unused-vars
import { createElement, Component, createContext, Fragment } from 'preact';
import { Component, createContext } from 'preact';
const { Provider, Consumer } = createContext();

class ThemeProvider extends Component {
Expand Down
2 changes: 0 additions & 2 deletions demo/controlled-inputs.js → demo/controlled-inputs.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { useState } from 'react';

/** @jsx React.createElement */

const ControlledInputs = () => {
const [value, set] = useState('');
const onChange = e => {
Expand Down
10 changes: 1 addition & 9 deletions demo/devtools.js → demo/devtools.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
// eslint-disable-next-line no-unused-vars
import {
createElement,
Component,
memo,
Fragment,
Suspense,
lazy
} from 'react';
import { Component, memo, Suspense, lazy } from 'react';

function Foo() {
return <div>I'm memoed</div>;
Expand Down
4 changes: 2 additions & 2 deletions demo/fragments.js → demo/fragments.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createElement, Component, Fragment } from 'preact';
import { Component } from 'preact';

export default class extends Component {
export default class FragmentComp extends Component {
state = { number: 0 };

componentDidMount() {
Expand Down
13 changes: 13 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Preact Demo</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/index.jsx"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion demo/index.js → demo/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createElement, render, Component, Fragment } from 'preact';
import { render, Component, Fragment } from 'preact';
// import renderToString from 'preact-render-to-string';
import './style.scss';
import { Router, Link } from 'preact-router';
Expand Down
2 changes: 1 addition & 1 deletion demo/key_bug.js → demo/key_bug.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createElement, Component } from 'preact';
import { Component } from 'preact';

function Foo(props) {
return <div>This is: {props.children}</div>;
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion demo/mobx.js → demo/mobx.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { createElement, forwardRef, useRef, useState } from 'react';
import React, { forwardRef, useRef, useState } from 'react';
import { decorate, observable } from 'mobx';
import { observer, useObserver } from 'mobx-react';
import 'mobx-react-lite/batchingForReactDom';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createElement, lazy } from 'react';
import { lazy } from 'react';

const pause = timeout =>
new Promise(d => setTimeout(d, timeout), console.log(timeout));

const SubComponent = lazy(() =>
pause(Math.random() * 1000).then(() => import('./subcomponent.js'))
pause(Math.random() * 1000).then(() => import('./subcomponent.jsx'))
);

export default function ComponentContainer({ appearance }) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ const pause = timeout =>
new Promise(d => setTimeout(d, timeout), console.log(timeout));

const DropZone = lazy(() =>
pause(Math.random() * 1000).then(() => import('./dropzone.js'))
pause(Math.random() * 1000).then(() => import('./dropzone.jsx'))
);
const Editor = lazy(() =>
pause(Math.random() * 1000).then(() => import('./editor.js'))
pause(Math.random() * 1000).then(() => import('./editor.jsx'))
);
const AddNewComponent = lazy(() =>
pause(Math.random() * 1000).then(() => import('./addnewcomponent.js'))
pause(Math.random() * 1000).then(() => import('./addnewcomponent.jsx'))
);
const GenerateComponents = lazy(() =>
pause(Math.random() * 1000).then(() => import('./component-container.js'))
pause(Math.random() * 1000).then(() => import('./component-container.jsx'))
);

export default class App extends Component {
Expand Down
File renamed without changes.
Loading

0 comments on commit b114dcc

Please sign in to comment.