Giter Site home page Giter Site logo

alexiej / electron-vue-storybook Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 8 MB

This is a fork of the original electron-vue source with additional .storybook implementation.

Home Page: https://simulatedgreg.gitbooks.io/electron-vue/content/

License: MIT License

JavaScript 49.84% Vue 49.30% HTML 0.42% CSS 0.02% Shell 0.42%
storybook vuejs vue electron element-ui bootstrap animated-css font-awesome

electron-vue-storybook's Introduction


electron-vue

The boilerplate for making electron applications built with vue (pretty much what it sounds like).

forthebadge forthebadge forthebadge

js-standard-style

Build Status

Overview

This is a fork of the original electron-vue project with some extrea features like:

  • Storybook that allows you to preview your components classes, behaviour and much more more

storybook

  • Bootstrap 4.0 with the preview in storybook for most of the futures to preview like buttons, layouts, etc... more

bootstrap

  • Element-UI wich is great framework for desktop applications, and also with a lot of examples from the original page more

element-ui

  • Animated.css with a lot of styles to animate your buttons, text, etc.. more

animated.css

  • Font-Awesome - A huge list of free icons.

font-awesome

  • Modular structure - This is comes from the Atomic Design with ability to create components or other functions like modules meaning one folder is one module and have everything (including tests, storybooks, documentation) in one folder by suffixes. All files can be included in the project by suffixes.

Getting Started

This boilerplate was built as a template for vue-cli and includes options to customize your final scaffolded app. The use of node@^7 or higher required. electron-vue also officially recommends the yarn package manager as it handles dependencies much better and can help reduce final build size with yarn clean.

# Install vue-cli and scaffold boilerplate
npm install -g vue-cli
vue init alexiej/electron-vue-storybook my-project

# Install dependencies and run your app
cd my-project
yarn # or npm install
yarn run dev # or npm run dev
yarn run storybook # or npm run storybook

Folder Structure

  • .electron-vue - Builder for electron desktop project
  • .storybook - Folder to initialize storybook.
  • src - Main Folder for sources
    • main - Main electron js file to create BrowserWindw
    • renderer - Main folder for rendering files
      • adds - Additional modules with stories or tests like bootstrap/element-ui,font-awesome or animated.css
      • assets - Files like additional images, fonts, etc...
      • components - List of basic components like buttons, lists, etc...
      • css - Style files with _global.scss to load all styles for application
      • methods - helpful methods for the application
      • modules - List of modules for the application like Content. Each module can have couple types of files depends on suffix.
      • App.vue - main view for BrowserWindow
      • components.js - Get all components with the .comp.vue suffix and install them to be available in your application.
      • main.js - main .js file to run
      • mixin.js - Get all mixins from folder renderer with the .mixin.js suffix.
      • router.js - Get all routes from the folder renderer with the suffix .routes.js.
      • store.js - Get all stores from the folder renderer with the suffix .store.js.
  • tests - Test folder that includes all files with the .spec.js suffix.

File suffixes

Suffix Example Description
.stories.js button.stories.js Information about stories for storybook
.comp.vue button-example.comp.vue Global atomic component for your project
.routes.js LandingPage.routes.js Information about routes for router
.mixin.js LandingPage.mixin.js Additional mixin for your project
.store.js LandingPage.store.js Vuex store for your project
.spec.js LandingPage.spec.js Unit test for your project

.stories.js

All files with the .stories.js are included in the storybook automaticly without putting the information in the main folder.

indes.stories.js

import Vue from 'vue'
import { storiesOf } from '@storybook/vue'
import MyButton from './MyButton.stories.vue'

const stories = storiesOf('Welcome/Examples', module)
stories.addDecorator(withKnobs)

stories
  .add('with text', () => ({
    components: { MyButton },
    template: '<div class="cd-border" @click="action">Hello Button </div>',
    methods: { action: action('clicked') }
  }))

mybutton.stories.vue

You can put .stories.vue as a suffix to exclude them from code cover test.

<template>
  <button class="button-styles color--red-1 button--40x40" @click="onClick">
    <b> </b>
    Example class of the control
    <slot/>
  </button>
</template>

<script>
export default {
  name: 'my-button',
  data () {
    return {
      messages: ['Cat']
    }
  },
  methods: {
    onClick () {
      this.$emit('click')
      console.log('button clicked')
    }
  }
}
</script>

<style>
.button-styles {
  border: 1px solid #eee;
  border-radius: 3px;
  background-color: #ffffff;
  cursor: pointer;
  font-size: 15pt;
  padding: 3px 10px;
  margin: 10px;
  background: brown;
  color: #fff;
}
</style>

storybook

.comp.vue

ButtonExample.comp.vue

<template>
    <button class="button-styles" >
        <slot/>
  </button>
</template>
<script>
export default {
}
</script>

<style lang="scss" scoped>
.button-styles {
  border: 1px solid #eee;
  border-radius: 3px;
  background-color: #ffffff;
  cursor: pointer;
  font-size: 15pt;
  padding: 3px 10px;
  margin: 10px;
  background: brown;
  color: #fff;
}
</style>

Use example:

<button-example >Example Text</button-example>

button-example

.routes.js

LandingPage.routes.js

export default [{
  path: '/',
  name: 'LandingPage',
  component: require('@/modules/LandingPage/LandingPage').default
}]

LandingPageInfo.routes.js

You can specify path of children elements by adding parent to them.

export default [{
  parent: '/',
  path: '/info',
  name: 'Info',
  component: require('@/modules/LandingPage/Info').default
}]

.mixin.js

LandingPage.mixin.js

export default {
  methods: {
    mixinExample () {
      return 'This method is available everywhere in your project'
    }
  }
}

.store.js

LandingPage.store.js

export default {
  namespaced: true,
  state: {
    message: 'Welcome to your new project! (store version)'
  },
  mutations: {

  },
  actions: {

  }
}

.spec.js

LandingPage.spec.js

import Vue from 'vue'
import LandingPage from './LandingPage'
import router from '../../router'

import Vuex from 'vuex'
Vue.use(Vuex)

const storeText = 'Title test'
const store = new Vuex.Store({
  modules: {
    'LandingPage': {
      state: {
        namespaced: true,
        message: storeText
      }
    }
  }
})

describe('LandingPage.vue', () => {
  it('should render correct contents', () => {
    const vm = new Vue({
      el: document.createElement('div'),
      render: h => h(LandingPage),
      store: store,
      router
    }).$mount()

    expect(vm.$el.querySelector('.title').textContent).to.contain(storeText)
  })
})

Other things comes originally from the Electron-Vue

The aim of this project is to remove the need of manually setting up electron apps using vue. electron-vue takes advantage of vue-cli for scaffolding, webpack with vue-loader, electron-packager or electron-builder, and some of the most used plugins like vue-router, vuex, and so much more.

Check out the detailed documentation here.

Things you'll find in this boilerplate...

*Customizable during vue-cli scaffolding

Are you a Windows User?

Make sure to check out A Note for Windows Users to make sure you have all the necessary build tools needed for electron and other dependencies.

Wanting to use Vue 1?

Just point to the 1.0 branch. Please note that electron-vue has officially deprecated the usage of vue@^1, so project structure, features, and documentation will reflect those changes (legacy documentation).

vue init simulatedgreg/electron-vue#1.0 my-project

Next Steps

Make sure to take a look at the documentation. Here you will find useful information about configuration, project structure, and building your app. There's also a handy FAQs section.

Made with electron-vue

Take a look at some of the amazing projects built with electron-vue. Want to have your own project listed? Feel free add your project to the bottom of the list below then submit a pull request.

  • Surfbird: A Twitter client built on Electron and Vue
  • Lulumi-browser: Lulumi-browser is a light weight browser coded with Vue.js 2 and Electron
  • Space-Snake: A Desktop game built with Electron and Vue.js.
  • Forrest: An npm scripts desktop client
  • miikun: A Simple Markdown Editor
  • Dakika: A minute taking application that makes writing minutes a breeze
  • Dynamoc: Dynamoc is a GUI client for dynamodb-local, dynalite and AWS dynamodb
  • Dockeron: A dockeron project, built on Electron + Vue.js for Docker
  • Easysubs: Download subtitles in a very fast and simple way
  • adminScheduler: An application leveraging electron for cross platform compatibility, Vue.js for lightning fast UI and full-calendar.io to deliver a premium calendar interface.
  • Backlog: Simple app for storing TODOs, ideas or backlog items. You can organize them with boards. Sleek flow. Built with Electron + Vue.js + iView
  • Opshell: Ops tool to make life easier working with AWS instances.
  • GitHoard: Hoard git repositories with ease.
  • Data-curator: Share usable open data.

electron-vue-storybook's People

Contributors

bguyl avatar calamari avatar calebroseland avatar czytelny avatar ekoeryanto avatar fluency03 avatar herrherrmann avatar jancvanb avatar jeremycook avatar kudapara avatar lawrr avatar lizhooh avatar luckylin avatar malept avatar mandrepont avatar mgd4375 avatar nelsonjchen avatar nicklaw5 avatar qazbnm456 avatar re-fort avatar riatio avatar ricktbaker avatar rob-- avatar serundeputy avatar simulatedgreg avatar slayerfat avatar snovey avatar sqlwwx avatar techtolentino avatar zxc23 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

reganan

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.