kopia lustrzana https://github.com/badgen/badgen.net
refactor: jsx => tsx (next.js)
rodzic
08af45e2fe
commit
ebbb97923e
|
@ -5,7 +5,7 @@ const DEFAULT_SIZE = 42
|
|||
interface BuilderBarProps {
|
||||
placeholder: string;
|
||||
badgeURL: string;
|
||||
host: string;
|
||||
host?: string;
|
||||
onChange: (value: string) => void;
|
||||
onFocus: () => void;
|
||||
onBlur: () => void;
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
import badgeList from '../static/.meta/badges.json'
|
||||
|
||||
const examples = [...badgeList.live, ...badgeList.static].reduce((accu, curr) => {
|
||||
return accu.concat(Object.entries(curr.examples))
|
||||
}, [])
|
||||
return (accu as any).concat(Object.entries(curr.examples))
|
||||
}, [] as [string, string][])
|
||||
|
||||
export default function BuilderHelper ({ badgeURL, onSelect }) {
|
||||
interface BuilderHelperProps {
|
||||
host?: string;
|
||||
badgeURL: string;
|
||||
onSelect: (value: string) => void;
|
||||
}
|
||||
|
||||
export default function BuilderHelper ({ badgeURL, onSelect }: BuilderHelperProps) {
|
||||
if (badgeURL.length < 2) {
|
||||
return <div className='helper' />
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import icons from 'badgen-icons'
|
||||
|
||||
export default function HomeIntro ({ isFlat }) {
|
||||
export default function HomeIntro ({ isFlat = false }) {
|
||||
return (
|
||||
<div>
|
||||
<pre>{explainCode(isFlat)}</pre>
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
import React from 'react'
|
||||
import App, { Container } from 'next/app'
|
||||
import App from 'next/app'
|
||||
import Head from 'next/head'
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
dataLayer: Array<any>;
|
||||
}
|
||||
}
|
||||
|
||||
export default class MyApp extends App {
|
||||
componentDidMount () {
|
||||
window.dataLayer = window.dataLayer || []
|
||||
function gtag () { window.dataLayer.push(arguments) }
|
||||
function gtag (...args) { window.dataLayer.push(args) }
|
||||
gtag('js', new Date())
|
||||
gtag('config', 'UA-4646421-14')
|
||||
}
|
||||
|
@ -14,7 +20,7 @@ export default class MyApp extends App {
|
|||
const { Component, pageProps } = this.props
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<>
|
||||
<Head>
|
||||
<title>Badgen - Fast badge generating service</title>
|
||||
<link rel='icon' type='image/png' href='/static/favicon.png' />
|
||||
|
@ -33,7 +39,7 @@ export default class MyApp extends App {
|
|||
a { text-decoration: none }
|
||||
`}
|
||||
</style>
|
||||
</Container>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ export default class BuilderPage extends React.Component {
|
|||
handleSelect = exampleURL => this.setState({ badgeURL: exampleURL })
|
||||
|
||||
componentDidMount () {
|
||||
const forceHost = new URL(window.location).searchParams.get('host')
|
||||
const forceHost = new URL(window.location.href).searchParams.get('host')
|
||||
this.setState({
|
||||
host: (forceHost || window.location.origin) + '/',
|
||||
badgeURL: window.location.hash.replace(/^#/, ''),
|
|
@ -12,7 +12,7 @@ const Index = () => {
|
|||
const badges = examples[tab]
|
||||
|
||||
useEffect(() => {
|
||||
const forceHost = new URL(window.location).searchParams.get('host')
|
||||
const forceHost = new URL(window.location.href).searchParams.get('host')
|
||||
setHost((forceHost || window.location.origin) + '/')
|
||||
})
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"jsx": "preserve",
|
||||
"target": "esnext",
|
||||
"target": "es2017",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
|
@ -24,7 +24,9 @@
|
|||
"include": [
|
||||
"index.ts",
|
||||
"endpoints",
|
||||
"types"
|
||||
"components",
|
||||
"pages",
|
||||
"static"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
|
|
Ładowanie…
Reference in New Issue