fix(frontend): use SVG component to theme menu icons (#30)

* use SVG component to theme menu icons

* fixed linting

* externalize github icon and add opencollective

* fixed spelling
This commit is contained in:
Anton Tranelis 2025-03-19 23:14:50 +00:00 committed by GitHub
parent 1d00438440
commit 8863f848d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 68 additions and 20 deletions

28
package-lock.json generated
View File

@ -17,7 +17,7 @@
"react-dom": "^18.2.0",
"react-rnd": "^10.4.1",
"react-router-dom": "^6.23.0",
"utopia-ui": "^3.0.76"
"utopia-ui": "^3.0.78"
},
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
@ -8067,6 +8067,14 @@
"react-dom": ">= 16.3.0"
}
},
"node_modules/react-from-dom": {
"version": "0.7.5",
"resolved": "https://registry.npmjs.org/react-from-dom/-/react-from-dom-0.7.5.tgz",
"integrity": "sha512-CO92PmMKo/23uYPm6OFvh5CtZbMgHs/Xn+o095Lz/TZj9t8DSDhGdSOMLxBxwWI4sr0MF17KUn9yJWc5Q00R/w==",
"peerDependencies": {
"react": "16.8 - 19"
}
},
"node_modules/react-image-crop": {
"version": "10.1.8",
"resolved": "https://registry.npmjs.org/react-image-crop/-/react-image-crop-10.1.8.tgz",
@ -8075,6 +8083,17 @@
"react": ">=16.13.1"
}
},
"node_modules/react-inlinesvg": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/react-inlinesvg/-/react-inlinesvg-4.2.0.tgz",
"integrity": "sha512-V59P6sFU7NACIbvoay9ikYKVFWyIIZFGd7w6YT1m+H7Ues0fOI6B6IftE6NPSYXXv7RHVmrncIyJeYurs3OJcA==",
"dependencies": {
"react-from-dom": "^0.7.5"
},
"peerDependencies": {
"react": "16.8 - 19"
}
},
"node_modules/react-is": {
"version": "16.13.1",
"license": "MIT"
@ -9782,9 +9801,9 @@
"license": "MIT"
},
"node_modules/utopia-ui": {
"version": "3.0.76",
"resolved": "https://registry.npmjs.org/utopia-ui/-/utopia-ui-3.0.76.tgz",
"integrity": "sha512-PnGlF2RXYDSAGdpmzfxMrDWj24nFwpjUeZXYq8n68Vlm0XaQV1DUYKqJ1Cg78+iUS1aSHSazXBeXHs3ArBTK1w==",
"version": "3.0.78",
"resolved": "https://registry.npmjs.org/utopia-ui/-/utopia-ui-3.0.78.tgz",
"integrity": "sha512-RmTW4Gb66FRCZmyvbWfDuncWI5G1NH4+DgS4kJcTnOY7/YkhfMDw2WGT4LgH5oki0pegF112d5HvE8028yvxpQ==",
"dependencies": {
"@heroicons/react": "^2.0.17",
"@tanstack/react-query": "^5.17.8",
@ -9795,6 +9814,7 @@
"radash": "^12.1.0",
"react-colorful": "^5.6.1",
"react-image-crop": "^10.1.8",
"react-inlinesvg": "^4.2.0",
"react-leaflet": "^4.2.1",
"react-leaflet-cluster": "^2.1.0",
"react-markdown": "^9.0.1",

View File

@ -19,7 +19,7 @@
"react-dom": "^18.2.0",
"react-rnd": "^10.4.1",
"react-router-dom": "^6.23.0",
"utopia-ui": "^3.0.76"
"utopia-ui": "^3.0.78"
},
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",

14
public/github.svg Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" fill="currentColor" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Dribbble-Light-Preview" transform="translate(-140.000000, -7559.000000)" fill="currentColor">
<g id="icons" transform="translate(56.000000, 160.000000)">
<path d="M94,7399 C99.523,7399 104,7403.59 104,7409.253 C104,7413.782 101.138,7417.624 97.167,7418.981 C96.66,7419.082 96.48,7418.762 96.48,7418.489 C96.48,7418.151 96.492,7417.047 96.492,7415.675 C96.492,7414.719 96.172,7414.095 95.813,7413.777 C98.04,7413.523 100.38,7412.656 100.38,7408.718 C100.38,7407.598 99.992,7406.684 99.35,7405.966 C99.454,7405.707 99.797,7404.664 99.252,7403.252 C99.252,7403.252 98.414,7402.977 96.505,7404.303 C95.706,7404.076 94.85,7403.962 94,7403.958 C93.15,7403.962 92.295,7404.076 91.497,7404.303 C89.586,7402.977 88.746,7403.252 88.746,7403.252 C88.203,7404.664 88.546,7405.707 88.649,7405.966 C88.01,7406.684 87.619,7407.598 87.619,7408.718 C87.619,7412.646 89.954,7413.526 92.175,7413.785 C91.889,7414.041 91.63,7414.493 91.54,7415.156 C90.97,7415.418 89.522,7415.871 88.63,7414.304 C88.63,7414.304 88.101,7413.319 87.097,7413.247 C87.097,7413.247 86.122,7413.234 87.029,7413.87 C87.029,7413.87 87.684,7414.185 88.139,7415.37 C88.139,7415.37 88.726,7417.2 91.508,7416.58 C91.513,7417.437 91.522,7418.245 91.522,7418.489 C91.522,7418.76 91.338,7419.077 90.839,7418.982 C86.865,7417.627 84,7413.783 84,7409.253 C84,7403.59 88.478,7399 94,7399" id="github-[#142]">
</path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-opencollective" viewBox="0 0 16 16">
<path fill-opacity=".4" d="M12.995 8.195c0 .937-.312 1.912-.78 2.693l1.99 1.99c.976-1.327 1.6-2.966 1.6-4.683 0-1.795-.624-3.434-1.561-4.76l-2.068 2.028c.468.781.78 1.679.78 2.732h.04Z"/>
<path d="M8 13.151a4.995 4.995 0 1 1 0-9.99c1.015 0 1.951.273 2.732.82l1.95-2.03a7.805 7.805 0 1 0 .04 12.449l-1.951-2.03a5.072 5.072 0 0 1-2.732.781H8Z"/>
</svg>

After

Width:  |  Height:  |  Size: 487 B

View File

@ -34,6 +34,7 @@ import {
SelectUser,
AttestationForm,
MarketView,
SVG,
} from 'utopia-ui'
import { Route, Routes } from 'react-router-dom'
@ -94,7 +95,15 @@ function App() {
?.filter((l: any) => l.listed)
.map((l: any) => ({
path: '/' + l.name, // url
icon: <img src={'https://api.utopia-lab.org/assets/' + l.indexIcon}></img>,
icon: (
<SVG
src={'https://api.utopia-lab.org/assets/' + l.indexIcon}
className='w-6 h-6'
preProcessor={(code: string) =>
code.replace(/stroke=".*?"/g, 'stroke="currentColor"')
}
/>
),
name: l.name, // name that appear in Sidebar
})),
)

View File

@ -1,4 +1,5 @@
import { MapIcon } from '@heroicons/react/24/outline'
import { SVG } from 'utopia-ui'
export const routes = [
{
@ -47,20 +48,20 @@ export const getBottomRoutes = (currentUrl: string) => {
]
if (!isEmbedded) {
bottomRoutes.push({
bottomRoutes.push(
{
path: 'https://github.com/utopia-os/utopia-ui', // url
icon: (
<svg viewBox='0 0 24 24' aria-hidden='true' className='tw-h-6 tw-w-6' stroke='currentColor'>
<path
fillRule='evenodd'
clipRule='evenodd'
d='M12 2C6.477 2 2 6.463 2 11.97c0 4.404 2.865 8.14 6.839 9.458.5.092.682-.216.682-.48 0-.236-.008-.864-.013-1.695-2.782.602-3.369-1.337-3.369-1.337-.454-1.151-1.11-1.458-1.11-1.458-.908-.618.069-.606.069-.606 1.003.07 1.531 1.027 1.531 1.027.892 1.524 2.341 1.084 2.91.828.092-.643.35-1.083.636-1.332-2.22-.251-4.555-1.107-4.555-4.927 0-1.088.39-1.979 1.029-2.675-.103-.252-.446-1.266.098-2.638 0 0 .84-.268 2.75 1.022A9.607 9.607 0 0 1 12 6.82c.85.004 1.705.114 2.504.336 1.909-1.29 2.747-1.022 2.747-1.022.546 1.372.202 2.386.1 2.638.64.696 1.028 1.587 1.028 2.675 0 3.83-2.339 4.673-4.566 4.92.359.307.678.915.678 1.846 0 1.332-.012 2.407-.012 2.734 0 .267.18.577.688.48 3.97-1.32 6.833-5.054 6.833-9.458C22 6.463 17.522 2 12 2Z'
></path>
</svg>
),
name: 'Github', // name that appear in Sidebar
icon: <SVG src='github.svg' className='w-6 h-6' />,
name: 'GitHub', // name that appear in Sidebar
blank: true,
})
},
{
path: 'https://opencollective.com/utopia-project', // url
icon: <SVG src='opencollective.svg' className='w-6 h-6' />,
name: 'Open Collective', // name that appear in Sidebar
blank: true,
},
)
}
return bottomRoutes