Skip to content

Commit

Permalink
feat: [MDS-1172] Create typography page (#412)
Browse files Browse the repository at this point in the history
Co-authored-by: Birgitt Majas <birgitt.majas@yolo.com>
  • Loading branch information
GittHub-d and Birgitt Majas committed Jun 5, 2024
1 parent d8fecbc commit 88bd6a7
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 75 deletions.
99 changes: 51 additions & 48 deletions example/lib/src/storybook/common/pages/colors_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:example/src/storybook/common/color_options.dart';
import 'package:example/src/storybook/common/colors_page_options.dart';
import 'package:example/src/storybook/common/constants.dart';
import 'package:example/src/storybook/common/widgets/colors_page_options.dart';
import 'package:example/src/storybook/common/widgets/page_footer.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
Expand Down Expand Up @@ -109,8 +109,8 @@ class ColorsPage extends StatelessWidget {
),
);

return RichText(
text: TextSpan(
return Text.rich(
TextSpan(
style: textStyle,
children: spans,
),
Expand Down Expand Up @@ -210,13 +210,14 @@ class ColorsPage extends StatelessWidget {
Container(
height: _colorContainerSizeValue,
width: colorContainerWidth,
decoration: ShapeDecoration(
color: getColor(context, moonColor),
shape: ContinuousRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
side: BorderSide(
color: context.moonColors!.beerus,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.0),
border: Border.all(color: context.moonColors!.beerus),
),
child: DecoratedBox(
decoration: BoxDecoration(
color: getColor(context, moonColor),
borderRadius: BorderRadius.circular(15.0),
),
),
),
Expand All @@ -241,46 +242,48 @@ class ColorsPage extends StatelessWidget {
right: 24,
bottom: 16.0,
),
child: Center(
child: SizedBox(
width: largeScreenWidth,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: mediumScreenWidth,
child: SelectionArea(
child: Center(
child: SizedBox(
width: largeScreenWidth,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: mediumScreenWidth,
),
child: Column(
children: [
_buildSectionHeader(
context,
ColorsPageSection.header,
),
const SizedBox(height: 24.0),
_buildSectionHeader(
context,
ColorsPageSection.mainColors,
),
_buildMainColorsSection(context),
const SizedBox(height: 48.0),
_buildSectionHeader(
context,
ColorsPageSection.supportiveColors,
),
_buildSupportiveColorsSection(context),
],
),
),
child: Column(
children: [
_buildSectionHeader(
context,
ColorsPageSection.header,
),
const SizedBox(height: 24.0),
_buildSectionHeader(
context,
ColorsPageSection.mainColors,
),
_buildMainColorsSection(context),
const SizedBox(height: 48.0),
_buildSectionHeader(
context,
ColorsPageSection.supportiveColors,
),
_buildSupportiveColorsSection(context),
],
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: _getFooterWidth(context),
),
child: const Center(
child: PageFooter(),
),
),
),
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: _getFooterWidth(context),
),
child: const Center(
child: PageFooter(),
),
),
],
],
),
),
),
),
Expand Down
55 changes: 29 additions & 26 deletions example/lib/src/storybook/common/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class HomePage extends StatelessWidget {
),
Text(
HomePageContentType.headerTitle.text,
style: typography.heading.text64.copyWith(height: 1.1),
style: typography.heading.text64,
),
const SizedBox(height: 24.0),
Text(
Expand All @@ -64,7 +64,7 @@ class HomePage extends StatelessWidget {
const SizedBox(height: 72.0),
Text(
HomePageContentType.bodyTitle.text,
style: typography.heading.text40.copyWith(height: 1.1),
style: typography.heading.text40,
),
],
),
Expand Down Expand Up @@ -96,7 +96,8 @@ class HomePage extends StatelessWidget {

return MoonButton(
width: double.infinity,
backgroundColor: isGitHub ? Colors.deepPurple : Colors.orange,
backgroundColor:
isGitHub ? context.moonColors!.piccolo : context.moonColors!.krillin,
onTap: () => launchURL(socialMedia.url),
leading: SvgPicture.asset(
socialMedia.buttonIconPath,
Expand Down Expand Up @@ -196,8 +197,7 @@ class HomePage extends StatelessWidget {
component.description,
maxLines: isExtraSmallScreen ? 3 : 2,
overflow: TextOverflow.ellipsis,
style: context.moonTypography!.heading.text14
.copyWith(height: 1.6),
style: context.moonTypography!.heading.text14,
),
],
),
Expand Down Expand Up @@ -227,27 +227,30 @@ class HomePage extends StatelessWidget {
right: 24,
bottom: 16.0,
),
child: Center(
child: SizedBox(
width: largeScreenWidth,
child: Column(
crossAxisAlignment: layoutWidth > mediumScreenWidth
? CrossAxisAlignment.start
: CrossAxisAlignment.center,
children: [
_buildHeaderSection(context, showLogo),
const SizedBox(height: 48.0),
LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Column(
children: [
_buildCards(context, constraints.maxWidth),
const PageFooter(),
],
);
},
),
],
child: SelectionArea(
child: Center(
child: SizedBox(
width: largeScreenWidth,
child: Column(
crossAxisAlignment: layoutWidth > mediumScreenWidth
? CrossAxisAlignment.start
: CrossAxisAlignment.center,
children: [
_buildHeaderSection(context, showLogo),
const SizedBox(height: 48.0),
LayoutBuilder(
builder:
(BuildContext context, BoxConstraints constraints) {
return Column(
children: [
_buildCards(context, constraints.maxWidth),
const PageFooter(),
],
);
},
),
],
),
),
),
),
Expand Down
144 changes: 144 additions & 0 deletions example/lib/src/storybook/common/pages/typography_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import 'package:example/src/storybook/common/constants.dart';
import 'package:example/src/storybook/common/typography_page_options.dart';
import 'package:example/src/storybook/common/widgets/page_footer.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:moon_design/moon_design.dart';

class TypographyPage extends StatelessWidget {
static const path = '/typography';

const TypographyPage({super.key});

Widget _buildSectionHeader(
BuildContext context,
TypographyPageSection section,
) {
final bool isHeader = section == TypographyPageSection.typography;
final bool showLogo =
MediaQuery.of(context).size.width < storybookAutoLayoutThreshold;

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (isHeader && showLogo)
Padding(
padding: const EdgeInsets.only(left: 12.0, bottom: 24.0),
child: SvgPicture.asset(
'assets/svg/moon-logo-long.svg',
height: 16.0,
),
),
Text(
section.titleText,
style: isHeader
? context.moonTypography!.heading.text40
: context.moonTypography!.heading.text24,
),
const SizedBox(height: 24),
if (section.bodyText.isNotEmpty)
Text(
section.bodyText,
style: context.moonTypography!.body.text16,
),
],
);
}

Widget _buildTypographyContainer(BuildContext context, MoonTextStyle style) {
return Container(
width: double.infinity,
padding: const EdgeInsets.all(24.0),
decoration: BoxDecoration(
color: context.moonColors!.gohan,
borderRadius: BorderRadius.circular(16.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(
MoonTextSize.values.length * 2 - 1,
(int index) {
final int derivedIndex = index ~/ 2;

return index.isEven
? Text(
MoonTextSize.values[derivedIndex].name,
style: style == MoonTextStyle.body
? getBodyTextStyle(
context,
MoonTextSize.values[derivedIndex],
)
: getHeadingTextStyle(
context,
MoonTextSize.values[derivedIndex],
),
)
: const SizedBox(height: 8.0);
},
),
),
);
}

@override
Widget build(BuildContext context) {
final bool showLogo =
MediaQuery.of(context).size.width < storybookAutoLayoutThreshold;

return Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
padding: EdgeInsets.only(
top: showLogo ? 40.0 : 80,
left: 24,
right: 24,
bottom: 16.0,
),
child: SelectionArea(
child: Center(
child: SizedBox(
width: largeScreenWidth,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: mediumScreenWidth,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildSectionHeader(
context,
TypographyPageSection.typography,
),
const SizedBox(height: 48.0),
_buildSectionHeader(
context,
TypographyPageSection.body,
),
_buildTypographyContainer(context, MoonTextStyle.body),
const SizedBox(height: 48.0),
_buildSectionHeader(
context,
TypographyPageSection.heading,
),
_buildTypographyContainer(
context,
MoonTextStyle.heading,
),
const Center(
child: PageFooter(),
),
],
),
),
],
),
),
),
),
),
);
}
}
Loading

0 comments on commit 88bd6a7

Please sign in to comment.