Skip to content

Commit cde89e3

Browse files
committed
Swap from React to Preact
This reduces the size of the JS bundles.
1 parent 4349485 commit cde89e3

29 files changed

+262
-1036
lines changed

site/astro.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { defineConfig } from 'astro/config'
2-
import react from '@astrojs/react'
32
import sitemap from '@astrojs/sitemap'
43
import mdx from '@astrojs/mdx'
54
import compress from 'astro-compress'
65
import { rehypeHeadingIds } from '@astrojs/markdown-remark'
76
import { autolinkHeadingsPlugin } from './src/plugins/rehypeHeadings'
87
import rehypeResponsiveTables from './src/plugins/rehypeResponsiveTable'
98

9+
import preact from '@astrojs/preact';
10+
1011
export default defineConfig({
1112
integrations: [
12-
react(),
1313
sitemap({
1414
filter: (page) =>
1515
!page.endsWith("/component-spec-template/"),
@@ -18,6 +18,7 @@ export default defineConfig({
1818
rehypePlugins: [rehypeHeadingIds, autolinkHeadingsPlugin, rehypeResponsiveTables],
1919
}),
2020
compress(),
21+
preact(),
2122
],
2223
site: 'https://open-ui.org',
2324
prefetch: {
@@ -34,4 +35,4 @@ export default defineConfig({
3435
external: ['svgo'],
3536
},
3637
},
37-
})
38+
})

site/package.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,22 @@
3333
},
3434
"devDependencies": {
3535
"@astrojs/mdx": "^4.0.8",
36-
"@astrojs/react": "4.2.0",
3736
"@astrojs/sitemap": "3.2.1",
3837
"astro": "5.2.5",
3938
"astro-compress": "^2.3.6",
4039
"eslint": "^8.18.0",
41-
"eslint-plugin-react": "^7.30.0",
4240
"hast-util-to-string": "^2.0.0",
4341
"hastscript": "^7.2.0",
4442
"husky": "^4.2.3",
4543
"lint-staged": "^11.1.2",
4644
"prettier": "^2.0.4",
4745
"prettier-plugin-astro": "^0.5.4",
48-
"react": "^18.2.0",
49-
"react-dom": "^18.2.0",
5046
"rehype-autolink-headings": "^6.1.1"
5147
},
5248
"dependencies": {
53-
"@fortawesome/fontawesome-svg-core": "^6.4.2",
54-
"@fortawesome/free-brands-svg-icons": "^6.4.2",
55-
"@fortawesome/free-solid-svg-icons": "^6.4.2",
56-
"@fortawesome/react-fontawesome": "^0.2.0",
57-
"@nanostores/react": "^0.4.0",
58-
"nanostores": "^0.7.1"
49+
"@astrojs/preact": "^4.0.4",
50+
"@preact/signals": "^2.0.1",
51+
"invokers-polyfill": "^0.4.7",
52+
"preact": "^10.25.4"
5953
}
6054
}

site/src/components/anatomy-components.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import './anatomy-component.css'
32

43
export const AnatomyWrapper = ({ children }) => (

site/src/components/anatomy.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import './anatomy.css'
32

43
import { anatomiesByComponent } from '../sources'

site/src/components/breadcrumb-anatomy.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import { AnatomyWrapper, Host, Slot, Part } from './anatomy-components'
32
import './breadcrumb-anatomy.css'
43

site/src/components/checkbox-anatomy.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import { AnatomyWrapper, Host, Part, Slot } from './anatomy-components'
32

43
const CheckboxAnatomy = () => {

site/src/components/combobox-anatomy.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import { AnatomyWrapper, Host, Part, Slot } from './anatomy-components'
32

43
const ComboboxAnatomy = () => {

site/src/components/community-links.jsx

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,48 @@
1-
import React from 'react'
2-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
3-
import { faDiscord, faGithub, faXTwitter } from '@fortawesome/free-brands-svg-icons'
41
import './community-links.css'
52

6-
const iconStyle = {
7-
width: '24px',
8-
height: '24px',
9-
}
10-
113
export default function CommunityLinks({ className = '' }) {
124
return (
135
<div className={'community-links ' + className}>
146
<a href="https://github.com/openui/open-ui" title="GitHub" rel="noreferrer noopener">
15-
<FontAwesomeIcon style={iconStyle} icon={faGithub} />
7+
<svg
8+
aria-hidden="true"
9+
style="width: 24px; height: 24px"
10+
xmlns="http://www.w3.org/2000/svg"
11+
viewBox="0 0 496 512"
12+
>
13+
<path
14+
fill="currentColor"
15+
d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"
16+
/>
17+
</svg>
1618
</a>
1719

1820
<a href="https://discord.gg/DEWjhSw" title="Discord" rel="noreferrer noopener">
19-
<FontAwesomeIcon style={iconStyle} icon={faDiscord} />
21+
<svg
22+
aria-hidden="true"
23+
style="width: 24px; height: 24px"
24+
xmlns="http://www.w3.org/2000/svg"
25+
viewBox="0 0 640 512"
26+
>
27+
<path
28+
fill="currentColor"
29+
d="M524.5 69.8a1.5 1.5 0 0 0 -.8-.7A485.1 485.1 0 0 0 404.1 32a1.8 1.8 0 0 0 -1.9 .9 337.5 337.5 0 0 0 -14.9 30.6 447.8 447.8 0 0 0 -134.4 0 309.5 309.5 0 0 0 -15.1-30.6 1.9 1.9 0 0 0 -1.9-.9A483.7 483.7 0 0 0 116.1 69.1a1.7 1.7 0 0 0 -.8 .7C39.1 183.7 18.2 294.7 28.4 404.4a2 2 0 0 0 .8 1.4A487.7 487.7 0 0 0 176 479.9a1.9 1.9 0 0 0 2.1-.7A348.2 348.2 0 0 0 208.1 430.4a1.9 1.9 0 0 0 -1-2.6 321.2 321.2 0 0 1 -45.9-21.9 1.9 1.9 0 0 1 -.2-3.1c3.1-2.3 6.2-4.7 9.1-7.1a1.8 1.8 0 0 1 1.9-.3c96.2 43.9 200.4 43.9 295.5 0a1.8 1.8 0 0 1 1.9 .2c2.9 2.4 6 4.9 9.1 7.2a1.9 1.9 0 0 1 -.2 3.1 301.4 301.4 0 0 1 -45.9 21.8 1.9 1.9 0 0 0 -1 2.6 391.1 391.1 0 0 0 30 48.8 1.9 1.9 0 0 0 2.1 .7A486 486 0 0 0 610.7 405.7a1.9 1.9 0 0 0 .8-1.4C623.7 277.6 590.9 167.5 524.5 69.8zM222.5 337.6c-29 0-52.8-26.6-52.8-59.2S193.1 219.1 222.5 219.1c29.7 0 53.3 26.8 52.8 59.2C275.3 311 251.9 337.6 222.5 337.6zm195.4 0c-29 0-52.8-26.6-52.8-59.2S388.4 219.1 417.9 219.1c29.7 0 53.3 26.8 52.8 59.2C470.7 311 447.5 337.6 417.9 337.6z"
30+
/>
31+
</svg>
2032
</a>
2133

2234
<a href="https://x.com/openuicg" title="X" rel="noreferrer noopener">
23-
<FontAwesomeIcon style={iconStyle} icon={faXTwitter} />
35+
<svg
36+
aria-hidden="true"
37+
style="width: 24px; height: 24px"
38+
xmlns="http://www.w3.org/2000/svg"
39+
viewBox="0 0 512 512"
40+
>
41+
<path
42+
fill="currentColor"
43+
d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"
44+
/>
45+
</svg>
2446
</a>
2547
</div>
2648
)

site/src/components/component-coverage.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import { componentsByName, get, uniqBy, groupBy } from '../sources'
32
import './component-coverage.css'
43

site/src/components/component-name-matrix.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react'
1+
import { useState } from 'preact/hooks'
22
import { componentOriginalNames, sources, sourcesCount } from '../sources'
33
import './component-name-matrix.css'
44

0 commit comments

Comments
 (0)