Skip to content

Commit

Permalink
remove defaults from button theme
Browse files Browse the repository at this point in the history
  • Loading branch information
dickermoshe committed Nov 1, 2024
1 parent 57b7305 commit 81f5217
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions lib/src/components/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ class _ShadButtonState extends State<ShadButton> {
if (widget.size != null) {
return defaultHeightForSize(theme, widget.size!);
}
return defaultHeightForSize(theme, buttonTheme(theme).size);
return defaultHeightForSize(
theme, buttonTheme(theme).size ?? ShadButtonSize.regular);
}

double? defaultWidthForSize(ShadThemeData theme, ShadButtonSize size) {
Expand All @@ -567,7 +568,8 @@ class _ShadButtonState extends State<ShadButton> {
if (widget.size != null) {
return defaultWidthForSize(theme, widget.size!);
}
return defaultWidthForSize(theme, buttonTheme(theme).size);
return defaultWidthForSize(
theme, buttonTheme(theme).size ?? ShadButtonSize.regular);
}

EdgeInsetsGeometry defaultPaddingForSize(
Expand All @@ -582,7 +584,8 @@ class _ShadButtonState extends State<ShadButton> {
if (widget.size != null) {
return defaultPaddingForSize(theme, widget.size!);
}
return defaultPaddingForSize(theme, buttonTheme(theme).size);
return defaultPaddingForSize(
theme, buttonTheme(theme).size ?? ShadButtonSize.regular);
}

Color? background(ShadThemeData theme) {
Expand Down Expand Up @@ -722,7 +725,7 @@ class _ShadButtonState extends State<ShadButton> {

// Applies the foreground color filter to the icon if provided
var icon = widget.icon;
if (icon != null && applyIconColorFilter) {
if (icon != null && (applyIconColorFilter ?? true)) {
icon = ColorFiltered(
colorFilter: ColorFilter.mode(
hasPressedForegroundColor && pressed
Expand Down
8 changes: 4 additions & 4 deletions lib/src/theme/components/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import 'package:shadcn_ui/src/utils/gesture_detector.dart';
class ShadButtonTheme {
const ShadButtonTheme({
this.merge = true,
this.applyIconColorFilter = true,
this.applyIconColorFilter,
this.cursor,
this.size = ShadButtonSize.regular,
this.size,
this.sizesTheme,
this.backgroundColor,
this.hoverBackgroundColor,
Expand All @@ -40,9 +40,9 @@ class ShadButtonTheme {
});

final bool merge;
final bool applyIconColorFilter;
final bool? applyIconColorFilter;
final MouseCursor? cursor;
final ShadButtonSize size;
final ShadButtonSize? size;
final ShadButtonSizesTheme? sizesTheme;
final Color? backgroundColor;
final Color? hoverBackgroundColor;
Expand Down

0 comments on commit 81f5217

Please sign in to comment.