Skip to content

Dev #87

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

Merged
merged 53 commits into from
Sep 19, 2020
Merged

Dev #87

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6f274e7
feat: add legendValueFormatter prop
setaman Aug 31, 2020
be4fa2b
feat: add possibility to format legendValue
setaman Aug 31, 2020
7319e59
feat: add possibility to format legendValue with custom HTML
setaman Aug 31, 2020
1ee21b7
feat: add possibility to format legendValue with slot
setaman Aug 31, 2020
6fa196f
feat: add possibility to format legendValue with scoped slot
setaman Aug 31, 2020
6fa3f3d
refac: run linter
setaman Aug 31, 2020
e9970e4
Merge pull request #81 from setaman/legend-value-formatter
setaman Aug 31, 2020
efd7fee
doc: add legendValueFormatter description
setaman Sep 1, 2020
f241d2c
doc: add default slot description
setaman Sep 1, 2020
295da3a
doc: update slot syntax in example
setaman Sep 1, 2020
7f4e775
doc: extend default slot description
setaman Sep 1, 2020
79027d1
fix: rename legendValueFormatter to legendFormatter
setaman Sep 1, 2020
0751ecb
doc: updaete legendValue desc
setaman Sep 1, 2020
220a87e
doc: fix legendFormatter header
setaman Sep 1, 2020
88f5a5c
refac: remove legendFormatter from common interface definition
setaman Sep 3, 2020
0daae84
refac: simplify data bindings on counter
setaman Sep 3, 2020
c49e62a
release: v1.3.0-beta.2
setaman Sep 3, 2020
515dcfe
doc: legendValue example corrections
setaman Sep 3, 2020
fa810f5
doc: default slot correction according to v1.3.0-beta.2
setaman Sep 3, 2020
db97c2c
test: add first legendFormatter tests
setaman Sep 5, 2020
3fe0322
refac: move custom formatting logic from Counter to container
setaman Sep 8, 2020
6f0a197
test: move legendFormatter test to container
setaman Sep 8, 2020
869f1b1
fix: clean up Counter.vue props
setaman Sep 8, 2020
697f63e
chore: render counter value even if slot from container not provided
setaman Sep 8, 2020
7d30dc2
test: adjust counter and valueFormatter tests
setaman Sep 8, 2020
abd52af
test: extend counter tests
setaman Sep 8, 2020
4c923bc
test: finish legend formatter tests
setaman Sep 9, 2020
3e5c058
test: fix deprecated syntax
setaman Sep 9, 2020
85085b6
release: v1.3.0-beta.4
setaman Sep 9, 2020
cf4ad24
doc: small correction in scoped slot example
setaman Sep 9, 2020
cee2210
fix: remove not used props from counter
setaman Sep 9, 2020
8232450
fix: moved dot out of svg
setaman Sep 12, 2020
114df49
fix: rewrite dot component with html pur
setaman Sep 12, 2020
5b6b265
fix: restructure CircleContainer.vue
setaman Sep 12, 2020
40ef69c
fix: apply reverse class correctly
setaman Sep 12, 2020
f03e389
fix: clean up dot component
setaman Sep 12, 2020
3955fee
tes: fix dot tests
setaman Sep 12, 2020
096d219
tes: extend dot tests
setaman Sep 12, 2020
a1a7539
chore: run linter
setaman Sep 12, 2020
2c25278
fix: set correct determinate loader opacity
setaman Sep 13, 2020
edd51c0
Merge pull request #85 from setaman/#82-fix-dot-for-ios
setaman Sep 13, 2020
aea6c85
release: v1.3.0-beta.6
setaman Sep 13, 2020
f1cff4a
fix: reuse element for animation and do not apply loading animation t…
setaman Sep 13, 2020
60ea0f4
fix: make smooth animation on states changes
setaman Sep 13, 2020
4417edf
fix: clean up loading circle computed styles
setaman Sep 13, 2020
2c963e5
fix: simplify loading circle structure
setaman Sep 13, 2020
742dbee
fix: simplify loading animation for half circle
setaman Sep 13, 2020
d02264d
test: fix animation tests
setaman Sep 18, 2020
0c1ad49
test: add test for transitions handling on state changes
setaman Sep 18, 2020
5117047
Merge pull request #86 from setaman/optimize-loading-animation
setaman Sep 18, 2020
1651ee0
release: v1.3.0-beta.7
setaman Sep 18, 2020
bbd83a2
chore: bump deps
setaman Sep 19, 2020
ca0c3f4
doc: default slot correction
setaman Sep 19, 2020
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
91 changes: 81 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ After you have initialized the component, use it everywhere you want in your app
lineMode="in 10"
:legend="true"
:legendValue="180"
:legendFormatter="({currentValue}) => new Intl.NumberFormat('de-DE').format(currentValue)"
legendClass="legend-custom-style"
dash="60 0.9"
animation="reverse 700 400"
Expand Down Expand Up @@ -111,6 +112,7 @@ This table below provides a quick overview over all available options. To gain m
| **[`emptyColorFill`](#emptycolorfill)** | String \| Object | same as `color` | "transparent" |
| **[`legend`](#legend)** | Boolean | | true |
| **[`legendValue`](#legendvalue)** | Number \| String | any number, accepts a `.` or `","` as decimals delimiter | |
| **[`legendFormatter`](#legendformatter)** [![npm](https://img.shields.io/badge/v1.3.0-blue?style=flat-square)](#legendformatter) | Function | Function that returns formatted value | |
| **[`animation`](#animation)** | String | "default \| rs \| loop \| reverse \| bounce [duration delay]" | "default 1000 400"|
| **[`loading`](#loading)** | Boolean | |false|
| **[`determinate`](#determinate)** | Boolean | |false|
Expand Down Expand Up @@ -150,7 +152,9 @@ this.myProgress = 55.5;
this.myProgress = this.tasksDone * 100 / maxTasks; // the percentage of done tasks
```

>:heavy_exclamation_mark: The `progress` is always used to fill the progress circle line. So you cannot customize this value, it should be always in the range [-100, 100] and not valid Numbers lead to **[`noData`](#noData)** state. For customization purpose please use **[`legendValue`](#legendvalue)**.
>:heavy_exclamation_mark: The `progress` is always used to fill the progress circle line. So you cannot customize this
>value, it should be always in the range [-100, 100] and not valid Numbers lead to **[`noData`](#noData)** state.
>For customization purpose please use **[`legendValue`](#legendvalue)** and take a look at **[`legendFormatter`](#legendformatter)**.

>If **[`legendValue`](#legendvalue)** is defined the progress will **NOT** be displayed as circle legend.

Expand Down Expand Up @@ -308,29 +312,75 @@ Is a Boolean. It defines whether the **[`progress`](#progress)** or from you def

###### Animated: :heavy_check_mark:

Is any number. Use this property if you want to customize the shown progress as the legend of the circle. If defined, `legendValue` will replace **[`progress`](#progress)** as the circle legend!

[![npm](https://img.shields.io/badge/v1.1.1-blue?style=flat-square)](#legendvalue) You can set any precision of the decimal numbers. If the prop is defined as a string, you can specify the `","` as decimals separator (e.g "123,123" for german numbers).
Is any Number or String. Use this property if you want to show progress value as the legend of the circle that is not in
the range [-100, 100]. If defined, `legendValue` will replace [`progress`](#progress) as the circle legend!
You can set any precision of the decimal numbers. If the prop is defined as a string, you can specify the `","`
as decimals delimiter (e.g "123,123" for german numbers), apart from this the value must generally be a valid JavaScript Number.
For more customization possibilities please use [`legendFormatter`](#legendformatter) or [`scoped slot`](#default).

###### Example: :scroll:

Let's say you need to display a rating from 0 to 5 of a product with 3.5 stars. Since **[`progress`](#progress)** can take values only from 0 to 100 your need an additional property `legendValue`. You can show the product rating like in the following example:
Let's say you need to display a rating from 0 to 5 of a product with 3.5 stars. Setting the [`progress`](#progress) to 3.5 will
fill the circle to 3.5 percent, and this is not what we need, since we want to display the percentage of 5 as progress.
At this point we need an additional property `legendValue`. We can show the product rating like in the following example:

```js
<vue-ellipse-progress progress="progress" :legend-value="rating" />
<vue-ellipse-progress :progress="progress" :legend-value="rating" />
...
this.rating = 3.5;
this.progress = this.rating * 100 / 5; // the rating percentage
```
Now you can display custom progress value that still animated and circle progress fills properly!

```vuejs
legend-value="345,12345" // set "," as delimiter defining the value as string
```vue
<vue-ellipse-progress legend-value="345,12345" /> // set "," as delimiter defining the value as string
```

>:heavy_exclamation_mark: note that `legendValue` replaces **[`progress`](#progress)** as circle legend but not vice versa.


<br>

- ### `legendFormatter`

[![npm](https://img.shields.io/badge/v1.3.0-blue?style=flat-square)](#legendformatter)

Is a Function that must return your custom formatted value. The function takes counter properties object as argument and
is called on every tick of the counter. Here the formatting of [legendValue](#legendvalue) or [progress](#progress)
is completely up to you and you have full freedom to adjust the presentation to your needs. The function can return any
value, even HTML.

>:grey_exclamation: alternatively you can use **[`scoped slot`](#default)** for custom formatting.

###### Example: :scroll:

Let's see how it works. The function takes counter properties object as argument that you can use to define custom formatting.
`currentValue` is the most relevant value, as it is the actual value at specific counter tick. The return value will be
displayed as the legend of the circle.

```js
const myFormatter = ({ currentValue, currentRawValue, duration, previousCountStepValue, start, end, difference, oneStepDifference, startTime, elapsed }) => {
return new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(currentValue);
}
```
You can also return HTML:
```js
const myFormatter = ({ currentValue }) => {
return `
<span style="font-weight: bold; font-size: 1.6rem">${new Intl.NumberFormat("de-DE").format(currentValue)}</span>
<span>€</span>
`;
}
```

Finally, set your formatter as prop:

```vue
<vue-ellipse-progress :legend-formatter="myFormatter"/>
<!-- shorter version if you wish-->
<vue-ellipse-progress :legend-formatter="({ currentValue }) => `My Format ${currentValue}`"/>
````

<br>

- ### `animation`
Expand Down Expand Up @@ -517,6 +567,23 @@ data: [

### Slot options

- #### `default`

Use this slot, if you want to customize the presentation of the circle legend and make a use of the animated counter,
so your formatting still animated. This works similar to the [`legendFormatter`](#legendformatter) and is just
an alternative way to provide a custom format. You can access animated counter properties through the scoped slot
props and adjust the presentation of the legend to your needs.

```vue
<vue-ellipse-progress :progress="50">
<template v-slot:default="{ counterTick }">
<span style="font-weight: bold; font-size: 1.6rem; color: green;">
{{ myFormatter(counterTick.currentValue) }}
</span>
</template>
</vue-ellipse-progress>
```

- #### `legend-value`

In this slot you can put an additional element that you want to display beside the progress
Expand All @@ -530,8 +597,12 @@ This code ...
```html
<vue-ellipse-progress ....>

<span slot="legend-value">/200</span>
<p slot="legend-caption">TASKS DONE</p>
<template v-slot:legend-value>
<span slot="legend-value">/200</span>
</template>
<template v-slot:legend-caption>
<p slot="legend-caption">TASKS DONE</p>
</template>

</vue-ellipse-progress>
```
Expand Down
Loading