GithubHelp home page GithubHelp logo

akcodeworks / react-emmet Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 5.0 829 KB

Gives you the ability to create React hooks with dot notation.

License: Other

JavaScript 34.75% TypeScript 65.25%
emmet extensions react reactjs vscode

react-emmet's People

Contributors

akcodeworks avatar zaaakher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-emmet's Issues

Have cursor end in a logical spot after the snippet is created.

Feature Request: Enhanced Cursor Placement for useState and useEffect Snippets

Description

When generating snippets for useState and useEffect using the Actual React Emmet extension, it would significantly enhance the developer experience if the cursor were automatically positioned within the snippet's editable area. Specifically, for useState, the cursor should be inside the parentheses to quickly set the initial value. For useEffect, it should be inside the code block to immediately write the effect's logic.

Expected Behavior

  • useState: After triggering a useState snippet (e.g., usestate.counter), the cursor should be placed inside the parentheses of useState(), allowing the user to immediately type the initial state value.
  • useEffect: For useEffect snippets, including both synchronous and asynchronous (e.g., useeffect.loadData or useeffect.loadData.async), the cursor should be placed inside the effect's function body, ready for the developer to start typing the logic.

This feature request aims to streamline the coding workflow, reducing the need for additional keystrokes or mouse clicks to navigate to the correct position in the snippet. It aligns with the goal of the Actual React Emmet extension to enhance productivity and ease of use.

PS I know I am opening an issue on my own codebase...i just don't want to forget about this.

Add support for nesting operators

## Description

This is a follow-up for #3. Emmet supports different kinds of Nesting operators. It would be a match made in heaven to have this supported in this vs code extension as well!

Read more

Specification

Child: >

fc.MyComponent>useState.firstName

would produce:

const MyComponent = () => {
  const [firstName, setFirstName] = useState();

  return (
    <></>
  );
}

Sibling: +

fc.MyComponent>useState.firstName+useState.lastName

would produce:

const MyComponent = () => {
  const [firstName, setFirstName] = useState();
  const [lastName, setLastName] = useState();

  return (
    <></>
  );
}

Climb-up: ^

fc.MyComponent>useState.firstName^fc.AnotherComponent

would produce:

const MyComponent = () => {
  const [firstName, setFirstName] = useState();

  return (
    <></>
  );
}

const AnotherComponent = () => {
  return (
    <></>
  );
}

Add support for creating function / class components

## Description

I'd like to have a snippet where I can generate functional/class components.

Specification

Class Component
cc.<ComponentName>[props]

Should generate the following structure:

In JS:

class <ComponentName> extends React.Component {
  render() {
    return null;
  }
}

In TS:

type <ComponentName>Props = {
  [...props]
}

class <ComponentName> extends React.Component<<ComponentName>Props> {
  render() {
    return null;
  }
}
Functional Components
fc.<ComponentName>[props]

Should generate the following structure:

In JS:

const <ComponentName> = ({ [...props] }) => {
  return null;
}

In TS:

type <ComponentName>Props = {
  [...props]
}

const <ComponentName> = ({ [...props] }: <ComponentName>Props) => {
  return null;
}

Configuration options

"actual-react-emmet.componentStyle": 'function' | 'const'

Whether the component should be written using const or function, e.g.

// using `function` as option
function MyComponent() {}

// using `const` as option
const MyComponent = () => {}

"actual-react-emmet.componentPropsStyle": 'interface' | 'type' | 'inline'

Whether it should use an interface or type for the component props, e.g.

// using `interface` as option
interface MyComponentProps { ... }
function MyComponent({...}: MyComponentProps) {}

// using `type` as option
type MyComponentProps = { ... }
const MyComponent = ({...}: MyComponentProps) => {}

// using `inline` as option
function MyComponent({ name }: {name: string}) {}

Examples

// Command
fc.MyComponent[name]

// Result
const <ComponentName> = ({ name }) => {
  return null;
}

// Command
fc.Person[name: string; id: number; address?: { zip: number; street: string }]

// Result
type PersonProps = {
  name: string;
  id: number;
  address?: {
    zip: number;
    street: string;
  }
}

const Person = ({ name: string; id: number; address }): PersonProps) => {
  return null;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.