Skip to content

Commit

Permalink
update and cleanup the code
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-daksh committed Oct 8, 2024
1 parent 061d91f commit 16fc781
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions lib/buttons-and-links/KIconButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
text=""
v-on="$listeners"
>
<!-- if no "position" is passed as a prop, defaults to bottom, as previously -->
<UiTooltip
v-if="tooltip"
:zIndex="24"
Expand All @@ -18,12 +19,15 @@
>
{{ tooltip }}
</UiTooltip>
<!-- UiIconButton used flexbox - 7px is the magic centering number -->
<KIcon :icon="icon" :color="color" :style="iconStyles" />
<!-- @slot Pass sub-components into the button, typically `KDropdownMenu` -->
<slot name="menu"></slot>
</KButton>

</template>


<script>
import UiTooltip from '../keen/UiTooltip.vue';
Expand All @@ -32,38 +36,65 @@
name: 'KIconButton',
components: { UiTooltip },
props: {
/**
* Name of icon to display
*/
icon: {
type: String,
required: true,
},
/**
* Button appearance: `'raised-button'` or `'flat-button'`
*/
appearance: {
type: String,
default: 'flat-button',
},
/**
* Optional hex or rgb[a] color for the button background
*/
color: {
type: String,
default: null,
},
/**
* Whether or not button is disabled
*/
disabled: {
type: Boolean,
default: false,
},
/**
* HTML button `type` attribute (e.g. `'submit'`, `'reset'`)
*/
buttonType: {
type: String,
default: 'button',
},
/**
* Button size: `'mini'`, `'small'`, `'regular'`, or `'large'`
*/
size: {
type: String,
default: 'regular',
},
/**
* `aria-label` attribute
*/
ariaLabel: {
type: String,
default: null,
default: null, // https://github.com/learningequality/kolibri-design-system/issues/168
},
/**
* Tooltip label
*/
tooltip: {
type: String,
default: null,
default: null, // https://github.com/learningequality/kolibri-design-system/issues/168
},
/**
* Tooltip position: `'top', 'right', 'bottom', 'left'`
*/
tooltipPosition: {
type: String,
default: 'bottom',
Expand All @@ -75,8 +106,11 @@
this.appearance === 'flat-button' ? { backgroundColor: 'rgba(0,0,0,.1)' } : {};
return {
...this.sizeStyles,
// Circle
borderRadius: '50%',
// Added minWidth to prevent squished/oval effect
minWidth: '32px',
// Remove minHeight & padding
minHeight: '0px',
padding: '0',
':hover': hover,
Expand Down Expand Up @@ -113,4 +147,5 @@
</script>


<style lang="scss" scoped></style>

0 comments on commit 16fc781

Please sign in to comment.