Skip to content
Open
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: 4 additions & 7 deletions example/lib/pages/components/button_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import 'package:zeta_example/config/components_config.dart';
import 'package:zeta_example/widgets.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

// ignore: deprecated_member_use
final buttonTypes = ZetaButtonType.values.where((e) => e != ZetaButtonType.secondary).toList();

class ButtonExample extends StatelessWidget {
const ButtonExample({super.key});

Expand All @@ -19,11 +16,11 @@ class ButtonExample extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: List.generate(
buttonTypes.length,
ZetaButtonType.values.length,
(index2) => ZetaButton(
label: 'Button',
onPressed: index == 0 ? null : () {},
type: buttonTypes[index2],
type: ZetaButtonType.values[index2],
size: ZetaWidgetSize.values[index == 0 ? 0 : index - 1],
borderType: borderType,
),
Expand Down Expand Up @@ -74,10 +71,10 @@ class IconButtonExample extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: List.generate(
buttonTypes.length,
ZetaButtonType.values.length,
(index2) => ZetaIconButton(
onPressed: index == 0 ? null : () {},
type: buttonTypes[index2],
type: ZetaButtonType.values[index2],
size: ZetaWidgetSize.values[index == 0 ? 0 : index - 1],
borderType: borderType,
icon: icons[index2],
Expand Down
59 changes: 54 additions & 5 deletions example/lib/pages/theme/color_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class _ColorExampleState extends State<ColorExample> {
'yellow': colors.primitives.yellow,
'teal': colors.primitives.teal,
'pink': colors.primitives.pink,
'blackBrand': colors.primitives.blackBrand,
'blueBrand': colors.primitives.blueBrand,
'brownBrand': colors.primitives.brownBrand,
'greenBrand': colors.primitives.greenBrand,
'magentaBrand': colors.primitives.magentaBrand,
'orangeBrand': colors.primitives.orangeBrand,
};
final Map<String, Color> primitivesPure = {
'white': colors.primitives.pure.shade0,
Expand All @@ -39,46 +45,80 @@ class _ColorExampleState extends State<ColorExample> {
};

final Map<String, Color> mainColors = {
'defaultColor': colors.mainDefault,
'default': colors.mainDefault,
'subtle': colors.mainSubtle,
'light': colors.mainLight,
'inverse': colors.mainInverse,
'inverseSubtle': colors.mainInverseSubtle,
'disabled': colors.mainDisabled,
'primary': colors.mainPrimary,
'primaryLegacy': colors.mainPrimaryLegacy,
'secondary': colors.mainSecondary,
'positive': colors.mainPositive,
'warning': colors.mainWarning,
'negative': colors.mainNegative,
'info': colors.mainInfo,
};
final Map<String, Color> textColors = {
"body": colors.textBody,
"inline": colors.textInline,
"disabled": colors.textDisabled,
"link": colors.textLink,
"inverse": colors.textInverse,
"inverseSubtle": colors.textInverseSubtle,
"primary": colors.textPrimary,
"secondary": colors.textSecondary,
"positive": colors.textPositive,
"warning": colors.textWarning,
"negative": colors.textNegative,
"info": colors.textInfo,
};
final Map<String, Color> iconColors = {
'default': colors.iconDefault,
'inverse': colors.iconInverse,
'pure': colors.iconPure,
'subtle': colors.iconSubtle,
'disabled': colors.iconDisabled,
'inverseSubtle': colors.iconInverseSubtle,
'positive': colors.iconPositive,
'warning': colors.iconWarning,
'negative': colors.iconNegative,
};

final Map<String, Color> borderColors = {
'defaultColor': colors.borderDefault,
'default': colors.borderDefault,
'subtle': colors.borderSubtle,
'hover': colors.borderHover,
'selected': colors.borderSelected,
'disabled': colors.borderDisabled,
'pure': colors.borderPure,
'primaryMain': colors.borderPrimaryMain,
'primary': colors.borderPrimary,
'primaryLegacy': colors.borderPrimaryLegacy,
'secondary': colors.borderSecondary,
'positive': colors.borderPositive,
'warning': colors.borderWarning,
'negative': colors.borderNegative,
'info': colors.borderInfo,
};
final Map<String, Color> surfaceColors = {
'defaultColor': colors.surfaceDefault,
'defaultInverse': colors.surfaceDefaultInverse,
'default': colors.surfaceDefault,
'hover': colors.surfaceHover,
'selected': colors.surfaceSelected,
'selectedHover': colors.surfaceSelectedHover,
'disabled': colors.surfaceDisabled,
'inversePure': colors.surfaceInversePure,
'inverse': colors.surfaceInverse,
'cool': colors.surfaceCool,
'warm': colors.surfaceWarm,
'warmer': colors.surfaceWarmer,
'primary': colors.surfacePrimary,
'primarySubtle': colors.surfacePrimarySubtle,
'primaryLegacy': colors.surfacePrimaryLegacy,
'primaryLegacySubtle': colors.surfacePrimaryLegacySubtle,
'secondary': colors.surfaceSecondary,
'secondarySubtle': colors.surfaceSecondarySubtle,
'secondaryLegacy': colors.surfaceSecondaryLegacy,
'secondaryLegacySubtle': colors.surfaceSecondaryLegacySubtle,
'positive': colors.surfacePositive,
'positiveSubtle': colors.surfacePositiveSubtle,
'warning': colors.surfaceWarning,
Expand Down Expand Up @@ -112,6 +152,12 @@ class _ColorExampleState extends State<ColorExample> {
'selected': colors.statePrimarySelected,
'focus': colors.statePrimaryFocus,
};
final Map<String, Color> primaryLegacy = {
'enabled': colors.statePrimaryLegacyEnabled,
'hover': colors.statePrimaryLegacyHover,
'selected': colors.statePrimaryLegacySelected,
'focus': colors.statePrimaryLegacyFocus,
};
final Map<String, Color> secondary = {
'enabled': colors.stateSecondaryEnabled,
'hover': colors.stateSecondaryHover,
Expand Down Expand Up @@ -169,11 +215,14 @@ class _ColorExampleState extends State<ColorExample> {
children: [
Text('Semantic colors', style: Zeta.of(context).textStyles.displaySmall),
MyRow(children: mainColors, title: 'Main Colors'),
MyRow(children: textColors, title: 'Text Colors'),
MyRow(children: iconColors, title: 'Icon Colors'),
MyRow(children: borderColors, title: 'Main Colors'),
MyRow(children: surfaceColors, title: 'Surface Colors'),
MyRow(children: disabled, title: 'State / disabled Colors'),
MyRow(children: defaultColors, title: 'State / default Colors'),
MyRow(children: primary, title: 'State / primary Colors'),
MyRow(children: primaryLegacy, title: 'State / primary-leegacy Colors'),
MyRow(children: secondary, title: 'State / secondary Colors'),
MyRow(children: positive, title: 'State / positive Colors'),
MyRow(children: negative, title: 'State / negative Colors'),
Expand Down
15 changes: 0 additions & 15 deletions packages/zeta_flutter/lib/src/components/buttons/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,6 @@ class ZetaButton extends ZetaStatelessWidget {
this.child,
}) : type = ZetaButtonType.primary;

/// Constructs [ZetaButton] with Secondary theme.
@Deprecated('Secondary buttons are deprecated and will be removed in a future version.')
const ZetaButton.secondary({
super.key,
required this.label,
this.onPressed,
this.size = ZetaWidgetSize.medium,
this.borderType,
this.leadingIcon,
this.trailingIcon,
this.focusNode,
this.semanticLabel,
this.child,
}) : type = ZetaButtonType.secondary;

/// Constructs [ZetaButton] with Positive theme.
const ZetaButton.positive({
super.key,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Ignored whilst secondary is still in use
// ignore_for_file: deprecated_member_use_from_same_package

import 'package:flutter/material.dart';

import '../../../zeta_flutter.dart';
Expand All @@ -11,12 +8,6 @@ enum ZetaButtonType {
/// Border: None.
primary,

/// Background: Secondary color; defaults to yellow.
/// Border: None.

@Deprecated('Secondary buttons are deprecated and will be removed in a future version.')
secondary,

/// Background: Positive color; defaults to green.
/// Border: None.
positive,
Expand Down Expand Up @@ -46,9 +37,7 @@ enum ZetaButtonType {
Color _backgroundColor(ZetaColors colors) {
switch (this) {
case ZetaButtonType.primary:
return colors.statePrimaryEnabled;
case ZetaButtonType.secondary:
return colors.stateSecondaryEnabled;
return colors.statePrimaryLegacyEnabled;
case ZetaButtonType.positive:
return colors.statePositiveEnabled;
case ZetaButtonType.negative:
Expand All @@ -66,9 +55,7 @@ enum ZetaButtonType {
Color _hoverColor(ZetaColors colors) {
switch (this) {
case ZetaButtonType.primary:
return colors.statePrimaryHover;
case ZetaButtonType.secondary:
return colors.stateSecondaryHover;
return colors.statePrimaryLegacyHover;
case ZetaButtonType.positive:
return colors.statePositiveHover;
case ZetaButtonType.negative:
Expand All @@ -85,9 +72,7 @@ enum ZetaButtonType {
Color _pressedColor(ZetaColors colors) {
switch (this) {
case ZetaButtonType.primary:
return colors.statePrimarySelected;
case ZetaButtonType.secondary:
return colors.stateSecondarySelected;
return colors.statePrimaryLegacySelected;
case ZetaButtonType.positive:
return colors.statePositiveSelected;
case ZetaButtonType.negative:
Expand Down Expand Up @@ -142,11 +127,10 @@ ButtonStyle buttonStyle(
switch (type) {
case ZetaButtonType.outline:
case ZetaButtonType.text:
return colors.mainPrimary;
return colors.mainPrimaryLegacy;
case ZetaButtonType.outlineSubtle:
return colors.mainDefault;
case ZetaButtonType.primary:
case ZetaButtonType.secondary:
case ZetaButtonType.positive:
case ZetaButtonType.negative:
return colors.stateDefaultEnabled;
Expand All @@ -164,11 +148,11 @@ ButtonStyle buttonStyle(
}
// TODO(UX-1134): This removes a defualt border when focused, rather than adding a second border when focused.
if (states.contains(WidgetState.focused)) {
return BorderSide(color: colors.borderPrimary, width: ZetaBorders.medium);
return BorderSide(color: colors.borderPrimaryLegacy, width: ZetaBorders.medium);
}
if (type._border) {
return BorderSide(
color: type == ZetaButtonType.outline ? colors.borderPrimaryMain : colors.borderSubtle,
color: type == ZetaButtonType.outline ? colors.borderPrimaryLegacy : colors.borderSubtle,
);
}

Expand All @@ -184,11 +168,10 @@ ButtonStyle buttonStyle(
switch (type) {
case ZetaButtonType.outline:
case ZetaButtonType.text:
return colors.mainPrimary;
return colors.mainPrimaryLegacy;
case ZetaButtonType.outlineSubtle:
return colors.mainDefault;
case ZetaButtonType.primary:
case ZetaButtonType.secondary:
case ZetaButtonType.positive:
case ZetaButtonType.negative:
return colors.stateDefaultEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ class ZetaIconButton extends ZetaStatelessWidget {
this.semanticLabel,
}) : type = ZetaButtonType.primary;

/// Constructs [ZetaIconButton] with Secondary theme.
@Deprecated('Secondary buttons are deprecated and will be removed in a future version.')
const ZetaIconButton.secondary({
super.key,
super.rounded,
required this.icon,
this.onPressed,
this.size = ZetaWidgetSize.medium,
this.borderType,
this.semanticLabel,
}) : type = ZetaButtonType.secondary;

/// Constructs [ZetaIconButton] with Positive theme.
const ZetaIconButton.positive({
super.key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class _CheckboxState extends State<ZetaInternalCheckbox> {
BoxShadow(
spreadRadius: 2,
blurStyle: BlurStyle.solid,
color: theme.colors.borderPrimary,
color: theme.colors.borderPrimaryLegacy,
),
],
color: _getBackground(theme),
Expand Down
2 changes: 1 addition & 1 deletion packages/zeta_flutter/lib/src/components/chips/chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class _ZetaChipState extends State<ZetaChip> {
if (states.contains(WidgetState.hovered)) {
return colors.borderHover;
}
return colors.surfaceDefaultInverse;
return colors.stateInverseEnabled;
}
if (states.contains(WidgetState.pressed) || isDragging) {
return colors.surfaceSelected;
Expand Down
2 changes: 1 addition & 1 deletion packages/zeta_flutter/lib/src/components/fabs/fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class _ZetaFABState extends State<ZetaFAB> {
(Set<WidgetState> states) {
if (states.contains(WidgetState.focused)) {
// TODO(UX-1134): This removes a defualt border when focused, rather than adding a second border when focused.
return BorderSide(color: Zeta.of(context).colors.borderPrimary, width: ZetaBorders.medium);
return BorderSide(color: Zeta.of(context).colors.borderPrimaryLegacy, width: ZetaBorders.medium);
}
return null;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class _ZetaRangeSelectorState extends State<ZetaRangeSelector> {
if (widget.onChange == null) {
return colors.mainDisabled;
}
return _selected ? colors.mainPrimary : colors.surfaceDefaultInverse;
return _selected ? colors.mainPrimary : colors.mainDefault;
}

void _onSubmit(TextEditingController controller, {bool lower = true}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class ZetaSnackBar extends SnackBar {
ZetaSnackBarType.warning => colors.surfaceWarningSubtle,
ZetaSnackBarType.deletion || ZetaSnackBarType.error => colors.surfaceNegativeSubtle,
ZetaSnackBarType.view => colors.surfacePrimarySubtle,
_ => colors.surfaceDefaultInverse,
_ => colors.surfaceInversePure,
};
}
}
Expand Down Expand Up @@ -225,12 +225,12 @@ class _Action extends StatelessWidget {
return switch (type) {
ZetaSnackBarType.defaultType => _IconButton(
onPressed: () => ScaffoldMessenger.of(context).removeCurrentSnackBar(),
color: colors.surfaceDefaultInverse,
color: colors.iconInverse,
),
ZetaSnackBarType.action => _ActionButton(
onPressed: onPressed,
label: label,
color: colors.borderPrimaryMain,
color: colors.mainLight,
),
ZetaSnackBarType.positive ||
ZetaSnackBarType.info ||
Expand All @@ -253,7 +253,7 @@ class _Action extends StatelessWidget {
_ => _ActionButton(
onPressed: onPressed,
label: label,
color: colors.borderPrimaryMain,
color: colors.mainDefault,
),
};
}(),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ void main() {
});

group('Accessibility Tests', () {
// Ignoring the secondary button type as it is deprecated.
// ignore: deprecated_member_use_from_same_package
final buttonTypes = ZetaButtonType.values.where((type) => type != ZetaButtonType.secondary);
for (final buttonType in buttonTypes) {
for (final buttonType in ZetaButtonType.values) {
for (final size in ZetaWidgetSize.values) {
meetsAccessibilityGuidelinesTest(
ZetaButton(
onPressed: () {},
label: '${buttonType.name} ${size.name}',
label: '$buttonType ${size.name}',
type: buttonType,
size: size,
),
testName: '$buttonType ${size.name}',
);
}
}
Expand Down
Loading
Loading