mirror of https://github.com/MaxLeiter/Drift
				
				
				
			dep improvements, style fixes, next/link codemod
							parent
							
								
									0405f821c4
								
							
						
					
					
						commit
						0a5a2adb26
					
				@ -0,0 +1,4 @@
 | 
			
		||||
{
 | 
			
		||||
  "typescript.tsdk": "./node_modules/typescript/lib",
 | 
			
		||||
  "typescript.enablePromptUseWorkspaceTsdk": true
 | 
			
		||||
}
 | 
			
		||||
@ -1,17 +0,0 @@
 | 
			
		||||
import type { LinkProps } from "@geist-ui/core"
 | 
			
		||||
import { Link as GeistLink } from "@geist-ui/core"
 | 
			
		||||
import { useRouter } from "next/router"
 | 
			
		||||
 | 
			
		||||
const Link = (props: LinkProps) => {
 | 
			
		||||
	const { basePath } = useRouter()
 | 
			
		||||
	const propHrefWithoutLeadingSlash =
 | 
			
		||||
		props.href && props.href.startsWith("/")
 | 
			
		||||
			? props.href.substring(1)
 | 
			
		||||
			: props.href
 | 
			
		||||
	const href = basePath
 | 
			
		||||
		? `${basePath}/${propHrefWithoutLeadingSlash}`
 | 
			
		||||
		: props.href
 | 
			
		||||
	return <GeistLink {...props} href={href} />
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default Link
 | 
			
		||||
@ -0,0 +1,26 @@
 | 
			
		||||
import { useRouter } from "next/router"
 | 
			
		||||
import NextLink from "next/link"
 | 
			
		||||
import styles from "./link.module.css"
 | 
			
		||||
 | 
			
		||||
type LinkProps = {
 | 
			
		||||
	href: string,
 | 
			
		||||
	colored?: boolean,
 | 
			
		||||
	children: React.ReactNode
 | 
			
		||||
} & React.ComponentProps<typeof NextLink>
 | 
			
		||||
 | 
			
		||||
const Link = ({ href, colored, children, ...props }: LinkProps) => {
 | 
			
		||||
	const { basePath } = useRouter()
 | 
			
		||||
	const propHrefWithoutLeadingSlash =
 | 
			
		||||
		href && href.startsWith("/") ? href.substring(1) : href
 | 
			
		||||
 | 
			
		||||
	const url = basePath ? `${basePath}/${propHrefWithoutLeadingSlash}` : href
 | 
			
		||||
 | 
			
		||||
	const className = colored ? `${styles.link} ${styles.color}` : styles.link
 | 
			
		||||
	return (
 | 
			
		||||
		<NextLink {...props} href={url} className={className}>
 | 
			
		||||
			{children}
 | 
			
		||||
		</NextLink>
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default Link
 | 
			
		||||
@ -0,0 +1,12 @@
 | 
			
		||||
.link {
 | 
			
		||||
    text-decoration: none;
 | 
			
		||||
    color: var(--fg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.color {
 | 
			
		||||
    color: var(--link);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.color:hover {
 | 
			
		||||
    text-decoration: underline;
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,17 @@
 | 
			
		||||
import styles from "./note.module.css"
 | 
			
		||||
 | 
			
		||||
const Note = ({
 | 
			
		||||
	type = "info",
 | 
			
		||||
	children,
 | 
			
		||||
	...props
 | 
			
		||||
}: {
 | 
			
		||||
	type: "info" | "warning" | "error"
 | 
			
		||||
	children: React.ReactNode
 | 
			
		||||
} & React.ComponentProps<"div">) => (
 | 
			
		||||
	<div className={`${styles.note} ${styles[type]}`} {...props}>
 | 
			
		||||
		<strong className={styles.type}>{type}:</strong>
 | 
			
		||||
		{children}
 | 
			
		||||
	</div>
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
export default Note
 | 
			
		||||
@ -0,0 +1,27 @@
 | 
			
		||||
.note {
 | 
			
		||||
	font-size: 0.8em;
 | 
			
		||||
	color: var(--fg);
 | 
			
		||||
	margin: 0;
 | 
			
		||||
	padding: var(--gap);
 | 
			
		||||
	margin-top: 0.5em;
 | 
			
		||||
	margin-bottom: 0.5em;
 | 
			
		||||
	border-radius: var(--radius);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.info {
 | 
			
		||||
	background: var(--gray);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.warning {
 | 
			
		||||
	background: #f33;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.error {
 | 
			
		||||
	background: red;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.type {
 | 
			
		||||
	color: var(--fg);
 | 
			
		||||
	margin-right: 0.5em;
 | 
			
		||||
	text-transform: capitalize;
 | 
			
		||||
}
 | 
			
		||||
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								
					Loading…
					
					
				
		Reference in New Issue