-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12_composition.html
More file actions
118 lines (101 loc) · 3.87 KB
/
Copy path12_composition.html
File metadata and controls
118 lines (101 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Composition vs Inheritance</title>
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono:300,300i,700,700i|Roboto:300,300i,700,700i" rel="stylesheet">
<link rel="stylesheet" href="css/react.css">
<script src="https://unpkg.com/react@latest/dist/react.js"></script>
<script src="https://unpkg.com/prop-types/prop-types.js"></script>
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel" src="js/readMore.js"></script>
<script type="text/babel" data-presets="es2015,stage-2,react" data-plugins="transform-class-properties">
( function() {
const NoSense = props => <p className="no-sense">{ props.content }</p>;
/**
* DialogFrame
*
* a wrapper element that defines the frame of a dialog box
*
* @param {Object} props props including children
*/
function DialogFrame( props )
{
console.log(props.children);
const classNames =
[
'Dialog',
props.borderType ? `Dialog-border-${props.borderType}` : false,
props.type ? `Dialog-${props.type}` : false,
]
.filter( Boolean )
.join( ' ' );
return (
<div className={ classNames } >
{props.children}
</div>
);
}
/**
* Dialog
*
* A component that uses the DialogFrame Component as
*
* @param {[type]} props [description]
*/
function Dialog( props )
{
const htmlContent = {
__html : props.content,
};
return (
<DialogFrame borderType={ props.borderType } type={ props.type }>
<h1 className="Dialog-header">{ props.title }</h1>
<div
className="Dialog-content"
dangerouslySetInnerHTML={ htmlContent }
/>
{
props.append != null && props.append
}
</DialogFrame>
);
}
// render to Component:
ReactDOM.render(
(
<div>
<h1>Composition vs Inheritance</h1>
<Dialog
type="highlight"
borderType="dashed"
title="Highlight Dialog"
content="<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna
aliquyam erat, sed diam voluptua</p>"
/>
<Dialog
type="light"
title="Light Dialog"
content="<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy.</p><p>Eirmod tempor invidunt ut labore et dolore magna
aliquyam erat, sed diam voluptua</p>"
append={ <NoSense content="this has no sense at all" /> }
/>
<ReadMore
url="https://facebook.github.io/react/docs/composition-vs-inheritance.html"
about="Composition vs Inheritance"
/>
</div>
),
document.querySelector( '#root' )
);
}() )
</script>
</body>
</html>