Giter Site home page Giter Site logo

grigs / mistica-web Goto Github PK

View Code? Open in Web Editor NEW

This project forked from telefonica/mistica-web

0.0 0.0 0.0 442.41 MB

React components library for Telefonica Design System (Mistica)

Home Page: https://mistica-web.now.sh

License: MIT License

CSS 0.33% JavaScript 1.18% TypeScript 98.48% Shell 0.01%

mistica-web's Introduction

Mística for Web


React components library for Telefonica Design System (Mistica)

Node.js CI

Getting started

Install

yarn add @telefonica/mistica

or

npm install @telefonica/mistica

Start using @telefonica/mistica

Before using any of our components you have to add <ThemeContextProvider> in the root of your React app. Here is a complete example of a form with two text fields and a submit button:

import ReactDOM from 'react-dom';
import React from 'react';
import {
  ThemeContextProvider,
  Form,
  Box,
  Stack,
  TextField,
  EmailField,
  ButtonLayout,
  ButtonPrimary,
  alert,
  getMovistarSkin,
} from '@telefonica/mistica';

const App = () => (
  <Form
    onSubmit={(formData) =>
      alert({
        title: 'This is your data',
        message: JSON.stringify(formData, null, 2),
      })
    }
  >
    <Box padding={16}>
      <Stack space={16}>
        <TextField name="name" label="Name" />
        <EmailField name="email" label="Email" />
        <ButtonLayout>
          <ButtonPrimary submit>Send</ButtonPrimary>
        </ButtonLayout>
      </Stack>
    </Box>
  </Form>
);

const misticaTheme = {
  skin: getMovistarSkin(),
  i18n: {locale: 'es-ES', phoneNumberFormattingRegionCode: 'ES'},
};

ReactDOM.render(
  <ThemeContextProvider theme={misticaTheme}>
    <App />
  </ThemeContextProvider>,
  document.getElementById('app')
);

The theme prop in ThemeContextProvider is mandatory, and you can use it to configure some aspects of the library. There are multiple settings but the only two mandatory fields are skin and i18n. Read the theme config doc for more info.

⚠️ Usually, the theme object is constant and won't need to change dynamically in your application, in that case we recommend to extract it to an external const variable outside of the component, this way the object reference will be the same in every re-render. If for some reason the theme must be dynamic in your app, consider to memoize it (for example, with React.useMemo hook).

Components

Explore the components in Mistica storybook

Start prototyping interfaces with Mistica components in the Mistica playroom

More docs

Development

  • yarn test: run tests
  • yarn test-acceptance: run acceptance tests headless (you need to start storybook first)
  • yarn test-acceptance --ui: run acceptance tests with ui (you need to start storybook first)
  • yarn lint: check codestyle
  • yarn ts-check: check static types
  • yarn build: build package
  • yarn storybook: starts storybook
  • yarn playroom: starts playroom

More about Mistica

Mistica in other platforms

Contributing

See CONTRIBUTING.md

mistica-web's People

Contributors

alvaromillans avatar anabelengp avatar anamontes11 avatar andyindahouse avatar atabel avatar cesarlopezfab avatar jrvidal avatar marcosld avatar pladaria avatar poloba avatar rubenmorpov avatar semantic-release-bot avatar sergiomorchon avatar sergivillar avatar yceballost 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.