Skip to content

Commit

Permalink
chore: Update text styles (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
thelukewalton committed Apr 12, 2024
1 parent 31bc20a commit 0c1ce6f
Show file tree
Hide file tree
Showing 19 changed files with 174 additions and 56 deletions.
2 changes: 1 addition & 1 deletion example/lib/pages/theme/typography_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class TypographyExample extends StatelessWidget {
'Body Large': ZetaTextStyles.bodyLarge,
'Body Medium': ZetaTextStyles.bodyMedium,
'Body Small': ZetaTextStyles.bodySmall,
'Body X-Small': ZetaTextStyles.bodyXSmall,
'Label Large': ZetaTextStyles.labelLarge,
'Label Medium': ZetaTextStyles.labelMedium,
'Label Small': ZetaTextStyles.labelSmall,
'Label Indicator': ZetaTextStyles.labelIndicator,
'Label Tiny': ZetaTextStyles.labelTiny,
};

return ExampleScaffold(
Expand Down
6 changes: 1 addition & 5 deletions example/lib/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:zeta_example/utils/theme_color_switch.dart';
import 'package:zeta_example/utils/theme_constrast_switch.dart';
import 'package:zeta_example/utils/theme_mode_switch.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

class ExampleScaffold extends StatelessWidget {
final String name;
Expand All @@ -29,10 +28,7 @@ class ExampleScaffold extends StatelessWidget {
floatingActionButton: floatingActionButton,
appBar: AppBar(
centerTitle: false,
title: Text(
name,
style: ZetaTextStyles.titleMedium,
),
title: Text(name),
backgroundColor: colors.primary,
foregroundColor: colors.onPrimary,
actions: [
Expand Down
2 changes: 1 addition & 1 deletion example/macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1510;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
33CC10EC2044A3C60003C045 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 3 additions & 3 deletions example/test/typography_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void main() {
Text(exampleText, style: ZetaTextStyles.displayLarge, key: key3),
Text(
exampleText,
style: TextStyle(fontSize: 52, fontWeight: FontWeight.w300, height: 64 / 52),
style: TextStyle(fontSize: 52, fontWeight: FontWeight.w300, height: 60 / 52),
key: key4,
),
],
Expand Down Expand Up @@ -55,10 +55,10 @@ void main() {
expect(text3.style, text4.style);

/// Test font size of [ZetaTextStyles.bodyMedium] is correct
expect(text1.style!.fontSize, 14);
expect(text1.style!.fontSize, 16);

/// Test line height of [ZetaTextStyles.bodyMedium] is correct
expect(text1.style!.height, 20 / 14);
expect(text1.style!.height, 24 / 16);

/// Test font weight of [ZetaTextStyles.bodyMedium] is correct
expect(text1.style!.fontWeight, FontWeight.w400);
Expand Down
2 changes: 1 addition & 1 deletion example/widgetbook/pages/theme/typography_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const Map<String, TextStyle> allTypes = {
'Body large': ZetaTextStyles.bodyLarge,
'Body medium': ZetaTextStyles.bodyMedium,
'Body small': ZetaTextStyles.bodySmall,
'Body X-small': ZetaTextStyles.bodyXSmall,
'Label large': ZetaTextStyles.labelLarge,
'Label medium': ZetaTextStyles.labelMedium,
'Label small': ZetaTextStyles.labelSmall,
'Label indicator': ZetaTextStyles.labelIndicator,
'Label tiny': ZetaTextStyles.labelTiny,
};

Widget typographyUseCase(BuildContext context) => Padding(
Expand Down
12 changes: 11 additions & 1 deletion lib/src/components/accordion/accordion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,17 @@ class _ZetaAccordionState extends State<ZetaAccordion> with TickerProviderStateM
axisAlignment: -1,
child: Padding(
padding: const EdgeInsets.fromLTRB(ZetaSpacing.x4, 0, ZetaSpacing.x4, ZetaSpacing.x4),
child: DefaultTextStyle(style: ZetaTextStyles.titleSmall, child: widget.child ?? const SizedBox()),
child: Theme(
data: Theme.of(context).copyWith(
listTileTheme: ListTileThemeData(
titleTextStyle: ZetaTextStyles.titleSmall.apply(color: zetaColors.textDefault),
),
),
child: DefaultTextStyle(
style: ZetaTextStyles.titleSmall,
child: widget.child ?? const SizedBox(),
),
),
),
),
],
Expand Down
6 changes: 4 additions & 2 deletions lib/src/components/badges/indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ class ZetaIndicator extends StatelessWidget {
return Center(
child: Text(
value.formatMaxChars(),
style: (size == ZetaWidgetSize.large ? ZetaTextStyles.labelIndicator : ZetaTextStyles.labelTiny)
.apply(color: foregroundColor),
style: ZetaTextStyles.labelIndicator.copyWith(
color: foregroundColor,
fontSize: size == ZetaWidgetSize.large ? null : 11,
), // TODO(thelukwalton): Awaiting updated design.
),
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/components/badges/priority_pill.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class ZetaPriorityPill extends StatelessWidget {
shape: rounded ? BoxShape.circle : BoxShape.rectangle,
color: backgroundColor,
),
child: Text(index.formatMaxChars(), style: ZetaTextStyles.bodyMedium.apply(color: foregroundColor)),
child: Text(index.formatMaxChars(), style: ZetaTextStyles.bodySmall.apply(color: foregroundColor)),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: ZetaSpacing.x2, vertical: ZetaSpacing.x1),
child: Text(
priority,
style: ZetaTextStyles.bodyMedium,
style: ZetaTextStyles.bodySmall,
overflow: TextOverflow.ellipsis,
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/badges/workcloud_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class ZetaWorkcloudIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ZetaColorSwatch color = priorityType.color(context);
final textStyle = prioritySize == ZetaWidgetSize.large ? ZetaTextStyles.labelMedium : ZetaTextStyles.labelTiny;
final textStyle = prioritySize == ZetaWidgetSize.large ? ZetaTextStyles.bodySmall : ZetaTextStyles.bodyXSmall;

return DecoratedBox(
decoration: BoxDecoration(
Expand Down
6 changes: 3 additions & 3 deletions lib/src/components/banners/in_page_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ class ZetaInPageBanner extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: ZetaSpacing.x2_5),
const SizedBox(height: ZetaSpacing.x2),
if (hasTitle)
Text(
title!,
style: ZetaTextStyles.titleSmall,
style: ZetaTextStyles.labelLarge,
).paddingBottom(ZetaSpacing.xxs),
DefaultTextStyle(
style: ZetaTextStyles.bodyMedium.apply(color: theme.colors.textDefault),
style: ZetaTextStyles.bodySmall.apply(color: theme.colors.textDefault),
child: content,
),
if (actions.isNotEmpty)
Expand Down
3 changes: 1 addition & 2 deletions lib/src/components/banners/system_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ class ZetaSystemBanner extends MaterialBanner {
}

return DefaultTextStyle(
style: ZetaTextStyles.titleSmall.copyWith(
style: ZetaTextStyles.labelLarge.copyWith(
color: foregroundColor,
overflow: TextOverflow.ellipsis,
height: 1,
),
child: Row(
mainAxisAlignment: titleStart ? MainAxisAlignment.center : MainAxisAlignment.start,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/breadcrumbs/breadcrumbs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class _ZetaBreadCrumbState extends State<ZetaBreadCrumb> {
),
Text(
widget.label,
style: TextStyle(color: getColor(controller.value, colors)),
style: ZetaTextStyles.bodySmall.apply(color: getColor(controller.value, colors)),
),
],
),
Expand Down
4 changes: 1 addition & 3 deletions lib/src/components/buttons/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import 'package:flutter/material.dart';

import '../../../zeta_flutter.dart';

///Button types
///Zeta Button
class ZetaButton extends StatelessWidget {
///Constructs [ZetaButton]
Expand Down Expand Up @@ -135,7 +133,7 @@ class ZetaButton extends StatelessWidget {
);
}

TextStyle get _textStyle => size == ZetaWidgetSize.small ? ZetaTextStyles.labelMedium : ZetaTextStyles.labelLarge;
TextStyle get _textStyle => size == ZetaWidgetSize.small ? ZetaTextStyles.labelSmall : ZetaTextStyles.labelLarge;

double get _minConstraints {
switch (size) {
Expand Down
11 changes: 4 additions & 7 deletions lib/src/components/buttons/button_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,11 @@ class _ZetaGroupButtonState extends State<ZetaGroupButton> {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (widget.icon != null) Icon(widget.icon),
Text(widget.label!),
if (widget.icon != null) Icon(widget.icon, size: ZetaSpacing.x5),
Text(widget.label ?? '', style: ZetaTextStyles.labelMedium),
if (widget.dropdown != null) // TODO(UX-1006): Dropdown
Icon(
widget.rounded ? ZetaIcons.expand_more_round : ZetaIcons.expand_more_sharp,
size: 20,
),
],
Icon(widget.rounded ? ZetaIcons.expand_more_round : ZetaIcons.expand_more_sharp, size: ZetaSpacing.x5),
].divide(const SizedBox(width: ZetaSpacing.x1)).toList(),
).paddingAll(_padding),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/checkbox/checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class _CheckboxState extends State<_Checkbox> {
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: ZetaSpacing.s),
child: Text(widget.label!, style: ZetaTextStyles.bodyLarge),
child: Text(widget.label!, style: ZetaTextStyles.bodyMedium),
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/chips/chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class _ZetaChipState extends State<ZetaChip> {
shape: MaterialStateProperty.all(
RoundedRectangleBorder(borderRadius: widget.rounded ? ZetaRadius.full : ZetaRadius.none),
),
textStyle: MaterialStateProperty.all(ZetaTextStyles.bodyMedium),
textStyle: MaterialStateProperty.all(ZetaTextStyles.bodySmall),
backgroundColor: MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled)) {
return colors.surfaceDisabled;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/radio/radio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class _ZetaRadioState<T> extends State<ZetaRadio<T>> with TickerProviderStateMix
GestureDetector(
onTap: () => onChanged?.call(true),
child: DefaultTextStyle(
style: ZetaTextStyles.bodyLarge.copyWith(
style: ZetaTextStyles.bodyMedium.copyWith(
color: states.contains(MaterialState.disabled) ? zetaColors.textDisabled : zetaColors.textDefault,
height: 1.33,
),
Expand Down
Loading

0 comments on commit 0c1ce6f

Please sign in to comment.