Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sabersalv/template-userscript

UserScript Template with Typescript, Esbuild, React/Preact/JSX, fetch polyfill, SVG loader, Prettier, Eslint
https://github.com/sabersalv/template-userscript

Last synced: 3 months ago
JSON representation

UserScript Template with Typescript, Esbuild, React/Preact/JSX, fetch polyfill, SVG loader, Prettier, Eslint

Awesome Lists containing this project

README

        

# Hello

> Click "Use this template" above

## Getting Started

Typescript, Esbuild, Preact/JSX, fetch polyfill, SVG loader, Emotion, Prettier, Eslint

```jsx
// Build UI
import { render } from 'react-dom'
import { useState } from 'react'
function Button() {
const [conuter, setCounter] = useState(0)
return setCounter(counter + 1)}>Click me! {counter}
}
render(, document.body) // appendChild

// insertBefore
const target = document.querySelector('#target')
const div = document.createElement('div')
render(, div)
target.parentNode.insertBefore(div.firstChild, target)

// Style
// You can replace Emotion with any CSS-in-JS, CSS Modules or Plain CSS file
import { css } from '@emotion/css'
const buttonStyle = css`
color: blue;
&:hover {
color: red;
}
`
Hello

// Import svg file
import HomeIcon from './home.svg'
render(, document.body)

// Fetch polyfill
const res = await fetch(url)
const body = await res.json()
```

## Development

```shell
npm install -g npm-check-updates && ncu -u # Upgrade deps
yarn # Install deps
yarn start # Start deployment, watch mode
yarn build # build for production
```