From 4fcbd5a575d4b0364ca68aca64ccf3488a211e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 18 Nov 2020 06:46:17 +0100 Subject: [PATCH 1/2] Add ListItemIcon component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- src/components/ListItemIcon/ListItemIcon.vue | 242 +++++++++++++++++++ src/components/ListItemIcon/index.js | 25 ++ src/components/index.js | 10 +- 3 files changed, 273 insertions(+), 4 deletions(-) create mode 100644 src/components/ListItemIcon/ListItemIcon.vue create mode 100644 src/components/ListItemIcon/index.js diff --git a/src/components/ListItemIcon/ListItemIcon.vue b/src/components/ListItemIcon/ListItemIcon.vue new file mode 100644 index 0000000000..767cb56026 --- /dev/null +++ b/src/components/ListItemIcon/ListItemIcon.vue @@ -0,0 +1,242 @@ + + +## This is used to display a avatar-title/subtitle + icon layout +It might be used for list rendering or within the multiselect for example + +> **Note:** Any binding will be forwarded on the Avatar component root + +```vue + +``` +```vue + +``` + +### With icon +```vue + +``` + +### Searching +```vue + + + +``` + +### With actions +```vue + + + Edit + Delete + + +``` + + + + + + + diff --git a/src/components/ListItemIcon/index.js b/src/components/ListItemIcon/index.js new file mode 100644 index 0000000000..cd6fb144be --- /dev/null +++ b/src/components/ListItemIcon/index.js @@ -0,0 +1,25 @@ +/** + * @copyright Copyright (c) 2020 John Molakvoæ + * + * @author John Molakvoæ + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +import ListItemIcon from './ListItemIcon' + +export default ListItemIcon diff --git a/src/components/index.js b/src/components/index.js index a76e1391de..c44ff3c018 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -42,6 +42,8 @@ import AppNavigationItem from './AppNavigationItem' import AppNavigationNew from './AppNavigationNew' import AppNavigationSettings from './AppNavigationSettings' import AppNavigationSpacer from './AppNavigationSpacer' +import AppSettingsDialog from './AppSettingsDialog' +import AppSettingsSection from './AppSettingsSection' import AppSidebar from './AppSidebar' import AppSidebarTab from './AppSidebarTab' import Avatar from './Avatar' @@ -51,6 +53,7 @@ import ColorPicker from './ColorPicker' import Content from './Content' import DatetimePicker from './DatetimePicker' import EmptyContent from './EmptyContent' +import ListItemIcon from './ListItemIcon' import Modal from './Modal' import Multiselect from './Multiselect' import MultiselectTags from './MultiselectTags' @@ -59,8 +62,6 @@ import PopoverMenu from './PopoverMenu' import RichContenteditable from './RichContenteditable' import SettingsSection from './SettingsSection' import UserBubble from './UserBubble' -import AppSettingsDialog from './AppSettingsDialog' -import AppSettingsSection from './AppSettingsSection' export { ActionButton, @@ -84,6 +85,8 @@ export { AppNavigationNew, AppNavigationSettings, AppNavigationSpacer, + AppSettingsDialog, + AppSettingsSection, AppSidebar, AppSidebarTab, Avatar, @@ -93,6 +96,7 @@ export { Content, DatetimePicker, EmptyContent, + ListItemIcon, Modal, Multiselect, MultiselectTags, @@ -101,6 +105,4 @@ export { RichContenteditable, SettingsSection, UserBubble, - AppSettingsDialog, - AppSettingsSection, } From dc9de62935cce7c5aef3318a4063ee8e82bfab3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 18 Nov 2020 07:19:36 +0100 Subject: [PATCH 2/2] Use ListItemIcon for Multiselect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- src/components/ListItemIcon/ListItemIcon.vue | 30 ++- .../Multiselect/AvatarSelectOption.vue | 205 ------------------ src/components/Multiselect/Multiselect.vue | 50 ++++- 3 files changed, 66 insertions(+), 219 deletions(-) delete mode 100644 src/components/Multiselect/AvatarSelectOption.vue diff --git a/src/components/ListItemIcon/ListItemIcon.vue b/src/components/ListItemIcon/ListItemIcon.vue index 767cb56026..69ac73cc5f 100644 --- a/src/components/ListItemIcon/ListItemIcon.vue +++ b/src/components/ListItemIcon/ListItemIcon.vue @@ -27,9 +27,10 @@ It might be used for list rendering or within the multiselect for example ```vue + ``` ```vue - + ``` ### With icon @@ -63,7 +64,7 @@ It might be used for list rendering or within the multiselect for example :disable-tooltip="true" :display-name="displayName || title" :is-no-user="isNoUser" - :size="size" + :size="avatarSize" class="option__avatar" />
@@ -92,7 +93,9 @@ import Avatar from '../Avatar' import Highlight from '../Highlight' import { userStatus } from '../../mixins' -const margin = 6 +// global margin, ^2 ratio +const margin = 8 +const defaultSize = 32 export default { name: 'ListItemIcon', @@ -114,6 +117,7 @@ export default { /** * Secondary optional line + * Only visible on size of 32 and above */ subtitle: { type: String, @@ -137,11 +141,12 @@ export default { }, /** - * Set a size in px for the height + * Set a size in px that will define the avatar height/width + * and therefore, the height of the component */ - size: { + avatarSize: { type: Number, - default: 32, + default: defaultSize, }, /** @@ -172,13 +177,20 @@ export default { hasIcon() { return this.icon !== '' }, - hasSlot() { return !!this.$slots.default }, + + isValidSubtitle() { + return this.subtitle?.trim?.() !== '' + }, + isSizeBigEnough() { + return this.avatarSize >= defaultSize + }, + cssVars() { return { - '--height': this.size + 2 * this.margin + 'px', + '--height': this.avatarSize + 2 * this.margin + 'px', '--margin': this.margin + 'px', } }, diff --git a/src/components/Multiselect/AvatarSelectOption.vue b/src/components/Multiselect/AvatarSelectOption.vue deleted file mode 100644 index a7ae014c2c..0000000000 --- a/src/components/Multiselect/AvatarSelectOption.vue +++ /dev/null @@ -1,205 +0,0 @@ - - -### User layout -By specifying `:user-select="true"`, you can benefit from a fully formatted layout. - -> **Note:** Any extra binding from the object will be added as attribute (`$attrs`) on the AvatarSelectOption root - -```vue - - - -``` - - - - - - - diff --git a/src/components/Multiselect/Multiselect.vue b/src/components/Multiselect/Multiselect.vue index 8140c725d1..c02c906860 100644 --- a/src/components/Multiselect/Multiselect.vue +++ b/src/components/Multiselect/Multiselect.vue @@ -101,7 +101,45 @@ export default { ``` ### User layout -Please see the [AvatarSelectOption](#AvatarSelectOption) component +By specifying `:user-select="true"`, you can benefit from a fully formatted layout. + +> **Note:** Any extra binding from the object will be added as attribute (`$attrs`) on the ListItemIcon component used here + +```vue + + + +```