Skip to content

Commit

Permalink
Merge pull request #493 from 3YOURMIND/refactor-kt-button-group
Browse files Browse the repository at this point in the history
refactor(KtButtonGroup): Proper TypeScript Types
  • Loading branch information
FlorianWendelborn committed Sep 9, 2021
2 parents 23bb3c7 + 21f6ab5 commit 057ebd6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 32 deletions.
45 changes: 16 additions & 29 deletions packages/kotti-ui/source/kotti-button-group/KtButtonGroup.vue
@@ -1,49 +1,36 @@
<template>
<div :class="objectClass">
<div class="kt-button-group">
<slot />
</div>
</template>

<script>
export default {
<script lang="ts">
import { defineComponent } from '@vue/composition-api'
import { KottiButtonGroup } from './types'
export default defineComponent<KottiButtonGroup.PropsInternal>({
name: 'KtButtonGroup',
props: {
shadow: Boolean,
},
computed: {
objectClass() {
return {
'button-group': true,
'button-group--shadow': this.shadow,
}
},
},
}
})
</script>

<style lang="scss">
@import '../kotti-style/_variables.scss';
.button-group {
/** Fix for inline element space
https://css-tricks.com/fighting-the-space-between-inline-block-elements/ **/
font-size: 0;
.kt-button-group {
font-size: 0; /* Fix for inline element space https://css-tricks.com/fighting-the-space-between-inline-block-elements/ */
.kt-button {
font-size: $font-size;
border-radius: 0;
}
.kt-button:first-of-type {
border-radius: $border-radius 0 0 $border-radius;
}
.kt-button:last-of-type {
border-radius: 0 $border-radius $border-radius 0;
}
&:first-of-type {
border-radius: $border-radius 0 0 $border-radius;
}
&--shadow {
box-shadow: 0 1px 2px rgba($color: #000000, $alpha: 0.24);
&:last-of-type {
border-radius: 0 $border-radius $border-radius 0;
}
}
}
</style>
4 changes: 3 additions & 1 deletion packages/kotti-ui/source/kotti-button-group/index.ts
Expand Up @@ -9,5 +9,7 @@ export const KtButtonGroup = attachMeta(makeInstallable(KtButtonGroupVue), {
slots: {
default: { description: 'Should contain KtButtons', scope: null },
},
typeScript: null,
typeScript: {
namespace: 'Kotti.ButtonGroup',
},
})
7 changes: 7 additions & 0 deletions packages/kotti-ui/source/kotti-button-group/types.ts
@@ -0,0 +1,7 @@
import { SpecifyRequiredProps } from '../types/utilities'

export namespace KottiButtonGroup {
export type PropsInternal = {}

export type Props = SpecifyRequiredProps<PropsInternal, never>
}
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-comment/KtComment.vue
Expand Up @@ -18,7 +18,7 @@
v-model="inlineMessageValue"
class="comment-inline-edit-input form-input"
></textarea>
<KtButtonGroup class="comment-inline-edit-buttons" shadow>
<KtButtonGroup class="comment-inline-edit-buttons">
<KtButton icon="close" @click="cancelInlineEdit" />
<KtButton icon="check" @click="handleEditConfirm" />
</KtButtonGroup>
Expand Down
Expand Up @@ -28,7 +28,7 @@
v-model="inlineMessageValue"
class="comment-inline-edit-input form-input"
></textarea>
<KtButtonGroup class="comment-inline-edit-buttons" shadow>
<KtButtonGroup class="comment-inline-edit-buttons">
<KtButton icon="close" @click="cancelInlineEdit" />
<KtButton icon="check" @click="handleConfirm" />
</KtButtonGroup>
Expand Down
1 change: 1 addition & 0 deletions packages/kotti-ui/source/types/kotti.ts
Expand Up @@ -3,6 +3,7 @@ export { KottiAvatarGroup as AvatarGroup } from '../kotti-avatar-group/types'
export { KottiBanner as Banner } from '../kotti-banner/types'
export { KottiBreadcrumb as Breadcrumb } from '../kotti-breadcrumb/types'
export { KottiButton as Button } from '../kotti-button/types'
export { KottiButtonGroup as ButtonGroup } from '../kotti-button-group/types'
export { KottiCol as Col } from '../kotti-col/types'
export { KottiField as Field } from '../kotti-field/types'
export { KottiFieldNumber as FieldNumber } from '../kotti-field-number/types'
Expand Down

0 comments on commit 057ebd6

Please sign in to comment.