Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Dark Theme #510

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions packages/remix/demo/lib/components/select_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,25 @@ class _SelectDemoState extends State<SelectDemo> {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Select<String>(
disabled:
context.knobs.boolean(label: 'disabled', initialValue: false),
variants: [context.knobs.variant(FortalezaSelectStyle.variants)],
value: selectedValue,
onChanged: (value) => setState(() => selectedValue = value),
button: (spec) => spec(
text: selectedValue,
trailingIcon: m.Icons.keyboard_arrow_down_rounded,
),
items: List.generate(
items.length,
(index) => SelectMenuItem<String>(
value: items[index],
child: XSelectMenuItemWidget(
text: items[index],
SizedBox(
width: 200,
child: Select<String>(
disabled:
context.knobs.boolean(label: 'disabled', initialValue: false),
variants: [context.knobs.variant(FortalezaSelectStyle.variants)],
value: selectedValue,
onChanged: (value) => setState(() => selectedValue = value),
button: (spec) => spec(
text: selectedValue,
trailingIcon: m.Icons.keyboard_arrow_down_rounded,
),
items: List.generate(
items.length,
(index) => SelectMenuItem<String>(
value: items[index],
child: XSelectMenuItemWidget(
text: items[index],
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class AccordionStyle extends SpecStyle<AccordionSpecUtility> {
final containerStyle = [
$.container.chain
..clipBehavior.antiAlias()
..border.bottom.color.black()
..border.bottom.color.withOpacity(0.2),
..border.bottom.color.grey.shade400(),
];

final contentStyle = [
Expand Down Expand Up @@ -70,7 +69,10 @@ class AccordionDarkStyle extends AccordionStyle {

return Style.create([
super.makeStyle(spec).call(),
$.container.border.bottom.color.white(),
$.container.border.bottom.color.grey.shade700(),
$.header.text.style.color.white(),
$.header.trailingIcon.color.white(),
$.textContent.style.color.white(),
]);
}
}
38 changes: 35 additions & 3 deletions packages/remix/lib/src/components/chip/chip_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

final labelStyle = [
$.label.chain
..textHeightBehavior(
const TextHeightBehavior(
applyHeightToFirstAscent: false,
applyHeightToLastDescent: true,
),
)

Check notice on line 31 in packages/remix/lib/src/components/chip/chip_style.dart

View workflow job for this annotation

GitHub Actions / Test Min SDK

'call' is deprecated and shouldn't be used. Use the utilities instead.

Try replacing the use of the deprecated member with the replacement. See https://dart.dev/diagnostics/deprecated_member_use to learn more about this problem.
..style.fontSize(14)
..style.height(1.5)
..style.color.black()
Expand All @@ -40,11 +40,14 @@
..borderRadius(6)
..color.white()
..border.all.width(1)
..border.color.grey.shade300()
..border.color.grey.shade200()
..padding.vertical(8)
..padding.horizontal(12),
spec.on.disabled($.container.color.grey.shade400()),
spec.on.selected($.container.color.grey.shade100()),
spec.on.selected($.container.color.grey.shade200()),
spec.on.disabled(
$.label.style.color.grey.shade800(),
spec.on.selected($.container.color.grey.shade300()),
),
];

return Style.create([
Expand All @@ -55,3 +58,32 @@
]);
}
}

class ChipDarkStyle extends ChipStyle {
const ChipDarkStyle();

@override
Style makeStyle(SpecConfiguration<ChipSpecUtility> spec) {
final $ = spec.utilities;

final containerStyle = [
$.container.chain
..border.all.color.grey.shade900()
..color.black(),
spec.on.selected($.container.color.grey.shade900()),
spec.on.disabled(
$.label.style.color.grey.shade600(),
$.container.color.black(),
spec.on.selected($.container.color.grey.shade900()),
),
];

final labelStyle = $.label.chain..style.color.white();

return Style.create([
super.makeStyle(spec).call(),
...containerStyle,
labelStyle,
]);
}
}
2 changes: 1 addition & 1 deletion packages/remix/lib/src/components/chip/chip_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FortalezaChipStyle extends ChipStyle {
..padding.horizontal(12),
(spec.on.hover & spec.on.unselected)($.container.color.$accent(3)),
spec.on.selected($.container.color.$accent(4)),
(spec.on.disabled)(
spec.on.disabled(
$.container.color.$neutral(2),
$.icon.color.$neutral(8),
),
Expand Down
21 changes: 21 additions & 0 deletions packages/remix/lib/src/components/dialog/dialog_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,24 @@ class DialogStyle extends SpecStyle<DialogSpecUtility> {
);
}
}

class DialogDarkStyle extends DialogStyle {
const DialogDarkStyle();

@override
Style makeStyle(SpecConfiguration<DialogSpecUtility> spec) {
final $ = spec.utilities;

return Style.create([
super.makeStyle(spec).call(),
$.container.chain
..color.black()
..border.all.width(1)
..border.color.grey.shade900(),
$.title.style.color.white(),
$.description.chain
..style.color.white()
..style.color.grey.shade400(),
]);
}
}
16 changes: 15 additions & 1 deletion packages/remix/lib/src/components/divider/divider_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DividerStyle extends SpecStyle<DividerSpecUtility> {

final containerStyle = [
$.container.chain
..color.black12()
..color.grey.shade300()
..borderRadius(99),
horizontal($.container.height(1)),
vertical($.container.width(1)),
Expand All @@ -21,3 +21,17 @@ class DividerStyle extends SpecStyle<DividerSpecUtility> {
return Style.create([...containerStyle]);
}
}

class DividerDarkStyle extends DividerStyle {
const DividerDarkStyle();

@override
Style makeStyle(SpecConfiguration<DividerSpecUtility> spec) {
final $ = spec.utilities;

return Style.create([
super.makeStyle(spec).call(),
$.container.color.grey.shade800(),
]);
}
}
1 change: 1 addition & 0 deletions packages/remix/lib/src/components/radio/radio_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class RadioDarkStyle extends RadioStyle {
super.makeStyle(spec).call(),
$.container.border.all.color.white(),
$.indicator.color.white(),
$.text.style.color.white(),
spec.on.disabled(
$.container.border.all.color.white30(),
$.indicator.color.white30(),
Expand Down
3 changes: 3 additions & 0 deletions packages/remix/lib/src/theme/remix_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class RemixComponentTheme {
callout: const CalloutDarkStyle(),
card: const CardDarkStyle(),
checkbox: const CheckboxDarkStyle(),
dialog: const DialogDarkStyle(),
chip: const ChipDarkStyle(),
divider: const DividerDarkStyle(),
iconButton: const IconButtonDarkStyle(),
progress: const ProgressDarkStyle(),
radio: const RadioDarkStyle(),
Expand Down
Loading