GithubHelp home page GithubHelp logo

matthiasadriaens / polaris-react Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shopify/polaris

1.0 0.0 0.0 40.55 MB

Shopify’s admin product component library

Home Page: https://polaris.shopify.com

License: Other

JavaScript 2.28% TypeScript 85.76% Ruby 0.03% SCSS 11.92% HTML 0.01%

polaris-react's Introduction

npm version CI storybook PRs Welcome

Polaris React is a component library designed to help developers create the best experience for merchants who use Shopify. Visit the Polaris style guide to learn more.

App development

For more information about creating apps for the Shopify App Store, take a look at the app development documentation.

Using the React components

While we do offer a CSS-only version, we strongly recommend using the React versions of our components. It’s the version that we use at Shopify. It allows for rich, complex components like Tabs and Popovers, and will not have as many breaking changes as the CSS-only version.

Installation

Run the following command using npm:

npm install @shopify/polaris --save

If you prefer Yarn, use the following command instead:

yarn add @shopify/polaris

Usage

  1. Import the CSS directly into your project if your asset packager supports it:
import '@shopify/polaris/build/esm/styles.css';

Otherwise include the CSS in your HTML. We suggest copying the styles file into your own project, but you may also use it directly:

<link
  rel="stylesheet"
  href="https://unpkg.com/@shopify/[email protected]/build/esm/styles.css"
/>
  1. Include the translations and any of the provided components in your project:
import enTranslations from '@shopify/polaris/locales/en.json';
import {AppProvider, Page, Card, Button} from '@shopify/polaris';
  1. Tell React to render the element in the DOM:
ReactDOM.render(
  <AppProvider i18n={enTranslations}>
    <Page title="Example app">
      <Card sectioned>
        <Button onClick={() => alert('Button clicked!')}>Example button</Button>
      </Card>
    </Page>
  </AppProvider>,
  document.querySelector('#app'),
);

Using the CSS components

If React doesn’t make sense for your application, you can use a CSS-only version of our components. This includes all the styles you need for every component in the library, but you’ll be responsible for writing the correct markup and updating classes and DOM attributes in response to user events.

Usage

  1. Include the CSS in your HTML. We suggest copying the styles file into your own project, but you may also use it directly:
<link
  rel="stylesheet"
  href="https://unpkg.com/@shopify/[email protected]/build/esm/styles.css"
/>
  1. Include the markup and associated classes in your HTML document:
<button class="Polaris-Button">Example button</button>

Development

We use Storybook to create a simple, hot-reloading playground for development on these components. You can edit the playground/Playground.tsx file to import the components you are working on, and run yarn dev in order to start the development server. Please do not commit your work on the playground so that it remains pristine for other developers to work on.

Testing on mobile or a virtual machine

To test the changes on a mobile or virtual machine, you will need to open the source of the iFrame, to do this:

  1. Run yarn dev
  2. Make sure your virtual machine and mobile device are on the same network
  3. Open http://YOUR_IP_ADDRESS:ASSIGNED_PORT/iframe.html?path=/story/playground-playground--playground in your mobile device or virtual machine

Testing in a consuming project

  1. In your terminal, run yarn run build-consumer PROJECT_DIRECTORY from the polaris-react repo

PROJECT_DIRECTORY is where the build will be copied, which must be a sibling of the polaris-react directory.

# Example
yarn run build-consumer polaris-styleguide
  1. In your terminal, open a second tab and run dev up && dev run from the polaris-styleguide repository (or yarn install && yarn dev in your consuming project)

In the example above, the build is copied to polaris-styleguide/node_modules/@shopify/polaris. And in this case, a rebuild of polaris-styleguide is required after copying the polaris-react build, but may not be the case for all consuming projects.

# Example
cd ../polaris-styleguide/
yarn run build:development

Also, when running yarn install, copied builds will be overwritten and will require running yarn run build-consumer PROJECT_DIRECTORY again.

Manual visual regression testing

To start a server for manually viewing the visual regression testing examples, run yarn run dev.

Learning resources

If you’re new to React, we recommend you start with the official React Getting Started documentation. As you read through the topics we suggest you follow along using their React Hello World CodePen example.

Additional resources:

Methodology

We set out to make our components easy to use. Each of our components has a well-documented (and fully typed) public interface with strong, consistently-applied conventions. This way, developers don’t need to worry about the underlying implementation. Instead, they can focus on creating amazing merchant experiences.

We ensure that our components are made for everyone. They meet accessibility standards and are responsive to any screen or device. We also put a lot of effort into optimizing the performance of the components, so everyone can build inclusive experiences that work.

We make our components flexible enough to meet diverse needs. They present the information you pass in and give you smart callbacks when something has changed, but they don’t enforce any structure beyond that. No matter what type of experience you’re creating, you can use components as the building blocks of your product or feature.

Contributing

Pull requests are welcome. See the contribution guidelines for more information.

Licenses

  • Source code is under a custom license based on MIT. The license restricts Polaris usage to applications that integrate or interoperate with Shopify software or services, with additional restrictions for external, stand-alone applications.
  • All icons and images are licensed under the Polaris Design Guidelines License Agreement

polaris-react's People

Contributors

alex-page avatar amrocha avatar andrewmusgrave avatar beefchimi avatar bpscott avatar cboltt avatar chloerice avatar danrosenthal avatar dependabot[bot] avatar dfmcphee avatar dleroux avatar dpersing avatar elileto avatar goodforonefare avatar harbify avatar ismail-syed avatar jkeussen avatar kaelig avatar kvendrik avatar kyledurand avatar lauraaubin avatar lemonmade avatar lwise avatar michenly avatar ry5n avatar selenehinkley avatar tmlayton avatar translation-platform avatar voiid avatar yangchen1 avatar

Stargazers

 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.