stayacid / draw-svg

Draw an svg with vue. Based on https://jxnblk.github.io/paths/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is it:

Draw an svg polygon with Vue. Based on Brent Jackson https://github.com/jxnblk/paths.

Build Setup:

# Download repository:
git clone https://gitlab.com/stayacid/draw-svg

# Install dependencies:
npm i

# Server with hot reload at http://localhost:8081/
npm run dev

# Output will be at dist/ folder
npm run build

Project Structure:

  • src/pug/pages/index.pug - main app PUG
  • src/scss - put custom app SCSS styles here. Don't forget to import them in index.js
  • src/assets/img - put images here. Don't forget to use correct path: assets/img/some.jpg
  • src/js - put custom app scripts here
  • src/index.js - main app file where you include/import all required libs and init app
  • src/components - folder with custom .vue components
  • src/store - app store for vue
  • static/ - folder with extra static assets that will be copied into output folder

Settings:

Main const:

Easy way to move all files. Default:

const PATHS = {
  // Path to main app dir
  src: path.join(__dirname, '../src'),
  // Path to Output dir
  dist: path.join(__dirname, '../dist'),
  // Path to Second Output dir (js/css/fonts etc folder)
  assets: 'assets/'
}

Customize:

Change any folders:

const PATHS = {
  // src must be src
  src: path.join(__dirname, '../src'),
  // dist to public
  dist: path.join(__dirname, '../public'),
  // assets to static
  assets: 'static/'
}

Import Another libs:

  1. Install libs
  2. Import libs in ./index.js
// React example
import React from 'react'
// Bootstrap example
import Bootstrap from 'bootstrap/dist/js/bootstrap.min.js'
import 'bootstrap/dist/js/bootstrap.min.js'

Import only SASS or CSS libs:

  1. Install libs
  2. Go to /assets/scss/utils/libs.scss
  3. Import libs in node modules
// Sass librarys example:
@import '../../node_modules/spinners/stylesheets/spinners';
// CSS librarys example:
@import '../../node_modules/flickity/dist/flickity.css';

Import js files:

  1. Create another js module in ./js/ folder
  2. Import modules in ./js/index.js file
// another js file for example
import './common.js'

PUG Dir Folder:

Default:

  • .pug dir: ./src/pug
  • Configurations: in ./build/webpack.base.conf.js
const PAGES_DIR = PATHS.src

Usage: All pages must be created in the ./src/pug/pages folder. Example:

./src/pug/pages/index.pug
./src/pug/pages/index.pug

Change Pug Default Dir Folder:

Example for ./src/pug/pages:

  1. Create folder for all pug files in ./src. Be like: ./src/pages
  2. Change ./build/webpack.base.conf.js const PAGES_DIR:
// Old path
// const PAGES_DIR = PATHS.src

// Your new path
const PAGES_DIR = `${PATHS.src}/pages`
  1. Rerun webpack dev server

Usage: All files must be created in the ./src/pug/pages folder. Example:

./src/pug/pages/index.pug
./src/pug/pages/about.pug

Create Another HTML Files:

Default:

Automatic creation any html pages:

  1. Create another html file in ./src (main folder)
  2. Open new page http://localhost:8081/about.html (Don't forget to RERUN dev server) See more - commit

Second method:

Manual (not Automaticlly) creation any html pages (Don't forget to RERUN dev server and COMMENT lines above)

  1. Create another html file in ./src (main folder)
  2. Go to ./build/webpack.base.conf.js
  3. Comment lines above (create automaticlly html pages)
  4. Create new page in html:
    new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/index.html`,
      filename: './index.html',
      inject: true
    }),
    new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/another.html`,
      filename: './another.html',
      inject: true
    }),
  1. Open new page http://localhost:8081/about.html (Don't forget to RERUN dev server)

Third method: (BEST)

Сombine the first method and the second. Example:

    ...PAGES.map(page => new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/${page}`,
      filename: `./${page}`
    })),
    new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/about/index.html`,
      filename: './about/index.html',
      inject: true
    }),
    new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/about/portfolio.html`,
      filename: './about/portfolio.html',
      inject: true
    }),

Add Vue Components:

Create your component in /components/

HTML Usage:

  1. Init component in index.js:
Vue.component('example-component', require('./components/Example.vue').default)
  1. Any html files:
 <example-component />

VUE Usage:

  1. import components in .vue:
import example from '~/components/Example.vue'
  1. Register component:
  components: {
    example
  }
  1. Init in vue component:
<example />

Add Fonts:

Сhoose one of the ways:

  1. Handle menthod,
  2. Use mixin;

Handle:

Add @font-face in /scss/utils/fonts.scss:

@include font-face( 
  "MullerBold",
  "../fonts/MullerBold",
  400,
  normal,
  woff woff2 
);

Add vars for font in /scss/global/helpers/_variables.scss:

$mySecontFont : 'Helvetica-Base', Arial, sans-serif;

Or with mixin:

By default template support only modern format fonts: .woff, .woffs;

Usage:

  1. Put your font to src/assets/fonts/FOLDERNAME/FONTNAME. FOLLOW: Files Required: Example: .woff, .woffs formats;
  2. Go to fonts.scss;
  3. Use mixin Example: @include font-face("OpenSans", "../fonts/OpenSans/opensans");, Example 2: @include font-face("OpenSans", "../fonts/OpenSans/opensansItalic", 400, italic);.

Image compression:

Images will be compressed on build by 'imagemin-webpack-plugin'. SVG won't be compressed

Related

License

MIT

About

Draw an svg with vue. Based on https://jxnblk.github.io/paths/


Languages

Language:Vue 44.6%Language:CSS 27.8%Language:JavaScript 26.7%Language:HTML 0.9%