From 2839454bc0b37114db1740320ec049d9eea43355 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Thu, 6 May 2021 20:01:26 +0530 Subject: [PATCH] feat: Creates label dropdown component (#2220) * Feat: Creates label dropdown component * fixes conflicts in i18n Co-authored-by: Nithin David Thomas --- app/javascript/dashboard/components/index.js | 4 + .../dashboard/i18n/locale/en/contact.json | 8 +- .../components/ui/dropdown/DropdownItem.vue | 26 +-- .../ui/label/LabelDropdown.stories.js | 58 +++++++ .../components/ui/label/LabelDropdown.vue | 156 ++++++++++++++++++ .../ui/label/LabelDropdownItem.stories.js | 39 +++++ .../components/ui/label/LabelDropdownItem.vue | 82 +++++++++ 7 files changed, 360 insertions(+), 13 deletions(-) create mode 100644 app/javascript/shared/components/ui/label/LabelDropdown.stories.js create mode 100644 app/javascript/shared/components/ui/label/LabelDropdown.vue create mode 100644 app/javascript/shared/components/ui/label/LabelDropdownItem.stories.js create mode 100644 app/javascript/shared/components/ui/label/LabelDropdownItem.vue diff --git a/app/javascript/dashboard/components/index.js b/app/javascript/dashboard/components/index.js index 981d9d476..cc2a70a2c 100644 --- a/app/javascript/dashboard/components/index.js +++ b/app/javascript/dashboard/components/index.js @@ -6,6 +6,8 @@ import Button from './ui/WootButton'; import Code from './Code'; import ColorPicker from './widgets/ColorPicker'; import DeleteModal from './widgets/modal/DeleteModal.vue'; +import DropdownItem from 'shared/components/ui/dropdown/DropdownItem'; +import DropdownMenu from 'shared/components/ui/dropdown/DropdownMenu'; import Input from './widgets/forms/Input.vue'; import Label from './ui/Label'; import LoadingState from './widgets/LoadingState'; @@ -26,6 +28,8 @@ const WootUIKit = { Code, ColorPicker, DeleteModal, + DropdownItem, + DropdownMenu, Input, LoadingState, Label, diff --git a/app/javascript/dashboard/i18n/locale/en/contact.json b/app/javascript/dashboard/i18n/locale/en/contact.json index 5b021a9e8..6a94011a5 100644 --- a/app/javascript/dashboard/i18n/locale/en/contact.json +++ b/app/javascript/dashboard/i18n/locale/en/contact.json @@ -28,11 +28,17 @@ "INACTIVE_LABELS": "Labels available in the account", "REMOVE": "Click on X icon to remove the label", "ADD": "Click on + icon to add the label", + "ADD_BUTTON": "Add Labels", "UPDATE_BUTTON": "Update labels", "UPDATE_ERROR": "Couldn't update labels, try again." }, "NO_LABELS_TO_ADD": "There are no more labels defined in the account.", - "NO_AVAILABLE_LABELS": "There are no labels added to this conversation." + "NO_AVAILABLE_LABELS": "There are no labels added to this conversation.", + "LABEL_SELECT": { + "TITLE": "Add Labels", + "PLACEHOLDER": "Search labels", + "NO_RESULT": "No labels found" + } }, "MUTE_CONTACT": "Mute Conversation", "UNMUTE_CONTACT": "Unmute Conversation", diff --git a/app/javascript/shared/components/ui/dropdown/DropdownItem.vue b/app/javascript/shared/components/ui/dropdown/DropdownItem.vue index 21a4f950c..b791fd937 100644 --- a/app/javascript/shared/components/ui/dropdown/DropdownItem.vue +++ b/app/javascript/shared/components/ui/dropdown/DropdownItem.vue @@ -27,19 +27,21 @@ export default { }; diff --git a/app/javascript/shared/components/ui/label/LabelDropdownItem.stories.js b/app/javascript/shared/components/ui/label/LabelDropdownItem.stories.js new file mode 100644 index 000000000..e5e7cf4af --- /dev/null +++ b/app/javascript/shared/components/ui/label/LabelDropdownItem.stories.js @@ -0,0 +1,39 @@ +import { action } from '@storybook/addon-actions'; +import LabelDropdownItem from './LabelDropdownItem'; + +export default { + title: 'Components/Label/Item', + component: LabelDropdownItem, + argTypes: { + title: { + defaultValue: 'sales', + control: { + type: 'text', + }, + }, + color: { + defaultValue: '#555', + control: { + type: 'text', + }, + }, + selected: { + defaultValue: true, + control: { + type: 'boolean', + }, + }, + }, +}; + +const Template = (args, { argTypes }) => ({ + props: Object.keys(argTypes), + components: { LabelDropdownItem }, + template: + '', +}); + +export const item = Template.bind({}); +item.args = { + onClick: action('Selected'), +}; diff --git a/app/javascript/shared/components/ui/label/LabelDropdownItem.vue b/app/javascript/shared/components/ui/label/LabelDropdownItem.vue new file mode 100644 index 000000000..e692bfd0b --- /dev/null +++ b/app/javascript/shared/components/ui/label/LabelDropdownItem.vue @@ -0,0 +1,82 @@ + + + + +