Skip to content

Commit

Permalink
Fixed ts and import issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dannelundqvist committed Oct 11, 2023
1 parent 782812d commit 6a02bde
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 43 deletions.
1 change: 0 additions & 1 deletion src/showroom/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react'
import { ButtonExample } from './components/button'

export function App() {
Expand Down
6 changes: 2 additions & 4 deletions src/showroom/code.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import * as React from 'react'
import { PropsWithChildren } from "react";
import SyntaxHighlighter from 'react-syntax-highlighter'

export function Code({ children }: PropsWithChildren) {
export function Code({ code }: { code: string | string[] }) {
return <div className="whitespace-pre-line font-mono text-xs text-indigo-600 dark:text-indigo-200">
<SyntaxHighlighter
showLineNumbers={true}
language="jsx"
>
{children}
{code}
</SyntaxHighlighter>

</div>
Expand Down
32 changes: 10 additions & 22 deletions src/showroom/components/button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from 'react'

import { Mail } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Header } from '../header'
Expand All @@ -12,50 +10,40 @@ export function ButtonExample() {
<div>
<Button>Button</Button>
</div>
<Code>
{`<Button>
<Code code={`<Button>
Secondary
</Button>`}
</Code>
</Button>`} />

<div>
<Button variant="secondary">Secondary</Button>
</div>
<Code>
{`<Button variant="secondary">
<Code code={`<Button variant="secondary">
Secondary
</Button>`}
</Code>
</Button>`} />

<div>
<Button variant="destructive">Destructive</Button>
</div>
<Code>
{`<Button variant="descructive">
<Code code={`<Button variant="descructive">
Descructive
</Button>`}
</Code>
</Button>`} />

<div>
<Button variant="outline">Outline</Button>
</div>
<Code>
{`<Button variant="outline">
<Code code={`<Button variant="outline">
Outline
</Button>`}
</Code>
</Button>`} />

<div>
<Button>
<Mail className="mr-2 h-4 w-4" /> Login&nbsp;with&nbsp;email&nbsp;icon
</Button>
</div>
<Code>
{`import { Mail } from 'lucide-react'
<Code code={`import { Mail } from 'lucide-react'
<Button>
<Mail className="mr-2 h-4 w-4" />
Login with email icon
</Button>`}
</Code>
</Button>`} />
</>
}
5 changes: 2 additions & 3 deletions src/showroom/header.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as React from 'react'
import { PropsWithChildren } from "react";

export function Header({children}: PropsWithChildren) {
export function Header({ children }: PropsWithChildren) {
return <div className="col-span-2 border-b">
<h2 className="font-bold text-xl not-prose">{children}</h2>
</div>
</div>
}
24 changes: 15 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,40 @@
"compilerOptions": {
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"lib": [
"ES2022",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "Node",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"baseUrl": ".",
"paths": {
"@/components/*": ["src/components/*"],
"@/lib/*": ["src/lib/*"]
"@/components/*": [
"src/components/*"
],
"@/lib/*": [
"src/lib/*"
]
},

/* Output */
"outDir": "dist",
"declaration": true,
"declarationMap": true
},
"include": ["./src/**/*"],
"exclude": ["./src/showroom"]
}
"include": [
"./src/**/*"
]
}
6 changes: 2 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import dts from 'vite-plugin-dts';

export default defineConfig({
plugins: [
react({
'jsxRuntime': 'classic',
}),
react(),
dts({
include: ['./src/**/*'],
}),
Expand All @@ -28,7 +26,7 @@ export default defineConfig({
rollupOptions: {
external: [...Object.keys(peerDependencies), ...Object.keys(dependencies)], output: { preserveModules: true, exports: 'named' }
},

target: 'esnext',
sourcemap: true
}
Expand Down

0 comments on commit 6a02bde

Please sign in to comment.