Skip to content

Commit

Permalink
Add support for custom width
Browse files Browse the repository at this point in the history
  • Loading branch information
joni-hrsignal committed Dec 9, 2022
1 parent d7d2534 commit a65adfa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ public function cards(NovaRequest $request)
}
```

### Custom width (small, medium or large)

```php
public function cards(NovaRequest $request)
{
return [
FieldProgressbar::make('Awesomeness')
->options([
'width' => 'medium',
]),
];
}
```

Feel free to come with suggestions for improvements.

Packages based on this package: [nova-progressbar-field](https://github.com/signifly/nova-progressbar-field) by [Signifly](https://github.com/signifly)
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"/js/field.js": "/js/field.js"
}
}
9 changes: 9 additions & 0 deletions resources/js/components/IndexField.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<template>
<div class="w-full" :class="padding">
<span class="pg-bar" ref="chartContainer"></span>
</div>
</template>

<script>
const ProgressBar = require('progressbar.js');
const widthSizes = {
large: '',
medium: 'px-6',
small: 'px-10'
}
export default {
props: ['resourceName', 'field'],
Expand All @@ -19,6 +26,7 @@
sub: null,
animateColor: false,
},
padding: ''
};
},
mounted: function () {
Expand All @@ -36,6 +44,7 @@
this.drawLine();
break;
}
this.padding = widthSizes[this.options.width] ?? widthSizes.full;
},
methods: {
drawLine() {
Expand Down

0 comments on commit a65adfa

Please sign in to comment.