Giter Club home page Giter Club logo

slate-react-starter's Introduction

This is a react starter template for slate, it is based on Shopify's starter template

Thanks to @dan-gamble for helping with the slate configurations

This project is based off shopify/skeleton-theme, checkout Slate for more information.

** do notice you should follow the slate guildlines for getting started, this is just a starter template, not a full project.

Get started

Install the theme with npx:

npx create slate-theme my-new-theme liron-navon/slate-react-starter

How to work with slate for Shopify:

  • rename .env-sample to .env and setup your development store config.

  • run: npm start

  • slate will open your localhost, just ignore that, and go to your development store.

  • In the development store you should have your theme loaded

  • Changes will hot reload in the dev store.

Using react in shopify

  • Do notice that this is not meant to be an SPA, for that you can use storefront, react here is purely to replace JQuery for logic operations and animations.

How to pass store data to my react components?

Look at this snippet, this div element is going to be where our react component will be rendered, You can pass prop-<propName> to it and fill in the data, in this example we will have a prop named shopname and it will receive the name of the shop

<div 
     prop-shopname='{{shop.name}}' 
     id="react-theme-component"> 
     a react component is rendered here (this will show if js is disabled)
</div>

How to mount my components

please use the helper function I made for it, it allows you to pass parameters from the liquid template to react:

import ThemeComponent from '../../react/layout/theme.jsx';
import {mountReact} from '../../react/mountReact';

// the component is rendered to replace the selected html element
mountReact(ThemeComponent, '#react-theme-component');

changes from the shopify barebone theme

Do notice I tried to change as little as possible to allow this to be updated when shopify will change the starter template, The only files changed are:

  1. scripts/layout/theme.js : added a function to load the react component
  2. layout/theme.liquid : added an anchor for react to load on to
  3. created /react directory which contain all of the react logic.

slate-react-starter's People

Contributors

dependabot[bot] avatar liron-navon 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

slate-react-starter's Issues

React Components not mounting?

Loaded straight from the install, no modifications, and the example theme-react-wrapper element doesn't compile into ExampleComponent. Is the intended function for the selector element to be replaced with the React component?

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.