-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0cde45
commit 51b5466
Showing
5 changed files
with
736 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,54 @@ | ||
// Copyright 2020 Workiva Inc. | ||
// | ||
// 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 meta = UiPropsMeta(props).meta; | ||
meta.consume(ParentOnlyPropsMixin); | ||
|
||
return ( | ||
Dom.div()( | ||
'The parent prop is: ${props.aParentProp}', | ||
(SomeChild()..modifyProps((propsToChange) => meta.deriveUnconsumedProps(props, propsToChange)))(), | ||
) | ||
); | ||
}, | ||
$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 | ||
); |
240 changes: 240 additions & 0 deletions
240
example/builder/src/functional_consumed_props.over_react.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,60 @@ | ||
// Copyright 2020 Workiva Inc. | ||
// | ||
// 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 'new_class_consumed_props.over_react.g.dart'; | ||
|
||
UiFactory<SomeParentProps> SomeClassParent = _$SomeClassParent; // ignore: undefined_identifier | ||
|
||
mixin ParentOnlyPropsMixin on UiProps { | ||
String aParentProp; | ||
} | ||
|
||
mixin SharedPropsMixin on UiProps { | ||
String aPropToBePassed; | ||
} | ||
|
||
class SomeParentProps = UiProps with ParentOnlyPropsMixin, SharedPropsMixin; | ||
|
||
class SomeClassParentComponent extends UiComponent2<SomeParentProps> { | ||
@override | ||
render() { | ||
final meta = UiPropsMeta(props).meta; | ||
meta.consume(ParentOnlyPropsMixin); | ||
|
||
return ( | ||
Dom.div()( | ||
'The parent prop is: ${props.aParentProp}', | ||
(SomeClassChild()..modifyProps((propsToChange) => meta.deriveUnconsumedProps(props, propsToChange)))(), | ||
) | ||
); | ||
} | ||
} | ||
|
||
UiFactory<SomeChildProps> SomeClassChild = _$SomeClassChild; // ignore: undefined_identifier | ||
|
||
class SomeChildProps = UiProps with SharedPropsMixin; | ||
|
||
class SomeClassChildComponent extends UiComponent2<SomeChildProps> { | ||
@override | ||
render() { | ||
return ( | ||
Fragment()( | ||
'The passed prop value is ${props.aPropToBePassed}', | ||
) | ||
); | ||
} | ||
} |
Oops, something went wrong.