Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove defaults from button theme & update border merge #185

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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