Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
witwash committed Sep 15, 2024
1 parent bedd8bd commit 8e98003
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 10 deletions.
49 changes: 49 additions & 0 deletions optimus/assets/dark/tada.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions optimus/assets/light/tada.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 16 additions & 8 deletions optimus/lib/src/pictogram/pictogram.dart
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:optimus/src/pictogram/pictograms.dart';
import 'package:optimus/src/theme/theme.dart';
import 'package:optimus/src/widget_size.dart';
import 'package:optimus/optimus.dart';

enum OptimusPictogramSize { small, medium, large }

/// Pictograms are a valuable tool for conveying information efficiently,
/// promoting interactivity, and simplifying complex concepts.
class OptimusPictogram extends StatelessWidget {
const OptimusPictogram({
super.key,
required this.variant,
this.size = OptimusWidgetSize.large,
this.size = OptimusPictogramSize.large,
});

/// The variant of the pictogram.
final OptimusPictogramVariant variant;

/// The size of the pictogram. Defaults to [OptimusWidgetSize.large]
final OptimusWidgetSize size;
/// The size of the pictogram. Defaults to [OptimusPictogramSize.large]
final OptimusPictogramSize size;

@override
Widget build(BuildContext context) => SizedBox(
width: size.getValue(context.tokens),
height: size.getValue(context.tokens),
width: size.getSize(context.tokens),
height: size.getSize(context.tokens),
child: SvgPicture.asset(
variant.path(context.theme.brightness),
package: 'optimus',
),
);
}

extension on OptimusPictogramSize {
double getSize(OptimusTokens tokens) => switch (this) {
OptimusPictogramSize.small => tokens.sizing600,
OptimusPictogramSize.medium => tokens.sizing800,
OptimusPictogramSize.large => 80, // TODO(witwash): add token
};
}
1 change: 1 addition & 0 deletions optimus/lib/src/pictogram/pictograms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum OptimusPictogramVariant {
settings,
success,
system_error,
tada,
target,
upload;

Expand Down
4 changes: 2 additions & 2 deletions storybook/lib/stories/pictogram.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ final pictogramsStory = Story(
builder: (context) => OptimusPictogram(
size: context.knobs.options(
label: 'Size',
initial: OptimusWidgetSize.large,
options: OptimusWidgetSize.values.toOptions(),
initial: OptimusPictogramSize.large,
options: OptimusPictogramSize.values.toOptions(),
),
variant: context.knobs.options(
label: 'Variant',
Expand Down

0 comments on commit 8e98003

Please sign in to comment.