Skip to content

Commit ab3404b

Browse files
committed
Add remaining code snippets, tweak styling
1 parent 05926bc commit ab3404b

File tree

8 files changed

+101
-9
lines changed

8 files changed

+101
-9
lines changed

src/components/1-ScopedSelectors/ScopedSelectorsDemo.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export default class ScopedSelectorsDemo extends Component {
1111
render() {
1212
return (
1313
<div>
14+
<br />
1415
<ScopedSelectors />
16+
<br />
1517
<Snippet js={js} css={css} />
1618
</div>
1719
);

src/components/2-GlobalSelectors/GlobalSelectorsDemo.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export default class GlobalSelectorsDemo extends Component {
1111
render() {
1212
return (
1313
<div>
14+
<br />
1415
<GlobalSelectors />
16+
<br />
1517
<Snippet js={js} css={css} />
1618
</div>
1719
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import ClassInheritance from './ClassInheritance';
2+
3+
import React, { Component } from 'react';
4+
5+
import js from '!!raw!./StyleVariantA/StyleVariantA.js';
6+
import css from '!!raw!./StyleVariantA/StyleVariantA.css';
7+
import Snippet from 'shared/Snippet/Snippet';
8+
9+
export default class ClassInheritanceDemo extends Component {
10+
11+
render() {
12+
return (
13+
<div>
14+
<br />
15+
<ClassInheritance />
16+
<br />
17+
<Snippet js={js} css={css} />
18+
</div>
19+
);
20+
}
21+
22+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import InheritanceOverrides from './InheritanceOverrides';
2+
3+
import React, { Component } from 'react';
4+
5+
import js from '!!raw!./InheritanceOverrides.js';
6+
import css from '!!raw!./InheritanceOverrides.css';
7+
import Snippet from 'shared/Snippet/Snippet';
8+
9+
export default class InheritanceOverridesDemo extends Component {
10+
11+
render() {
12+
return (
13+
<div>
14+
<br />
15+
<InheritanceOverrides />
16+
<br />
17+
<Snippet js={js} css={css} />
18+
</div>
19+
);
20+
}
21+
22+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import ScopedAnimations from './ScopedAnimations';
2+
3+
import React, { Component } from 'react';
4+
5+
import js from '!!raw!./ScopedAnimations.js';
6+
import css from '!!raw!./ScopedAnimations.css';
7+
import Snippet from 'shared/Snippet/Snippet';
8+
9+
export default class ScopedAnimationsDemo extends Component {
10+
11+
render() {
12+
return (
13+
<div>
14+
<br />
15+
<ScopedAnimations />
16+
<br />
17+
<Snippet js={js} css={css} />
18+
</div>
19+
);
20+
}
21+
22+
};

src/components/App.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44
line-height: 24px;
55
padding: 6px 20px 30px;
66
}
7+
8+
.hr {
9+
margin: 40px 0;
10+
height: 1px;
11+
border: 0;
12+
background: #ccc;
13+
}

src/components/App.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import React, { Component } from 'react';
55
import Logo from './0-Logo/Logo';
66
import ScopedSelectorsDemo from './1-ScopedSelectors/ScopedSelectorsDemo';
77
import GlobalSelectorsDemo from './2-GlobalSelectors/GlobalSelectorsDemo';
8-
import ClassInheritance from './3-ClassInheritance/ClassInheritance';
9-
import InheritanceOverrides from './4-InheritanceOverrides/InheritanceOverrides';
10-
import ScopedAnimations from './5-ScopedAnimations/ScopedAnimations';
8+
import ClassInheritanceDemo from './3-ClassInheritance/ClassInheritanceDemo';
9+
import InheritanceOverridesDemo from './4-InheritanceOverrides/InheritanceOverridesDemo';
10+
import ScopedAnimationsDemo from './5-ScopedAnimations/ScopedAnimationsDemo';
1111

1212
export default class App extends Component {
1313

@@ -17,31 +17,41 @@ export default class App extends Component {
1717
<Logo />
1818
<h1>CSS Modules Webpack Demo</h1>
1919

20+
<hr className={styles.hr} />
21+
2022
<h2>Scoped Selectors</h2>
2123
<p>In CSS Modules, selectors are scoped by default.</p>
2224
<p>The following component uses two classes, <strong>.root</strong> and <strong>.text</strong>, both of which would typically be too vague in a larger project.</p>
2325
<p>CSS Module semantics ensure that these <strong>classes are locally scoped</strong> to the component and don't collide with other classes in the global scope.</p>
2426
<ScopedSelectorsDemo />
2527

28+
<hr className={styles.hr} />
29+
2630
<h2>Global Selectors</h2>
2731
<p>Although they should be used as sparingly as possible, <strong>global selectors are still available when required.</strong></p>
2832
<p>The following component styles all <strong>&lt;p&gt;</strong> tags nested inside it.</p>
2933
<GlobalSelectorsDemo />
3034

35+
<hr className={styles.hr} />
36+
3137
<h2>Class Inheritance</h2>
3238
<p>Both of the components below have <strong>locally scoped CSS</strong> that <strong>inherits from a common set of CSS Modules.</strong></p>
3339
<p>Since <strong>CSS Modules can be composed</strong>, the resulting markup is optimised by <b>reusing classes between components</b>.</p>
34-
<ClassInheritance />
40+
<ClassInheritanceDemo />
41+
42+
<hr className={styles.hr} />
3543

3644
<h2>Inheritance Overrides</h2>
3745
<p>When extending classes, <strong>inherited style properties can be overridden</strong> as you'd expect.</p>
3846
<p>The following component extends two different classes, but provides overrides which then take precedence.</p>
39-
<InheritanceOverrides />
47+
<InheritanceOverridesDemo />
48+
49+
<hr className={styles.hr} />
4050

4151
<h2>Scoped Animations</h2>
4252
<p>CSS Modules even provide <strong>locally scoped animations</strong>, which are typically defined in the global scope.</p>
4353
<p>The animation's keyframes are private to the animations module, only exposed publicly via a class which this component inherits from.</p>
44-
<ScopedAnimations />
54+
<ScopedAnimationsDemo />
4555

4656
</div>
4757
);
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
.pre {
2-
background: #222;
3-
color: white;
2+
background: #003957;
3+
color: rgba(255, 255, 255, 0.9);
44
padding: 20px;
5-
max-width: 600px;
5+
max-width: 700px;
6+
border-radius: 10px;
7+
overflow: auto;
8+
font-family: menlo, consolas, monospace;
9+
font-size: 14px;
10+
line-height: 20px;
611
}

0 commit comments

Comments
 (0)