Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ListItem css & add compact mode #2856

Merged
merged 2 commits into from
Jul 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 94 additions & 8 deletions src/components/ListItem/ListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
-->
<docs>

# Usage
### Default Usage
```
<ul>
<listItem
Expand Down Expand Up @@ -118,6 +118,65 @@
</listItem>
</ul>

```

### ListItem compact mode
```
<ul style="width: 350px;">
<listItem
:title="'Title of the element'"
:counter-number=1
:compact="true" >
<template #icon>
<div class="icon-edit" />
</template>
<template #subtitle>
This one is with subtitle
</template>
<template #actions>
<ActionButton>
Button one
</ActionButton>
<ActionButton>
Button two
</ActionButton>
</template>
</listItem>
<listItem
:title="'Title of the element'"
:compact="true" >
<template #icon>
<div class="icon-edit" />
</template>
</listItem>
<listItem
:title="'Title of the element'"
:counter-number=3
:compact="true" >
<template #icon>
<div class="icon-edit" />
</template>
<template #subtitle>
This one is with subtitle
</template>
<template #actions>
<ActionButton>
Button one
</ActionButton>
<ActionButton>
Button two
</ActionButton>
</template>
</listItem>
<listItem
:title="'Title of the element'"
:counter-number=4
:compact="true" >
<template #icon>
<div class="icon-edit" />
</template>
</listItem>
</ul>
```
</docs>

Expand All @@ -139,13 +198,15 @@
@click="onClick"
@keydown.esc="hideActions">

<div class="list-item-content__wrapper">
<div class="list-item-content__wrapper"
:class="{ 'list-item-content__wrapper--compact': compact }">
<!-- @slot This slot is used for the avatar or icon -->
<slot name="icon" />

<!-- Main content -->
<div class="list-item-content">
<div class="list-item-content__main">
<div class="list-item-content__main"
:class="{ 'list-item-content__main--oneline': oneLine }">

<!-- First line, title and details -->
<div class="line-one"
Expand Down Expand Up @@ -274,6 +335,14 @@ export default {
default: false,
},

/**
* Show the ListItem in compact design
*/
compact: {
type: Boolean,
default: false,
},

/**
* Toggle the active state of the component
*/
Expand Down Expand Up @@ -360,6 +429,10 @@ export default {
}
},

oneLine() {
return !this.hasSubtitle && !this.showDetails
},

showCounter() {
return !this.displayActionsOnHoverFocus || this.forceDisplayActions
},
Expand Down Expand Up @@ -500,6 +573,16 @@ export default {
&-content__wrapper {
display: flex;
align-items: center;
height: 48px;

&--compact {
height: 36px;

.line-one, .line-two {
margin-top: -4px;
margin-bottom: -4px;
}
}
}

&-content {
Expand All @@ -510,16 +593,19 @@ export default {

&__main {
flex: 1 1 auto;
flex-direction: column;
width: 0;
margin: auto 0;

&--oneline {
display: flex;
}
}

&__actions {
flex: 0 0 auto;
align-self: center;
justify-content: center;

margin-left: 4px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before After
actions_old actions_new2

}
}

Expand All @@ -533,7 +619,8 @@ export default {
align-items: center;
justify-content: space-between;
white-space: nowrap;
margin: 0 auto;
margin: 0 auto 0 0;
overflow: hidden;
&--bold {
font-weight: bold;
}
Expand Down Expand Up @@ -565,15 +652,14 @@ export default {
&__subtitle {
overflow: hidden;
flex-grow: 1;
padding-right: 4px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shifted to counter margin, so it also applies if no subtitle used.

cursor: pointer;
white-space: nowrap;
text-overflow: ellipsis;
color: var(--color-text-lighter);
}

&__counter {
margin: 2px 4px 0 0;
margin: 2px 4px 0 4px;
}
}

Expand Down