diff --git a/core/client/assets/sass/components/splitbuttons.scss b/core/client/assets/sass/components/splitbuttons.scss new file mode 100644 index 0000000000..22fded1697 --- /dev/null +++ b/core/client/assets/sass/components/splitbuttons.scss @@ -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; + } + } +} \ No newline at end of file diff --git a/core/client/assets/sass/helpers/mixins.scss b/core/client/assets/sass/helpers/mixins.scss index 3b6fceb777..332127c410 100644 --- a/core/client/assets/sass/helpers/mixins.scss +++ b/core/client/assets/sass/helpers/mixins.scss @@ -4,4 +4,24 @@ @mixin baseline { margin: 1.6em 0; -} \ No newline at end of file +} + +// 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; +} diff --git a/core/client/assets/sass/helpers/variables.scss b/core/client/assets/sass/helpers/variables.scss index 679dd70ac2..a634fd6454 100644 --- a/core/client/assets/sass/helpers/variables.scss +++ b/core/client/assets/sass/helpers/variables.scss @@ -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; diff --git a/core/client/assets/sass/patterns/buttons.scss b/core/client/assets/sass/patterns/buttons.scss index e12572771d..7053dcac34 100644 --- a/core/client/assets/sass/patterns/buttons.scss +++ b/core/client/assets/sass/patterns/buttons.scss @@ -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; - } - } } \ No newline at end of file diff --git a/core/client/assets/sass/screen.scss b/core/client/assets/sass/screen.scss index 4e5cde25ff..262105af95 100644 --- a/core/client/assets/sass/screen.scss +++ b/core/client/assets/sass/screen.scss @@ -37,6 +37,7 @@ @import "components/modals"; @import "components/notifications"; @import "components/uploader"; +@import "components/splitbuttons"; @import "components/dropdowns"; diff --git a/core/client/docs/buttons.html b/core/client/docs/buttons.html new file mode 100644 index 0000000000..63f6b6f2b4 --- /dev/null +++ b/core/client/docs/buttons.html @@ -0,0 +1,176 @@ +--- +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