GithubHelp home page GithubHelp logo

brianbroderick / phoenix_bootstrap Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 113 KB

Phoenix 1.3 with Bootstrap 4 Example

JavaScript 14.09% CSS 0.70% Elixir 77.93% HTML 7.28%
phoenix-framework bootstrap4 elixir-lang elixir-phoenix brunch phoenix13

phoenix_bootstrap's Introduction

Phoenix 1.3 with Bootstrap 4 and Font Awesome 4.7

This is an example of using Phoenix with Bootstrap. One of the example Bootstrap templates is being used. The main changes to the default install is in /assets/package.json, /assets/brunch-config.js, and /assets/css/* (namely that app.css was renamed to app.scss and some custom css was imported).

To start Phoenix:

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.create && mix ecto.migrate
  • Install Node.js dependencies with cd assets && npm install
  • Start Phoenix endpoint with mix phx.server

Now you can visit localhost:4000 from your browser.

To Install Bootstrap 4 and Font Awesome:

  1. Remove the existing Bootstrap
$ rm assets/css/phoenix.css
  1. Install Bootstrap 4 and Font Awesome
$ cd assets
$ npm install --save [email protected] font-awesome jquery
  1. Install Sass-Brunch & Copycat-Brunch
$ npm install --save-dev sass-brunch copycat-brunch
  1. Add sass-brunch, font-awesome, and copycat config to assets/brunch-config.js
// Configure your plugins
plugins: {
  babel: {
    // Do not use ES6 compiler in vendor code
    ignore: [/vendor/]
  },
  copycat: {
    "fonts": ["node_modules/font-awesome/fonts"]
  },
  sass: {
    options: {
      includePaths: ["node_modules/bootstrap/scss", "node_modules/font-awesome/scss"], // for sass-brunch to @import files
      precision: 8 // minimum precision required by bootstrap
    }
  }
},

And the scss folder to the watch path.

paths: {
    // Dependencies and current project directories to watch
    watched: ["static", "css", "scss", "js", "vendor"],
    ...
  },
...

And finally, add Bootstrap and JQuery to the NPM section:

npm: {
    enabled: true,
    globals: {
      // Bootstrap JavaScript requires both '$', 'jQuery'
      $: 'jquery',
      jQuery: 'jquery',
      bootstrap: 'bootstrap' // require Bootstrap JavaScript globally too
    }
  }
  1. Rename app.css to app.scss
$ cd assets/css; mv app.css app.scss
  1. Import Font Awesome and Bootstrap in app.scss
/* This file is for your main application css. */

$fa-font-path: "../fonts";
@import "font-awesome";
@import "bootstrap";
  1. Make sure your template is up to date with Bootstrap 4 classes.

phoenix_bootstrap's People

Contributors

brianbroderick avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

denielchiang

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.