-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ba98cb
commit 75bd816
Showing
70 changed files
with
11,272 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react-hooks/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# React + TypeScript + Vite | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
||
## Expanding the ESLint configuration | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
|
||
```js | ||
export default { | ||
// other rules... | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: ['./tsconfig.json', './tsconfig.node.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
} | ||
``` | ||
|
||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` | ||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
# Claude Artifact Runner | ||
|
||
## Table of Contents | ||
|
||
- [Summary](#summary) | ||
- [Project scope](#project-scope) | ||
- [Overview](#overview) | ||
- [What's included?](#whats-included) | ||
- [Prerequisites](#prerequisites) | ||
- [Getting started](#getting-started) | ||
- [Project structure](#project-structure) | ||
- [Usage](#usage) | ||
- [Customization](#customization) | ||
- [Building for production](#building-for-production) | ||
- [Troubleshooting](#troubleshooting) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
- [Acknowledgements](#acknowledgements) | ||
|
||
## Summary | ||
|
||
If you're searching for a way to take the small web applications Claude generates with its Artifacts feature, and run them outside of its website, you've come to the right place. | ||
|
||
This project provides a standalone environment that mimics the Artifacts runtime, enabling you to run, test, and further develop the code generated by Claude independently from its website. | ||
|
||
## Project scope | ||
|
||
Note that this project is meant only for running Artifacts that are interactive web apps, usually made in React, and for which Claude writes Javascript or Typescript code. | ||
|
||
**Mermaid diagrams, SVGs and other document-type Artifacts are out of the scope of the project.** | ||
|
||
Why? Well, because those types of simple static content are easily viewable by other means. | ||
For example, to view Mermaid diagrams, you can use an online viewer/editor, like [mermaidflow.app](https://www.mermaidflow.app). | ||
|
||
## Overview | ||
|
||
If you've created a web application or component using Claude's Artifacts feature and want to: | ||
|
||
1. run the component locally for testing and development, | ||
2. use the component as a starting point for a new project or integrate it into a larger project, or | ||
3. deploy the component as a standalone application, | ||
|
||
you'll be disappointed to find out that, if you download the artifact code via the download button, you'll only receive a single file containing the main logic of the app, not the full project with all necessary files to run it on your computer. | ||
|
||
If you're unfamiliar with the technologies used on the project, you'll have a hard time assembling and configuring all the required libraries and tooling required to make a running standalone app. | ||
|
||
Even if you're an experienced developer, you may just want to save time and effort and get the Artifact running as easily and as soon as possible. | ||
|
||
This scaffold/boilerplate provides the perfect environment to address these needs. It includes all the necessary dependencies and configurations to seamlessly transition your Claude-generated artifact into a fully functional web application in no time. | ||
|
||
## What's included? | ||
|
||
1. **React 18** for building user interfaces. | ||
2. **TypeScript** to support artifacts written in type-safe Javascript. | ||
3. **Vite** for fast development and building. | ||
4. **Shadcn UI** for pre-built, customizable components. | ||
5. **Tailwind CSS** for compact and expressive embedded styling. | ||
6. **Recharts** for creating dynamic, customizable charts and data visualizations. | ||
7. **Lucide React** for a comprehensive library of open-source icons designed for React applications. | ||
|
||
## Prerequisites | ||
|
||
Before you begin, ensure you have the following installed: | ||
- Node.js (version 14 or later) | ||
- npm (usually comes with Node.js) | ||
|
||
## Getting started | ||
|
||
1. Clone the repository: | ||
``` | ||
git clone https://github.com/claudio-silva/claude-artifact-runner.git | ||
cd claude-artifact-runner | ||
``` | ||
|
||
2. Install dependencies: | ||
``` | ||
npm install | ||
``` | ||
|
||
3. Start the development server: | ||
``` | ||
npm run dev | ||
``` | ||
|
||
4. Open your browser and visit `http://localhost:5173` to see the default app running. | ||
|
||
## Project structure | ||
|
||
- `src/`: Contains the source code for the application | ||
- `App.tsx`: Main application component | ||
- `artifact-component.tsx`: Place to paste the component generated by Claude | ||
- `components/`: Reusable UI components | ||
- `lib/`: Utility functions and helpers | ||
- `public/`: Static assets | ||
- `index.html`: Entry HTML file | ||
- `vite.config.ts`: Vite configuration | ||
- `tsconfig.json`: TypeScript configuration | ||
- `tailwind.config.js`: Tailwind CSS configuration | ||
- `package.json`: all the required packages are registered here. | ||
|
||
## Usage | ||
|
||
1. Generate a React component using Claude on the Artifacts environment. | ||
2. Copy the generated component code. | ||
3. Paste the code into `src/artifact-component.tsx`. | ||
4. The page should refresh automatically to display the new component. | ||
|
||
## Customization | ||
|
||
- Use `src/index.css` to add additional CSS rules. | ||
- Place static assets (such as images) in the `public` folder. | ||
- Modify `tailwind.config.js` to customize the Tailwind CSS theme. | ||
- Update `App.tsx` to change the overall layout or add new features. | ||
- Add or modify components in the `src/components/` directory. | ||
> **Note:** Shadcn components installed via `npx` are automatically placed in `src/components`. All components come pre-installed by default, but if you remove some and later want to reinstall any, you may simply run `npx shadcn-ui@latest add your-component`. | ||
### Removing unneeded components / libraries | ||
|
||
The **Recharts** library and ALL **Shadcn** components come pre-installed, so that all code that Claude may generate will run *out-of-the-box*. | ||
|
||
If you just want to run the artifact locally, you may leave things as they are, but if you to deploy the application or use it as a base for a larger project, you may want to optimize your application's bundle size. | ||
|
||
To do that, you may remove the pre-installed components or libraries that are not required by your application. | ||
|
||
#### Unneeded Shadcn components: | ||
Just delete the component's folder from `src/components`. | ||
|
||
#### Unneeded packages (ex: Recharts): | ||
Use `npm remove` to uninstall them. | ||
|
||
## Building for production | ||
|
||
To create a production build, run: | ||
|
||
``` | ||
npm run build | ||
``` | ||
|
||
This will generate optimized files in the `dist/` directory, ready for deployment. | ||
|
||
## Troubleshooting | ||
|
||
If you encounter any issues, try the following: | ||
|
||
1. Clear your browser cache and restart the development server. | ||
2. Delete the `node_modules` folder and run `npm install` again. | ||
3. Make sure your Node.js version is compatible with the project requirements. | ||
4. Check for any error messages in the console and search for solutions online. | ||
|
||
If problems persist, please open an issue on this project's GitHub repository. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please feel free to submit a Pull Request. | ||
|
||
## License | ||
|
||
This project is open source and available under the [MIT License](LICENSE). | ||
|
||
## Acknowledgements | ||
|
||
I found [Claude-React-Jumpstart](https://github.com/Bklieger/Claude-React-Jumpstart) when looking for a way to run Artifacts outside of [claude.ai](https://claude.ai). | ||
|
||
However, it did not fully meet my needs, so I decided to make my own project, as I wanted something that: | ||
* was completely pre-configured (no need to install or configure additional stuff), | ||
* was ready to go with a single `npm install`, and | ||
* included all components and libraries needed to fully replicate the Artifacts environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/index.css", | ||
"baseColor": "slate", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "src/components", | ||
"utils": "src/lib/utils" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Artifact Viewer</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.