@mozaic-ds/vue
TypeScript icon, indicating that this package has built-in type declarations

0.53.0 • Public • Published

Mozaic Vue.js

Introduction

Mozaic-Vue is the Vue.js implementation of Mozaic Design System

Note that this package is built to be used with Vue.js version 2.

You can have an overview of each component of this library by visiting the dedicated Storybook: Storybook

Installation

PREREQUISITE: To allow you to include and use our package in your library, we assume that you are using a module bundlers like Webpack, Parcel or rollup.js, or that your project has been initiated with Vue CLI. Otherwise, the package might not work.

In order to use Mozaic-Vue in your Vue.js project, you must first install the npm package:

$ npm install @mozaic-ds/vue --save --save-exact

Or with Yarn:

$ yarn add @mozaic-ds/vue -E

Usage

Mozaic-Vue is a component library that responds to the different usage contexts proposed by Vue.js.

Indeed, as indicated in its documentation, Vue.js proposes to register/use the components in a global or local way:

  • The global import allows you to make your components accessible throughout your application
  • The local import, on the other hand, makes a component accessible only in the part of the application that uses it

Learn more about the notion of global/local registration on the Vue.js documentation

Global import

Import all components

The easiest way to start using Mozaic-Vue, is to import all the components and make them available throughout your application.

To do this, in your entry point file, insert the following code:

// In the entry point file of your application - usually src/main.js

import MozaicVue from '@mozaic-ds/vue';
import '@mozaic-ds/vue/dist/mozaic-vue.css'; // Import the css of all components

Vue.use(MozaicVue);

NOTE: If you are working on a project that requires the use of the ADEO theme, you should use the following style sheet: import '@mozaic-ds/vue/dist/mozaic-vue.adeo.css';

Import only the desired components

If you do not want to use all the components of the library, but only some of them, you can proceed as follows:

// In the entry point file of your application - usually src/main.js

import { MAccordion, MButton } from '@mozaic-ds/vue';
import '@mozaic-ds/vue/dist/mozaic-vue.css'; // Import the css of all components

Vue.use(MAccordion);
Vue.use(MButton);

NOTE: As you can see, the way to import the CSS is the same for both the import of individual components and the import of all components. Indeed, it is not possible to split the generated CSS file. If you want to import only the CSS related to your individual component import, it may be better to use the local import method described below.

Use the component

That's it! You are now able to use the Mozaic components in your Vue.js project.

Simply call the component of your choice at the desired location anywhere in your application:

<MButton label="Default button" />

Local import

If you want to import a component locally, you can proceed as follows:

// In one the .vue file of your application

<script>
...
import { MButton } from '@mozaic-ds/vue/src/components/button';
...
components: {
  MButton,
},
...
</script>

About the CSS of locally imported components

Regarding CSS, you should know that Mozaic components embed their styles in SCSS format; and that Mozaic uses Dart Sass x PostCSS to interpret and build the final CSS.

Therefore, for your local import to work perfectly, you need to create a vue.config.js file at the root of your project.

Inside this file, you will have to configure your module bundler to use Sass loader x PostCSS loader (or equivalents) to interpret the SCSS code of Mozaic components..

For that, we recommend you to get the code present in the following file => vue.config.js for Mozaic

Then insert it in your vue.config.js file.

Use the component

That's it! You are now able to use the Mozaic components in your Vue.js project.

Simply call the component as follows:

<MButton label="Default button" />

Package Sidebar

Install

npm i @mozaic-ds/vue

Weekly Downloads

160

Version

0.53.0

License

ISC

Unpacked Size

30.3 MB

Total Files

156

Last publish

Collaborators

  • caqueste
  • mohamedmok
  • tiloyi