Skip to content

Commit

Permalink
Merge pull request #2 from murdercode/hide-icon
Browse files Browse the repository at this point in the history
Hide icon
  • Loading branch information
Claudio-Emmolo authored Feb 23, 2024
2 parents 9ef89bd + 6d1451d commit 2bb1b88
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function fields(NovaRequest $request)
{
SeoTitle::make(__('Title'), 'title')
->rangeLength(30, 60)
->hideIcon() // For hide the SEO icon
->rules('required', 'max:255', 'min:3');
}
```
Expand Down
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions dist/js/field.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
/*!
* vuex v4.0.2
* (c) 2021 Evan You
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/

/*!
* vuex v4.1.0
* (c) 2022 Evan You
* @license MIT
*/

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
"production": "mix --production",
"nova:install": "npm --prefix='../../vendor/laravel/nova' ci"
},
"devDependencies": {
"@vue/compiler-sfc": "^3.2.22",
Expand Down
1 change: 1 addition & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
6 changes: 5 additions & 1 deletion resources/js/components/IndexField.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<span>
<div
v-if="hideIcon"
class="inline-block w-2 h-2 rounded-full opacity-75"
:class="isInRange ? 'bg-green-500' : 'bg-red-500'"
:title="isInRange ? 'This title is good for SEO. Great work!' : `You're out of ${overChars} characters. Please make a better title!`"
Expand All @@ -11,10 +12,13 @@

<script>
export default {
props: ['resourceName', 'field', 'min', 'max'],
props: ['resourceName', 'field', 'min', 'max', 'hideIcon'],
computed: {
isInRange() {
return this.field.value.length >= this.field.min && this.field.value.length <= this.field.max
},
hideIcon() {
return this.field.hideIcon ?? true
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/SeoTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,15 @@ public function rangeLength(int $min = 30, int $max = 60): self
'max' => $max,
]);
}

/**
* Hide the SEO icon
* @return $this
*/
public function hideIcon(): self
{
return $this->withMeta([
'hideIcon' => false,
]);
}
}

0 comments on commit 2bb1b88

Please sign in to comment.