Skip to content

Commit

Permalink
New button classes and full width modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Yeshtukova committed Feb 23, 2021
1 parent 37efd8e commit 7cc329f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/components/button/_button-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{else}}
type="button"
{{/if}}
class="nsw-button nsw-button--{{style}}"
class="nsw-button nsw-button--{{style}}{{#if isFullWidth}} nsw-button--full-width{{/if}}"
{{#if isDisabled}}disabled{{/if}}
value="{{text}}"
>
2 changes: 1 addition & 1 deletion src/components/button/_button-link.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<a href="{{url}}" class="nsw-button nsw-button--{{style}}">
<a href="{{url}}" class="nsw-button nsw-button--{{style}}{{#if isFullWidth}} nsw-button--full-width{{/if}}">
{{text}}
</a>
2 changes: 1 addition & 1 deletion src/components/button/_button.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{else}}
type="button"
{{/if}}
class="nsw-button nsw-button--{{style}}"
class="nsw-button nsw-button--{{style}}{{#if isFullWidth}} nsw-button--full-width{{/if}}"
{{#if isDisabled}}disabled{{/if}}>
{{text}}
</button>
10 changes: 10 additions & 0 deletions src/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@
margin-bottom: 0;
}
}

.nsw-button--full-width {
display: block;
width: 100%;

@include breakpoint($desktop-breakpoint) {
display: inline-block;
width: auto;
}
}
45 changes: 28 additions & 17 deletions src/components/button/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ title: Buttons
{{>_button-input type="reset" style="primary" text="Input Reset"}}
</div>
<div class="nsw-col">
<h2 class="nsw-section-title">Highlight</h2>
{{>_button-link url="#" style="highlight" text="Link"}}
{{>_button type="button" style="highlight" text="Button"}}
{{>_button type="submit" style="highlight" text="Submit Button"}}
{{>_button type="reset" style="highlight" text="Reset Button"}}
{{>_button-input type="button" style="highlight" text="Input"}}
{{>_button-input type="submit" style="highlight" text="Input Submit"}}
{{>_button-input type="reset" style="highlight" text="Input Reset"}}
<h2 class="nsw-section-title">Secondary</h2>
{{>_button-link url="#" style="secondary" text="Link"}}
{{>_button type="button" style="secondary" text="Button"}}
{{>_button type="submit" style="secondary" text="Submit Button"}}
{{>_button type="reset" style="secondary" text="Reset Button"}}
{{>_button-input type="button" style="secondary" text="Input"}}
{{>_button-input type="submit" style="secondary" text="Input Submit"}}
{{>_button-input type="reset" style="secondary" text="Input Reset"}}
</div>
<div class="nsw-col">
<h2 class="nsw-section-title">Outline</h2>
{{>_button-link url="#" style="outline" text="Link"}}
{{>_button type="button" style="outline" text="Button"}}
{{>_button type="submit" style="outline" text="Submit Button"}}
{{>_button type="reset" style="outline" text="Reset Button"}}
{{>_button-input type="button" style="outline" text="Input"}}
{{>_button-input type="submit" style="outline" text="Input Submit"}}
{{>_button-input type="reset" style="outline" text="Input Reset"}}
<h2 class="nsw-section-title">Danger</h2>
{{>_button-link url="#" style="danger" text="Link"}}
{{>_button type="button" style="danger" text="Button"}}
{{>_button type="submit" style="danger" text="Submit Button"}}
{{>_button type="reset" style="danger" text="Reset Button"}}
{{>_button-input type="button" style="danger" text="Input"}}
{{>_button-input type="submit" style="danger" text="Input Submit"}}
{{>_button-input type="reset" style="danger" text="Input Reset"}}
</div>
</div>
</div>
Expand Down Expand Up @@ -70,14 +70,25 @@ title: Buttons
<div class="nsw-grid">
<div class="nsw-col">
<h2 class="nsw-section-title">Disabled</h2>
<p><strong>Note:</strong> Its not possible to disable links, a class of .disable should only be applied to buttons and inputs</p>
<p><strong>Note:</strong> It is not possible to disable links, therefore attribute "disabled" should only be applied to buttons and inputs.</p>
{{>_button type="button" style="primary" text="Button" isDisabled=true}}
{{>_button type="submit" style="primary" text="Submit Button" isDisabled=true}}
{{>_button type="reset" style="primary" text="Reset Button" isDisabled=true}}
{{>_button-input type="button" style="primary" text="Input" isDisabled=true}}
{{>_button-input type="submit" style="primary" text="Input Submit" isDisabled=true}}
{{>_button-input type="reset" style="primary" text="Input Reset" isDisabled=true}}
</div>
<div class="nsw-col">
<h2 class="nsw-section-title">Full width</h2>
<p><strong>Note:</strong> Full width buttons will stretch to 100% on mobile but will revert back to usual behaviour on desktop.</p>
{{>_button-link url="#" style="primary" text="Link" isFullWidth=true}}
{{>_button type="button" style="primary" text="Button" isFullWidth=true}}
{{>_button type="submit" style="primary" text="Submit Button" isFullWidth=true}}
{{>_button type="reset" style="primary" text="Reset Button" isFullWidth=true}}
{{>_button-input type="button" style="primary" text="Input" isFullWidth=true}}
{{>_button-input type="submit" style="primary" text="Input Submit" isFullWidth=true}}
{{>_button-input type="reset" style="primary" text="Input Reset" isFullWidth=true}}
</div>
</div>
</div>
</div>
Expand Down
27 changes: 22 additions & 5 deletions src/global/scss/settings/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ $light10: #f4f4f7 !default;
$white: #ffffff !default;

// Utility colors
$danger: #d7153a !default;
$info: $nsw-secondary-blue !default;
$info-background: #eaedf4 !default;
$success: #00a908 !default;
Expand Down Expand Up @@ -246,13 +247,21 @@ $button-variations: (
border: $nsw-primary-blue,
border-hover: lighten($nsw-primary-blue, 5.88)
),
highlight: (
secondary: (
text-color: $dark80,
text-color-hover: $white,
background: $white,
background-hover: $nsw-primary-blue,
border: $nsw-primary-blue,
border-hover: $nsw-primary-blue
),
danger: (
text-color: $white,
text-color-hover: $white,
background: $nsw-primary-highlight,
background-hover: lighten($nsw-primary-highlight, 5.88),
border: $nsw-primary-highlight,
border-hover: lighten($nsw-primary-highlight, 5.88)
background: $danger,
background-hover: lighten($danger, 5.88),
border: $danger,
border-hover: lighten($danger, 5.88)
),
outline: (
text-color: $dark80,
Expand All @@ -262,6 +271,14 @@ $button-variations: (
border: $nsw-primary-blue,
border-hover: $nsw-primary-blue
),
highlight: (
text-color: $white,
text-color-hover: $white,
background: $nsw-primary-highlight,
background-hover: lighten($nsw-primary-highlight, 5.88),
border: $nsw-primary-highlight,
border-hover: lighten($nsw-primary-highlight, 5.88)
),
white: (
text-color: $dark80,
text-color-hover: $dark80,
Expand Down

0 comments on commit 7cc329f

Please sign in to comment.