Skip to content

Commit

Permalink
a lot of issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Jan 1, 2024
1 parent 2c9bf05 commit 6885924
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 129 deletions.
3 changes: 1 addition & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ website/pages/docs/compiler.mdx
website/pages/docs/install.mdx
website/pages/docs/quickstart.mdx
website/pages/docs/rules.mdx
website/pages/docs/automatic.mdx
website/pages/docs/install.mdx
website/pages/docs/automatic.mdx
22 changes: 4 additions & 18 deletions website/components/home/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import OpenSaucedLogo from '../../public/opensauced.svg';
import MetamaskLogo from '../../public/metamask.svg';
import { Container } from './container';
import { ShimmerButton } from './shimmer-button';
import { Tooltip as ReactTooltip } from 'react-tooltip';

const CountUp = dynamic(() => import('react-countup'), {
loading: () => <span>70</span>,
Expand All @@ -30,27 +29,14 @@ export function Hero() {
<p className="mt-8 text-xl text-zinc-600 dark:text-zinc-300 leading-8">
The{' '}
<span className="font-medium dark:text-zinc-100">
<span
data-tooltip-id="virtual-dom-explanation"
className="text-purple-500 hover:text-purple-700"
>
Virtual DOM
</span>{' '}
Replacement
Virtual DOM Replacement
</span>{' '}
for React. Experience improved performance for UI and data-heavy
React apps. Minimal effort required - all it takes is {' '}
for React. The Virtual DOM Replacement for React. Gain big performance wins for UI and data heavy React apps. Dead simple to use – try it out {' '}
<Link href="/docs" className="font-medium hover:underline">
a single plugin
now
</Link>
.
!
</p>
<ReactTooltip
id="virtual-dom-explanation"
place="bottom"
style={{ width: '50%', zIndex: '13' }}
content="The Virtual DOM is a technique in web development, like React.js, that boosts efficiency by first making changes to a virtual copy of the DOM before updating the actual DOM."
/>
<div className="mt-16 flex flex-wrap justify-center gap-y-4 gap-x-6">
<Link href="/docs" className="w-full sm:w-max">
<ShimmerButton
Expand Down
3 changes: 1 addition & 2 deletions website/components/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ export function Home() {
return (
<main className="space-y-40 mb-40">
<Hero />
<About />
<Showcase />
{/* <Community /> */}
<About />
<CTA />
</main>
);
Expand Down
14 changes: 4 additions & 10 deletions website/pages/docs/automatic.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ import { Callout, Tab, Tabs } from 'nextra-theme-docs';

# Automatic Mode

Million.js comes with Automatic Mode as its default setting. This transforms your React components into Million.js components, improving speed without any major code changes.

When [installing Million into your project](/docs/install), automatic mode is recommended for most users and this is because it packs in it all the necessary optimizations that your application needs. The `auto` option of the compiler toggles it.

### `auto`

The `auto` option is a boolean that enables automatic mode. By default it is unset, because Million offers [a way to manually set your configuration](/docs/install#configure-it-yourself).
Million.js uses Automatic Mode out of the box if you installed via CLI. This optimizes your React components, improving speed without any major code changes. This is the recommended way to use Million.js.

### Advanced customization

Expand All @@ -33,7 +27,7 @@ auto: {
```

<Tabs items={['Next.js', 'Astro', 'Gatsby', 'Vite', 'Remix', 'Create React App', 'Webpack', 'Rollup']} storageKey="selected-bundler-compiler">
<Tab>
<Tab>
```js filename="next.config.mjs"
import million from 'million/compiler';

Expand All @@ -42,12 +36,12 @@ const nextConfig = {
reactStrictMode: true,
};

const millionConfig = {{
const millionConfig = {
auto: {
threshold: 0.05, // default: 0.1,
skip: ['useBadHook', /badVariable/g], // default []
// if you're using RSC: auto: { rsc: true },
}}
}
}

export default million.next(nextConfig, millionConfig);
Expand Down
16 changes: 7 additions & 9 deletions website/pages/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ export const Demo = dynamic(() =>
**Million.js** is a fast and lightweight (`<4kb`) virtual DOM that can improve [React's speed by up to 70%](https://krausest.github.io/js-framework-benchmark/current.html).
With a fine-tuned, optimized virtual DOM, Million.js can have your React components running at the speed of raw JavaScript.

<Callout type="info">
Million.js is compatible with React 16 and above. If you're using an older
version of React, you'll need to upgrade first.
</Callout>

The [Installation Guide](/docs/install) can help you get started right away.

### Setup in seconds
## Setup in seconds

The Million.js CLI will automatically install the package and configure your project for you.

Expand Down Expand Up @@ -50,6 +43,11 @@ The Million.js CLI will automatically install the package and configure your pro
</Tab>
</Tabs>

<Callout type="info">
Million.js is compatible with React 16 and above. If you're using an older
version of React, you'll need to upgrade first.
</Callout>

That's it! Your project is now running on Million.js 🎉

## Million.js vs. React
Expand All @@ -64,4 +62,4 @@ to show how Million.js performance compares to React.

## Any questions?

If you have any questions or need support, please feel free to ask them in the `questions` channel on the [Discord](https://million.dev/chat) or check out <Link href="/blog/million-beyond-speed">Million Beyond "Speed"</Link>
If you have any questions or need support, please feel free to ask them in [Discord](https://million.dev/chat) or submit an issue on [GitHub](https://github.com/aidenybai/million).
53 changes: 49 additions & 4 deletions website/pages/docs/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,57 @@ import { Callout, Tabs, Tab, Steps } from 'nextra-theme-docs';

Million.js assumes that you have an existing React project. To learn about how to create a React app, please see [React's documentation](https://react.dev).

## Install via CLI

The Million.js CLI will automatically install the package and configure your project for you.

**For more control, Million offers customizable options.**
<Tabs items={['npm', 'pnpm', 'yarn', 'bun']} storageKey="selected-manager">
{/* prettier-ignore */}
<Tab>
```bash copy
npx million@latest
```
</Tab>
{/* prettier-ignore */}
<Tab>
```bash copy
pnpx million@latest
```
</Tab>
{/* prettier-ignore */}
<Tab>
```bash copy
yarn add million@latest
```
</Tab>
{/* prettier-ignore */}
<Tab>
```bash copy
bunx million@latest
```
</Tab>
</Tabs>


<Callout type="info">
Million.js is compatible with React 16 and above. If you're using an older
version of React, you'll need to upgrade first.
</Callout>

That's it! Your project is now running on Million.js 🎉

## Install manually

If you have issues [installing via the CLI](#install-via-cli), or you have a custom setup, you can
install Million.js manually.

Notice that there are two modes you can choose: **Automatic** and **Manual**:

- **Automatic mode** will automatically configure, analyze, and optimize your project for you.
This is the recommended mode.

- **Manual mode** will require you to write code to [optimize certain parts of
your project](/docs/manual-mode/manual-mode). This mode is recommended for advanced users who want to have more control over their project.

<Tabs items={['Automatic', 'Manual']} storageKey="mode">

Expand Down Expand Up @@ -197,8 +245,6 @@ npm install million

### Add the compiler to your application

<details open>
<summary>React Instructions</summary>
<Tabs items={['Next.js', 'Astro', 'Gatsby', 'Vite', 'Remix', 'Create React App', 'Webpack', 'Rollup']} storageKey="selected-bundler-compiler">
<Tab>
Million.js is supported within the `/app` ("use client" components only) and `/pages`
Expand Down Expand Up @@ -298,7 +344,6 @@ export default {
</Tab>

</Tabs>
</details>

</Steps>

Expand Down
1 change: 1 addition & 0 deletions website/pages/docs/internals/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"block": "block()",
"mount": "mount()",
"patch": "patch()",
"map-array": "mapArray()",
Expand Down
77 changes: 77 additions & 0 deletions website/pages/docs/internals/block.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: "block()"
description: "A function that creates a stateless component."
---

import { Callout } from 'nextra-theme-docs';

{' '}
<Callout type="warning">
**This function is part of the internal API.** You should only be using this
if you are making your own framework.
</Callout>

{' '}
<br />


# `block(){:jsx}`

**Syntax:** `block((props) => vnode){:jsx}`\
**Example:** `block((props) => <div>{props.foo}</div>){:jsx}`

The `block` function instantiates a `Block` (_a stateless "component"_). It accepts a function with a `props` object parameter that returns a `VNode`.

### Rules of usage

##### `props` is an immutable object with primitive or `Block` values.

```jsx
someBlock({
one: '1', //
two: 1 + 1, //
three: true, //
four: Date.now(), //
five: anotherBlock({ crewmate: true }), //
six: { imposter: true }, //
seven: new Date(), //
});
```

##### Top level values of `props` may not be interpolated with other values.

The `props` are filled with immutable `Hole` values. These values are replaced with the actual values when the `block(){:jsx}` is called.

```jsx
// Anatomy of a `Hole`
{
$: 'prop';
}

// Example:
block((props) => {
console.log(props.foo); // { $: 'foo' } ✅
console.log(props.foo + ' bar'); // { $: 'foo' } + ' bar' ❌
return <div>{props.foo}</div>;
});
```

The following are examples of this rule:

```jsx
block((props) => {
const { favorite } = props.favorite; //
<div className={props.className /**/}>
{props.hello /**/}
{Date.now() /**/}
<button
onClick={() => {
console.log(props.world); /* ❌ (no holes inside listeners) */
}}
>
{props.count + 1 /**/}
{props.foo.toString() /**/}
</button>
</div>;
});
```
Loading

0 comments on commit 6885924

Please sign in to comment.