Skip to content

Commit 6d45c20

Browse files
committed
feat: add shadow tokens (#7726)
1 parent 64a2d2d commit 6d45c20

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

frontend/appflowy_flutter/packages/appflowy_ui/lib/src/theme/data/builder.dart

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:appflowy_ui/src/theme/color_scheme/icon/icon_color_theme.dart';
88
import 'package:appflowy_ui/src/theme/color_scheme/surface/surface_color_scheme.dart';
99
import 'package:appflowy_ui/src/theme/color_scheme/text/text_color_scheme.dart';
1010
import 'package:appflowy_ui/src/theme/dimensions.dart';
11+
import 'package:appflowy_ui/src/theme/shadow/shadow.dart';
1112
import 'package:appflowy_ui/src/theme/spacing/spacing.dart';
1213
import 'package:flutter/material.dart';
1314

@@ -321,4 +322,43 @@ class AppFlowyThemeBuilder {
321322
xxl: AppFlowySpacingConstant.spacing600,
322323
);
323324
}
325+
326+
AppFlowyShadow buildShadow(
327+
Brightness brightness,
328+
) {
329+
return switch (brightness) {
330+
Brightness.light => AppFlowyShadow(
331+
small: [
332+
BoxShadow(
333+
offset: Offset(0, 2),
334+
blurRadius: 16,
335+
color: Color(0x1F000000),
336+
),
337+
],
338+
medium: [
339+
BoxShadow(
340+
offset: Offset(0, 4),
341+
blurRadius: 32,
342+
color: Color(0x1F000000),
343+
),
344+
],
345+
),
346+
Brightness.dark => AppFlowyShadow(
347+
small: [
348+
BoxShadow(
349+
offset: Offset(0, 2),
350+
blurRadius: 16,
351+
color: Color(0x7A000000),
352+
),
353+
],
354+
medium: [
355+
BoxShadow(
356+
offset: Offset(0, 4),
357+
blurRadius: 32,
358+
color: Color(0x7A000000),
359+
),
360+
],
361+
),
362+
};
363+
}
324364
}

frontend/appflowy_flutter/packages/appflowy_ui/lib/src/theme/data/data.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:appflowy_ui/src/theme/color_scheme/icon/icon_color_theme.dart';
88
import 'package:appflowy_ui/src/theme/color_scheme/surface/surface_color_scheme.dart';
99
import 'package:appflowy_ui/src/theme/color_scheme/text/text_color_scheme.dart';
1010
import 'package:appflowy_ui/src/theme/data/builder.dart';
11+
import 'package:appflowy_ui/src/theme/shadow/shadow.dart';
1112
import 'package:appflowy_ui/src/theme/spacing/spacing.dart';
1213
import 'package:appflowy_ui/src/theme/text_style/text_style.dart';
1314
import 'package:flutter/material.dart';
@@ -35,6 +36,8 @@ abstract class AppFlowyBaseTheme {
3536

3637
AppFlowySpacing get spacing;
3738

39+
AppFlowyShadow get shadow;
40+
3841
AppFlowyBrandColorScheme get brandColorScheme;
3942
}
4043

@@ -70,6 +73,7 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
7073
final brandColorScheme = themeBuilder.buildBrandColorScheme(colorScheme);
7174
final borderRadius = themeBuilder.buildBorderRadius(colorScheme);
7275
final spacing = themeBuilder.buildSpacing(colorScheme);
76+
final shadow = themeBuilder.buildShadow(Brightness.light);
7377

7478
return AppFlowyThemeData(
7579
colorScheme: colorScheme,
@@ -82,6 +86,7 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
8286
surfaceColorScheme: surfaceColorScheme,
8387
borderRadius: borderRadius,
8488
spacing: spacing,
89+
shadow: shadow,
8590
brandColorScheme: brandColorScheme,
8691
);
8792
}
@@ -116,6 +121,7 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
116121
final brandColorScheme = themeBuilder.buildBrandColorScheme(colorScheme);
117122
final borderRadius = themeBuilder.buildBorderRadius(colorScheme);
118123
final spacing = themeBuilder.buildSpacing(colorScheme);
124+
final shadow = themeBuilder.buildShadow(Brightness.dark);
119125

120126
return AppFlowyThemeData(
121127
colorScheme: colorScheme,
@@ -128,6 +134,7 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
128134
surfaceColorScheme: surfaceColorScheme,
129135
borderRadius: borderRadius,
130136
spacing: spacing,
137+
shadow: shadow,
131138
brandColorScheme: brandColorScheme,
132139
);
133140
}
@@ -141,6 +148,7 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
141148
required this.surfaceColorScheme,
142149
required this.borderRadius,
143150
required this.spacing,
151+
required this.shadow,
144152
required this.brandColorScheme,
145153
required this.iconColorTheme,
146154
required this.backgroundColorScheme,
@@ -175,6 +183,9 @@ class AppFlowyThemeData extends AppFlowyBaseTheme {
175183
@override
176184
final AppFlowySpacing spacing;
177185

186+
@override
187+
final AppFlowyShadow shadow;
188+
178189
@override
179190
final AppFlowyBrandColorScheme brandColorScheme;
180191

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'package:flutter/widgets.dart';
2+
3+
class AppFlowyShadow {
4+
AppFlowyShadow({
5+
required this.small,
6+
required this.medium,
7+
});
8+
9+
final List<BoxShadow> small;
10+
final List<BoxShadow> medium;
11+
}

0 commit comments

Comments
 (0)