Skip to content

Commit 28cbb92

Browse files
authored
Merge pull request #13 from aihowes/change-field-width
Fix #10 - Make field full width
2 parents 2cbdace + 946f7ae commit 28cbb92

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,16 @@ By default, the Trumbowyg field will not display their content when viewing a re
6060
];
6161
}
6262
```
63+
64+
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.
65+
66+
```
67+
public function fields(Request $request)
68+
{
69+
return [
70+
...,
71+
NovaTrumbowyg::make('body')->defaultWidth(),
72+
...
73+
];
74+
}
75+
```

resources/js/components/FormField.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<default-field :field="field">
2+
<default-field :field="field" :full-width-content="field.fullWidth">
33
<template slot="field">
44
<div :class="[errorClasses, errorClasses.length ? 'border' : '']" @keydown.stop>
55
<trumbowyg v-model="value" :config="field.options"></trumbowyg>

src/NovaTrumbowyg.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ class NovaTrumbowyg extends Field
1616
*/
1717
public $component = 'nova-trumbowyg';
1818

19+
/**
20+
* Set field default size as fullWidth
21+
*
22+
* @var bool
23+
*/
24+
public $fullWidth = true;
25+
26+
/**
27+
* Set the field width back to Nova's default
28+
*
29+
* @return $this
30+
*/
31+
public function defaultWidth()
32+
{
33+
$this->fullWidth = false;
34+
35+
return $this;
36+
}
37+
1938
public function options(array $options = [])
2039
{
2140
return $this->withMeta(['options' => $options]);
@@ -30,6 +49,7 @@ public function jsonSerialize()
3049
{
3150
return array_merge(parent::jsonSerialize(), [
3251
'shouldShow' => $this->shouldBeExpanded(),
52+
'fullWidth' => $this->fullWidth,
3353
]);
3454
}
3555
}

0 commit comments

Comments
 (0)