0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Merge pull request #93 from TryGhost/GUI2-buttons

Gui2 buttons
This commit is contained in:
John O'Nolan 2014-08-04 18:57:19 +02:00
commit 5c135fd88d
6 changed files with 546 additions and 192 deletions

View file

@ -0,0 +1,155 @@
//
// Base Splitbutton
// --------------------------------------------------
%splitbtn {
display: inline-block;
position: relative;
font-size: 0; // hack to stop space after button
white-space: nowrap;
button {
font-size: 11px; // hack to restore font size
@include border-right-radius(0);
}
// This is the additional dropdown arrow, to the right of the button.
.options {
display: inline-block;
position:relative;
width: 35px;
height: 35px;
margin-left: -1px;
vertical-align: top;
text-align: center;
color: #fff;
background: #e5e5e5;
border-radius: 0 2px 2px 0;
border-left: 0;
box-shadow:
rgba(0,0,0,0.02) 0 1px 0 inset,
rgba(0,0,0,0.02) -1px 0 0 inset,
rgba(0,0,0,0.02) 0 -1px 0 inset;
@include icon($i-chevron-down, 9px) {
position: absolute;
top: 50%;
right: 50%;
margin-top: -3px;
margin-right: -5px;
@include transition(margin-top 0.3s ease);
/* Transition of transform properties are split out due to a
defect in the vendor prefixing of transform transitions.
See: http://github.com/thoughtbot/bourbon/pull/86 */
@include transition-property(transform);
@include transition-duration(0.3);
@include transition-timing-function(ease);
};
@include transition(background-color 0.3s linear);
// Keep the arrow spun when the associated menu is open
&.active:before {
@include transform(rotate(360deg));
}
&.up.active:before {
margin-top:-4px;
@include transform(rotate(540deg));
}
// Spin the arrow on hover and while menu is open
&:hover,
&:focus {
will-change: box-shadow, background;
box-shadow: none;
background: #f8f8f8;
@include icon($i-chevron-down) {
will-change: transform;
@include transform(rotate(360deg));
};
}
// If it has a class of "up" spin it an extra 180degress to point up
&.up:hover,
&.up:focus {
@include icon($i-chevron-down) {
margin-top:-4px;
@include transform(rotate(540deg));
@include transition-property(transform);
@include transition-duration(0.6);
@include transition-timing-function(ease);
};
}
}
}
//
// The Splitbuttons
// --------------------------------------------------
// The default splitbutton
.splitbutton {
@extend %splitbtn;
.options {
color:#777;
&:hover,
&:focus {
box-shadow:
rgba(0,0,0,0.07) 0 1px 0 inset,
rgba(0,0,0,0.07) -1px 0 0 inset,
rgba(0,0,0,0.07) 0 -1px 0 inset;
}
}
}
// For save/next/continue/confirm actions
.splitbutton-save {
@extend %splitbtn;
.options {
background: darken($blue, 5%);
&:hover,
&.active,
&:focus {
background: darken($blue, 10%);
}
}
}
// For actions which add something
.splitbutton-add {
@extend %splitbtn;
.options {
background: darken($green, 6%);
&:hover,
&:focus {
background: darken($green, 8%);
}
}
}
// For actions which delete something
.splitbutton-delete {
@extend %splitbtn;
.options {
background: darken($red, 6%);
&:hover,
&:focus {
background: darken($red, 10%);
}
}
}
// Alternative style with more visual attention,
// but no extra semantic meaning
.splitbutton-alt {
@extend %splitbtn;
.options {
background: lighten($darkgrey, 4%);
&:hover,
&:focus {
background: $darkgrey;
}
}
}

View file

@ -4,4 +4,24 @@
@mixin baseline {
margin: 1.6em 0;
}
}
// User select
// For selecting text on the page
@mixin user-select($select) {
-webkit-user-select: $select;
-moz-user-select: $select;
-ms-user-select: $select; // IE10+
user-select: $select;
}
// WebKit-style focus
@mixin tab-focus() {
// Default
outline: thin dotted;
// WebKit
outline: 0px auto -webkit-focus-ring-color;
outline-offset: -2px;
}

View file

@ -32,7 +32,7 @@ $list-colours:
// Styles
// --------------------------------------------------
$rounded: 2px;
$rounded: 3px;
$shadow: rgba(0,0,0,0.05) 0 1px 5px;
$default-transition-duration: 0.3s;

View file

@ -1,15 +1,201 @@
//
// Button Reset
// Buttons
// --------------------------------------------------
button {
border: 0;
padding: 0;
background: transparent;
@include transition(all 0.15s ease-in-out);
// Base styles
// --------------------------------------------------
.btn {
display: inline-block;
margin-bottom: 0; // For input.btn
padding: 6px 12px;
font-size: 1.4rem;
line-height: 1.428571429;
font-weight: normal;
text-align: center;
vertical-align: middle;
cursor: pointer;
background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
border: 1px solid transparent;
white-space: nowrap;
border-radius: $rounded;
@include user-select(none);
&,
&:active,
&.active {
&:focus {
@include tab-focus();
}
}
&:hover,
&:focus {
color: $blue;
text-decoration: none;
}
&:active,
&.active {
outline: 0;
background-image: none;
box-shadow: inset 0 2px 2px rgba(0,0,0,.125);
}
&.disabled,
&[disabled],
fieldset[disabled] & {
cursor: not-allowed;
pointer-events: none; // Future-proof disabling of clicks
opacity: 0.65;
box-shadow: none;
}
}
// Alternate buttons
// --------------------------------------------------
@mixin button-style($color, $background, $border) {
color: $color;
background-color: $background;
border-color: $border;
&:hover,
&:focus,
&:active,
&.active,
.open > &.dropdown-toggle {
color: $color;
background-color: darken($background, 10%);
border-color: darken($border, 12%);
}
&:active,
&.active,
.open > &.dropdown-toggle {
background-image: none;
}
&.disabled,
&[disabled],
fieldset[disabled] & {
&,
&:hover,
&:focus,
&:active,
&.active {
background-color: $background;
border-color: $border;
}
}
.badge {
color: $background;
background-color: $color;
}
}
.btn-default {
@include button-style($darkgrey, #fff, lighten($midgrey, 30%));
}
.btn-primary {
@include button-style(#fff, $blue, darken($blue, 5%));
}
// Success appears as green
.btn-success {
@include button-style(#fff, $green, darken($green, 5%));
}
// Danger and error appear as red
.btn-danger {
@include button-style(#fff, $red, darken($red, 5%));
}
// Link buttons
// -------------------------
// Make a button look and behave like a link
.btn-link {
color: $blue;
font-weight: normal;
cursor: pointer;
border-radius: 0;
&,
&:active,
&[disabled],
fieldset[disabled] & {
background-color: transparent;
box-shadow: none;
}
&,
&:hover,
&:focus,
&:active {
border-color: transparent;
}
&:hover,
&:focus {
text-decoration: underline;
background-color: transparent;
}
&[disabled],
fieldset[disabled] & {
&:hover,
&:focus {
color: $midgrey;
text-decoration: none;
}
}
}
// Button Sizes
// --------------------------------------------------
.btn-lg {
padding: 10px 16px;
font-size: 1.8rem;
line-height: 1.33;
border-radius: 4px;
}
.btn-sm {
padding: 5px 10px;
font-size: 1.2rem;
line-height: 1.5;
border-radius: 2px;
}
// Block button
// --------------------------------------------------
.btn-block {
display: block;
width: 100%;
}
// Vertically space out multiple block buttons
.btn-block + .btn-block {
margin-top: 5px;
}
// Specificity overrides
input[type="submit"],
input[type="reset"],
input[type="button"] {
&.btn-block {
width: 100%;
}
}
// --------------------------------------------------
//
// TODO: These are the old styles to be removed.
//
// --------------------------------------------------
//
// Base Button
// --------------------------------------------------
@ -179,20 +365,6 @@ button {
}
}
// Alternative button with more visual attention,
// but no extra semantic meaning
.button-alt {
@extend %btn;
background: lighten($darkgrey, 10%);
&:hover,
&:focus {
background: $darkgrey;
}
&[class*='icon-']:before {
border-right-color: lighten($darkgrey, 10%);
}
}
// Alternative button with more visual attention, but no extra semantic meaning
.button-info {
@extend %btn;
@ -203,19 +375,6 @@ button {
}
}
// This applies normal link styles to de-emphasise a button
.button-link {
@extend %btn;
color: $blue;
background: transparent;
border: none;
&:hover,
&:focus {
background: transparent;
text-decoration: underline;
}
}
// Back button for pane animations
.button-back {
@extend %btn;
@ -255,161 +414,4 @@ button {
}
}
}
//
// Base Splitbutton
// --------------------------------------------------
%splitbtn {
display: inline-block;
position: relative;
font-size: 0; // hack to stop space after button
white-space: nowrap;
button {
font-size: 11px; // hack to restore font size
@include border-right-radius(0);
}
// This is the additional dropdown arrow, to the right of the button.
.options {
display: inline-block;
position:relative;
width: 35px;
height: 35px;
margin-left: -1px;
vertical-align: top;
text-align: center;
color: #fff;
background: #e5e5e5;
border-radius: 0 2px 2px 0;
border-left: 0;
box-shadow:
rgba(0,0,0,0.02) 0 1px 0 inset,
rgba(0,0,0,0.02) -1px 0 0 inset,
rgba(0,0,0,0.02) 0 -1px 0 inset;
@include icon($i-chevron-down, 9px) {
position: absolute;
top: 50%;
right: 50%;
margin-top: -3px;
margin-right: -5px;
@include transition(margin-top 0.3s ease);
/* Transition of transform properties are split out due to a
defect in the vendor prefixing of transform transitions.
See: http://github.com/thoughtbot/bourbon/pull/86 */
@include transition-property(transform);
@include transition-duration(0.3);
@include transition-timing-function(ease);
};
@include transition(background-color 0.3s linear);
// Keep the arrow spun when the associated menu is open
&.active:before {
@include transform(rotate(360deg));
}
&.up.active:before {
margin-top:-4px;
@include transform(rotate(540deg));
}
// Spin the arrow on hover and while menu is open
&:hover,
&:focus {
will-change: box-shadow, background;
box-shadow: none;
background: #f8f8f8;
@include icon($i-chevron-down) {
will-change: transform;
@include transform(rotate(360deg));
};
}
// If it has a class of "up" spin it an extra 180degress to point up
&.up:hover,
&.up:focus {
@include icon($i-chevron-down) {
margin-top:-4px;
@include transform(rotate(540deg));
@include transition-property(transform);
@include transition-duration(0.6);
@include transition-timing-function(ease);
};
}
}
}
//
// The Splitbuttons
// --------------------------------------------------
// The default splitbutton
.splitbutton {
@extend %splitbtn;
.options {
color:#777;
&:hover,
&:focus {
box-shadow:
rgba(0,0,0,0.07) 0 1px 0 inset,
rgba(0,0,0,0.07) -1px 0 0 inset,
rgba(0,0,0,0.07) 0 -1px 0 inset;
}
}
}
// For save/next/continue/confirm actions
.splitbutton-save {
@extend %splitbtn;
.options {
background: darken($blue, 5%);
&:hover,
&.active,
&:focus {
background: darken($blue, 10%);
}
}
}
// For actions which add something
.splitbutton-add {
@extend %splitbtn;
.options {
background: darken($green, 6%);
&:hover,
&:focus {
background: darken($green, 8%);
}
}
}
// For actions which delete something
.splitbutton-delete {
@extend %splitbtn;
.options {
background: darken($red, 6%);
&:hover,
&:focus {
background: darken($red, 10%);
}
}
}
// Alternative style with more visual attention,
// but no extra semantic meaning
.splitbutton-alt {
@extend %splitbtn;
.options {
background: lighten($darkgrey, 4%);
&:hover,
&:focus {
background: $darkgrey;
}
}
}

View file

@ -37,6 +37,7 @@
@import "components/modals";
@import "components/notifications";
@import "components/uploader";
@import "components/splitbuttons";
@import "components/dropdowns";

View file

@ -0,0 +1,176 @@
---
layout: default
title: Ghost UI · Making publishing beautiful.
---
<header class="page-header">
<a class="menu-button" href="#"><span class="sr-only">Menu</span></a>
<h2>Home</h2>
</header>
<section class="page-content">
<div class="bs-docs-section">
<h1 id="buttons">Buttons</h1>
<h2 id="buttons-options">Options</h2>
<p>Use any of the available button classes to quickly create a styled button.</p>
<div class="bs-example">
<button type="button" class="btn btn-default">Default</button>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-link">Link</button>
</div>
{% highlight html %}
<!-- Standard button -->
<button type="button" class="btn btn-default">Default</button>
<!-- Provides extra visual weight and identifies the primary action in a set of buttons -->
<button type="button" class="btn btn-primary">Primary</button>
<!-- Indicates a successful or positive action -->
<button type="button" class="btn btn-success">Success</button>
<!-- Indicates a dangerous or potentially negative action -->
<button type="button" class="btn btn-danger">Danger</button>
<!-- Deemphasize a button by making it look like a link while maintaining button behavior -->
<button type="button" class="btn btn-link">Link</button>
{% endhighlight %}
<h2 id="buttons-sizes">Sizes</h2>
<p>Fancy larger or smaller buttons? Add <code>.btn-lg</code>, <code>.btn-sm</code>, or <code>.btn-xs</code> for additional sizes.</p>
<div class="bs-example">
<p>
<button type="button" class="btn btn-primary btn-lg">Large button</button>
<button type="button" class="btn btn-default btn-lg">Large button</button>
</p>
<p>
<button type="button" class="btn btn-primary">Default button</button>
<button type="button" class="btn btn-default">Default button</button>
</p>
<p>
<button type="button" class="btn btn-primary btn-sm">Small button</button>
<button type="button" class="btn btn-default btn-sm">Small button</button>
</p>
</div>
{% highlight html %}
<p>
<button type="button" class="btn btn-primary btn-lg">Large button</button>
<button type="button" class="btn btn-default btn-lg">Large button</button>
</p>
<p>
<button type="button" class="btn btn-primary">Default button</button>
<button type="button" class="btn btn-default">Default button</button>
</p>
<p>
<button type="button" class="btn btn-primary btn-sm">Small button</button>
<button type="button" class="btn btn-default btn-sm">Small button</button>
</p>
{% endhighlight %}
<p>Create block level buttons&mdash;those that span the full width of a parent&mdash; by adding <code>.btn-block</code>.</p>
<div class="bs-example">
<div class="well" style="max-width: 400px; margin: 0 auto 10px;">
<button type="button" class="btn btn-primary btn-lg btn-block">Block level button</button>
<button type="button" class="btn btn-default btn-lg btn-block">Block level button</button>
</div>
</div>
{% highlight html %}
<button type="button" class="btn btn-primary btn-lg btn-block">Block level button</button>
<button type="button" class="btn btn-default btn-lg btn-block">Block level button</button>
{% endhighlight %}
<h2 id="buttons-active">Active state</h2>
<p>Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. For <code>&lt;button&gt;</code> elements, this is done via <code>:active</code>. For <code>&lt;a&gt;</code> elements, it's done with <code>.active</code>. However, you may use <code>.active</code> on <code>&lt;button&gt;</code>s should you need to replicate the active state programmatically.</p>
<h3>Button element</h3>
<p>No need to add <code>:active</code> as it's a pseudo-class, but if you need to force the same appearance, go ahead and add <code>.active</code>.</p>
<p class="bs-example">
<button type="button" class="btn btn-primary btn-lg active">Primary button</button>
<button type="button" class="btn btn-default btn-lg active">Button</button>
</p>
{% highlight html %}
<button type="button" class="btn btn-primary btn-lg active">Primary button</button>
<button type="button" class="btn btn-default btn-lg active">Button</button>
{% endhighlight %}
<h3>Anchor element</h3>
<p>Add the <code>.active</code> class to <code>&lt;a&gt;</code> buttons.</p>
<p class="bs-example">
<a href="#" class="btn btn-primary btn-lg active" role="button">Primary link</a>
<a href="#" class="btn btn-default btn-lg active" role="button">Link</a>
</p>
{% highlight html %}
<a href="#" class="btn btn-primary btn-lg active" role="button">Primary link</a>
<a href="#" class="btn btn-default btn-lg active" role="button">Link</a>
{% endhighlight %}
<h2 id="buttons-disabled">Disabled state</h2>
<p>Make buttons look unclickable by fading them back 50%.</p>
<h3>Button element</h3>
<p>Add the <code>disabled</code> attribute to <code>&lt;button&gt;</code> buttons.</p>
<p class="bs-example">
<button type="button" class="btn btn-primary btn-lg" disabled="disabled">Primary button</button>
<button type="button" class="btn btn-default btn-lg" disabled="disabled">Button</button>
</p>
{% highlight html %}
<button type="button" class="btn btn-lg btn-primary" disabled="disabled">Primary button</button>
<button type="button" class="btn btn-default btn-lg" disabled="disabled">Button</button>
{% endhighlight %}
<div class="bs-callout bs-callout-danger">
<h4>Cross-browser compatibility</h4>
<p>If you add the <code>disabled</code> attribute to a <code>&lt;button&gt;</code>, Internet Explorer 9 and below will render text gray with a nasty text-shadow that we cannot fix.</p>
</div>
<h3>Anchor element</h3>
<p>Add the <code>.disabled</code> class to <code>&lt;a&gt;</code> buttons.</p>
<p class="bs-example">
<a href="#" class="btn btn-primary btn-lg disabled" role="button">Primary link</a>
<a href="#" class="btn btn-default btn-lg disabled" role="button">Link</a>
</p>
{% highlight html %}
<a href="#" class="btn btn-primary btn-lg disabled" role="button">Primary link</a>
<a href="#" class="btn btn-default btn-lg disabled" role="button">Link</a>
{% endhighlight %}
<p>
We use <code>.disabled</code> as a utility class here, similar to the common <code>.active</code> class, so no prefix is required.
</p>
<div class="bs-callout bs-callout-warning">
<h4>Link functionality caveat</h4>
<p>This class uses <code>pointer-events: none</code> to try to disable the link functionality of <code>&lt;a&gt;</code>s, but that CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11. So to be safe, use custom JavaScript to disable such links.</p>
</div>
<div class="bs-callout bs-callout-warning">
<h4>Context-specific usage</h4>
<p>While button classes can be used on <code>&lt;a&gt;</code> and <code>&lt;button&gt;</code> elements, only <code>&lt;button&gt;</code> elements are supported within our nav and navbar components.</p>
</div>
<h2 id="buttons-tags">Button tags</h2>
<p>Use the button classes on an <code>&lt;a&gt;</code>, <code>&lt;button&gt;</code>, or <code>&lt;input&gt;</code> element.</p>
<form class="bs-example">
<a class="btn btn-default" href="#" role="button">Link</a>
<button class="btn btn-default" type="submit">Button</button>
<input class="btn btn-default" type="button" value="Input">
<input class="btn btn-default" type="submit" value="Submit">
</form>
{% highlight html %}
<a class="btn btn-default" href="#" role="button">Link</a>
<button class="btn btn-default" type="submit">Button</button>
<input class="btn btn-default" type="button" value="Input">
<input class="btn btn-default" type="submit" value="Submit">
{% endhighlight %}
<div class="bs-callout bs-callout-warning">
<h4>Cross-browser rendering</h4>
<p>As a best practice, <strong>we highly recommend using the <code>&lt;button&gt;</code> element whenever possible</strong> to ensure matching cross-browser rendering.</p>
<p>Among other things, there's <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=697451">a bug in Firefox &lt;30</a> that prevents us from setting the <code>line-height</code> of <code>&lt;input&gt;</code>-based buttons, causing them to not exactly match the height of other buttons on Firefox.</p>
</div>
</div>
</section>