Skip to content

Commit

Permalink
typescript snippet update
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoLuglio committed Oct 13, 2024
1 parent 6119fd0 commit 1fdb5e5
Showing 1 changed file with 0 additions and 76 deletions.
76 changes: 0 additions & 76 deletions src/lib/utils/codeSnippets.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,5 @@
export const codeSnippets = {
'typescript.tsx':
"import React, { useState, useEffect } from 'react';\n" +
'\n' +
'// Interface and Type\n' +
'interface User {\n' +
' id: number;\n' +
' name: string;\n' +
'}\n' +
'\n' +
'type UserProps = {\n' +
' user: User;\n' +
'};\n' +
'\n' +
'// Decorator\n' +
'function logged(target: any, key: string, descriptor: PropertyDescriptor) {\n' +
' const original = descriptor.value;\n' +
' descriptor.value = function (...args: any[]) {\n' +
' console.log(`Calling ${key} with`, args);\n' +
' return original.apply(this, args);\n' +
' };\n' +
' return descriptor;\n' +
'}\n' +
'\n' +
'// Class with generics\n' +
'class DataFetcher<T> {\n' +
' private url: string;\n' +
'\n' +
' constructor(url: string) {\n' +
' this.url = url;\n' +
' }\n' +
'\n' +
' @logged\n' +
' async fetchData(): Promise<T> {\n' +
' const response = await fetch(this.url);\n' +
' return response.json();\n' +
' }\n' +
'}\n' +
'\n' +
'// React component\n' +
'const UserProfile: React.FC<UserProps> = ({ user }) => {\n' +
' const [loading, setLoading] = useState<boolean>(true);\n' +
'\n' +
' useEffect(() => {\n' +
' // Async function in useEffect\n' +
' const loadUser = async () => {\n' +
' try {\n' +
' const fetcher = new DataFetcher<User>(`/api/users/${user.id}`);\n' +
' await fetcher.fetchData();\n' +
' setLoading(false);\n' +
' } catch (error) {\n' +
' console.error("Failed to load user:", error);\n' +
' }\n' +
' };\n' +
'\n' +
' loadUser();\n' +
' }, [user.id]);\n' +
'\n' +
' if (loading) return <div>Loading...</div>;\n' +
'\n' +
' return (\n' +
' <div>\n' +
" <h1>{user.name}'s Profile</h1>\n" +
' <p>User ID: {user.id}</p>\n' +
' </div>\n' +
' );\n' +
'};\n' +
'\n' +
'export default UserProfile;\n' +
'import type {\n' +
' UIColors,\n' +
' SyntaxColors,\n' +
' AnsiColors,\n' +
' VSCodeTheme,\n' +
'} from "@/lib/types/colors"\n' +
'\n' +
'import Color from "color"\n' +
'\n' +
'export function generateSemanticThemeJSON(\n' +
' name: string = "Generated Color Theme",\n' +
' colors: UIColors,\n' +
Expand Down

0 comments on commit 1fdb5e5

Please sign in to comment.