Skip to content

Commit

Permalink
fix: WIdgetbook theme (#16)
Browse files Browse the repository at this point in the history
* Added theme support for Widgetbook. This had been casuing issues where the theme mode was not rendering the correct widgets. This also lead to the discovery of theme issues on checkbox and avatar, which have been fixed.

* fix type story and add icon story

* Adding spacing widgetbook

* adding icon names
  • Loading branch information
thelukewalton authored Feb 14, 2024
1 parent de6d76d commit 5e1c48a
Show file tree
Hide file tree
Showing 26 changed files with 820 additions and 401 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Build example app
run: |
cd example
flutter build web -o ../build --no-tree-shake-icons
flutter build web -t widgetbook/main.dart -o ../build --no-tree-shake-icons
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
sdk: flutter
go_router: ^11.1.2
google_fonts: ^6.1.0
path_drawing: ^1.0.1
shared_preferences: ^2.2.2
zeta_flutter:
path: ../
Expand Down
39 changes: 0 additions & 39 deletions example/widgetbook/components/accordion_widgetbook.dart

This file was deleted.

32 changes: 0 additions & 32 deletions example/widgetbook/components/checkbox_widgetbook.dart

This file was deleted.

63 changes: 63 additions & 0 deletions example/widgetbook/pages/assets/icon_widgetbook.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';

WidgetbookComponent iconWidgetbook() {
return WidgetbookComponent(
isInitiallyExpanded: false,
name: 'Icons',
useCases: [
WidgetbookUseCase(
name: 'All Icons',
builder: (context) {
Map<String, IconData> icons =
(context.knobs.boolean(label: 'Rounded', initialValue: true)) ? iconsRounded : iconsSharp;

return WidgetbookTestWidget(
removeBody: true,
widget: SingleChildScrollView(
child: Center(
child: Column(
children: [
Text('Tap icon to copy name to clipboard', style: ZetaTextStyles.titleMedium)
.paddingAll(ZetaSpacing.l),
Wrap(
spacing: ZetaSpacing.l,
runSpacing: ZetaSpacing.l,
children: icons.entries.map(
(e) {
final nameArr = e.key.split('_')..removeLast();
return Container(
width: 100,
height: 100,
child: InkWell(
borderRadius: ZetaRadius.rounded,
hoverColor: Zeta.of(context).colors.surfaceHovered,
onTap: () async {
await Clipboard.setData(ClipboardData(text: 'ZetaIcons.' + e.key));
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(e.value, size: 40),
Text(nameArr.join(' '), textAlign: TextAlign.center)
],
),
),
);
},
).toList(),
),
],
),
),
),
);
},
),
],
);
}
40 changes: 40 additions & 0 deletions example/widgetbook/pages/components/accordion_widgetbook.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';

WidgetbookComponent accordionWidgetBook() {
return WidgetbookComponent(
isInitiallyExpanded: false,
name: 'Accordion',
useCases: [
WidgetbookUseCase(
name: 'Accordion',
builder: (context) {
return WidgetbookTestWidget(
widget: Padding(
padding: const EdgeInsets.all(20),
child: ZetaAccordion(
child: context.knobs.boolean(label: 'Disabled')
? null
: Column(
children: [
ListTile(title: Text('Item One')),
ListTile(title: Text('Item two')),
ListTile(title: Text('Item three')),
ListTile(title: Text('Item four')),
],
),
title: context.knobs.string(label: 'Accordion Title', initialValue: 'Title'),
contained: context.knobs.boolean(label: 'Contained', initialValue: false),
isOpen: context.knobs.boolean(label: 'Open', initialValue: false),
rounded: context.knobs.boolean(label: 'Rounded', initialValue: false),
),
),
);
},
),
],
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../test/test_components.dart';
import '../../test/test_components.dart';

WidgetbookComponent avatarWidgetBook() {
return WidgetbookComponent(
Expand All @@ -15,7 +15,6 @@ WidgetbookComponent avatarWidgetBook() {
final Widget image = Image.network('https://i.ytimg.com/vi/KItsWUzFUOs/maxresdefault.jpg', fit: BoxFit.cover);

return WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
children: [
Padding(
Expand All @@ -40,7 +39,6 @@ WidgetbookComponent avatarWidgetBook() {
name: 'Initials Avatar',
builder: (context) {
return WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
children: [
Padding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../test/test_components.dart';
import '../../test/test_components.dart';

WidgetbookComponent badgeWidgetBook() {
return WidgetbookComponent(
Expand All @@ -13,7 +13,6 @@ WidgetbookComponent badgeWidgetBook() {
name: 'Status Label',
builder: (context) {
return WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
children: [
Padding(
Expand Down Expand Up @@ -48,7 +47,6 @@ WidgetbookComponent badgeWidgetBook() {
WidgetbookUseCase(
name: 'Priority Pill',
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
children: [
Padding(
Expand All @@ -66,7 +64,6 @@ WidgetbookComponent badgeWidgetBook() {
WidgetbookUseCase(
name: 'Badge',
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand All @@ -85,7 +82,6 @@ WidgetbookComponent badgeWidgetBook() {
WidgetbookUseCase(
name: 'Indicators',
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand Down Expand Up @@ -121,7 +117,6 @@ WidgetbookComponent badgeWidgetBook() {
WidgetbookUseCase(
name: 'Tags',
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand All @@ -140,7 +135,6 @@ WidgetbookComponent badgeWidgetBook() {
WidgetbookUseCase(
name: 'Workcloud Indicators',
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../test/test_components.dart';
import '../../test/test_components.dart';

WidgetbookComponent BannerWidgetBook() {
WidgetbookComponent bannerWidgetBook() {
return WidgetbookComponent(
isInitiallyExpanded: false,
name: 'Banners',
Expand Down Expand Up @@ -49,7 +49,6 @@ WidgetbookComponent BannerWidgetBook() {
WidgetbookUseCase(
name: 'In Page Banner',
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Padding(
padding: EdgeInsets.all(20),
child: Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../test/test_components.dart';
import '../../test/test_components.dart';

WidgetbookComponent bottomSheetWidgetBook() {
return WidgetbookComponent(
Expand All @@ -12,7 +12,6 @@ WidgetbookComponent bottomSheetWidgetBook() {
WidgetbookUseCase(
name: 'Content',
builder: (context) => WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Padding(
padding: const EdgeInsets.all(20),
child: _bottomSheet(context),
Expand All @@ -24,7 +23,6 @@ WidgetbookComponent bottomSheetWidgetBook() {
builder: (context) {
final sheet = _bottomSheet(context);
return WidgetbookTestWidget(
themeMode: ThemeMode.dark,
widget: Padding(
padding: const EdgeInsets.all(20),
child: ElevatedButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../test/test_components.dart';
import '../../test/test_components.dart';

WidgetbookComponent buttonWidgetBook() {
return WidgetbookComponent(
Expand All @@ -13,15 +13,21 @@ WidgetbookComponent buttonWidgetBook() {
name: 'Button',
builder: (context) {
return WidgetbookTestWidget(
widget: Padding(
padding: EdgeInsets.all(20),
child: ZetaButton(
label: context.knobs.string(label: 'Text', initialValue: 'Button'),
onPressed: context.knobs.boolean(label: 'Disabled') ? null : () {},
borderType: context.knobs.boolean(label: 'Rounded') ? ZetaWidgetBorder.rounded : ZetaWidgetBorder.sharp,
size: context.knobs.list(label: 'Size', options: ZetaWidgetSize.values),
type: context.knobs.list(label: 'Type', options: ZetaButtonType.values),
),
widget: Row(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsets.all(20),
child: ZetaButton(
label: context.knobs.string(label: 'Text', initialValue: 'Button'),
onPressed: context.knobs.boolean(label: 'Disabled') ? null : () {},
borderType:
context.knobs.boolean(label: 'Rounded') ? ZetaWidgetBorder.rounded : ZetaWidgetBorder.sharp,
size: context.knobs.list(label: 'Size', options: ZetaWidgetSize.values),
type: context.knobs.list(label: 'Type', options: ZetaButtonType.values),
),
),
],
),
);
},
Expand Down
Loading

0 comments on commit 5e1c48a

Please sign in to comment.