Skip to content

Commit

Permalink
Make the default width for the field to be full width and provide a m…
Browse files Browse the repository at this point in the history
…ethod for changing back to half width.
  • Loading branch information
aihowes committed Jul 22, 2019
1 parent 2cbdace commit 946f7ae
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,16 @@ By default, the Trumbowyg field will not display their content when viewing a re
];
}
```

By default, the Trumbowyg field will display in full width you can change this back to Nova's default (half) by using the `defaultWidth` method on the field, as shown below.

```
public function fields(Request $request)
{
return [
...,
NovaTrumbowyg::make('body')->defaultWidth(),
...
];
}
```
2 changes: 1 addition & 1 deletion resources/js/components/FormField.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<default-field :field="field">
<default-field :field="field" :full-width-content="field.fullWidth">
<template slot="field">
<div :class="[errorClasses, errorClasses.length ? 'border' : '']" @keydown.stop>
<trumbowyg v-model="value" :config="field.options"></trumbowyg>
Expand Down
20 changes: 20 additions & 0 deletions src/NovaTrumbowyg.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ class NovaTrumbowyg extends Field
*/
public $component = 'nova-trumbowyg';

/**
* Set field default size as fullWidth
*
* @var bool
*/
public $fullWidth = true;

/**
* Set the field width back to Nova's default
*
* @return $this
*/
public function defaultWidth()
{
$this->fullWidth = false;

return $this;
}

public function options(array $options = [])
{
return $this->withMeta(['options' => $options]);
Expand All @@ -30,6 +49,7 @@ public function jsonSerialize()
{
return array_merge(parent::jsonSerialize(), [
'shouldShow' => $this->shouldBeExpanded(),
'fullWidth' => $this->fullWidth,
]);
}
}

0 comments on commit 946f7ae

Please sign in to comment.