Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Get rid of icon prop and adjust examples to showcase how to use icons…
Browse files Browse the repository at this point in the history
… now

Added aria-label example
  • Loading branch information
Lukas Hirt authored and LukasHirt committed Jan 10, 2020
1 parent 824e58e commit 9d715ec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
51 changes: 29 additions & 22 deletions src/elements/OcButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
:disabled="disabled"
@click="onClick"
>
<oc-icon v-if="icon" :class="$_ocButton_iconClass" :name="icon" />
<span v-if="$slots.default">
<slot name="default" />
</span>
<slot name="default" />
</component>
</template>

Expand All @@ -23,6 +20,8 @@
* Defaults to appearance that has white background with grey border.
* Primary style should be used only once per view for main call-to-action.
*
* When using icons inside of the button, assign to the icon small margin to the appropriate side (e. g. `uk-margin-small-right`).
*
* ## Accessibility
* ### Distinction when to use a `<button>`, when to use an `<a>`
*
Expand Down Expand Up @@ -108,13 +107,6 @@ export default {
return value.match(/(null|submit)/)
},
},
/**
* Set the button’s icon to display.
*/
icon: {
type: String,
default: null,
},
/**
* Style variation to give additional meaning.
* `primary, secondary, danger`
Expand All @@ -135,11 +127,6 @@ export default {
},
},
computed: {
$_ocButton_iconClass() {
return this.$slots.default
? "uk-position-small uk-position-center-left"
: "uk-position-center"
},
$_ocButton_buttonClass() {
if (this.stopClassPropagation) return ""
Expand All @@ -151,6 +138,8 @@ export default {
if (this.size) classes.push(`uk-button-${this.size}`)
if (this.size !== "large") classes.push("uk-padding-small")
return classes
},
},
Expand All @@ -176,7 +165,10 @@ export default {
<oc-button @click="onClick">Default Button</oc-button>
<oc-button variation="primary">Primary Button</oc-button>
<oc-button variation="secondary">Secondary Button</oc-button>
<oc-button variation="danger" icon="delete">Danger Button</oc-button>
<oc-button variation="danger">
<oc-icon name="delete" class="uk-margin-small-right" />
Danger Button
</oc-button>
<oc-button disabled>Disabled Button</oc-button>

<h3 class="uk-heading-divider">
Expand All @@ -188,18 +180,33 @@ export default {
<h3 class="uk-heading-divider">
Button with icons
</h3>
<oc-button icon="home">Home</oc-button>
<oc-button variation="primary" icon="save">Save</oc-button>
<oc-button icon="save" disabled>Save disabled</oc-button>
<oc-button variation="primary" icon="cloud_upload" />
<oc-button>
<oc-icon name="home" class="uk-margin-small-right" />
Home
</oc-button>
<oc-button variation="primary">
Select
<oc-icon name="expand_more" class="uk-margin-small-left" />
</oc-button>
<oc-button variation="secondary">
<oc-icon name="save" class="uk-margin-small-right" />
Save to
<oc-icon name="expand_more" class="uk-margin-small-left" />
</oc-button>
<oc-button variation="primary" aria-label="Upload a file">
<oc-icon name="cloud_upload" />
</oc-button>

<h3 class="uk-heading-divider">
Using buttons in a group
</h3>
<div class="uk-button-group">
<oc-button variation="primary">Hello</oc-button>
<oc-button variation="secondary">What's up?</oc-button>
<oc-button icon="folder">Demo Button</oc-button>
<oc-button>
<oc-icon name="folder" class="uk-margin-small-right" />
Demo Button
</oc-button>
</div>
</section>
</template>
Expand Down
10 changes: 5 additions & 5 deletions src/styles/theme/oc-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

.oc-button {
@extend .uk-button;
@extend .uk-position-relative;

.oc-icon + span {
margin-left: $global-margin;
}
@extend .uk-flex-inline;
@extend .uk-flex-wrap;
@extend .uk-flex-middle;
@extend .uk-padding-remove-top;
@extend .uk-padding-remove-bottom;

&:not(.uk-button-small):not(.uk-button-large) {
min-height: $global-control-height;
Expand Down

0 comments on commit 9d715ec

Please sign in to comment.