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

CPLAT-12194 Enable functional components to use consumed props #633

Merged
merged 24 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from 17 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
10 changes: 10 additions & 0 deletions example/builder/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import './src/basic_library.dart';
import './src/generic_inheritance_sub.dart';
import './src/generic_inheritance_super.dart';
import './src/function_component.dart' as function;
import 'src/functional_consumed_props.dart';
import 'src/new_class_consumed_props.dart';

main() {
react_dom.render(
Expand Down Expand Up @@ -59,6 +61,14 @@ main() {
' - ',
componentConstructorsByName[name]().toString(),
)).toList(),
(SomeParent()
..aParentProp = 'parent'
..aPropToBePassed = 'passed'
)(),
(SomeClassParent()
..aParentProp = 'classParent'
..aPropToBePassed = 'passed'
)()
), querySelector('#content')
);
}
Expand Down
8 changes: 8 additions & 0 deletions example/builder/src/abstract_inheritance.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions example/builder/src/basic.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions example/builder/src/basic_library.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions example/builder/src/basic_with_state.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions example/builder/src/basic_with_type_params.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions example/builder/src/function_component.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions example/builder/src/functional_consumed_props.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2020 Workiva Inc.
greglittlefield-wf marked this conversation as resolved.
Show resolved Hide resolved
//
// Licensed 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:over_react/over_react.dart';

// ignore_for_file: uri_has_not_been_generated
part 'functional_consumed_props.over_react.g.dart';

mixin ParentOnlyPropsMixin on UiProps {
String aParentProp;
}

mixin SharedPropsMixin on UiProps {
String aPropToBePassed;
}

class SomeParentProps = UiProps with ParentOnlyPropsMixin, SharedPropsMixin;

UiFactory<SomeParentProps> SomeParent = uiFunction((props) {
final consumedProps = props.staticMeta.forMixin(ParentOnlyPropsMixin);

return (
Dom.div()(
Dom.div()(
'The parent prop is: ${props.aParentProp}',
),
(SomeChild()..addUnconsumedProps(props, consumedProps.inList()))(),
)
);
},
$SomeParentConfig, // ignore: undefined_identifier
);

class SomeChildProps = UiProps with SharedPropsMixin;

UiFactory<SomeChildProps> SomeChild = uiFunction((props) {
return (
Fragment()(
'The passed prop value is ${props.aPropToBePassed}',
)
);
},
$SomeChildConfig, // ignore: undefined_identifier
);
Loading