forked from chatwoot/chatwoot
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a component to display contact attributes in CRM (chatwoot#…
…2217) Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
- Loading branch information
1 parent
fd67a57
commit 262d153
Showing
4 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
app/javascript/dashboard/modules/contact/components/ContactAttribute.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<template> | ||
<div class="contact-attribute"> | ||
<div class="title-wrap"> | ||
<h4 class="text-block-title title"> | ||
<div class="title--icon"> | ||
<emoji-or-icon :icon="icon" :emoji="emoji" /> | ||
</div> | ||
{{ label }} | ||
</h4> | ||
</div> | ||
<div class="value-wrap"> | ||
<p v-if="value" class="value"> | ||
{{ value }} | ||
</p> | ||
<woot-button | ||
v-if="showEdit" | ||
variant="clear link" | ||
size="tiny" | ||
color-scheme="secondary" | ||
icon="ion-compose" | ||
class-names="edit-button" | ||
@click="onEdit" | ||
/> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import EmojiOrIcon from 'shared/components/EmojiOrIcon'; | ||
export default { | ||
components: { | ||
EmojiOrIcon, | ||
}, | ||
props: { | ||
label: { type: String, required: true }, | ||
icon: { type: String, default: '' }, | ||
emoji: { type: String, default: '' }, | ||
value: { type: [String, Number], default: '' }, | ||
showEdit: { type: Boolean, default: false }, | ||
}, | ||
methods: { | ||
onEdit() { | ||
this.$emit('edit'); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.contact-attribute { | ||
margin-bottom: var(--space-normal); | ||
} | ||
.title-wrap { | ||
display: flex; | ||
align-items: center; | ||
} | ||
.title { | ||
display: flex; | ||
align-items: center; | ||
margin: 0; | ||
} | ||
.title--icon { | ||
width: var(--space-two); | ||
} | ||
.edit-button { | ||
display: none; | ||
} | ||
.value-wrap { | ||
display: flex; | ||
&:hover { | ||
.value { | ||
background: var(--color-background); | ||
} | ||
.edit-button { | ||
display: block; | ||
} | ||
} | ||
} | ||
.value { | ||
display: inline-block; | ||
border-radius: var(--border-radius-small); | ||
word-break: break-all; | ||
margin: 0 var(--space-smaller) 0 var(--space-normal); | ||
padding: var(--space-micro) var(--space-smaller); | ||
} | ||
</style> |
43 changes: 43 additions & 0 deletions
43
app/javascript/dashboard/modules/contact/stories/ContactAttribute.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import ContactAttribute from '../components/ContactAttribute'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
export default { | ||
title: 'Components/Contact/ContactAttribute', | ||
component: ContactAttribute, | ||
argTypes: { | ||
label: { | ||
defaultValue: 'Email', | ||
control: { | ||
type: 'text', | ||
}, | ||
}, | ||
value: { | ||
defaultValue: 'dwight@schrute.farms', | ||
control: { | ||
type: 'text', | ||
}, | ||
}, | ||
icon: { | ||
defaultValue: 'ion-email', | ||
control: { | ||
type: 'text', | ||
}, | ||
}, | ||
showEdit: { | ||
control: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const Template = (args, { argTypes }) => ({ | ||
props: Object.keys(argTypes), | ||
components: { ContactAttribute }, | ||
template: '<contact-attribute v-bind="$props" @edit="onEdit" />', | ||
}); | ||
|
||
export const DefaultAttribute = Template.bind({}); | ||
DefaultAttribute.args = { | ||
onEdit: action('edit'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters