From 28c7fac9f0b740473575200051bc2983ec5c9be9 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 29 Feb 2024 17:49:56 +0200 Subject: [PATCH] implement list item styles --- src/App.scss | 32 +++++++++++-- .../basic_user_card/basic_user_card.vue | 1 - .../chat_list_item/chat_list_item.scss | 12 ++--- src/components/list/list.vue | 22 ++------- src/components/list/list_item.style.js | 48 +++++++++++++++++++ src/components/menu_item.style.js | 2 +- src/components/nav_panel/nav_panel.vue | 13 ++--- src/components/panel.style.js | 3 +- src/components/popover/popover.vue | 7 +-- .../selectable_list/selectable_list.vue | 27 ++++------- 10 files changed, 103 insertions(+), 64 deletions(-) create mode 100644 src/components/list/list_item.style.js diff --git a/src/App.scss b/src/App.scss index 8c60a05d90..219269a18c 100644 --- a/src/App.scss +++ b/src/App.scss @@ -384,7 +384,8 @@ nav { } } -.menu-item { +.menu-item, +.list-item { display: block; box-sizing: border-box; border: none; @@ -397,9 +398,11 @@ nav { color: inherit; clear: both; position: relative; - border-bottom: 1px solid; white-space: nowrap; border-color: var(--border); + border-style: solid; + border-width: 0; + border-top-width: 1px; width: 100%; line-height: var(--__line-height); padding: var(--__vertical-gap) var(--__horizontal-gap); @@ -408,8 +411,28 @@ nav { --__horizontal-gap: 0.75em; --__vertical-gap: 0.5em; + &.-active, + &:hover { + border-top-width: 1px; + border-bottom-width: 1px; + } + + &.-active + &, + &:hover + & { + border-top-width: 0; + } + + &:hover + .menu-item-collapsible:not(.-expanded) + &, + &.-active + .menu-item-collapsible:not(.-expanded) + & { + border-top-width: 0; + } + + &[aria-expanded="true"] { + border-bottom-width: 1px; + } + a, - button { + button:not(.button-default) { text-align: initial; padding: 0; background: none; @@ -425,12 +448,13 @@ nav { &:first-child { border-top-right-radius: var(--roundness); border-top-left-radius: var(--roundness); + border-top-width: 0; } &:last-child { border-bottom-right-radius: var(--roundness); border-bottom-left-radius: var(--roundness); - border: none; + border-bottom-width: 0; } } diff --git a/src/components/basic_user_card/basic_user_card.vue b/src/components/basic_user_card/basic_user_card.vue index 705e20f59a..9e2b0295d4 100644 --- a/src/components/basic_user_card/basic_user_card.vue +++ b/src/components/basic_user_card/basic_user_card.vue @@ -47,7 +47,6 @@ display: flex; flex: 1 0; margin: 0; - padding: 0.6em 1em; --emoji-size: 14px; diff --git a/src/components/chat_list_item/chat_list_item.scss b/src/components/chat_list_item/chat_list_item.scss index af28e1c01d..04bec8dd93 100644 --- a/src/components/chat_list_item/chat_list_item.scss +++ b/src/components/chat_list_item/chat_list_item.scss @@ -1,8 +1,6 @@ .chat-list-item { display: flex; flex-direction: row; - padding: 0.75em; - height: 5em; overflow: hidden; box-sizing: border-box; cursor: pointer; @@ -12,7 +10,6 @@ } &:hover { - background-color: var(--selectedPost, $fallback--lightBg); box-shadow: 0 0 3px 1px rgb(0 0 0 / 10%); } @@ -29,7 +26,7 @@ .heading { width: 100%; - display: inline-flex; + display: flex; justify-content: space-between; line-height: 1em; } @@ -47,18 +44,17 @@ } .chat-preview { - display: inline-flex; + display: flex; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin: 0.35em 0; - color: $fallback--text; - color: var(--faint, $fallback--text); + color: var(--faintText); width: 100%; } a { - color: var(--faintLink, $fallback--link); + color: var(--faintLink); text-decoration: none; pointer-events: none; } diff --git a/src/components/list/list.vue b/src/components/list/list.vue index a3562c5d75..b8fcaf9d23 100644 --- a/src/components/list/list.vue +++ b/src/components/list/list.vue @@ -7,6 +7,7 @@ v-for="item in items" :key="getKey(item)" class="list-item" + :class="getClass(item)" role="listitem" > item.id + }, + getClass: { + type: Function, + default: item => '' } } } - - diff --git a/src/components/list/list_item.style.js b/src/components/list/list_item.style.js new file mode 100644 index 0000000000..ae8dc5f4d5 --- /dev/null +++ b/src/components/list/list_item.style.js @@ -0,0 +1,48 @@ +export default { + name: 'ListItem', + selector: '.list-item', + states: { + active: '.-active', + hover: ':hover' + }, + validInnerComponents: [ + 'Text', + 'Link', + 'Icon', + 'Border', + 'Button', + 'ButtonUnstyled', + 'RichContent', + 'Input', + 'Avatar' + ], + defaultRules: [ + { + directives: { + background: '--bg', + opacity: 0 + } + }, + { + state: ['active'], + directives: { + background: '--inheritedBackground, 10', + opacity: 1 + } + }, + { + state: ['hover'], + directives: { + background: '--inheritedBackground, 10', + opacity: 1 + } + }, + { + state: ['hover', 'active'], + directives: { + background: '--inheritedBackground, 20', + opacity: 1 + } + } + ] +} diff --git a/src/components/menu_item.style.js b/src/components/menu_item.style.js index 29376e5ed4..51388155d3 100644 --- a/src/components/menu_item.style.js +++ b/src/components/menu_item.style.js @@ -12,7 +12,7 @@ export default { ], states: { hover: ':hover', - active: '.active' + active: '.-active' }, defaultRules: [ { diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index 074d9f83ff..6380deac47 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -37,8 +37,8 @@