Skip to content

Commit

Permalink
Add new examples
Browse files Browse the repository at this point in the history
  • Loading branch information
joebingham-wk committed Oct 9, 2020
1 parent e0cde45 commit 51b5466
Show file tree
Hide file tree
Showing 5 changed files with 736 additions and 0 deletions.
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
54 changes: 54 additions & 0 deletions example/builder/src/functional_consumed_props.dart
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 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.

60 changes: 60 additions & 0 deletions example/builder/src/new_class_consumed_props.dart
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}',
)
);
}
}
Loading

0 comments on commit 51b5466

Please sign in to comment.