0.0.14 • Published 6 years ago

forty-two-vue v0.0.14

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

42 Vue Library

A component library for Vue.js applications built according to Company42's design specifications. The aim of this package is to provide out-of-the-box components for a Vue.js web application.

Installation

Using npm:

$ npm install forty-two-vue --save

Include the following code in your main.js file or entry file to your Vue application:

// Import the entire library
import FortyTwo from 'forty-two-vue';

// Import the stylesheet
import 'forty-two-vue/dist/lib/forty-two-vue.min.css';

// Vue.use will automatically register
// the components globally, so that they
// can be used anywhere in your templates
Vue.use(FortyTwo);

Basic Example

All components are prefixed with 'ft-'. For example <ft-input></ft-input> will render a custom input component in your .vue file.

Many of the components come with dynamic properties allowing you to create flexible application flows. Below is an example of how you could use the custom input and button components in a subscription form.

// SomeForm.vue
<template>
  <form>
    <ft-input
      :type="'email'"
      :label="'Email'"
      :placeholder="'Your email address'"
      :success-message="'Valid email'"
      :warning-message="'The email is already registered in our system...'"
      :error-message="'Invalid email, please try again'"
      :state="inputState"
      v-model="email" >
    </ft-input>
    
    <ft-button :on-click="subscribe">
      Subscribe
    </ft-button>
  </form>
</template>

<script>
export default {
  data() {
    return {
      email: '',
      inputState: '',
    };
  },
  watch: {
    email: (val) => {
      // Watch for email changes and change 'inputState'
      // to toggle between the different input messages,
      // e.g. warning-message is visible when :state="'warning"
    },
  }
  methods: {
    subscribe() {
      // Handle email subscription...
    },
  },
};
</script>

Components

Button

<ft-button>

Comes with the following the custom properties:

PropsDefaultOptionsDescription
:disabledfalsetrue falseIf true it prevents the 'on-click' function from executing and adds the 'disabled' class to the button.
:on-clicknonen/aA function to be executed when clicking on the button.

Optional classes that you can add to the <ft-button> tag:

ClassesDescription
.largeFor a large button.
.xlargeFor an extra large button.
.xxlargeFor an extra extra large button.
.greyFor a grey button.
.greenFor a green button.
.orangeFor an orange button.
.redFor a red button.
.purple For a purple button.
.disabledFor a disabled button. This style can be added, but it is recommended to use the :disabled prop instead to also prevent the :on-click function from executing.

Card

<ft-card>

A card component for content. Use together with the <ft-card-section> tag to group content within a single card.

<ft-card>
  <ft-card-section>
    // Some content goes here.
  </ft-card-section>
  
  <ft-card-section>
    // Some more content goes here.
  </ft-card-section>
</ft-card>

Container

<ft-container>

Used for grouping content and aligning content horizontally or vertically. Also comes with gutter classes for easy flex gutters as well as standardised padding classes.

ClassesDescription
.padding-xsmallSets extra small padding inside the container.
.padding-smallSets small padding inside the container.
.paddingSets standard padding inside the container.
.padding-largeSets large padding inside the container.
.padding-xlargeSets extra large padding inside the container.
.padding-xxlargeSets extra extra large padding inside the container.
.rowSets display to flex and flex-direction to row.
.columnSets display to flex and flex-direction to column.
.gutter-xsmallAdds an extra small gutter between each item.
.gutter-smallAdds a small gutter between each item.
.gutterAdds a standard gutter between each item.
.gutter-largeAdds a large gutter between each item.

Input

<ft-input>

Comes with the following the custom properties:

PropsDefaultOptionsDescription
:labelnonen/aAdds a label to the input.
:statenone'success' 'warning' 'error'Adds certain styling and shows corresponding message depending on the given state.
:valuenonen/aSet the value of the input. Works with v-model.
:placeholder none n/aSets the input placeholder.
:typenone 'text' 'email' 'password'Sets the type of input.
:success-messagenone n/aSets the success message to be shown when the state equals 'success'.
:warning-messagenone n/aSets the warning message to be shown when the state equals 'warning'.
:error-messagenone n/aSets the error message to be shown when the state equals 'error'.
:full-widthfalsetrue falseSet the width of the input to fill its container.

Link

<ft-link>

An alternative to an <a> tag that comes with easy to use props and styling.

PropsDefaultOptionsDescription
:link-tononen/aThe link that you wish to send the user to.
:new-tabtruetrue falseOpens the link in the current window if set to false.

Message

<ft-message>

Wraps content in a blue box with styling options to create success, warning and error messages.

Optional classes that you can add to the <ft-message> tag:

ClassesDescription
.successFor a green success message.
.warningFor an orange warning message.
.errorFor a red error message.
.mutedFor a muted grey message.

Spacer

<ft-spacer>

A utility component used to create space between other components. Must have either .row or .column class. .row is used to create vertical space between items and .column is used to create horizontal space between items.

If no size class is given, the spacer will take up the standard space. However, you can modify the spacer with one of the following size classes:

ClassesDescription
.xxsmallFor an extra extra small spacer.
.xsmallFor an extra small spacer.
.smallFor a small spacer.
.largeFor a large spacer.
.xlargeFor an extra large spacer.
.xxlargeFor an extra extra large spacer.
.xxxlargeFor an extra extra extra large spacer.

Spinner

<ft-spinner>

A spinning loader that comes in standard and large sizes. For a large spinner, simply add the class .large to the <ft-spinner> tag.

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago