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

Replace AppNavigationCounter with CounterBubble #1895

Merged
merged 3 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/components/AppNavigationCounter/AppNavigationCounter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
-
-->

<docs>
<docs>

### Normal Counter

Expand All @@ -46,6 +46,9 @@

<script>

/**
* @deprecated use [CounterBubble](#/Components/CounterBubble) instead
*/
export default {
name: 'AppNavigationCounter',

Expand Down
4 changes: 2 additions & 2 deletions src/components/AppNavigationItem/AppNavigationItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ Just nest the counter into `<AppNavigationItem>` and add `slot="counter"` to it.

```
<AppNavigationItem title="Item with counter" icon="icon-folder">
<AppNavigationCounter slot="counter">
<CounterBubble slot="counter">
99+
</AppNavigationCounter>
</CounterBubble>
</AppNavigationItem>
```

Expand Down
82 changes: 82 additions & 0 deletions src/components/CounterBubble/CounterBubble.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!--
- @copyright Copyright (c) 2019 Marco Ambrosini <marcoambrosini@pm.me>
-
- @author Marco Ambrosini <marcoambrosini@pm.me>
Copy link
Contributor

Choose a reason for hiding this comment

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

@PVince81 Probably not really important, but I guess this is the wrong year and author?

-
- @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 <http://www.gnu.org/licenses/>.
-
-->

<docs>

### Normal Counter

```
<CounterBubble>314+</CounterBubble>
```

### Highlighted Counter (i.e. mentions)

```
<CounterBubble :highlighted="true">@admin</CounterBubble>
<CounterBubble :highlighted="true">314+</CounterBubble>
```

</docs>

<template>
<div :class="{ 'counter-bubble__counter--highlighted': highlighted }"
class="counter-bubble__counter">
<slot />
</div>
</template>

<script>

export default {
name: 'CounterBubble',

props: {
highlighted: {
type: Boolean,
default: false,
},
},
}

</script>

<style lang="scss" scoped>
.counter-bubble__counter {
font-size: calc(var(--default-font-size) * .8);
overflow: hidden;
width: fit-content;
max-width: $clickable-area;
text-align: center;
text-overflow: ellipsis;
line-height: 1em;
padding: 4px 8px;
border-radius: var(--border-radius-pill);
background-color: var(--color-background-darker);

&--highlighted {
padding: 4px 6px;
color: var(--color-primary-text);
background-color: var(--color-primary);
}
}

</style>
25 changes: 25 additions & 0 deletions src/components/CounterBubble/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @copyright Copyright (c) 2021 Vincent Petry <vincent@nextcloud.com>
*
* @author Vincent Petry <vincent@nextcloud.com>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/

import CounterBubble from './CounterBubble'

export default CounterBubble
28 changes: 14 additions & 14 deletions src/components/ListItem/ListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
:counter-number="44"
:counter-highlighted="true">
<template #icon>
<avatar size="44" user="janedoe" display-name="Jane Doe" />
<avatar :size="44" user="janedoe" display-name="Jane Doe" />
</template>
<template #subtitle>
In this slot you can put both text and other components such as icons
</template>
<AppNavigationCounter #counter>
<CounterBubble #counter>
7
</AppNavigationCounter>
</CounterBubble>
<template #actions>
<ActionButton>
Button one
Expand All @@ -54,14 +54,14 @@
:title="'Title of the element'"
:bold="false">
<template #icon>
<avatar size="44" user="janedoe" display-name="Jane Doe" />
<avatar :size="44" user="janedoe" display-name="Jane Doe" />
</template>
<template #subtitle>
In this slot you can put both text and other components such as icons
</template>
<AppNavigationCounter #counter>
<CounterBubble #counter>
7
</AppNavigationCounter>
</CounterBubble>
<template #actions>
<ActionButton>
Button one
Expand All @@ -79,14 +79,14 @@
:bold="false"
:details="'One hour ago'">
<template #icon>
<avatar size="44" user="janedoe" display-name="Jane Doe" />
<avatar :size="44" user="janedoe" display-name="Jane Doe" />
</template>
<template #subtitle>
In this slot you can put both text and other components such as icons
</template>
<AppNavigationCounter #counter>
<CounterBubble #counter>
7
</AppNavigationCounter>
</CounterBubble>
</listItem>
</ul>

Expand Down Expand Up @@ -145,11 +145,11 @@

<!-- Counter -->
<span v-if="!displayActions" class="line-two__counter">
<AppNavigationCounter
<CounterBubble
v-if="counterNumber != 0"
:highlighted="counterHighlighted">
{{ counterNumber }}
</AppNavigationCounter>
</CounterBubble>
</span>
</div>
</div>
Expand Down Expand Up @@ -182,14 +182,14 @@

<script>
import Actions from '../Actions'
import AppNavigationCounter from '../AppNavigationCounter'
import CounterBubble from '../CounterBubble'

export default {
name: 'ListItem',

components: {
Actions,
AppNavigationCounter,
CounterBubble,
},

props: {
Expand Down Expand Up @@ -268,7 +268,7 @@ export default {

/**
* If different from from 0 this component will display the
* AppNavigationCounter component
* CounterBubble component
*/
counterNumber: {
type: [Number, String],
Expand Down
2 changes: 2 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import Breadcrumbs from './Breadcrumbs'
import CheckboxRadio from './CheckboxRadio'
import ColorPicker from './ColorPicker'
import Content from './Content'
import CounterBubble from './CounterBubble'
import DatetimePicker from './DatetimePicker'
import EmptyContent from './EmptyContent'
import ListItem from './ListItem'
Expand Down Expand Up @@ -100,6 +101,7 @@ export {
CheckboxRadio,
ColorPicker,
Content,
CounterBubble,
DatetimePicker,
EmptyContent,
ListItem,
Expand Down