-
Notifications
You must be signed in to change notification settings - Fork 7
/
Intro.jsx
171 lines (141 loc) · 6.28 KB
/
Intro.jsx
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* eslint-disable quotes */
/* eslint-disable no-template-curly-in-string */
import React from 'react';
import ThemeProvider from 'react-theme-provider';
import setCSS from './.themes/setCSS';
/*
const propTypes = {
title: PropTypes.string,
subtitle: PropTypes.string,
};
const defaultProps = {
title: 'Welcome to React-Theming',
subtitle: 'Boilerplate Project',
};
const contextTypes = {
muiTheme: PropTypes.object,
};
*/
class Intro extends React.Component {
render() {
// const { palette } = this.context.muiTheme;
// const styleTitle = {
// color: palette.alternateTextColor,
// };
// const styleSubtitle = {
// color: palette.alternate1Color,
// };
// const styleHeader = {
// backgroundColor: palette.alternateСanvasColor,
// };
return (
<div className="App-intro" style={{ maxWidth: 1000, margin: '0 auto' }}>
<ThemeProvider setCSS={setCSS} >
<h1>Quick start</h1>
<p>
At the heart of this project the desire to collect the best practices of
application development
via <a href="https://github.com/storybooks/react-storybook">React-Storybook</a>
environment. This project is transparent and friendly for developers.
You do not need to eject anything. Therefore you can easily
add your own configuration and extend it using any packages.
</p>
<p>
It contains the <span>fully-charged</span> setup of the Storybook
with pre-installed <span>plugins</span>, configuration,
quick examples, and tips.
</p>
<h2>Instal the project</h2>
<code>
git clone https://github.com/sm-react/react-theming.git<br />
cd react-theming<br />
npm i<br />
npm start<br />
</code>
<p>Press <code>Ctrl-Shft-F</code> to exit from <code>Full screen</code> mode</p>
<p>
Let's select another theme for this page.
Do it via dropdown list at the bottom panel.
Out of the box there are three themes: 'Light',
'Dark' and 'Gray'. Check out them.
</p>
<p>
Okay, now let's look at the panel on the left.
In fact, our application consists of two components:
<code>src/Header.jsx</code> and <code>src/Intro.jsx</code>.
Selecting the appropriate items in the left-side list you switch to an
isolated view of the component. It's how <span>React Storybook</span>
works - allows you 'step-by-step' to create and
works with React components.
You can improve the quality of development by applying different
addons to Storybook. Most of them is already pre-installed in this project.
You will find excellent <a href="https://getstorybook.io/docs/">
documentation and examples</a> on the React Storybook website.
</p>
<p>A short guide for other Storybook Addons will be here...</p>
<h2>ThemeProvider:</h2>
<code><ThemeProvider><br />
{'\u00A0\u00A0'}<YourThemedComponentOrPlainHTML /><br />
</ThemeProvider></code>
<p>A generic theme provider and (very) simple CSS styler</p>
<h2>What is Theme?</h2>
<p>It's just plain javascript object, typically with two levels of nesting.</p>
<p>Primer:</p>
<code>
{'const greyTheme = {'}<br />
{"\u00A0\u00A0themeName: 'Grey Theme',"}<br />
{"\u00A0\u00A0themeFile: 'greyTheme.json',"}<br />
{"\u00A0\u00A0palette: {"}<br />
{"\u00A0\u00A0\u00A0\u00A0primary1Color: '#00bcd4',"}<br />
{"\u00A0\u00A0\u00A0\u00A0alternateTextColor: '#4a4a4a',"}<br />
{"\u00A0\u00A0\u00A0\u00A0canvasColor: '#616161',"}<br />
{"\u00A0\u00A0\u00A0\u00A0textColor: '#bdbdbd',"}<br />
{"\u00A0\u00A0\u00A0\u00A0secondaryTextColor: 'rgba(255, 255, 255, 0.54)',"}<br />
{"\u00A0\u00A0\u00A0\u00A0disabledColor: '#757575',"}<br />
{"\u00A0\u00A0\u00A0\u00A0accent1Color: '#607d8b',"}<br />
{"\u00A0\u00A0},"}<br />
{"};"}<br />
</code>
<h2>What is CSSrule?</h2>
<p>
a string containing CSS rules. Typically it's a
template string with passed theme props:
</p>
<code>
{".themed div {"}<br />
{"\u00A0\u00A0color: ${palette.textColor};"}<br />
{"\u00A0\u00A0background-color: ${palette.canvasColor};"}<br />
{"}"}<br />
<br />
{".themed a {"}<br />
{"\u00A0\u00A0color: ${palette.primary1Color};"}<br />
{"}"}<br />
</code>
<p>
if you use it without any
props <span>inside</span> the <span>MuiThemeProvider</span>,
it will provide CSS style for your html elements based on the current theme
</p>
<p>
if you use it without any
props <span>outside</span> the <span>MuiThemeProvider</span>,
it will provide CSS style for your html elements based on the
default theme and pass this theme to your components
via context same way as MuiThemeProvider.
</p>
<p>
See project's <a href="https://github.com/sm-react/react-theme-provider">
repo
</a>
</p>
<br />
<br />
</ThemeProvider>
</div>
);
}
}
// Intro.propTypes = propTypes;
// Intro.defaultProps = defaultProps;
// Intro.contextTypes = contextTypes;
export default Intro;