Skip to content

Commit

Permalink
feat: adding widgetbook use cases for texts
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzanardo committed Jun 19, 2024
1 parent 2558fb6 commit 2fd056f
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 5 deletions.
110 changes: 110 additions & 0 deletions widgetbook/lib/widgetbook/use_cases/typography.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// ignore_for_file: public_member_api_docs

import 'package:flutter/material.dart';
import 'package:nes_ui/nes_ui.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;

Widget build({
required List<TextStyle?> textStyles,
required List<String> texts,
}) =>
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
for (var i = 0; i < textStyles.length; i++)
Padding(
padding: const EdgeInsets.all(8),
child: Text(
texts[i],
style: textStyles[i],
),
),
],
),
);

@widgetbook.UseCase(
name: 'body',
type: Text,
)
Widget body(BuildContext context) => build(
textStyles: [
Theme.of(context).textTheme.bodySmall,
Theme.of(context).textTheme.bodyMedium,
Theme.of(context).textTheme.bodyLarge,
],
texts: [
'Body Small',
'Body Medium',
'Body Large',
],
);

@widgetbook.UseCase(
name: 'display',
type: Text,
)
Widget display(BuildContext context) => build(
textStyles: [
Theme.of(context).textTheme.displaySmall,
Theme.of(context).textTheme.displayMedium,
Theme.of(context).textTheme.displayLarge,
],
texts: [
'Display Small',
'Display Medium',
'Display Large',
],
);

@widgetbook.UseCase(
name: 'headline',
type: Text,
)
Widget headline(BuildContext context) => build(
textStyles: [
Theme.of(context).textTheme.headlineSmall,
Theme.of(context).textTheme.headlineMedium,
Theme.of(context).textTheme.headlineLarge,
],
texts: [
'Headline Small',
'Headline Medium',
'Headline Large',
],
);

@widgetbook.UseCase(
name: 'title',
type: Text,
)
Widget title(BuildContext context) => build(
textStyles: [
Theme.of(context).textTheme.titleSmall,
Theme.of(context).textTheme.titleMedium,
Theme.of(context).textTheme.titleLarge,
],
texts: [
'Title Small',
'Title Medium',
'Title Large',
],
);

@widgetbook.UseCase(
name: 'label',
type: Text,
)
Widget label(BuildContext context) => build(
textStyles: [
Theme.of(context).textTheme.labelSmall,
Theme.of(context).textTheme.labelMedium,
Theme.of(context).textTheme.labelLarge,
],
texts: [
'Label Small',
'Label Medium',
'Label Large',
],
);
36 changes: 31 additions & 5 deletions widgetbook/lib/widgetbook/widgetbook.directories.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import 'package:widgetbook/widgetbook.dart' as _i1;
import 'package:widgetbook_app/widgetbook/use_cases/buttons.dart' as _i2;
import 'package:widgetbook_app/widgetbook/use_cases/checkboxes.dart' as _i3;
import 'package:widgetbook_app/widgetbook/use_cases/containers.dart' as _i6;
import 'package:widgetbook_app/widgetbook/use_cases/containers.dart' as _i7;
import 'package:widgetbook_app/widgetbook/use_cases/dropdown_menus.dart' as _i4;
import 'package:widgetbook_app/widgetbook/use_cases/running_texts.dart' as _i5;
import 'package:widgetbook_app/widgetbook/use_cases/typography.dart' as _i6;

final directories = <_i1.WidgetbookNode>[
_i1.WidgetbookFolder(
Expand Down Expand Up @@ -79,6 +80,31 @@ final directories = <_i1.WidgetbookNode>[
builder: _i5.lines,
),
),
_i1.WidgetbookComponent(
name: 'Text',
useCases: [
_i1.WidgetbookUseCase(
name: 'body',
builder: _i6.body,
),
_i1.WidgetbookUseCase(
name: 'display',
builder: _i6.display,
),
_i1.WidgetbookUseCase(
name: 'headline',
builder: _i6.headline,
),
_i1.WidgetbookUseCase(
name: 'label',
builder: _i6.label,
),
_i1.WidgetbookUseCase(
name: 'title',
builder: _i6.title,
),
],
),
_i1.WidgetbookFolder(
name: 'containers',
children: [
Expand All @@ -87,19 +113,19 @@ final directories = <_i1.WidgetbookNode>[
useCases: [
_i1.WidgetbookUseCase(
name: 'default',
builder: _i6.normal,
builder: _i7.normal,
),
_i1.WidgetbookUseCase(
name: 'with corner inner square painter',
builder: _i6.cornerInnerSquare,
builder: _i7.cornerInnerSquare,
),
_i1.WidgetbookUseCase(
name: 'with label',
builder: _i6.label,
builder: _i7.label,
),
_i1.WidgetbookUseCase(
name: 'with square corner painter',
builder: _i6.squareConer,
builder: _i7.squareConer,
),
],
)
Expand Down

0 comments on commit 2fd056f

Please sign in to comment.