Browse Source

Shapes: working on example for shapes

Former-commit-id: 22faf837e4
Former-commit-id: e65a75df8a
pull/258/head
Jack Lukic 11 years ago
parent
commit
b33867ff22
11 changed files with 216 additions and 155 deletions
  1. 17
      examples/button.html
  2. 63
      examples/example.css
  3. 3
      examples/example.js
  4. BIN
      examples/images/heroku.png
  5. BIN
      examples/images/jira.png
  6. BIN
      examples/images/quirky.png
  7. 11
      examples/index.html
  8. 109
      examples/module.html
  9. 2
      examples/ui/button.css
  10. 2
      src/shape.css
  11. 164
      src/shape.js

17
examples/button.html

@ -53,9 +53,6 @@
<h4>Can show a loading indicator:</h4>
<div class="ui loading button">Loading Button</div>
<h4>Can show a toggled state:</h4>
<div class="ui toggle button">Toggled Button</div>
<h4>Can alert to a succesful action:</h4>
<div class="ui success button">Succesful Button</div>
@ -109,8 +106,20 @@
<div class="ui button">Two</div>
<div class="ui button">Three</div>
</div>
<h4>Groups can be vertical</h4>
<div class="ui vertical buttons">
<div class="ui button">One</div>
<div class="ui button">Two</div>
<div class="ui button">Three</div>
</div>
<h4>Groups can be divided evenly to fit parent</h4>
<div class="ui three fluid buttons">
<div class="ui button">One</div>
<div class="ui button">Two</div>
<div class="ui button">Three</div>
</div>
<h4>Variations can modify groups</h4>
<h4>Singular variations can be applied to groups to infer all elements share the same quality</h4>
<p><b>Blue</b></p>
<div class="blue ui buttons">
<div class="ui button">One</div>

63
examples/example.css

@ -77,6 +77,16 @@ a:hover {
list-style-type: decimal;
margin: 0px 0px 10px;
}
#example .list {
list-style-position: inside;
margin: 10px 0px 40px;
padding: 0px;
}
#example .list li {
list-style-type: disc;
margin: 0px 0px 10px;
}
/* content */
#example .container {
@ -101,15 +111,15 @@ a:hover {
#example .demo.shape .side {
width: 300px;
height: 300px;
width: 250px;
height: 250px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
background-color: #22C1FC;
background-color: #E6E6E6;
color: #FFFFFF;
@ -117,6 +127,13 @@ a:hover {
-webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
}
#example .demo.shape .side img {
display: block;
margin: 0px auto;
max-width: 100%;
}
#example .demo.shape .side b {
display: block;
position: absolute;
@ -127,44 +144,6 @@ a:hover {
text-align: center;
}
#example .demo.shape .up.side,
#example .demo.shape .down.side {
background-color: #E6E6E6;
color: #737373;
}
/* Shapes */
#example .demo.rectangle.shape .side {
width: 500px;
height: 300px;
}
#example .demo.rectangle.shape .up.side,
#example .demo.rectangle.shape .down.side {
height: 100px;
}
#example .demo.rectangle.shape .left.side,
#example .demo.rectangle.shape .right.side,
#example .demo.rectangle.shape .over.side {
width: 300px;
}
#example .demo.irregular.shape .side {
padding: 0px;
}
#example .demo.irregular.shape .side:nth-child(1n) {
width: 514px;
height: 210px;
}
#example .demo.irregular.shape .side:nth-child(2n) {
width: 126px;
height: 115px;
}
#example .demo.irregular.shape .side:nth-child(3n) {
width: 864px;
height: 510px;
}
#example .demo.irregular.shape .side:nth-child(4n) {
width: 322px;
height: 210px;
width: 350px;
}

3
examples/example.js

@ -26,7 +26,6 @@ shape.ready = function() {
if(direction && animation) {
$('.active.side')
.next()
.attr('class', direction + ' side')
;
$demo
.shape(animation + '.' + direction)
@ -54,7 +53,7 @@ shape.ready = function() {
$shape
.addClass('active')
;
$otherShapes
$otherShapes
.removeClass('active')
.each(handler.removeShape)
;

BIN
examples/images/heroku.png

Before After
Width: 250  |  Height: 250  |  Size: 5.5 KiB

BIN
examples/images/jira.png

Before After
Width: 250  |  Height: 250  |  Size: 13 KiB

BIN
examples/images/quirky.png

Before After
Width: 250  |  Height: 250  |  Size: 6.8 KiB

11
examples/index.html

@ -32,7 +32,7 @@
<p>Shapes makes creating 3D tweens easier by taking care of the dirty business of calculating translations based on content sizing, which can be a confusing, frustrating task.</p>
<p>The module uses 3D transformations which are currently only supported in modern versions of Chrome, Safari, and Firefox.</p>
<p>Shapes is written using the semantic module specification. Semantic is a standard pattern for writing Javascript modules which intends to make understanding new code less confusing, and debugging errors less frustrating, by making coding decisions less arbitrary and more semantic. <a href="#">
<p>Shapes is written using the semantic module specification. Semantic is a standard pattern for writing Javascript modules which intends to make understanding new code less confusing, and debugging errors less frustrating, by making coding decisions less arbitrary and more semantic. <a href="module.html">
<p>Click here to read more</a> about Semantic spec, and the upcoming library.</p>
@ -42,16 +42,13 @@
<div class="demo square shape module">
<div class="shape">
<div class="active side">
<b>1</b>
<img src="images/jira.png">
</div>
<div class="side">
<b>2</b>
<img src="images/heroku.png">
</div>
<div class="side">
<b>3</b>
</div>
<div class="side">
<b>4</b>
<img src="images/quirky.png">
</div>
</div>
</div>

109
examples/module.html

@ -30,42 +30,55 @@
<h1>Semantic</h1>
<p>Semantic is a set of standards designed to make front end development less arbitrary.</p>
<div class="ui buttons">
<div class="ui button">Just the details</div>
<div class="ui button active">Tell me everything</div>
</div>
<h2>What is Semantic?</h2>
<p>Semantic has two parts. <b>The semantic standard, and the semantic library.</b></p>
<p>Semantic has two parts. The <a href="#standard">semantic standard</a>, and the <a href="#library">semantic library</a>.</b></p>
<a name="standard"></a>
<h2>The standard</h2>
<p>The semantic standard attempts to create a standard design pattern for describing static UI components (UI elements), and dynamic UI components (modules).</p>
<p>The semantic standard attempts to create a standard design pattern for describing static UI components (UI elements), and dynamic UI components or behavioral definitions (Javascript modules).</p>
<p>Static components are things like: menus, columns, grids, tables, buttons, forms. Dynamic components are things like: popups, modals, chat rooms.</p>
<p><b>Static elements</b>: menus, columns, grids, tables, buttons, forms.</p>
<p><b>Dynamic components</b>: popups, modals, chat rooms.</p>
<p><b>Behavioral components</b>: form validation, state management, history.</p>
<h3>Defining UI</h3>
<p>The DNA of the web is UI. Semantic's goal is to create an exchange format for UI, by architecting a consistent HTML structure and classname usage for defining UI elements.</p>
<p>If as a community we can agree on consistent UI definitions to, for example, describe what a button is, then we can freely share variations of element designs without having to modify our site's structure to match the expectations of the library.</p>
<h2>Defining UI</h2>
<p>Semantic creates an exchange format for UI, by defining a consistent HTML structure and set of class names for representing UI elements.</p>
<p>Sharing a structural standard for UI releases the burden from developers at being a naming authorities in their own projects.</p>
<p>If, as a community we can agree on consistent UI definitions, then we can freely share variations of element designs without having to modify our site's codebase to match any declarative expectations by other developers, and interface designs can be freely exchanged between projects and teams.</p>
<h4>What's in an element</h4>
<h3>What's in an element</h3>
<p><b>UI elements definitions are made of 4 parts</b>:
<ol>
<li>A prototype format of an element (A bunny has two long ears and is furry)</li>
<li>An ideal form of an element (A bunny has two long ears and is furry)</li>
<li>A list of states which the element can exist. (A bunny can either be hopping, eating or sitting still)</li>
<li>A definition of the relationship between a plural and singular instance of an element (Three white bunnies are each white)</li>
<li>A definition of possible variations of the element (A bunny can be tall or short and can be friendly or mean)</li>
<li>A definition of possible variations of the element (A bunny can be large or small and can be spotted or fuzzy)</li>
</ol>
<p>UI elements can be thought of as nouns, and variations as adjectives. Variations should be written in a way which only describe the innate features of that variation, so that variations can be used together without affecting each other.</p>
<p>UI elements can be thought of as nouns, and variations as adjectives. Variations are written in a way which only describe the innate features of that variation in the context of the noun. For example, in english, a large planet has a different meaning than a large chair, but both are the same variant "largeness".</p>
<p>Variations can be used together without negating each other unless used in a pardoxical way (A large small bunny).</p>
<h3>I don't know what you're talking about just show me the code</h3>
<p>If you'd like to shortcut any more explanation, check out the standard definition for a UI button for a live example.</p>
<a class="big blue ui button" href="button.html">UI Button Spec</a>
<a class="blue ui button" href="button.html">UI Button Spec</a>
<h2>Defining Modules</h2>
<p>The Semantic modules standard is created primarily to accomplish two things:</p>
<ol>
<li>Provide conveniences for module authors so that they can be written faster and without clutter.</li>
<li>Add features which make understanding and debugging other developers' modules simpler</li>
</ol>
<h2>The library</h2>
<p>The semantic library is a UI library and set of javascript modules which have been written to adhere to the semantic standard.</p>
<p>The aim is to release pieces of the library on a schedule over the course of the next few months. <a href="#">Check out the Semantic library release calendar</a></p>
<h2>Why use Semantic Modules?</h2>
<h3>Why use Semantic Modules?</h3>
<ol>
<li><b>Puts accessibility first</b>. Although Coffeescript is beautiful, and Angular is smart, Semantic has a different agenda: to be easy to use, and opinionless. Semantic can be thought of more as the <a href="http://en.wikipedia.org/wiki/Aaron_Copland">Aaron Copland</a> of programming libraries. To code in Semantic only requires an understanding of jQuery and Javascript to begin writing code. If you're stuck there are also plenty of examples to help you get started.</li>
<li><b>Puts accessibility first</b>. Although Coffeescript is beautiful, and Angular is smart, Semantic has a different agenda: to be easy to use, and opinionless. Semantic can be thought of more as the <a href="http://en.wikipedia.org/wiki/Aaron_Copland">Aaron Copland</a> of programming libraries. It only requires an understanding of jQuery and Javascript to begin writing code. If you're stuck there are also <a href="#">plenty of examples</a> to help you get started.</li>
<li><b>Is self documenting.</b> Instead of reading through inline comments to determine what a developer is intending, semantic allows developers to pass meaningful debug data where its most useful: the javascript console. This allows you to see the sequence of events that occur in a module , along with useful debug information, like the value of significant variables. If you're in the source code, debug statements also read similarly to code comments which provide context. <a href="#">Show me</a>
<li><b>Designed to separate the arbitrary bits from the core logic of your module.</b> Ever scroll through an unfimiliar library looking for the line of code where they define the ID tag for an expected html structure? Semantic keeps you from ever having to do that again. Developer decisions like metadata, classnames, selectors, and messages are separated from the less arbitrary parts of code. <a href="#">Show me</a> </li>
<li><b>Lets you access anything, and change everything.</b> Methods defined as part of module definitions are all invokable. Semantic also maps from dot notation to their appropriate locations inside the module, allowing developers not to only make flat modules. Settings can be changed at initialization, or after. Module defaults can be changed whenever. <a href="#">Show me</a></li>
@ -73,17 +86,53 @@
<li><b>Patterns for every need</b>. Semantic has patterns that work well both as a widget factory, and as a single entity.</li>
</ol>
<h2>How to write a module</h2>
<div class="big ui button">View Annotated Source</div>
<ol>
<li>Select the most appropriate design pattern.</li>
<li>Define a settings object.</li>
<li>Define a selector cache.</li>
<li>Add an object literal defining invokable methods for your plugin</li>
<li>You're done!</li>
</ol>
<h3>You really like to talk. Lets see some code</h3>
<p>For a complete definition of the specification check to annotated source:</p>
<div class="ui blue buttons">
<div class="ui button">Single Instance / Behavioral </div>
<div class="ui button">Many Instances</div>
</div>
<a name="library"></a>
<h2>The Libraries</h2>
<p>To semantic library is a set of UI elements and javascript modules that provides an example implementation of the Semantic standard. The purpose is to be useful in their own right for developers, but also to provide a guide for how the standard can be used.</p>
<h3>The UI Library</h3>
<ul class="list">
<li><a href="button.html">Buttons</a></li>
<li><a>Text</a></li>
<li><a>Headers</a></li>
<li><a>Columns</a></li>
<li><a>Elements (Grid System)</a></li>
<li><a>Tags</a></li>
<li><a>Items (Lists of Content)</a></li>
<li><a>Panels (Type of Menu)</a></li>
<li><a>Forms</a></li>
<li><a>Fields</a></li>
<li><a>Checkboxes</a></li>
<li><a>Icons</a></li>
<li><a>Dividers</a></li>
</ul>
<p>The aim is to release pieces of the library on a schedule over the course of the next few months.</p><a class="big ui button">UI Release Calendar</a>
<h3>The module library</h3>
<p>Javascript modules.</p>
<ul class="list">
<li>Accordion</li>
<li>API</li>
<li>Animation</li>
<li>Chat Room</li>
<li>Form Validation</li>
<li>Placeholder Text</li>
<li>Modal</li>
<li>Nag</li>
<li>Popup</li>
<li>Search</li>
<li>Star Rating</li>
<li>Shape</li>
<li>State</li>
<li>Tabs</li>
</ul>
</div>
</body>

2
examples/ui/button.css

@ -315,7 +315,7 @@
.ui.toggle.buttons .button.active,
.ui.buttons .button.toggle.active,
.ui.button.toggle.active {
background-color: #BBF0A9;
}
.ui.buttons.toggle .ui.button.active.hover,
.ui.buttons .ui.button.toggle.active.hover,

2
src/shape.css

@ -48,7 +48,7 @@
z-index: 100;
}
.shape.module .hidden.side {
opacity: 0.5;
opacity: 0.7;
}
/* css animation */

164
src/shape.js

@ -80,47 +80,58 @@ $.fn.shape = function(parameters) {
},
animate: function(propertyObject, callback) {
module.verbose('Animating box with properties', propertyObject);
callback = callback || function() {
module.reset();
module.set.active();
$.proxy(settings.onChange, $nextSide)();
};
if(settings.useCSS || 1) {
module.verbose('Using CSS transitions to animate');
$module
.addClass(className.animating)
;
module.set.stageSize();
module.repaint();
$module
.addClass(className.css)
;
$activeSide
.addClass(className.hidden)
;
if( $module.hasClass(className.animating) ) {
module.debug('Animation in progress, queing animation');
$shape
.css(propertyObject)
.one(endTransition, callback)
.one(endTransition, function() {
console.verbose('Executing queued animation');
module.animate(propertyObject, callback);
})
;
}
else {
// not yet supported until .animate() is extended to allow RotateX/Y
module.verbose('Using javascript to animate');
$module
.addClass(className.animating)
.removeClass(className.css)
;
module.set.stageSize();
module.repaint();
$activeSide
.animate({
opacity: 0
}, settings.duration, settings.easing)
;
$shape
.animate(propertyObject, settings.duration, settings.easing, callback)
;
module.verbose('Animating box with properties', propertyObject);
callback = callback || function() {
module.reset();
module.set.active();
$.proxy(settings.onChange, $nextSide)();
};
if(settings.useCSS || 1) {
module.verbose('Using CSS transitions to animate');
$module
.addClass(className.animating)
;
module.set.stageSize();
module.repaint();
$module
.addClass(className.css)
;
$activeSide
.addClass(className.hidden)
;
$shape
.css(propertyObject)
.one(endTransition, callback)
;
}
else {
// not yet supported until .animate() is extended to allow RotateX/Y
module.verbose('Using javascript to animate');
$module
.addClass(className.animating)
.removeClass(className.css)
;
module.set.stageSize();
module.repaint();
$activeSide
.animate({
opacity: 0
}, settings.duration, settings.easing)
;
$shape
.animate(propertyObject, settings.duration, settings.easing, callback)
;
}
}
},
@ -201,10 +212,44 @@ $.fn.shape = function(parameters) {
;
module.set.defaultSide();
}
},
flip: {
up: function() {
module.debug('Flipping up', $nextSide);
module.stage.above();
module.animate( module.getTransform.up() );
},
down: function() {
module.debug('Flipping down', $nextSide);
module.stage.below();
module.animate( module.getTransform.down() );
},
left: function() {
module.debug('Flipping left', $nextSide);
module.stage.left();
module.animate(module.getTransform.left() );
},
right: function() {
module.debug('Flipping right', $nextSide);
module.stage.right();
module.animate(module.getTransform.right() );
},
over: function() {
module.debug('Flipping over', $nextSide);
module.stage.behind();
module.animate(module.getTransform.behind() );
}
},
getTransform: {
up: function() {
var
translate = {
@ -216,6 +261,7 @@ $.fn.shape = function(parameters) {
transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(-90deg)'
};
},
down: function() {
var
translate = {
@ -227,6 +273,7 @@ $.fn.shape = function(parameters) {
transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(90deg)'
};
},
left: function() {
var
translate = {
@ -238,6 +285,7 @@ $.fn.shape = function(parameters) {
transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(90deg)'
};
},
right: function() {
var
translate = {
@ -249,6 +297,7 @@ $.fn.shape = function(parameters) {
transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(-90deg)'
};
},
behind: function() {
var
translate = {
@ -259,9 +308,11 @@ $.fn.shape = function(parameters) {
transform: 'translateX(' + translate.x + 'px) rotateY(180deg)'
};
}
},
stage: {
above: function() {
var
box = {
@ -287,6 +338,7 @@ $.fn.shape = function(parameters) {
})
;
},
below: function() {
var
box = {
@ -312,6 +364,7 @@ $.fn.shape = function(parameters) {
})
;
},
left: function() {
var
box = {
@ -337,6 +390,7 @@ $.fn.shape = function(parameters) {
})
;
},
right: function() {
var
box = {
@ -362,6 +416,7 @@ $.fn.shape = function(parameters) {
})
;
},
behind: function() {
var
box = {
@ -389,37 +444,6 @@ $.fn.shape = function(parameters) {
}
},
flip: {
up: function() {
module.debug('Flipping up', $nextSide);
module.stage.above();
module.animate( module.getTransform.up() );
},
down: function() {
module.debug('Flipping down', $nextSide);
module.stage.below();
module.animate( module.getTransform.down() );
},
left: function() {
module.debug('Flipping left', $nextSide);
module.stage.left();
module.animate(module.getTransform.left() );
},
right: function() {
module.debug('Flipping right', $nextSide);
module.stage.right();
module.animate(module.getTransform.right() );
},
over: function() {
module.debug('Flipping over', $nextSide);
module.stage.behind();
module.animate(module.getTransform.behind() );
}
},
/* standard module */
setting: function(name, value) {
if( $.isPlainObject(name) ) {
@ -432,11 +456,13 @@ $.fn.shape = function(parameters) {
settings[name] = value;
}
},
verbose: function() {
if(settings.verbose) {
module.debug.apply(this, arguments);
}
},
debug: function() {
var
output = [],
@ -450,6 +476,7 @@ $.fn.shape = function(parameters) {
log.apply(console, output.concat(variables) );
}
},
error: function() {
var
output = [],
@ -464,6 +491,7 @@ $.fn.shape = function(parameters) {
log.apply(console, output.concat(variables) );
}
},
invoke: function(query, context, passedArguments) {
var
maxDepth,

Loading…
Cancel
Save