Skip to content

Commit 2a3bc33

Browse files
implement variable for bootstrap
1 parent 4f25f89 commit 2a3bc33

File tree

2 files changed

+65
-35
lines changed

2 files changed

+65
-35
lines changed

src/AireBootstrapServiceProvider.php

+64-34
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function boot()
2424
'group_errors' => 'd-none',
2525
'label' => '',
2626
'input' => 'form-control',
27+
2728
'checkbox' => 'custom-control-input',
2829
'checkbox_label' => 'custom-control-label',
2930
'checkbox_wrapper' => 'custom-control custom-checkbox',
@@ -66,47 +67,76 @@ public function boot()
6667
'group_help_text' => 'invalid-feedback d-block',
6768
],
6869
],
70+
'variant_classes' => [
71+
'input' => [
72+
'default' => 'form-control',
73+
'sm' => 'form-control-sm',
74+
'lg' => 'form-control-lg',
75+
],
76+
'group_input_group' => [
77+
'default' => 'input-group',
78+
'sm' => 'input-group-sm',
79+
'lg' => 'input-group-lg',
80+
],
81+
'group_input_range' => [
82+
'default' => [
83+
'display' => 'range-default'
84+
]
85+
],
86+
'select' => [
87+
'default' => [
88+
'display' => 'custom-select',
89+
'size' => '',
90+
'color' => '',
91+
],
92+
'sm' => 'custom-select-sm',
93+
'lg' => 'custom-select-lg',
94+
],
95+
'button' => [
96+
'default' => [
97+
'display' => 'btn',
98+
'size' => '',
99+
'color' => 'btn-primary',
100+
],
101+
'sm' => [
102+
'size' => 'btn-sm',
103+
],
104+
'lg' => [
105+
'size' => 'btn-sm',
106+
],
107+
'primary' => [
108+
'color' => 'btn-primary'
109+
],
110+
'secondary' => [
111+
'color' => 'btn-secondary'
112+
],
113+
'success' => [
114+
'color' => 'btn-success'
115+
],
116+
'danger' => [
117+
'color' => 'btn-danger'
118+
],
119+
'warning' => [
120+
'color' => 'btn-warning'
121+
],
122+
'info' => [
123+
'color' => 'btn-info'
124+
],
125+
'light' => [
126+
'color' => 'btn-light'
127+
],
128+
'dark' => [
129+
'color' => 'btn-dark'
130+
],
131+
]
132+
]
69133
]);
70134

71135
Checkbox::registerElementMutator(function (Checkbox $checkbox) {
72136
$checkbox->group->addClass('custom-control custom-checkbox');
73137
});
74138

75139
Input::registerElementMutator(function (Input $input) {
76-
$input->attributes->registerMutator('class', function (ClassNames $classNames) use ($input) {
77-
if (in_array($input->getViewData('variant'), ['sm', 'small'])) {
78-
$classNames->add('form-control-sm');
79-
}
80-
81-
if (in_array($input->getViewData('variant'), ['lg', 'large'])) {
82-
$classNames->add('form-control-lg');
83-
}
84-
85-
return $classNames;
86-
});
87-
88-
$input->group->attributes->input_group->registerMutator('class', function (ClassNames $classNames) use ($input) {
89-
90-
if ($input->attributes->primary()->class->has('form-control-sm')) {
91-
$classNames->add('input-group-sm');
92-
}
93-
94-
if ($input->attributes->primary()->class->has('form-control-lg')) {
95-
$classNames->add('input-group-lg');
96-
}
97-
98-
if (in_array($input->getViewData('variant'), ['sm', 'small'])) {
99-
$classNames->add('input-group-sm');
100-
}
101-
102-
if (in_array($input->getViewData('variant'), ['lg', 'large'])) {
103-
$classNames->add('input-group-lg');
104-
}
105-
106-
107-
return $classNames;
108-
});
109-
110140
$input->attributes->registerMutator('class', function (ClassNames $classNames) use ($input) {
111141

112142
if ('range' === $input->attributes->get('type')) {

views/group.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{{ $label }}
55

66
@if($prepend || $append)
7-
<div class="input-group">
7+
<div {{ $attributes->input_group }}>
88
@if($prepend)
99
<div {{ $attributes->prepend }}>
1010
<div class="input-group-text">

0 commit comments

Comments
 (0)