Giter Site home page Giter Site logo

prodo-dev / snoopy Goto Github PK

View Code? Open in Web Editor NEW
4.0 5.0 0.0 1.58 MB

Immediate feedback on your React components, as you develop.

Home Page: https://snoopy.dev/

License: MIT License

TypeScript 96.47% HTML 0.28% JavaScript 1.18% CSS 1.95% Shell 0.13%

snoopy's Introduction

Snoopy

Current CircleCI build status. Current npm package version. Join the community on Spectrum

To get started, we recommend installing Snoopy with yarn add --dev @prodo-ai/snoopy or npm install --save-dev @prodo-ai/snoopy. Then you can run:

$ ./node_modules/.bin/snoopy

Alternatively, you can simply run this inside your project's root or source directory, but it might be slower:

$ npx @prodo-ai/snoopy

To interact with the UI, go to localhost:3042/ (or a different port that the CLI will notify you about if this one is busy).

Components

Snoopy will detect most exported components automatically. If you find any that are missing, add // @snoopy above the export line to display/preview/visualize it (and let us know so we can detect it in the future). If you want Snoopy to ignore your component, put the // @snoopy:ignore tag above the export line.

For pure components, you don't need to do anything else. If your component requires props to be passed in, you will need to define examples.

Examples are defined in a separate examples/ directory at the root of your project (where your package.json file is). All source files in this directory are searched, but the convention is to name the file Component.example.jsx). The default export of this file is the component that the examples are for. All other named exports are examples that will be displayed in the UI.

Here is a simple example:

// src/components/Counter.tsx
import React from "react";

export default ({count}) => <p>{count}</p>;
// examples/Counter.example.jsx
import Counter from "../src/components/Counter";

export default Counter;

export const count0 = <Counter count={0} />;
count0.title = "Count is 0";

export const count10 = <Counter count={10} />;
count10.title = "Count is 10";

You can also use Snoopy with TypeScript.

Styles & Themes

If you use the styled-components ThemeProvider, you can also annotate your exported themes with // @snoopy:theme to visualize your components in different themes.

If you want to include any application-level CSS files, just put a /* @snoopy:styles */ comment anywhere inside the file, and they will be applied to all your examples.

What is and isn't supported yet

We support many libraries and use cases, including:

  • styled components with themes
  • react-router
  • hooks

Here's a list of things we don't support yet, most of which are on the roadmap:

  • Redux
  • React Context
  • react-modal
  • chroma.js (due to a chroma issue with parcel)
  • some CSS attributes (for example absolute positioning)

There are a couple of cases where you may want to tweak something in your code to get it fully working in Snoopy.

  • Images should render in Snoopy, but if yours isn't, check how it's imported. If you're using import * as image from ... syntax, try replacing it with import image from ....
  • If you're seeing duplication, make sure you're not unintentionally running Snoopy on your build files.

Examples

Here is a basic example of a Counter project set up for testing with Snoopy. In it, we test the following components: App, Button and Counter.

We also test Snoopy with Snoopy, so you can check our source code directly.

Contact

We'd love your feedback! You can reach us at [email protected].

You can also talk to us directly on Spectrum.

snoopy's People

Contributors

coffee-cup avatar andrejak avatar tdawes avatar samirtalwar avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar The Son of Hope avatar  avatar

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.