-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-12963] [Playground] Create base Beam Playground page structure #15626
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7e1a070
[BEAM-12961]: add base theme and header for playground
ElessarST b2f212a
[BEAM-12963]: implement sdk selector
ElessarST e66784c
[BEAM-12964]: add tests to editor state
ElessarST fbb44c4
[BEAM-12963]: reorganize project structure
ElessarST 3720f91
[BEAM-12962]: add app colors
ElessarST 9467ab0
[BEAM-12962]: rename accent color to primary
ElessarST aa64881
[BEAM-12963]: reorganize files
ElessarST 1e8a4bd
[BEAM-12963]: add missing licence files
ElessarST 251be4c
[BEAM-12963]: refactor constants with dark/light theme
ElessarST 37f05f5
[BEAM-12963]: extract text const for toggle theme button
ElessarST File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
playground/frontend/lib/components/logo/logo_component.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
|
|
||
| class Logo extends StatelessWidget { | ||
| const Logo({Key? key}) : super(key: key); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final theme = Theme.of(context); | ||
| return RichText( | ||
| text: TextSpan( | ||
| style: theme.textTheme.headline6, | ||
| children: <TextSpan>[ | ||
| TextSpan(text: 'Beam', style: TextStyle(color: theme.primaryColor)), | ||
| const TextSpan(text: ' Playground'), | ||
| ], | ||
| ), | ||
| ); | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
playground/frontend/lib/components/toggle_theme_button/toggle_theme_button.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
| import 'package:playground/config/theme.dart'; | ||
| import 'package:playground/constants/sizes.dart'; | ||
| import 'package:provider/provider.dart'; | ||
|
|
||
| const kLightMode = "Light Mode"; | ||
| const kDartMode = "Dark Mode"; | ||
|
|
||
| class ToggleThemeButton extends StatelessWidget { | ||
| const ToggleThemeButton({Key? key}) : super(key: key); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Consumer<ThemeProvider>(builder: (context, theme, child) { | ||
| final text = theme.isDarkMode ? kLightMode : kDartMode; | ||
| final icon = theme.isDarkMode | ||
| ? Icons.light_mode_outlined | ||
| : Icons.mode_night_outlined; | ||
| return Padding( | ||
| padding: const EdgeInsets.symmetric( | ||
| vertical: kSmPadding, | ||
| horizontal: kMdPadding, | ||
| ), | ||
| child: TextButton.icon( | ||
| icon: Icon(icon), | ||
| label: Text(text), | ||
| onPressed: theme.toggleTheme, | ||
| ), | ||
| ); | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
| import 'package:playground/constants/colors.dart'; | ||
| import 'package:playground/constants/sizes.dart'; | ||
| import 'package:provider/provider.dart'; | ||
|
|
||
| class ThemeProvider extends ChangeNotifier { | ||
| ThemeMode themeMode = ThemeMode.light; | ||
|
|
||
| bool get isDarkMode { | ||
| return themeMode == ThemeMode.dark; | ||
| } | ||
|
|
||
| void toggleTheme() { | ||
| themeMode = themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light; | ||
| notifyListeners(); | ||
| } | ||
| } | ||
|
|
||
| final kLightTheme = ThemeData( | ||
| brightness: Brightness.light, | ||
| primaryColor: kLightPrimary, | ||
| backgroundColor: kLightPrimaryBackground, | ||
| appBarTheme: const AppBarTheme( | ||
| color: kLightSecondaryBackground, | ||
| elevation: 1, | ||
| centerTitle: false, | ||
| ), | ||
| textButtonTheme: TextButtonThemeData( | ||
| style: TextButton.styleFrom( | ||
| primary: kLightText, | ||
| shape: const RoundedRectangleBorder( | ||
| borderRadius: BorderRadius.all(Radius.circular(kBorderRadius)), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| final kDarkTheme = ThemeData( | ||
| brightness: Brightness.dark, | ||
| primaryColor: kDarkPrimary, | ||
| backgroundColor: kDarkGrey, | ||
| appBarTheme: const AppBarTheme( | ||
| color: kDarkSecondaryBackground, | ||
| elevation: 1, | ||
| centerTitle: false, | ||
| ), | ||
| textButtonTheme: TextButtonThemeData( | ||
| style: TextButton.styleFrom( | ||
| primary: kDarkText, | ||
| shape: const RoundedRectangleBorder( | ||
| borderRadius: BorderRadius.all(Radius.circular(kBorderRadius)), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| class ThemeColors { | ||
| final bool isDark; | ||
|
|
||
| static ThemeColors of(BuildContext context) { | ||
| final theme = Provider.of<ThemeProvider>(context); | ||
| return ThemeColors(theme.isDarkMode); | ||
| } | ||
|
|
||
| ThemeColors(this.isDark); | ||
|
|
||
| Color get greyColor => isDark ? kDarkGrey : kLightGrey; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
|
|
||
| const Color kLightPrimaryBackground = Colors.white; | ||
| const Color kLightSecondaryBackground = Color(0xFFFCFCFC); | ||
| const Color kLightGrey = Color(0xFFE5E5E5); | ||
| const Color kLightGrey1 = Color(0xFFA0A4AB); | ||
| const Color kLightText = Color(0xFF242639); | ||
| const Color kLightPrimary = Color(0xFFE74D1A); | ||
|
|
||
| const Color kDarkPrimaryBackground = Color(0xFF18181B); | ||
| const Color kDarkSecondaryBackground = Color(0xFF2E2E34); | ||
| const Color kDarkGrey = Color(0xFF3F3F46); | ||
| const Color kDarkGrey1 = Color(0xFF606772); | ||
| const Color kDarkText = Color(0xFFFFFFFF); | ||
| const Color kDarkPrimary = Color(0xFFF26628); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| // paddings | ||
| const double kZeroPadding = 0.0; | ||
| const double kSmPadding = 4.0; | ||
| const double kMdPadding = 8.0; | ||
| const double kLgPadding = 16.0; | ||
|
|
||
| // border radius | ||
| const double kBorderRadius = 8.0; | ||
|
|
||
| // elevation | ||
| const int kElevation = 1; | ||
|
|
||
| // icon sizes | ||
| const double kIconSizeMd = 24.0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
playground/frontend/lib/modules/editor/components/editor_textarea.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
|
|
||
| class EditorTextArea extends StatelessWidget { | ||
| const EditorTextArea({Key? key}) : super(key: key); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return const Center(child: Text('Editor Text Area')); | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
playground/frontend/lib/modules/output/components/output_area.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
|
|
||
| class OutputArea extends StatelessWidget { | ||
| const OutputArea({Key? key}) : super(key: key); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return const Center( | ||
| child: Text('Output'), | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not blocking of the PR.
Related to this comment, I wonder creating
final kLightTheme ...andfinal kDarkThememight be more readable instead of creating color classes.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damondouglas Thank you for your suggestion, could you please give an example for cases where we can't use
ThemeData? For example, if we have aContainerwith some unique background colorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElessarST thank you for listening. I have seen cases where the color assigned to a
TextStyleproperty of aTextwidget derived fromThemeData. I imagine the same could be true of aContainer. I think the big picture is that as the application grows, changing styling becomes more difficult when hardcoded in specific places.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damondouglas yes, but I think
ThemeColorswill help with that because all colors will be here with switching between light and dark theme.