VSCode extension with helpful code snippets for SolidJS.

Overview

Solid Snippets

Solid Snippets

VSCode extension with helpful code snippets for SolidJS.

GET THE EXTENSION

Snippets

Trigger Content Languages

JSX

sinput→ Input two-way binding jsx, tsx
Toggle Code Snippet
<input type="${1:text}" value={${2:value}()} onInput={e => ${3:setValue}(e.currentTarget.value)}/>

Component

scomp→ Base for an empty solidJS component jsx
Toggle Code Snippet
 function ${1:${TM_FILENAME_BASE}}() {

  return (
    <div>${1:${TM_FILENAME_BASE}}</div>
  );
}
  export default ${1:${TM_FILENAME_BASE}};
scomp→ Solid empty function component tsx
Toggle Code Snippet
const ${1:${TM_FILENAME_BASE}}: Component<{$2}> = (props) => {
  $0
  return <div></div>;
};
spcomp→ Solid empty Parent Component tsx
Toggle Code Snippet
const ${1:${TM_FILENAME_BASE}}: ParentComponent<{$2}> = (props) => {
  $0
  return <div>{props.children}</div>;
};
sfcomp→ Solid empty Flow Component tsx
Toggle Code Snippet
const ${1:${TM_FILENAME_BASE}}: FlowComponent<{$2}, ${3:JSX.Element}> = (props) => {
  $0
  return <div>{props.children}</div>;
};
svcomp→ Solid empty Void Component tsx
Toggle Code Snippet
const ${1:${TM_FILENAME_BASE}}: VoidComponent<{$2}> = (props) => {
  $0
  return <div></div>;
};
scompi→ Solid empty function componen. With Importst tsx
Toggle Code Snippet
import { Component } from "solid-js";

const ${1:${TM_FILENAME_BASE}}: Component<{$2}> = (props) => {
  $0
  return <div></div>;
};
spcompi→ Solid empty Parent Component. With Imports tsx
Toggle Code Snippet
import { ParentComponent } from "solid-js";

const ${1:${TM_FILENAME_BASE}}: ParentComponent<{$2}> = (props) => {
  $0
  return <div>{props.children}</div>;
};
sfcompi→ Solid empty Flow Component. With Imports tsx
Toggle Code Snippet
import { FlowComponent, JSX } from "solid-js";

const ${1:${TM_FILENAME_BASE}}: FlowComponent<{$2}, ${3:JSX.Element}> = (props) => {
  $0
  return <div>{props.children}</div>;
};
svcompi→ Solid empty Void Component. With Imports tsx
Toggle Code Snippet
import { VoidComponent } from "solid-js";

const ${1:${TM_FILENAME_BASE}}: VoidComponent<{$2}> = (props) => {
  $0
  return <div></div>;
};
shtmlcomp→ Component extending an HTML Element tsx
Toggle Code Snippet
const ${1:${TM_FILENAME_BASE}}: ParentComponent<
  JSX.IntrinsicElements["${2:div}"] & {
    $0
  }
> = (props) => {
  const [local, attrs] = splitProps(props, []);

  return <${2:div} {...attrs}>{props.children}</${2:div}>;
};
shtmlcompi→ Component extending an HTML Element. With Imports tsx
Toggle Code Snippet
import { ParentComponent, splitProps, JSX } from "solid-js";

const ${1:${TM_FILENAME_BASE}}: ParentComponent<
  JSX.IntrinsicElements["${2:div}"] & {
    $0
  }
> = (props) => {
  const [local, attrs] = splitProps(props, []);

  return <${2:div} {...attrs}>{props.children}</${2:div}>;
};

Context

sctxp→ Solid Context Provider component jsx
Toggle Code Snippet
import { createContext, createSignal, useContext } from "solid-js";

const ${TM_FILENAME_BASE/(.*?)\Context.*/${1:/capitalize}/i}Context = createContext();

export function ${TM_FILENAME_BASE/(.*?)\Context.*/${1:/capitalize}/i}Provider(props) {
  const [${TM_FILENAME_BASE/(.*?)\Context.*/${1:/downcase}/i}, set${TM_FILENAME_BASE/(.*?)\Context.*/${1:/capitalize}/i}] = createSignal(props.${TM_FILENAME_BASE/(.*?)\Context.*/${1:/downcase}/i} || ""),
    store = [${TM_FILENAME_BASE/(.*?)\Context.*/${1:/downcase}/i}, set${TM_FILENAME_BASE/(.*?)\Context.*/${1:/capitalize}/i}];

  return (
    <${TM_FILENAME_BASE/(.*?)\Context.*/${1:/capitalize}/i}Context.Provider value={store}>{props.children}</${TM_FILENAME_BASE/(.*?)\Context.*/${1:/capitalize}/i}Context.Provider>
  );
}

export function use${TM_FILENAME_BASE/(.*?)\Context.*/${1:/capitalize}/i}() {
  return useContext(${TM_FILENAME_BASE/(.*?)\Context.*/${1:/capitalize}/i}Context);
}
sctxp→ Solid Context Provider component tsx
Toggle Code Snippet
import { createContext, useContext, ParentComponent } from "solid-js";
import { createStore } from "solid-js/store";

const defaultState = {};

const ${1:Name}Context = createContext<[state: typeof defaultState, actions: {}]>([
  defaultState,
  {},
]);

export const ${1/(.*)/${1:/capitalize}/}Provider: ParentComponent = (props) => {
  const [state, setState] = createStore(defaultState);

  return (
    <${1/(.*)/${1:/capitalize}/}Context.Provider value={[state, {}]}>
      {props.children}
    </${1/(.*)/${1:/capitalize}/}Context.Provider>
  );
};

export const use${1/(.*)/${1:/capitalize}/} = () => useContext(${1/(.*)/${1:/capitalize}/}Context);

Reactivity

ssig→ Simple createSignal ts, tsx, js, jsx
Toggle Code Snippet
const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = createSignal(${2});
seff→ Simple createEffect ts, tsx, js, jsx
Toggle Code Snippet
createEffect(() => {
  const value = ${1:source}();
  $0
});
seffon→ createEffect with explicit sources ts, tsx, js, jsx
Toggle Code Snippet
createEffect(on(${1: source}, (value, prev) => {
  $0
}));

Contributing

This is an open source project open to everyone. Contributions are welcome. (github)

If you are contributing a snippet, please read about the naming convention below and update only the snippet files. (readme and package.json are updated automatically) You can use a Snippet Generator and Solid Playground to get desired code.

Downloading and installing the repository isn't required to work on snippets. But if you want to test your changes before commiting, we use a pnpm package manager. Once node modules are installed, you can use CLI Scripts to build and install locally built extension. (You might have to reload your vscode window to apply extension update)

Naming Convention

When creating new snippets, please name the files with according suffix representing the target language:

snippets/
  # snippets for "Category Name" category only for .ts and tsx files
  Category-Name.ts.json
  # "Context" snippets only for .jsx
  context.jsx.json
  # "Component" snippets only for .tsx
  component.tsx.json
  # "Component" snippets for both .jsx and .tsx
  component.jsx.tsx.json
  # universal snippets for all languages (js, jsx, ts, tsx)
  effect.json

CLI Scripts

# update snippets table & package.json config
pnpm run update-snippets

# update snippets & build extension package
pnpm run build

# install built extension package
pnpm run install-extension
You might also like...

Show a helpful summary of test results in GitHub Actions CI/CD workflow runs

Test Summary Produce an easy-to-read summary of your project's test data as part of your GitHub Actions CI/CD workflow. This helps you understand at-a

Jan 2, 2023

A community-led experiment to build better docs and helpful content :)

Website This website is built using Docusaurus 2, a modern static website generator. Installation $ npm Local Development $ npm start This command s

Jan 1, 2023

Statistics plugin for RemNote that will give you some helpful numbers, charts and heatmap for your knowledge base.

RemNote statistics plugin Features This plugin will give you the following statistics: Retention rate Number of cards due in future Type of buttons yo

Sep 9, 2022

An interactive Bitcoin tutorial for orange-pilled beginners. Illustrates technical Bitcoin concepts using JavaScript and some Bitcoin Core RPC commands. Programming experience is helpful, but not required.

An interactive Bitcoin tutorial for orange-pilled beginners. Illustrates technical Bitcoin concepts using JavaScript and some Bitcoin Core RPC commands. Programming experience is helpful, but not required.

Try Bitcoin Try Bitcoin is an interactive Bitcoin tutorial inspired by and forked from Try Regex, which is inspired by Try Ruby and Try Haskell. It il

Nov 25, 2022

This is my first website. It has helpful information, games, lots of pages & more.

This is my first website. It has helpful information, games, lots of pages & more.

Mitko.Vtori World This is my first website. It has helpful information, games, lots of pages & more. 🎞 Presentation & Introduction Here's link to my

Dec 30, 2022

An example implementation of the slack-gpt starter which ingests confluence pages to create a helpful slack bot

Slack-GPT (HR bot example implementation) Table of Contents Introduction Prerequisites Creating and installing the application Configuration Starting

Jul 31, 2023

Short JavaScript code snippets for all your development needs

Short JavaScript code snippets for all your development needs

30 seconds of code Short JavaScript code snippets for all your development needs Visit our website to view our snippet collection. Use the Search page

Dec 30, 2022

Short CSS code snippets for all your development needs

Short CSS code snippets for all your development needs

30 seconds of CSS Short CSS code snippets for all your development needs Visit our website to view our snippet collection. Use the Search page to find

Jan 3, 2023

official Alibaba Design system vue components snippets for visual studio code

official Alibaba Design system vue components snippets for visual studio code

Alibaba DLS Snippets for vscode Installation You can either install this extension by searching for Alibaba DLS Snippets in your vscode extensions sto

Sep 25, 2021
Comments
  • option to target only jsx

    option to target only jsx

    this changes the file naming convention to be able to specifically target only jsx or tsx files. To not show jsx snippets in ts/js files. Examples:

    snippets/
      # snippets for "Category Name" category only for .ts and tsx files
      Category-Name.ts.json
      # "Context" snippets only for .jsx
      context.jsx.json
      # "Component" snippets only for .tsx
      component.tsx.json
      # "Component" snippets for both .jsx and .tsx
      component.jsx.tsx.json
      # universal snippets for all languages (js, jsx, ts, tsx)
      effect.json
    
    opened by thetarnav 0
Create beautiful code snippets from your VSCode environment.

Snippets Photo Shoot Create beautiful code snippets from your VSCode environment. How it works Select the code snippet you want to use, then right cli

Renato Pozzi 24 Aug 3, 2022
AWS SAM project that adds the snippets from serverlessland.com/snippets as saved queries in CloudWatch Logs Insights

cw-logs-insights-snippets Serverlessland.com/snippets hosts a growing number of community provided snippets. Many of these are useful CloudWatch Logs

Lars Jacobsson 12 Nov 8, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Code Playground is a online application for testing and showcasing user-created and collaborational HTML, CSS and JavaScript code snippets

Code Playground About Code Playground is a online application for testing and showcasing user-created and collaborational HTML, CSS and JavaScript cod

Arshansh Agarwal 5 Dec 17, 2022
Chrome extension to generate tests for solidjs.

Solid Test Recorder Automated Chrome extension to generate unit/integration tests for solidjs Features Generates UI tests which relay on vitest and ms

Chris Czopp 14 Dec 16, 2022
Chrome Extension Boilerplate with SolidJS + Vite + TypeScript + Manifest V3 + HMR

mv3-solid-chrome-extension-template chrome-extension development template with firebase Support Chrome Extension Manifest V3 SolidJS Typescript HMR Fi

munron 6 Dec 13, 2022
A list of helpful front-end related questions you can use to interview potential candidates, test yourself or completely ignore.

Front-end Developer Interview Questions This repository contains a number of front-end interview questions that can be used when vetting potential can

H5BP 56.1k Jan 4, 2023
Helpful for-loop shorthands in JavaScript

Optimized.JS This package aims to optimize your JavaScript where speed it critical. It has long been known that the JS for-loop is the fastest method

E 1 Jan 21, 2022