diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..61617be --- /dev/null +++ b/.editorconfig @@ -0,0 +1,49 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# Howto with your editor: +# Sublime: https://github.com/sindresorhus/editorconfig-sublime + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[**] +end_of_line = lf +insert_final_newline = true + +# Standard at: https://github.com/felixge/node-style-guide +[**.js, **.json] +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 +max_line_length = 80 +quote_type = single +curly_bracket_next_line = false +spaces_around_operators = true +space_after_control_statements = true +space_after_anonymous_functions = false +spaces_in_brackets = false + +# https://github.com/jedmao/codepainter +[node_modules/**.js] +codepaint = false + +# No Standard. Please document a standard if different from .js +[**.yml, **.html, **.css] +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +# No standard. Please document a standard if different from .js +[**.md] +indent_style = space + +# Standard at: +[**.py] +indent_style = space +indent_size = 4 + +# Standard at: +[Makefile] +indent_style = tab +indent_size = 8 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc6622f --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.sass-cache +node_modules + +dist + +*.sublime-workspace + +Thumbs.db diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..de8c23e --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'compass' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..b146465 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,31 @@ +GEM + remote: https://rubygems.org/ + specs: + chunky_png (1.3.4) + compass (1.0.3) + chunky_png (~> 1.2) + compass-core (~> 1.0.2) + compass-import-once (~> 1.0.5) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + sass (>= 3.3.13, < 3.5) + compass-core (1.0.3) + multi_json (~> 1.0) + sass (>= 3.3.0, < 3.5) + compass-import-once (1.0.5) + sass (>= 3.2, < 3.5) + ffi (1.9.8) + multi_json (1.11.1) + rb-fsevent (0.9.5) + rb-inotify (0.9.5) + ffi (>= 0.5.0) + sass (3.4.15) + +PLATFORMS + ruby + +DEPENDENCIES + compass + +BUNDLED WITH + 1.10.1 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..12bca17 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Dimitar Stojanov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 421565c..f15f134 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,32 @@ -# flexbox +# Flexbox Playground CSS3 FlexBox 在线调试 -CSS3 FlexBox 在线调试 \ No newline at end of file +This is project to demonstrate the capabilities of the CSS3 Flexbox Layout. + +## Prerequisites + +In order to build this project you need to have Node.js and npm (Node Package Manager) installed on your system. You can download them from [here](https://nodejs.org/download/) and follow this [install instructions](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager). + +To compile the Sass source to CSS, you'll need Ruby, Sass and Compass. To install Ruby follow this [guide](https://www.ruby-lang.org/en/documentation/installation/), for Sass [this](http://sass-lang.com/install), and for Compass refer to [this guide](http://compass-style.org/install/). + +In some cases when installing node packages you'll need [Python 2.7](https://www.python.org/downloads/) and [C++ Libraries](https://support.microsoft.com/en-us/kb/2977003) (Windows) to build them. + +Note that these executables need to be accessed from command line, so make sure they're added in the environment path. On Linux and Mac they're automatically added to the path, and for Windows you may need to follow this [instructions](http://www.computerhope.com/issues/ch000549.htm), just be careful not to mess the existing path value. + +## Setup + +First install gulp command line tool globally with: + +`npm install --global gulp` + +And from the project's root install the dependencies with: + +`npm install` + +After it's done, this will attempt to run `bundle` in the current dir to install the `compass` gem defines as a dependency in the `Gemfile`. Without the Ruby `compass` gem, `gulp build` will fail. + +## Build + +To build the code just run `gulp` from the command line. This will produce functional version in the `dist` folder. + +## License +This source code is under [MIT license](https://github.com/imjustd/flexbox-playground/blob/master/LICENSE). diff --git a/flexbox-playground.sublime-project b/flexbox-playground.sublime-project new file mode 100644 index 0000000..710c137 --- /dev/null +++ b/flexbox-playground.sublime-project @@ -0,0 +1,11 @@ +{ + "folders": + [ + { + "follow_symlinks": true, + "path": ".", + "folder_exclude_patterns": ["node_modules", ".sass-cache", ".git"], + "file_exclude_patterns": ["*.sublime-workspace"] + } + ] +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..2d85551 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,61 @@ +var gulp = require('gulp'), + gutil = require('gulp-util'), + + jshint = require('gulp-jshint'), + compass = require('gulp-compass'), + concat = require('gulp-concat'), + uglify = require('gulp-uglify'), + + input = { + 'html': 'source/*.html', + 'sass': 'source/sass/**/*.scss', + 'javascript': 'source/javascript/**/*.js' + }, + + output = { + 'html': 'dist', + 'stylesheets': 'dist/css', + 'javascript': 'dist/js' + }; + +/* run javascript through jshint */ +gulp.task('jshint', function() { + return gulp.src(input.javascript) + .pipe(jshint()) + .pipe(jshint.reporter('jshint-stylish')); +}); + +/* concat javascript files, minify if --type production */ +gulp.task('build-js', function() { + return gulp.src(input.javascript) + .pipe(concat('app.js')) + //only uglify if gulp is ran with '--type production' + .pipe(gutil.env.type === 'production' ? uglify() : gutil.noop()) + .pipe(gulp.dest(output.javascript)); +}); + +/* compile scss files */ +gulp.task('build-css', function() { + return gulp.src(input.sass) + .pipe(compass({ + css: 'dist/css', + sass: 'source/sass' + })) + .pipe(gulp.dest(output.stylesheets)); +}); + +/* copy any html files to dist */ +gulp.task('copy-html', function() { + return gulp.src(input.html) + .pipe(gulp.dest(output.html)); +}); + +/* Watch these files for changes and run the task on update */ +gulp.task('watch', function() { + gulp.watch(input.javascript, ['jshint', 'build-js']); + gulp.watch(input.sass, ['build-css']); + gulp.watch(input.html, ['copy-html']); +}); + +/* run the watch task when gulp is called without arguments */ +gulp.task('default', ['jshint', 'build-js', 'build-css', 'copy-html', 'watch']); diff --git a/package.json b/package.json new file mode 100644 index 0000000..3203858 --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "flexbox-playground", + "version": "1.0.0", + "description": "Web demo to demonstrate CSS3 flexbox properties", + "homepage": "http://invoicebus.com", + "repository": "imjustd/flexbox-playground", + "main": "index.js", + "keywords": [ + "CSS3", + "flexbox", + "demo" + ], + "author": "Dimitar Stojanov ", + "license": "MIT", + "engines": { + "node": ">= 0.10" + }, + "devDependencies": { + "gulp": "^3.8.11", + "gulp-compass": "^2.0.3", + "gulp-concat": "^2.5.2", + "gulp-jshint": "^1.9.2", + "gulp-sourcemaps": "^1.3.0", + "gulp-uglify": "^1.1.0", + "gulp-util": "^3.0.4", + "jshint-stylish": "^1.0.1" + }, + "scripts": { + "postinstall": "which bundle && bundle" + } +} diff --git a/source/index.html b/source/index.html new file mode 100644 index 0000000..9de2722 --- /dev/null +++ b/source/index.html @@ -0,0 +1,205 @@ + + + + + + + CSS3 Flexbox Playground + + + + + + + + + +
+
+

Children Width

+
+
width: {{children_width}}%
+ +
+ + + +

Parent Flex Properties – flex container

+
+
+
+ flex-direction + + row + row-reverse + column + column-reverse + +
+ +
+ flex-wrap + + nowrap + wrap + wrap-reverse + +
+
+ +
+
+ justify-content + + flex-start + flex-end + center + space-between + space-around + +
+ +
+ align-items + + stretch + flex-start + flex-end + center + baseline + +
+
+ +
+
+ align-content + + stretch + flex-start + flex-end + center + space-between + space-around + +
+
+
+ + * The default property values are highlighed. + + + +

Children Flex Properties – flex items

+ +
+

The children flex properties can be applied at child level, separate for each child. See the results section and change some of their properties. Hover with the mouse pointer or touch the fields to see the property name.

+
+ + +
+ +
+

Result

+

+ Add child +

+ +
+ +
+
+
+ {{$index + 1}} + + ✖ + +
+ +
+ + order + + + + + flex-grow + + + + + flex-shrink + + + + + flex-basis + + + + + align-self + + {{value}} + + +
+ +
+
+
+
+
+ + + + + + + + + + + + + diff --git a/source/javascript/app.js b/source/javascript/app.js new file mode 100644 index 0000000..f3f3766 --- /dev/null +++ b/source/javascript/app.js @@ -0,0 +1,45 @@ +// Declare the flexboxDemoApp module and its dependency 'ngMaterial' +var app = angular.module('flexboxDemoApp', ['ngMaterial']); +// Declare the AppCtrl controller +app +.config(['$mdThemingProvider', function ($mdThemingProvider) { + $mdThemingProvider + .theme('default') + .accentPalette('amber', { + default: '700' + }); +}]) +.controller('AppCtrl', ['$scope', function ($scope) { + $scope.parent = { + flexDirection: 'row', + flexWrap: 'nowrap', + justifyContent: 'flex-start', + alignItems: 'stretch', + alignContent: 'stretch' + }; + + $scope.children_width = 12; // % + + $scope.children = []; + + var addChild = function (order, flexGrow, flexShrink, flexBasis, alignSelf) { + $scope.children.push({ + order: order || 0, + flexGrow: flexGrow || 0, + flexShrink: flexShrink || 1, + flexBasis: flexBasis || 'auto', + alignSelf: alignSelf || 'auto' + }); + }; + var removeChild = function (index) { + $scope.children.splice(index, 1); + }; + + $scope.addChild = addChild; + $scope.removeChild = removeChild; + + for (var i = 0; i < 5; i++) { + addChild(); + } + +}]); diff --git a/source/sass/style.scss b/source/sass/style.scss new file mode 100644 index 0000000..e737acb --- /dev/null +++ b/source/sass/style.scss @@ -0,0 +1,113 @@ +@import "compass"; + +// Flex container +.flexbox-parent { + @include display-flex; + background: #FFD54F; + overflow: hidden; + width: 100%; + padding: 3px; + min-height: 550px; + max-height: 1000px; + width:50vw; + max-width:50vw; + height:50vh; + + // Flex items + > div { + display: inline-block; + background: white; + overflow: hidden; + margin: 3px; + padding: 5px; + + .child-controls { + margin-top: 7px; + } + } +} + +.child-number { + display: block; + width: 22px; + height: 22px; + background: #FFB300; + color: white; + font-size: 14px; + font-weight: bold; + padding-top: 3px; + text-align: center; + @include border-radius(50%); + float: left; +} + +.code { + font-family: Consolas, "Courier New", Monospace; + font-size: 15px; +} + +.remove-child { + background: transparent; + color: #FF6F00; + font-size: 14px; + cursor: pointer; +} + +.highlight { + color: #FF8F00; +} + +.pull-left { + float: left; +} + +.pull-right { + float: right; +} + +.clearfix { + &:after { + content: ''; + display: block; + clear: both; + } +} + +.right-padding { + padding-right: 15px; +} + +h3 { + margin: 0 0 10px 0 !important; +} + +p { + margin: 0 0 10px 0 !important; + line-height: 1.4em !important; +} + +md-input-container { + padding: 0 0 5px 0 !important; + + .md-input { + padding: 0 !important; + line-height: 1em !important; + } +} + +md-select { + margin-top: 0 !important; + + .md-select-label { + padding-top: 2px !important; + padding-bottom: 4px !important; + } +} + +md-radio-button { + margin: 5px 10px !important; +} + +md-divider { + margin: 10px 0 !important; +}