Skip to content

Commit

Permalink
Make link button variants match other buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
LegNeato committed Mar 16, 2016
1 parent 9586e5f commit cc544fa
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 58 deletions.
68 changes: 18 additions & 50 deletions less/components/Button.less
Original file line number Diff line number Diff line change
Expand Up @@ -153,65 +153,33 @@

// Make a button look and behave like a link
.Button--link {
color: @link-color;
font-weight: normal;

&,
&:active,
&.active,
&[disabled],
fieldset[disabled] & {
.box-shadow(none);
background-color: transparent;
}
&,
&:hover,
&:focus,
&:active {
border-color: transparent;
outline: none;
}
&:hover,
&:focus {
background-color: transparent;
color: @link-hover-color;
text-decoration: @link-hover-decoration;
}
.button-link-variant(@link-color; @link-hover-color; @link-hover-decoration);
}
.Button--link-text {
.Button--link();
color: @text-color;

&:hover,
&:focus {
color: @app-primary;
outline: none;
}
// Make a button look and behave like text.
.Button--link-text {
.button-link-variant(@text-color; @app-primary; @link-hover-decoration);
}
.Button--link-cancel {
.Button--link();
color: @gray-light;

&:hover,
&:focus {
color: @app-danger;
outline: none;
}
.Button--link-primary {
.button-link-variant(@app-primary; @app-primary; @link-hover-decoration);
}
.Button--link-success {
.Button--link();
color: @app-success;
.button-link-variant(@app-success; @app-success; @link-hover-decoration);
}
.Button--link-warning {
.button-link-variant(@app-warning; @app-warning; @link-hover-decoration);
}
.Button--link-danger {
.button-link-variant(@app-danger; @app-danger; @link-hover-decoration);
}

&:hover,
&:focus {
color: @app-success;
outline: none;
}
// Some special link button styles.
.Button--link-cancel {
.button-link-variant(@gray-light; @app-danger; @link-hover-decoration);
}
.Button--link-delete {
.Button--link();
color: @gray-light;

.button-link-variant(@gray-light; @app-danger; @link-hover-decoration);
&:hover,
&:focus {
#gradient .vertical(lighten(@app-danger, 4%), darken(@app-danger, 4%));
Expand Down
35 changes: 33 additions & 2 deletions less/mixins/buttons.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Button variants
// ==============================

Expand Down Expand Up @@ -103,4 +103,35 @@
border-color: darken(@border, 20%);
box-shadow: none;
}
}
}



// Link

.button-link-variant(@color; @hover-color; @hover-decoration) {
color: @color;
font-weight: normal;

&,
&:active,
&.active,
&[disabled],
fieldset[disabled] & {
.box-shadow(none);
background-color: transparent;
}
&,
&:hover,
&:focus,
&:active {
border-color: transparent;
outline: none;
}
&:hover,
&:focus {
background-color: transparent;
color: @hover-color;
text-decoration: @hover-decoration;
}
}
17 changes: 11 additions & 6 deletions site/src/pages/Buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const BUTTON_HOLLOW_VARIANTS = [
const BUTTON_LINK_VARIANTS = [
{ label: 'Link', value: 'link' },
{ label: 'Link Text', value: 'link-text' },
{ label: 'Link Primary', value: 'link-primary' },
{ label: 'Link Success', value: 'link-success' },
{ label: 'Link Warning', value: 'link-warning' },
{ label: 'Link Danger', value: 'link-danger' },
{ label: 'Link Cancel', value: 'link-cancel' },
{ label: 'Link Delete', value: 'link-delete' }
];
Expand Down Expand Up @@ -77,6 +81,12 @@ var Buttons = React.createClass({
);
});
},
renderButtonSource(variantType) {
var parts = variantType.map(type => {
return `<Button type="${type.value}">${type.label}</Button>`;
});
return parts.join('\n');
},

render () {
return (
Expand Down Expand Up @@ -146,12 +156,7 @@ var Buttons = React.createClass({
{this.renderButtonVariants(BUTTON_LINK_VARIANTS)}
</div>
<ExampleSource>
{`
<Button type="link">Link</Button>
<Button type="link-text">Link Text</Button>
<Button type="link-cancel">Link Cancel</Button>
<Button type="link-delete">Link Delete</Button>
`}
{this.renderButtonSource(BUTTON_LINK_VARIANTS)}
</ExampleSource>
</div>

Expand Down
4 changes: 4 additions & 0 deletions src/components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const BUTTON_TYPES = [
'danger',
'link',
'link-text',
'link-primary',
'link-success',
'link-warning',
'link-danger',
'link-cancel',
'link-delete',
];
Expand Down

0 comments on commit cc544fa

Please sign in to comment.