Git Product home page Git Product logo

generator-foundation's Introduction

Foundation Generator Build Status

Yeoman generator (1.0 beta) for Zurb Foundation v4, based on Foundation Sass Version

The Stylus version of Foundation!

While Sass works great with Ruby projects, I think Stylus makes more sense for Node.js web applications for its native modular support using npm. I spent some time creating the a Stylus port of the Foundation framework, so for those fans of Node.js, you no longer need Ruby/Gem installed in your system to use Foundation! It is not officially adopted by Zurb yet, so if you like the idea, please help vote for it. I also published my fork of the Foundation (with Stylus port) to npm here while Zurb is making up their mind to adopt it. Starting from v0.2.0, this generator will use the Stylus port by default (you can still choose to use Sass version from the prompt).

fashionista makes it easy to integrate custom Foundation themes with express.js

Usage

First make a new directory, and cd into it:

mkdir my-foundation && cd $_

Then install generator-foundation:

npm install -g generator-foundation

Run yo foundation, optionally passing an app name:

yo foundation [app-name] [--base=my-base-foundation]

Finally, install npm dependencies:

npm install

Running the generated foundation project

grunt

Generated output

yo foundation basic generator

When you run yo foundation without any parameter from your project folder (e.g. my-foundatino-theme), and accept the default options, you will get the following tree (omitting the content in public folder):

~/my-foundation-theme> tree
.
├── Gruntfile.js
├── README.md
├── assets
│   └── favicon.ico
├── index.js
├── index.styl
├── package.json
├── public
│   (omitting the content here...)
└── stylus
    ├── my-foundation-theme
    │   └── variables.styl
    ├── my-foundation-theme-components.styl
    ├── my-foundation-theme.styl
    └── foundation
        ├── components.styl
        └── variables.styl

The project files

Let us go over some important parts of the generated project files/folders to see how it works.

package.json

Your npm project file, laying out all the dependencies, your project name (as the npm package name), and other project information.

Gruntfile.js

This is the Grunt configuration file with a bunch of (opinionated) predefined setup. By default, running grunt will compile the theme files, start a server at port 3000, and open a browser with livereload (using the default livereload port) so you can just start editing your theme and see the changes as you go. If you know grunt, feel free to make changes as you see fit.

index.styl

A simple one-liner referencing your main theme files. Usually you do not have to touch this.

index.js

Here we exports all the necessary information for any descending theme to have a way to get their hands on the resources of the current theme. For example, the generator by default generates a folder called assets, and index.js will export the absolute path to the assets folder so any Node.js server that is hosting the theme can expose it as a static path.

public (or whatever folder name you appointed as the public folder)

This folder contains a set of default foundation html/css/javascript files for you to visually inspect the theme. This folder is not part of the paths being exported in index.js, so basically, you can put any testing html/css/javascript here.

stylus (or the folder name you choose to hold the theme files)

Let us say you have generated this theme from a project folder named my-foundation-theme, you will automatically get 1 folder and 3 files:

  • stylus/my-foundation-theme.styl
  • stylus/my-foundation-theme-components.styl
  • stylus/my-foundation-theme
  • stylus/my-foundation-theme/variables.styl

Please take a look at the stylus port of Foundation itself https://github.com/blai/foundation as an example. It is recommended for you to manage components under stylus/my-foundation-theme/components/, and for each new component file you created, you link it into the theme by adding an import statement in stylus/my-foundation-theme-components.styl. If you decide to expose variables for descending themes to override, you would also want to add it to the stylus/my-foundation-theme/variables.styl using ?= and comment it out.

Any ancestoring themes in you theme inheritance structure should have been properly flatten and ported to their individual folder (of the theme name itself) under stylus folder. If you did not specify a theme to extend from, Foundation would be the ancestor and you should see a stylus/foundation/ folder generated for you with 2 files in it

  • stylus/foundation/components.styl
  • stylus/foundation/variables.styl

Feel free to comment/uncomment/change these two files to customize the default set of components provided by Foundation theme. Your customization to these files would be inherited automatically to any descending theme as well.

assets folder

As mentioned above in index.js section, assets folder would be exported along with your theme files as port of the npm package. This gives you to place any none-stylus assets (e.g. font, image, etc), knowing that they will be available to you when this theme is being hosted by a node.js server. You may refer to the assets from your css/stylus files using relative path (without mentioning assets as part of the path) like so: Assuming your assets folder has this:

└── assets
    └── images
        └── my-background.png
.my-nice-background {
  background: url('images/my-background.png');
  background-size: 100% 100%;
}

Any assets of your ancestor(s) would also be available to you the same way.

Release History

  • 2013-04-29 v0.5.0 Use Foundation 4.1.5 structure, use local project override to extend inherited styles.
  • 2013-04-15 v0.4.1 Enhanced logic to expose assetPaths from baseTheme
  • 2013-04-15 v0.4.0 For stylus version, updated the environment.styl and settings.styl to use the variables from Foundation 4.1.2
  • 2013-04-15 v0.3.4 Check for the existence of theme.assetPaths before iterating
  • 2013-04-14 v0.3.3 Mount all asset folders from dependencies in grunt for development environment.
  • 2013-04-14 v0.3.2 Exports plugin function from index.js
  • 2013-04-10 v0.3.1 save the dependency in package.json when doing npm install
  • 2013-04-09 v0.3.0 Integration with fashionista
  • 2013-04-02 v0.2.6 Also run "npm install" programmatically on the theme dependencies.
  • 2013-03-28 v0.2.5 Add instruction at end of project generation
  • 2013-03-28 v0.2.4 Fixed middleware bug, it did not call 'stylus.use' on the base theme
  • 2013-03-28 v0.2.3 Clean up deprecated contents
  • 2013-03-27 v0.2.2 Re-factored theme-global to make themes more extensible. Use 'foundation' module from public npm.
  • 2013-03-26 v0.2.1 For stylus port, import foundation-global settings after importing local setting
  • 2013-03-26 v0.2.0 Added Stylus port of foundation version
  • 2013-03-19 v0.1.1 fixed incorrect task name in watcher
  • 2013-03-12 v0.1.0 first draft.

generator-foundation's People

Contributors

blai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

generator-foundation's Issues

Global install

Generators can now be installed globally. Please update readme:

npm install -g generator-foundation

Error: Task "sass" not found.

In Gruntfile.js the task should be named 'compass' instead of 'sass' like so:

sass: {
files: 'sass/*/.scss',
tasks: ['compass']
}

Error "Cannot call method 'forEach' of undefined Use"

Hi,

when I follow the steps to scaffold a new project using [email protected], I have this issue, which prevent grunt from running the server. I tried to --force it, but it fails too:

$ mkdir foo
$ cd foo
$ npm install -g generator-foundation
npm http GET https://registry.npmjs.org/generator-foundation
...
...
...
[email protected] /usr/local/lib/node_modules/generator-foundation
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

$ yo foundation foo
Which css preprocessing language would you prefer? stylus, sass
Using "foundation" as base theme
Where would you want to place your static contents? (public)
Where would you want to place your foundation stylus files? (stylus)
create public/index.html
create public/javascripts/foundation/foundation.alerts.js
create public/javascripts/foundation/foundation.clearing.js
create public/javascripts/foundation/foundation.cookie.js
create public/javascripts/foundation/foundation.dropdown.js
create public/javascripts/foundation/foundation.forms.js
create public/javascripts/foundation/foundation.joyride.js
create public/javascripts/foundation/foundation.js
create public/javascripts/foundation/foundation.magellan.js
create public/javascripts/foundation/foundation.orbit.js
create public/javascripts/foundation/foundation.placeholder.js
create public/javascripts/foundation/foundation.reveal.js
create public/javascripts/foundation/foundation.section.js
create public/javascripts/foundation/foundation.tooltips.js
create public/javascripts/foundation/foundation.topbar.js
create public/javascripts/vendor/custom.modernizr.js
create public/javascripts/vendor/jquery.js
create public/javascripts/vendor/zepto.js
create stylus/MIT-LICENSE.txt
create stylus/normalize.styl
create assets/favicon.ico
create .gitignore
create .jshintrc
create Gruntfile.js
create package.json
create README.md
create index.js
create index.styl
create stylus/foo.styl
create stylus/foo/environment.styl
create stylus/foo/settings.styl
create stylus/foo/foo-global.styl
{ data: { save: true, registry: 'https://registry.npmjs.org/' } }
npm http GET https://registry.npmjs.org/foundation
...
[email protected] node_modules/foundation
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected])

Foundation theme "foo"" created. Now run:

  1. npm install to install the required dependencies.
  2. grunt to start modifying your theme.

$ npm install
npm http GET https://registry.npmjs.org/grunt-contrib-jshint
npm http GET https://registry.npmjs.org/grunt
...
...
[email protected] node_modules/grunt-contrib-clean

[email protected] node_modules/grunt-open
└── [email protected]

[email protected] node_modules/grunt-contrib-compass
├── [email protected]
└── [email protected] ([email protected])

[email protected] node_modules/grunt-contrib-stylus
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected])

[email protected] node_modules/grunt-contrib-livereload
└── [email protected] ([email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/grunt-regarde
└── [email protected] ([email protected], [email protected])

[email protected] node_modules/grunt-contrib-connect
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/grunt-contrib-jshint
└── [email protected] ([email protected], [email protected])

[email protected] node_modules/grunt
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected])

$ grunt
Running "clean:build" (clean) task

Running "stylus:compile" (stylus) task
File dist/app.css created.
File dist/normalize.css created.

Running "livereload-start" task
... Starting Livereload server on 35729 ...

Running "connect:server" (connect) task
Warning: Cannot call method 'forEach' of undefined Use --force to continue.

percent function not being processed in grid.styl

I think the percent function is not being processed due to the stylus-type-utils not being imported. I'm having to manually import it into my main app.styl file to get the grid to work.

@import "node_modules/foundation/node_modules/stylus-type-utils";

Unable to run "npm install -g generator-foundation" successfully

Running this commend gives me the following:

npm http 200 https://registry.npmjs.org/generator-foundation/-/generator-foundation-0.5.0.tg
pm ERR! tar pack Error reading /var/folders/8x/d115mm_j0_s7_f3mbmngjvd40000gn/T/npm-4497/1368114822724-0.9169824172277004/package
npm ERR! TypeError: Cannot call method 'filter' of undefined
npm ERR! at Packer.IgnoreReader.addIgnoreRules (/usr/local/Cellar/node/0.8.21/lib/node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js:148:13)
npm ERR! at Packer.IgnoreReader.addIgnoreFile (/usr/local/Cellar/node/0.8.21/lib/node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js:133:10)
npm ERR! at fs.readFile (fs.js:176:14)
npm ERR! at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]

"undefined" in final generator output

The final output of the command reads:

Foundation theme "undefined" created. Now run:
1. undefined to install the required dependencies.
2. undefined to start modifying your theme.

Here is the full dump:

$ yo foundation

Which css preprocessing language would you prefer? stylus/sass (stylus) sass
Where would you want to place your static contents? (public) 
Where would you want to place your foundation sass files? (sass) 
   create public/css/normalize.css
   create public/index.html
   create public/javascripts/foundation/foundation.alerts.js
   create public/javascripts/foundation/foundation.clearing.js
   create public/javascripts/foundation/foundation.cookie.js
   create public/javascripts/foundation/foundation.dropdown.js
   create public/javascripts/foundation/foundation.forms.js
   create public/javascripts/foundation/foundation.joyride.js
   create public/javascripts/foundation/foundation.js
   create public/javascripts/foundation/foundation.magellan.js
   create public/javascripts/foundation/foundation.orbit.js
   create public/javascripts/foundation/foundation.placeholder.js
   create public/javascripts/foundation/foundation.reveal.js
   create public/javascripts/foundation/foundation.section.js
   create public/javascripts/foundation/foundation.tooltips.js
   create public/javascripts/foundation/foundation.topbar.js
   create public/javascripts/vendor/custom.modernizr.js
   create public/javascripts/vendor/jquery.js
   create public/javascripts/vendor/zepto.js
   create assets/favicon.ico
   create .gitignore
   create .jshintrc
   create Gruntfile.js
   create package.json
   create README.md

     info ... Fetching http://github.com/blai/foundation/archive/master.tar.gz ...
     info undefined
...........................................................................................................................................................................................................................................................................
✔ Done in 19.572s.
✔ Done in /Users/alejandro/.yeoman/cache/blai/foundation/master

   create sass/app.scss
   create sass/_variables.scss

Foundation theme "undefined" created. Now run:
1. undefined to install the required dependencies.
2. undefined to start modifying your theme.

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.