Skip to content

Commit 15a448c

Browse files
authored
fix(form_field): add color input on helper and label (#147)
* fix(form_field): add color input on helper and label
1 parent 6640e16 commit 15a448c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

libs/flowbite-angular/form/src/helper/helper.directive.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { injectFlowbiteHelperConfig } from '../config/helper-config';
22
import { injectFlowbiteFormFieldState } from '../form-field/form-field-state';
3+
import type { FlowbiteFormFieldColors } from '../form-field/theme';
34
import { flowbiteHelperState, provideFlowbiteHelperState } from './helper-state';
45

56
import { colorToTheme, mergeDeep } from 'flowbite-angular';
@@ -28,6 +29,11 @@ export class Helper {
2829
readonly config = injectFlowbiteHelperConfig();
2930
readonly formFieldState = injectFlowbiteFormFieldState();
3031

32+
/**
33+
* @see {@link injectFlowbiteFormFieldState}
34+
*/
35+
readonly color = input<keyof FlowbiteFormFieldColors>();
36+
3137
/**
3238
* @see {@link injectFlowbiteHelperConfig}
3339
*/
@@ -41,7 +47,7 @@ export class Helper {
4147
root: twMerge(
4248
mergedTheme.host.base,
4349
mergedTheme.host.transition,
44-
colorToTheme(mergedTheme.host.color, this.formFieldState().color())
50+
colorToTheme(mergedTheme.host.color, this.state.color() ?? this.formFieldState().color())
4551
),
4652
},
4753
};

libs/flowbite-angular/form/src/label/label.directive.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { injectFlowbiteLabelConfig } from '../config/label-config';
22
import { injectFlowbiteFormFieldState } from '../form-field/form-field-state';
3+
import type { FlowbiteFormFieldColors } from '../form-field/theme';
34
import { flowbiteLabelState, provideFlowbiteLabelState } from './label-state';
45

56
import { colorToTheme, mergeDeep } from 'flowbite-angular';
@@ -28,6 +29,11 @@ export class Label {
2829
readonly config = injectFlowbiteLabelConfig();
2930
readonly formFieldState = injectFlowbiteFormFieldState();
3031

32+
/**
33+
* @see {@link injectFlowbiteFormFieldState}
34+
*/
35+
readonly color = input<keyof FlowbiteFormFieldColors>();
36+
3137
/**
3238
* @see {@link injectFlowbiteLabelConfig}
3339
*/
@@ -41,7 +47,7 @@ export class Label {
4147
root: twMerge(
4248
mergedTheme.host.base,
4349
mergedTheme.host.transition,
44-
colorToTheme(mergedTheme.host.color, this.formFieldState().color()),
50+
colorToTheme(mergedTheme.host.color, this.state.color() ?? this.formFieldState().color()),
4551
mergedTheme.host.mode[this.formFieldState().mode()]
4652
),
4753
},

0 commit comments

Comments
 (0)