Giter VIP home page Giter VIP logo

extract-to-react's Introduction

Extract to React Chrome DevTools Plugin

bitHound Dependencies

Chrome/Chromium extension for easy HTML to React conversion.

Usage

Extract all the HTML & CSS of any portion of any website directly into a ready-to-go React Component!

Installation

Grab it from Google: Extract to React

Usage

Quick start

Inspect an element on the page > "Extract To React" tab > Extract the code to CodePen or JSFiddle.

Advanced usage

It is possible to split a monolithic component up into multiple nested components.

Find the elements you wish to become their own component in the "Elements" tab. Add an attribute called data-component. Set the value of data-component to be the extracted name of the component:

<h1 class="heading" data-component="Heading">Hello, world!</h1>

<nav class="nav" data-component="Nav">
  <ul class="list">
    <li class="list-item" data-component="ListItem">#1</li>
    <li class="list-item" data-component="ListItem">#2</li>
  </ul>
</nav>

Will result in 3 components being extracted: Heading, Nav, and ListItem

Building From Source

git clone https://github.com/jesstelford/extract-to-react.git
cd extract-to-react
npm install
npm run build

Now load as an Unpacked extension via chrome extensions page. Point to the extract-to-react/lib folder for the compiled extension.

Bugs and Features

If you found a bug or have a feature request, please create an issue here on GitHub.

https://github.com/jesstelford/extract-to-react/issues

Attribution

This project is based on excellent open source software:

  • SnappySnippet: Chrome/Chromium extension that allows easy CSS+HTML extraction of specific DOM element. Created snippet can be then exported to CodePen, jsFiddle or JS Bin with one click.
  • html-to-react-components: Extract annotated portions of HTML into React components as separate modules

License

Ugh... The GPL virus has infected this codebase :/

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

extract-to-react's People

Contributors

jesstelford avatar bassjacob avatar

Stargazers

Rihards Mantejs avatar  avatar Adeel Ahmad avatar DemanJ avatar  avatar Dinh Ngoc Hien avatar Ryota Murakami avatar Brian Roach avatar Justyna Ilczuk avatar Fred Carlsen avatar  avatar Rakesh Harishbhai Purohit avatar Jonathan ten Hove avatar Eduardo Santos avatar Weston Brown avatar  avatar Chris Field avatar Alessandro Aresta avatar Muhamad Zulfiqor avatar Johns Beharry avatar Messi Li avatar Adeola Adeleke avatar Philippe Huysmans avatar Atef Ben Ali avatar  avatar  avatar Arun  avatar Diego jimenes avatar Guy Barnard avatar --- avatar  avatar Yamini avatar Sebastiao Almeida avatar Santiago García Nieto avatar Renier Strydom avatar Jikku Jose avatar Shashank avatar Etch avatar Vlad Trukhin avatar  avatar  avatar Jose Ramon Aleman avatar Carl avatar  avatar Davidson Nascimento avatar David Higginbotham avatar Ken Huang avatar libchaos avatar Kirill Volkovich avatar Aarón García Hervás avatar Pankaj Patel avatar Phil Steinke avatar Laidlaw avatar Lisovskii Vladislav avatar Reyhan Sofian avatar Yue Chen avatar Cameron avatar Zadkiel AHARONIAN avatar Amil Vasishtha avatar Will J. Haggard avatar Denis Denisov avatar Roman Liutikov avatar

Watchers

James Cloos avatar Shashank avatar  avatar

extract-to-react's Issues

Dark letters in "Extract to React" tab in Chrome

Hi.

I'm using Dark Theme in Chrome Inspector (Settings in developer tools -> Appareance) and in the "Extract to React" tab i can't read the info because the contrast.

Can you add a white background or change font color for dark themes?

Thank you

Usage info in UI

Such as:

  • How to select what to extract
  • Extracting multiple nested components

Error after extracting

Error:

<TODO: Fill in your error>

Version: v1.0.2

URL: https://flone.reactdemo.hasthemes.com/home-grid-banner

Extracting:

<img src="/assets/img/product/hm6-pro-3.jpg" alt="" data-snapshooter-original-id="" id="IMG_1">
#IMG_1 {
    block-size: 626.422px;
    box-sizing: border-box;
    cursor: pointer;
    height: 626.422px;
    inline-size: 381px;
    perspective-origin: 190.5px 313.203px;
    text-align: left;
    text-size-adjust: 100%;
    transform: matrix(1, 0, 0, 1, 0, 0);
    transform-origin: 190.5px 313.211px;
    vertical-align: middle;
    width: 381px;
    font: 14px / 24px Poppins, sans-serif;
    transition: all 0.5s ease 0s;
}/*#IMG_1*/

#IMG_1:after {
    box-sizing: border-box;
    cursor: pointer;
    text-align: left;
    text-size-adjust: 100%;
    font: 14px / 24px Poppins, sans-serif;
}/*#IMG_1:after*/

#IMG_1:before {
    box-sizing: border-box;
    cursor: pointer;
    text-align: left;
    text-size-adjust: 100%;
    font: 14px / 24px Poppins, sans-serif;
}/*#IMG_1:before*/

Render in extension

Depends on #8.

We can render extracted components directly in the extension's panel UI.

Don't double-extract HTML/CSS

It is extracted once when the extension opened, then again when the button to extract is clicked.

The only action we need to perform when clicking the button is to convert to react.

Some CSS rules missing

Possibly due to ancestor CSS not being applied?

In particular; the font-face is missing.

Looks like it should be applied though, since the algorithm uses getComputedStyle for each element.

Try wrapping the output elements in ancestor html, and also dumping ancestor css to see if it fixes it.

Support psuedo elements when inlining styles

  • Stringify psuedo elements' properties along with the selector, then add as a <style> tag as a child node to the node being converted
  • If node being converted cannot have children, throw a warning about losing psuedo selectors
  • Alternatively; Keep the separately generated stylesheets

Error after extracting

Error:

<TODO: Just try to identify the error>

Version: v1.0.2

URL: https://www.creativeboom.com/resources/20-best-websites-with-mockups-for-your-graphic-design-projects/

Extracting:

<div class="masthead__logo-container masthead__logo-container--eyes-visible" data-snapshooter-original-id="" id="DIV_1">
              <a class="masthead__logo" href="https://www.creativeboom.com/" data-snapshooter-original-id="" id="A_2">
                
              </a>
            <canvas class="masthead__eyes" width="90" height="90" style="width: 70px; height: 70px;" data-snapshooter-original-id="" id="CANVAS_3"></canvas></div>

Inline styles

Give user the option to generate inline styles instead of separate CSS.

  • Remove the to-string conversion
  • Stringify the properties only, and add them as a style attribute to the HTML node

Easier way to indicate nested copmonents

Maybe a UI where the user can select sub-elements from the already selected element?

Also need to be able to name the component (or at least; change the default)

EU data tracking laws?

I seem to remember something having to get the user to opt-in to tracking in some cases, such as the EU. If so, we need to add this option.

How to report issues?

So I have a pen that fails, but I don't have a real way to report it. Maybe the generator could output a hash that can be used to deterministically retry builds to test and retest features?

url + xpath or something?

Error after extracting

Error:

<TODO: Fill in your error>

Version: v1.0.2

URL: https://sofinnovapartners.com/

Extracting:

<header class="container padding index_header__8k7Yb" data-snapshooter-original-id="" id="HEADER_1"><h1 class="hm-3 hd-1 titleLoop_titleLoop__AKd5z" data-snapshooter-original-id="" id="H1_2"><span class="titleLoop_wrapper__AZGCx" data-snapshooter-original-id="" id="SPAN_3"><span class="titleLoop_title__qeRMf" style="transform: translate3d(0px, -7%, 0px);" data-snapshooter-original-id="" id="SPAN_4">Partners for</span></span><span class="titleLoop_wrapper__AZGCx" data-snapshooter-original-id="" id="SPAN_5"><span class="titleLoop_word__lqR1c" style="transform: translate3d(0px, -7%, 0px);" data-snapshooter-original-id="" id="SPAN_6">Healthcare</span></span></h1></header>

Error after extracting

Error:

<TODO: Fill in your error>

Version: v1.0.2

Extracting:

<link rel="stylesheet" type="text/css" property="stylesheet"  data-snapshooter-original-id="" id="LINK_1">

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.