Skip to content

Commit

Permalink
Add component-gallery-react sample (microsoft#146)
Browse files Browse the repository at this point in the history
Description of changes

Add `component-gallery-react` sample, which demonstrates the usage of every React component available in the toolkit.
  • Loading branch information
hawkticehurst authored May 11, 2023
1 parent dc61716 commit edaead8
Show file tree
Hide file tree
Showing 46 changed files with 8,779 additions and 11 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ Don't see a demonstration for your desired use case, VS Code API, etc.? Open an

A set of sample extensions that demonstrate how to use various web frameworks to render the webview UI.

| Sample extension | Description |
| --------------------------------------------------------------| --------------------------------------------------------------------- |
| [hello-world-angular](./frameworks/hello-world-angular) | A basic hello-world starter extension using Angular. |
| [hello-world-react-cra](./frameworks/hello-world-react-cra) | A basic hello-world starter extension using React + Create React App. |
| [hello-world-react-vite](./frameworks/hello-world-react-vite) | A basic hello-world starter extension using React + Vite. |
| [hello-world-solidjs](./frameworks/hello-world-solidjs) | A basic hello-world starter extension using SolidJS. |
| [hello-world-svelte](./frameworks/hello-world-svelte) | A basic hello-world starter extension using Svelte. |
| [hello-world-vue](./frameworks/hello-world-vue) | A basic hello-world starter extension using Vue. |
| Sample extension | Description |
| ---------------------------------------------------------------- | --------------------------------------------------------------------- |
| [component-gallery-react](./frameworks/component-gallery-react) | Demonstrates every React component in the Webview UI Toolkit. |
| [hello-world-angular](./frameworks/hello-world-angular) | A basic hello-world starter extension using Angular. |
| [hello-world-react-cra](./frameworks/hello-world-react-cra) | A basic hello-world starter extension using React + Create React App. |
| [hello-world-react-vite](./frameworks/hello-world-react-vite) | A basic hello-world starter extension using React + Vite. |
| [hello-world-solidjs](./frameworks/hello-world-solidjs) | A basic hello-world starter extension using SolidJS. |
| [hello-world-svelte](./frameworks/hello-world-svelte) | A basic hello-world starter extension using Svelte. |
| [hello-world-vue](./frameworks/hello-world-vue) | A basic hello-world starter extension using Vue. |

## Contributing

Expand Down
6 changes: 3 additions & 3 deletions default/component-gallery/src/panels/demos/panels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ export const panelsDemo = /*html*/ `
<vscode-panels aria-label="With Badge">
<vscode-panel-tab id="tab-1">
PROBLEMS
<vscode-badge appearance="secondary">1</vscode-badge>
<vscode-badge>1</vscode-badge>
</vscode-panel-tab>
<vscode-panel-tab id="tab-2">
OUTPUT
<vscode-badge appearance="secondary">1</vscode-badge>
<vscode-badge>1</vscode-badge>
</vscode-panel-tab>
<vscode-panel-tab id="tab-3">
DEBUG CONSOLE
</vscode-panel-tab>
<vscode-panel-tab id="tab-4">
TERMINAL
<vscode-badge appearance="secondary">1</vscode-badge>
<vscode-badge>1</vscode-badge>
</vscode-panel-tab>
<vscode-panel-view id="view-1"> Problems Content </vscode-panel-view>
<vscode-panel-view id="view-2"> Output Content </vscode-panel-view>
Expand Down
18 changes: 18 additions & 0 deletions frameworks/component-gallery-react/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": ["webview-ui/**"]
}
22 changes: 22 additions & 0 deletions frameworks/component-gallery-react/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build
/dist

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
13 changes: 13 additions & 0 deletions frameworks/component-gallery-react/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"quoteProps": "consistent",
"jsxSingleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"arrowParens": "always"
}
7 changes: 7 additions & 0 deletions frameworks/component-gallery-react/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
34 changes: 34 additions & 0 deletions frameworks/component-gallery-react/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
11 changes: 11 additions & 0 deletions frameworks/component-gallery-react/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
20 changes: 20 additions & 0 deletions frameworks/component-gallery-react/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
32 changes: 32 additions & 0 deletions frameworks/component-gallery-react/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file contains all the files/directories that should
# be ignored (i.e. not included) in the final packaged extension.

# Ignore extension configs
.vscode/**

# Ignore test files
.vscode-test/**
out/test/**

# Ignore source code
src/**

# Ignore all webview-ui files except the build directory
webview-ui/src/**
webview-ui/public/**
webview-ui/scripts/**
webview-ui/index.html
webview-ui/README.md
webview-ui/package.json
webview-ui/package-lock.json
webview-ui/node_modules/**

# Ignore Misc
.yarnrc
vsc-extension-quickstart.md
**/.gitignore
**/tsconfig.json
**/vite.config.ts
**/.eslintrc.json
**/*.map
**/*.ts
29 changes: 29 additions & 0 deletions frameworks/component-gallery-react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Component Gallery (React)

This sample extension demonstrates every React component in the Webview UI Toolkit for Visual Studio Code.

![A screenshot of the sample extension.](./assets/component-gallery-react.png)

## Run The Sample

```bash
# Copy sample extension locally
npx degit microsoft/vscode-webview-ui-toolkit-samples/frameworks/component-gallery-react component-gallery-react

# Navigate into sample directory
cd component-gallery-react

# Install dependencies for both the extension and webview UI source code
npm run install:all

# Build webview UI source code
npm run build:webview

# Open sample in VS Code
code .
```

Once the sample is open inside VS Code you can run the extension by doing the following:

1. Press `F5` to open a new Extension Development Host window
2. Inside the host window, open the command palette (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and type `Component Gallery (React): Show`
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit edaead8

Please sign in to comment.