diff --git a/ghost/admin/assets/sass/patterns/buttons.scss b/ghost/admin/assets/sass/patterns/buttons.scss index e12572771d..30f2cf4a72 100644 --- a/ghost/admin/assets/sass/patterns/buttons.scss +++ b/ghost/admin/assets/sass/patterns/buttons.scss @@ -1,3 +1,162 @@ +// +// Buttons +// -------------------------------------------------- + + +// Base styles +// -------------------------------------------------- + +.btn { + display: inline-block; + margin-bottom: 0; // For input.btn + font-weight: $btn-font-weight; + 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; + @include button-size($padding-base-vertical, $padding-base-horizontal, $font-size-base, $line-height-base, $border-radius-base); + @include user-select(none); + + &, + &:active, + &.active { + &:focus { + @include tab-focus(); + } + } + + &:hover, + &:focus { + color: $btn-default-color; + text-decoration: none; + } + + &:active, + &.active { + outline: 0; + background-image: none; + @include box-shadow(inset 0 3px 5px rgba(0,0,0,.125)); + } + + &.disabled, + &[disabled], + fieldset[disabled] & { + cursor: not-allowed; + pointer-events: none; // Future-proof disabling of clicks + @include opacity(.65); + @include box-shadow(none); + } +} + + +// Alternate buttons +// -------------------------------------------------- + +.btn-default { + @include button-variant($btn-default-color, $btn-default-bg, $btn-default-border); +} +.btn-primary { + @include button-variant($btn-primary-color, $btn-primary-bg, $btn-primary-border); +} +// Success appears as green +.btn-success { + @include button-variant($btn-success-color, $btn-success-bg, $btn-success-border); +} +// Info appears as blue-green +.btn-info { + @include button-variant($btn-info-color, $btn-info-bg, $btn-info-border); +} +// Warning appears as orange +.btn-warning { + @include button-variant($btn-warning-color, $btn-warning-bg, $btn-warning-border); +} +// Danger and error appear as red +.btn-danger { + @include button-variant($btn-danger-color, $btn-danger-bg, $btn-danger-border); +} + + +// Link buttons +// ------------------------- + +// Make a button look and behave like a link +.btn-link { + color: $link-color; + font-weight: normal; + cursor: pointer; + border-radius: 0; + + &, + &:active, + &[disabled], + fieldset[disabled] & { + background-color: transparent; + @include box-shadow(none); + } + &, + &:hover, + &:focus, + &:active { + border-color: transparent; + } + &:hover, + &:focus { + color: $link-hover-color; + text-decoration: underline; + background-color: transparent; + } + &[disabled], + fieldset[disabled] & { + &:hover, + &:focus { + color: $btn-link-disabled-color; + text-decoration: none; + } + } +} + + +// Button Sizes +// -------------------------------------------------- + +.btn-lg { + // line-height: ensure even-numbered height of button next to large input + @include button-size($padding-large-vertical, $padding-large-horizontal, $font-size-large, $line-height-large, $border-radius-large); +} +.btn-sm { + // line-height: ensure proper height of button next to small input + @include button-size($padding-small-vertical, $padding-small-horizontal, $font-size-small, $line-height-small, $border-radius-small); +} +.btn-xs { + @include button-size($padding-xs-vertical, $padding-xs-horizontal, $font-size-small, $line-height-small, $border-radius-small); +} + + +// 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%; + } +} + + // // Button Reset // -------------------------------------------------- diff --git a/ghost/admin/docs/buttons.html b/ghost/admin/docs/buttons.html new file mode 100644 index 0000000000..1c6ad3b569 --- /dev/null +++ b/ghost/admin/docs/buttons.html @@ -0,0 +1,192 @@ +--- +layout: default +title: Ghost UI · Making publishing beautiful. +--- + + + +
+ +
+

Buttons

+ +

Options

+

Use any of the available button classes to quickly create a styled button.

+
+ + + + + + + +
+{% highlight html %} + + + + + + + + + + + + + + + + + + + + +{% endhighlight %} + +

Sizes

+

Fancy larger or smaller buttons? Add .btn-lg, .btn-sm, or .btn-xs for additional sizes.

+
+

+ + +

+

+ + +

+

+ + +

+

+ + +

+
+{% highlight html %} +

+ + +

+

+ + +

+

+ + +

+

+ + +

+{% endhighlight %} + +

Create block level buttons—those that span the full width of a parent— by adding .btn-block.

+
+
+ + +
+
+{% highlight html %} + + +{% endhighlight %} + + +

Active state

+

Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. For <button> elements, this is done via :active. For <a> elements, it's done with .active. However, you may use .active on <button>s should you need to replicate the active state programmatically.

+ +

Button element

+

No need to add :active as it's a pseudo-class, but if you need to force the same appearance, go ahead and add .active.

+

+ + +

+{% highlight html %} + + +{% endhighlight %} + +

Anchor element

+

Add the .active class to <a> buttons.

+

+ Primary link + Link +

+{% highlight html %} +Primary link +Link +{% endhighlight %} + + +

Disabled state

+

Make buttons look unclickable by fading them back 50%.

+ +

Button element

+

Add the disabled attribute to <button> buttons.

+

+ + +

+{% highlight html %} + + +{% endhighlight %} + +
+

Cross-browser compatibility

+

If you add the disabled attribute to a <button>, Internet Explorer 9 and below will render text gray with a nasty text-shadow that we cannot fix.

+
+ +

Anchor element

+

Add the .disabled class to <a> buttons.

+

+ Primary link + Link +

+{% highlight html %} +Primary link +Link +{% endhighlight %} +

+ We use .disabled as a utility class here, similar to the common .active class, so no prefix is required. +

+
+

Link functionality caveat

+

This class uses pointer-events: none to try to disable the link functionality of <a>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.

+
+
+

Context-specific usage

+

While button classes can be used on <a> and <button> elements, only <button> elements are supported within our nav and navbar components.

+
+ + +

Button tags

+

Use the button classes on an <a>, <button>, or <input> element.

+
+ Link + + + +
+{% highlight html %} +Link + + + +{% endhighlight %} + +
+

Cross-browser rendering

+

As a best practice, we highly recommend using the <button> element whenever possible to ensure matching cross-browser rendering.

+

Among other things, there's a bug in Firefox <30 that prevents us from setting the line-height of <input>-based buttons, causing them to not exactly match the height of other buttons on Firefox.

+
+
+ +
\ No newline at end of file